• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/wpan/p802_15_4nam.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_4nam.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_4nam.h,v 1.1 2005/01/24 18:34:25 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_4nam_h
00054 #define p802_15_4nam_h
00055 
00056 #define mac_oper_del    1
00057 #define mac_oper_est    2
00058 
00059 class Mac802_15_4;
00060 
00061 class MACLINK 
00062 {
00063 public:
00064         Mac802_15_4 *mac;
00065         int addr;
00066         MACLINK *last;
00067         MACLINK *next;
00068         MACLINK(int ad,Mac802_15_4 *m)
00069         {
00070                 addr = ad;
00071                 mac = m;
00072                 last = NULL;
00073                 next = NULL;
00074         }
00075 };
00076 
00077 int addMacLink(int ad,Mac802_15_4 *m);
00078 int updateMacLink(int oper,int ad);
00079 Mac802_15_4 *getMacLink(int ad);
00080 int chkAddMacLink(int ad,Mac802_15_4 *m);
00081 
00082 //------------------------------------------------------------------
00083 
00084 #define at_oper_del     1
00085 #define at_oper_est     2
00086 
00087 extern int ATTRIBUTE_SN;
00088 
00089 class ATTRIBUTELINK 
00090 {
00091 public:
00092         packet_t ptype;
00093         char color[21];
00094         int src,dst;
00095         int attribute;
00096         ATTRIBUTELINK *last;
00097         ATTRIBUTELINK *next;
00098         ATTRIBUTELINK(packet_t pt,char *clr,int s,int d)
00099         {
00100                 ptype = pt;
00101                 strncpy(color,clr,20);
00102                 color[20] = 0;
00103                 src = s;
00104                 dst = d;
00105                 attribute = ATTRIBUTE_SN++;
00106                 last = NULL;
00107                 next = NULL;
00108         }
00109 };
00110 
00111 packet_t nam_pktName2Type(const char *name);
00112 int addAttrLink(packet_t pt,char *clr,int s = -2,int d = -2);
00113 int updateAttrLink(int oper,packet_t pt,int s = -2,int d = -2);
00114 int chkAddAttrLink(packet_t pt,char *clr,int s = -2,int d = -2);
00115 ATTRIBUTELINK *findAttrLink(packet_t pt,int s = -2,int d = -2);
00116 
00117 //------------------------------------------------------------------
00118 
00119 class Nam802_15_4
00120 {
00121         friend class Mac802_15_4;
00122         friend class Phy802_15_4;
00123 public:
00124         Nam802_15_4(const char *ncolor,const char *mcolor,Mac802_15_4 *m);
00125         //~Nam802_15_4();
00126         static void     flowAttribute(int clrID,const char *clrName);
00127         static void     changePlaybackRate(double atTime,const char *stepLen);
00128 
00129 protected:
00130         void            changeNodeColor(double atTime,const char *newColor,bool save = true);
00131         void            changeBackNodeColor(double atTime);
00132         void            flashNodeColor(double atTime,const char *flashColor = "");
00133         void            changeMarkColor(double atTime,const char *newColor);
00134         void            flashNodeMark(double atTime);
00135         void            changeLabel(double atTime,const char *lb);
00136         void            flashLinkFail(double atTime,int dst,const char *flashColor = "");
00137         void            annotate(double atTime,const char *note);
00138 
00139 public:
00140         static bool Nam_Status;
00141         static bool emStatus;                   //energy model used?
00142         static bool emHandling;                 //need special handling for energy model?
00143         static char def_PANCoor_clr[21];
00144         static char def_Coor_clr[21];
00145         static char def_Dev_clr[21];
00146         static char def_Node_clr[21];
00147         static char def_Mark_clr[21];
00148         static char def_ColFlash_clr[21];
00149         static char def_NodeFail_clr[21];
00150         static char def_LinkFailFlash_clr[21];
00151 
00152 protected:
00153         char    nodePreColor[21];
00154         char    nodeColor[21];
00155         char    markColor[21];
00156         char    label[81];
00157 
00158 private:
00159         Mac802_15_4 *mac;
00160 
00161 };
00162 
00163 #endif
00164 
00165 // End of file: p802_15_4nam.h

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