• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/wpan/p802_15_4transac.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_4transac.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_4transac.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_4transac_h
00054 #define p802_15_4transac_h
00055 
00056 #include <packet.h>
00057 #include "p802_15_4def.h"
00058 #include "p802_15_4const.h"
00059 #include "p802_15_4field.h"
00060 
00061 #define tr_oper_del     1
00062 #define tr_oper_est     2
00063 #define tr_oper_EST     3
00064 
00065 //----------------------------------------------------------------------------------------
00066 
00067 class DEVICELINK
00068 {
00069 public:
00070         IE3ADDR addr64;         //extended address of the associated device
00071         UINT_16 addr16;         //assigned short address
00072         UINT_8 capability;      //device capability
00073         
00074         DEVICELINK *last;
00075         DEVICELINK *next;
00076         DEVICELINK(IE3ADDR addr, UINT_8 cap)
00077         {
00078                 addr64 = addr;
00079                 addr16 = (UINT_16)addr;         
00080                 capability = cap;
00081                 last = NULL;
00082                 next = NULL;
00083         };
00084 };
00085 
00086 int addDeviceLink(DEVICELINK **deviceLink1, DEVICELINK **deviceLink2, IE3ADDR addr, UINT_8 cap);
00087 int updateDeviceLink(int oper, DEVICELINK **deviceLink1, DEVICELINK **deviceLink2, IE3ADDR addr);
00088 int numberDeviceLink(DEVICELINK **deviceLink1);
00089 int chkAddDeviceLink(DEVICELINK **deviceLink1, DEVICELINK **deviceLink2, IE3ADDR addr, UINT_8 cap);
00090 void emptyDeviceLink(DEVICELINK **deviceLink1, DEVICELINK **deviceLink2);
00091 void dumpDeviceLink(DEVICELINK *deviceLink1, IE3ADDR coorAddr);
00092 
00093 //----------------------------------------------------------------------------------------
00094 
00095 #define maxNumTransactions      70
00096 
00097 class TRANSACLINK
00098 {
00099 public:
00100         UINT_8 pendAddrMode;
00101         union
00102         {
00103                 UINT_16 pendAddr16;
00104                 IE3ADDR pendAddr64;
00105         };
00106         Packet *pkt;
00107         UINT_8 msduHandle;
00108         double expTime;
00109         TRANSACLINK *last;
00110         TRANSACLINK *next;
00111         TRANSACLINK(UINT_8 pendAM, IE3ADDR pendAddr, Packet *p, UINT_8 msduH, double kpTime)
00112         {
00113                 pendAddrMode = pendAM;
00114                 pendAddr64 = pendAddr;
00115                 pkt = p;
00116                 msduHandle = msduH;
00117                 expTime = CURRENT_TIME + kpTime;
00118                 last = NULL;
00119                 next = NULL;
00120         };
00121 };
00122 
00123 void purgeTransacLink(TRANSACLINK **transacLink1, TRANSACLINK **transacLink2);
00124 int addTransacLink(TRANSACLINK **transacLink1, TRANSACLINK **transacLink2, UINT_8 pendAM, IE3ADDR pendAddr, Packet *p, UINT_8 msduH, double kpTime);
00125 Packet *getPktFrTransacLink(TRANSACLINK **transacLink1, UINT_8 pendAM, IE3ADDR pendAddr);
00126 int updateTransacLink(int oper, TRANSACLINK **transacLink1, TRANSACLINK **transacLink2, UINT_8 pendAM, IE3ADDR pendAddr);
00127 int updateTransacLinkByPktOrHandle(int oper, TRANSACLINK **transacLink1, TRANSACLINK **transacLink2, Packet *pkt, UINT_8 msduH = 0);
00128 int numberTransacLink(TRANSACLINK **transacLink1, TRANSACLINK **transacLink2);
00129 int chkAddTransacLink(TRANSACLINK **transacLink1, TRANSACLINK **transacLink2, UINT_8 pendAM, IE3ADDR pendAddr, Packet *p, UINT_8 msduH, double kpTime);
00130 void emptyTransacLink(TRANSACLINK **transacLink1, TRANSACLINK **transacLink2);
00131 void dumpTransacLink(TRANSACLINK *transacLink1, IE3ADDR coorAddr);
00132 
00133 #endif
00134 
00135 // End of file: p802_15_4transac.h

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