• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/wpan/p802_15_4pkt.h

00001 /********************************************/
00002 /*     NS2 Simulator for IEEE 802.15.4      */
00003 /*           (per P802.15.4/D18)            */
00004 /*------------------------------------------*/
00005 /* by:        Jianliang Zheng               */
00006 /*        (zheng@ee.ccny.cuny.edu)          */
00007 /*              Myung J. Lee                */
00008 /*          (lee@ccny.cuny.edu)             */
00009 /*        ~~~~~~~~~~~~~~~~~~~~~~~~~         */
00010 /*           SAIT-CUNY Joint Lab            */
00011 /********************************************/
00012 
00013 // File:  p802_15_4pkt.h
00014 // Mode:  C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t
00015 
00016 // $Header: /cvsroot/nsnam/ns-2/wpan/p802_15_4pkt.h,v 1.1 2005/01/24 18:35:35 haldar Exp $
00017 
00018 /*
00019  * Copyright (c) 2003-2004 Samsung Advanced Institute of Technology and
00020  * The City University of New York. All rights reserved.
00021  *
00022  * Redistribution and use in source and binary forms, with or without
00023  * modification, are permitted provided that the following conditions
00024  * are met:
00025  * 1. Redistributions of source code must retain the above copyright
00026  *    notice, this list of conditions and the following disclaimer.
00027  * 2. Redistributions in binary form must reproduce the above copyright
00028  *    notice, this list of conditions and the following disclaimer in the
00029  *    documentation and/or other materials provided with the distribution.
00030  * 3. All advertising materials mentioning features or use of this software
00031  *    must display the following acknowledgement:
00032  *      This product includes software developed by the Joint Lab of Samsung 
00033  *      Advanced Institute of Technology and The City University of New York.
00034  * 4. Neither the name of Samsung Advanced Institute of Technology nor of 
00035  *    The City University of New York may be used to endorse or promote 
00036  *    products derived from this software without specific prior written 
00037  *    permission.
00038  *
00039  * THIS SOFTWARE IS PROVIDED BY THE JOINT LAB OF SAMSUNG ADVANCED INSTITUTE
00040  * OF TECHNOLOGY AND THE CITY UNIVERSITY OF NEW YORK ``AS IS'' AND ANY EXPRESS 
00041  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
00042  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 
00043  * NO EVENT SHALL SAMSUNG ADVANCED INSTITUTE OR THE CITY UNIVERSITY OF NEW YORK 
00044  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
00045  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
00046  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
00047  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
00048  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 
00049  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00050  */
00051 
00052 
00053 #ifndef p802_15_4pkt_h
00054 #define p802_15_4pkt_h
00055 
00056 #include <packet.h>
00057 #include "p802_15_4const.h"
00058 #include "p802_15_4field.h"
00059 
00060 #define HDR_LRWPAN(p)   (hdr_lrwpan::access(p))
00061 
00062 struct panAddrInfo
00063 {
00064         UINT_16 panID;
00065         union
00066         {
00067                 UINT_16 addr_16;
00068                 IE3ADDR addr_64;
00069         };
00070 };
00071 
00072 //---PHY header---
00073 #define defSHR_PreSeq           0x00000000
00074 #define defSHR_SFD              0xe5
00075 #define defPHY_HEADER_LEN       6
00076 
00077 struct lrwpan_beacon_frame
00078 {
00079         //---beacon frame (Figures 10,37)---
00080         UINT_32         SHR_PreSeq;             //(PPDU) Preamble Sequence (const 0x00000000)(sec. 6.3.1.1)
00081         UINT_8          SHR_SFD;                //(PPDU) Start of Frame Delimiter (const 0xe5)(sec 6.3.1.2)
00082         UINT_8          PHR_FrmLen;             //(PPDU) Frame Length (sec. 6.3.1.3)
00083         UINT_16         MHR_FrmCtrl;            //(PSDU/MPDU) Frame Control (Figure 35)
00084                                                 // --leftmost bit numbered 0 and transmitted first
00085                                                 // --(012):     Frame type (Table 65)
00086                                                 //               --(210)=000:           Beacon
00087                                                 //               --(210)=001:           Data
00088                                                 //               --(210)=010:           Ack.
00089                                                 //               --(210)=011:           MAC command
00090                                                 //               --(210)=others:        Reserved
00091                                                 // --(3):       Security enabled
00092                                                 // --(4):       Frame pending
00093                                                 // --(5):       Ack. req.
00094                                                 // --(6):       Intra PAN
00095                                                 // --(789):     Reserved
00096                                                 // --(ab):      Dest. addressing mode (Table 66)
00097                                                 //               --(ba)=00:     PAN ID and Addr. field not present
00098                                                 //               --(ba)=01:     Reserved
00099                                                 //               --(ba)=10:     16-bit short address
00100                                                 //               --(ba)=11:     64-bit extended address
00101                                                 // --(cd):      Reserved
00102                                                 // --(ef):      Source addressing mode (see Dest. addressing mode)
00103         UINT_8          MHR_BSN;                //(PSDU/MPDU) Beacon Sequence Number
00104         panAddrInfo     MHR_SrcAddrInfo;        //(PSDU/MPDU) Source Address Information
00105         UINT_16         MSDU_SuperSpec;         //(MSDU) Superframe Specification (Figures 40,59)
00106                                                 // --(0123):    Beacon order
00107                                                 // --(4567):    Superframe order
00108                                                 // --(89ab):    Final CAP slot
00109                                                 // --(c):       Battery life extension
00110                                                 // --(d):       Reserved
00111                                                 // --(e):       PAN Coordinator
00112                                                 // --(f):       Association permit
00113         GTSFields       MSDU_GTSFields;         //GTS Fields (Figure 38)
00114         PendAddrFields  MSDU_PendAddrFields;    //(MSDU) Address Fields (Figure 39)
00115                                                 // --(012):     # of short addressing pending
00116                                                 // --(3):       Reserved
00117                                                 // --(456):     # of extended addressing pending
00118                                                 // --(7):       Reserved
00119         //MSDU_BeaconPL;                        //(MSDU) Beacon Payload
00120         UINT_16         MFR_FCS;                //(PSDU/MPDU) FCS
00121 };
00122 
00123 struct lrwpan_data_frame
00124 {
00125         //---data frame (Figures 11,45)---
00126         UINT_32         SHR_PreSeq;             //same as above
00127         UINT_8          SHR_SFD;                //same as above
00128         UINT_8          PHR_FrmLen;             //same as above
00129         UINT_16         MHR_FrmCtrl;            //same as above
00130         UINT_8          MHR_DSN;                //Date Sequence Number
00131         panAddrInfo     MHR_DstAddrInfo;        //(PSDU/MPDU) Source Address Information
00132         panAddrInfo     MHR_SrcAddrInfo;        //(PSDU/MPDU) Destination Address Information
00133         //MSDU_DataPL;                          //(MSDU) Data Payload
00134         UINT_16         MFR_FCS;                //same as above
00135 };
00136 
00137 struct lrwpan_ack_frame
00138 {
00139         //---acknowledgement frame (Figures 12,46)---
00140         UINT_32         SHR_PreSeq;             //same as above
00141         UINT_8          SHR_SFD;                //same as above
00142         UINT_8          PHR_FrmLen;             //same as above
00143         UINT_16         MHR_FrmCtrl;            //same as above
00144         UINT_8          MHR_DSN;                //same as above
00145         UINT_16         MFR_FCS;                //same as above
00146 };
00147 
00148 struct lrwpan_command_frame
00149 {
00150         //---MAC command frame (Figures 13,47)---
00151         UINT_32         SHR_PreSeq;             //same as above
00152         UINT_8          SHR_SFD;                //same as above
00153         UINT_8          PHR_FrmLen;             //same as above
00154         UINT_16         MHR_FrmCtrl;            //same as above
00155         UINT_8          MHR_DSN;                //same as above
00156         panAddrInfo     MHR_DstAddrInfo;        //same as above
00157         panAddrInfo     MHR_SrcAddrInfo;        //same as above
00158         UINT_8          MSDU_CmdType;           //(MSDU) Command Type/Command frame identifier (Table 67)
00159                                                 // --0x01:      Association request (Figures 48 -> 49)
00160                                                 // --0x02:      Association response (Figure 50;Table 68)
00161                                                 // --0x03:      Disassociation notification (Figure 51;Table 69)
00162                                                 // --0x04:      Data request (Figure 52)
00163                                                 // --0x05:      PAN ID conflict notification (Figure 53)
00164                                                 // --0x06:      Orphan notification (Figure 54)
00165                                                 // --0x07:      Beacon request (Figure 55)
00166                                                 // --0x08:      Coordinator realignment (Figure 56
00167                                                 // --0x09:      GTS request (Figures 57 -> 58)
00168                                                 // --0x0a-0xff: Reserved
00169         //MSDU_CmdPL;                           //(MSDU) Command Payload
00170         UINT_16         MFR_FCS;                //same as above
00171 };
00172 
00173 struct hdr_lrwpan
00174 {
00175         //---PHY header---
00176         UINT_32 SHR_PreSeq;
00177         UINT_8  SHR_SFD;
00178         UINT_8  PHR_FrmLen;
00179         
00180         //---MAC header---
00181         UINT_16         MHR_FrmCtrl;
00182         UINT_8          MHR_BDSN;
00183         panAddrInfo     MHR_DstAddrInfo;
00184         panAddrInfo     MHR_SrcAddrInfo;
00185 
00186         //---PHY layer---
00187         UINT_8  ppduLinkQuality;
00188         double rxTotPower;
00189         
00190         //---MAC sublayer---
00191         UINT_16         MFR_FCS;
00192         UINT_16         MSDU_SuperSpec;
00193         GTSFields       MSDU_GTSFields;
00194         PendAddrFields  MSDU_PendAddrFields;
00195         UINT_8          MSDU_CmdType;
00196         UINT_8          MSDU_PayloadLen;
00197         UINT_16         pad;                                    
00198         UINT_8          MSDU_Payload[aMaxMACFrameSize];         //MSDU_BeaconPL/MSDU_DataPL/MSDU_CmdPL
00199         bool            SecurityUse;
00200         UINT_8          ACLEntry;
00201 
00202         //---SSCS entity---
00203         UINT_8          msduHandle;
00204 
00205         //---Other---
00206         bool            setSN;          //SN already been set
00207         UINT_8          phyCurrentChannel;
00208         bool            indirect;       //this is a pending packet (indirect transmission)
00209         UINT_32         uid;            //for debug purpose
00210         UINT_16         clusTreeDepth;
00211         UINT_16         clusTreeParentNodeID;
00212         
00213         bool            colFlag;        //for nam purpose
00214         int             attribute;      //for nam purpose
00215 
00216 
00217         //---Packet header access functions---
00218         static int offset_;
00219         inline static int& offset() {return offset_;}
00220         inline static hdr_lrwpan* access(const Packet* p)
00221         {
00222                 return (hdr_lrwpan*) p->access(offset_);
00223         }
00224 };
00225 
00226 #endif
00227 
00228 // End of file: p802_15_4pkt.h

Generated on Tue Aug 10 2010 16:16:09 for ns-2.33 by  doxygen 1.7.1