• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/wpan/p802_15_4sscs.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_4sscs.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_4sscs.h,v 1.2 2005/07/13 03:51:33 tomh Exp $
00017 
00018 // Functions in this file are out of the scope of 802.15.4.
00019 // But they elaborate how a higher layer interfaces with 802.15.4.
00020 // You can modify this file at will to fit your need.
00021 
00022 /*
00023  * Copyright (c) 2003-2004 Samsung Advanced Institute of Technology and
00024  * The City University of New York. All rights reserved.
00025  *
00026  * Redistribution and use in source and binary forms, with or without
00027  * modification, are permitted provided that the following conditions
00028  * are met:
00029  * 1. Redistributions of source code must retain the above copyright
00030  *    notice, this list of conditions and the following disclaimer.
00031  * 2. Redistributions in binary form must reproduce the above copyright
00032  *    notice, this list of conditions and the following disclaimer in the
00033  *    documentation and/or other materials provided with the distribution.
00034  * 3. All advertising materials mentioning features or use of this software
00035  *    must display the following acknowledgement:
00036  *      This product includes software developed by the Joint Lab of Samsung 
00037  *      Advanced Institute of Technology and The City University of New York.
00038  * 4. Neither the name of Samsung Advanced Institute of Technology nor of 
00039  *    The City University of New York may be used to endorse or promote 
00040  *    products derived from this software without specific prior written 
00041  *    permission.
00042  *
00043  * THIS SOFTWARE IS PROVIDED BY THE JOINT LAB OF SAMSUNG ADVANCED INSTITUTE
00044  * OF TECHNOLOGY AND THE CITY UNIVERSITY OF NEW YORK ``AS IS'' AND ANY EXPRESS 
00045  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
00046  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 
00047  * NO EVENT SHALL SAMSUNG ADVANCED INSTITUTE OR THE CITY UNIVERSITY OF NEW YORK 
00048  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
00049  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
00050  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
00051  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
00052  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 
00053  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00054  */
00055 
00056 
00057 #ifndef p802_15_4sscs_h
00058 #define p802_15_4sscs_h
00059 
00060 //enable/disable ZigBee interface
00061 //#define ZigBeeIF
00062 
00063 #include "p802_15_4def.h"
00064 #include "p802_15_4mac.h"
00065 
00066 
00067 //task pending (callback)
00068 #define sscsTP_startPANCoord            1
00069 #define sscsTP_startDevice              2
00070 struct sscsTaskPending
00071 {
00072         sscsTaskPending()
00073         {
00074                 init();
00075         }
00076         inline void init()
00077         {
00078                 startPANCoord = false;
00079                 startPANCoord_STEP = 0;
00080                 startDevice = false;
00081                 startDevice_STEP = 0;
00082         }
00083 
00084         bool &taskStatus(UINT_8 task)
00085         {
00086                 switch (task)
00087                 {
00088                         case sscsTP_startPANCoord:
00089                                 return startPANCoord;
00090                         case sscsTP_startDevice:
00091                                 return startDevice;
00092                         default:
00093                                 assert(0);
00094                                 // shutup compiler.
00095                                 return startDevice;
00096                 }
00097         }
00098 
00099         UINT_8 &taskStep(UINT_8 task)
00100         {
00101                 switch (task)
00102                 {
00103                         case sscsTP_startPANCoord:
00104                                 return startPANCoord_STEP;
00105                         case sscsTP_startDevice:
00106                                 return startDevice_STEP;
00107                         default:
00108                                 assert(0);
00109                                 // shutup compiler.
00110                                 return startDevice_STEP;
00111                 }
00112         }
00113 
00114         //----------------
00115         bool    startPANCoord;
00116         bool    startPANCoord_isCluster_Tree;
00117         UINT_8  startPANCoord_STEP;
00118         bool    startPANCoord_txBeacon;
00119         UINT_8  startPANCoord_BO;
00120         UINT_8  startPANCoord_SO;
00121         UINT_8  startPANCoord_Channel;
00122         //----------------
00123         bool    startDevice;
00124         bool    startDevice_isCluster_Tree;
00125         UINT_8  startDevice_STEP;
00126         bool    startDevice_isFFD;
00127         bool    startDevice_assoPermit;
00128         bool    startDevice_txBeacon;
00129         UINT_8  startDevice_BO;
00130         UINT_8  startDevice_SO;
00131         UINT_8  startDevice_Channel;
00132         PAN_ELE startDevice_panDes;
00133         //----------------
00134 };
00135 
00136 class SSCS802_15_4;
00137 class SSCS802_15_4Timer : public Handler
00138 {
00139         friend class SSCS802_15_4;
00140 public:
00141         SSCS802_15_4Timer(SSCS802_15_4 *s) : Handler()
00142         {
00143                 sscs = s;
00144                 active = false;
00145         }
00146         virtual void start(double wtime);
00147         virtual void cancel(void);
00148         virtual void handle(Event* e);
00149 
00150 protected:
00151         SSCS802_15_4 *sscs;
00152         bool active;
00153         Event nullEvent;
00154 };
00155 
00156 #ifdef ZigBeeIF
00157 class ZBR;
00158 #endif
00159 class SSCS802_15_4
00160 {
00161         friend class Mac802_15_4;
00162         friend class SSCS802_15_4Timer;
00163 public:
00164         SSCS802_15_4(Mac802_15_4 *m);
00165         ~SSCS802_15_4();
00166         void MCPS_DATA_confirm(UINT_8 msduHandle,MACenum status);
00167         void MCPS_DATA_indication(UINT_8 SrcAddrMode,UINT_16 SrcPANId,IE3ADDR SrcAddr,
00168                                   UINT_8 DstAddrMode,UINT_16 DstPANId,IE3ADDR DstAddr,
00169                                   UINT_8 msduLength,Packet *msdu,UINT_8 mpduLinkQuality,
00170                                   bool SecurityUse,UINT_8 ACLEntry);
00171         void MCPS_PURGE_confirm(UINT_8 msduHandle,MACenum status);
00172         void MLME_ASSOCIATE_indication(IE3ADDR DeviceAddress,UINT_8 CapabilityInformation,bool SecurityUse,UINT_8 ACLEntry);
00173         void MLME_ASSOCIATE_confirm(UINT_16 AssocShortAddress,MACenum status);
00174         void MLME_DISASSOCIATE_confirm(MACenum status);
00175         void MLME_BEACON_NOTIFY_indication(UINT_8 BSN,PAN_ELE *PANDescriptor,UINT_8 PendAddrSpec,IE3ADDR *AddrList,UINT_8 sduLength,UINT_8 *sdu);
00176         void MLME_GET_confirm(MACenum status,MPIBAenum PIBAttribute,MAC_PIB *PIBAttributeValue);
00177         void MLME_ORPHAN_indication(IE3ADDR OrphanAddress,bool SecurityUse,UINT_8 ACLEntry);
00178         void MLME_RESET_confirm(MACenum status);
00179         void MLME_RX_ENABLE_confirm(MACenum status);
00180         void MLME_SET_confirm(MACenum status,MPIBAenum PIBAttribute);
00181         void MLME_SCAN_confirm(MACenum status,UINT_8 ScanType,UINT_32 UnscannedChannels,
00182                                UINT_8 ResultListSize,UINT_8 *EnergyDetectList,
00183                                PAN_ELE *PANDescriptorList);
00184         void MLME_COMM_STATUS_indication(UINT_16 PANId,UINT_8 SrcAddrMode,IE3ADDR SrcAddr,
00185                                          UINT_8 DstAddrMode,IE3ADDR DstAddr,MACenum status);
00186         void MLME_START_confirm(MACenum status);
00187         void MLME_SYNC_LOSS_indication(MACenum LossReason);
00188         void MLME_POLL_confirm(MACenum status);
00189 
00190 protected:
00191         void checkTaskOverflow(UINT_8 task);
00192         void dispatch(MACenum status,char *frFunc);
00193         void startPANCoord(bool isClusterTree,bool txBeacon,UINT_8 BO,UINT_8 SO,bool firsttime,MACenum status = m_SUCCESS);
00194         void startDevice(bool isClusterTree,bool isFFD,bool assoPermit,bool txBeacon,UINT_8 BO,UINT_8 SO,bool firsttime,MACenum status = m_SUCCESS);
00195         int command(int argc, const char*const* argv);
00196 
00197 #ifdef ZigBeeIF
00198         //for cluster tree
00199         void assertZBR(void);
00200         int RNType(void);
00201         void setGetClusTreePara(char setGet,Packet *p);
00202 #endif
00203 
00204 protected:
00205         bool t_isCT,t_txBeacon,t_isFFD,t_assoPermit;
00206         UINT_8 t_BO,t_SO;
00207         //for cluster tree
00208         UINT_16 rt_myDepth;
00209         UINT_16 rt_myNodeID;
00210         UINT_16 rt_myParentNodeID;
00211 
00212 public:
00213         static UINT_32 ScanChannels;
00214         bool neverAsso;                 
00215 
00216 private:
00217         Mac802_15_4 *mac;
00218 #ifdef ZigBeeIF
00219         ZBR *zbr;                       
00220 #endif
00221         SSCS802_15_4Timer assoH;
00222         sscsTaskPending sscsTaskP;
00223 
00224         //--- store results returned from MLME_SCAN_confirm() ---
00225         UINT_32 T_UnscannedChannels;
00226         UINT_8  T_ResultListSize;
00227         UINT_8  *T_EnergyDetectList;
00228         PAN_ELE *T_PANDescriptorList;
00229         UINT_8  Channel;
00230         //-------------------------------------------------------
00231 
00232         HLISTLINK *hlistLink1;
00233         HLISTLINK *hlistLink2;
00234 };
00235 
00236 #endif
00237 
00238 // End of file: p802_15_4sscs.h

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