• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/wpan/p802_15_4csmaca.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_4csmaca.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_4csmaca.h,v 1.2 2007/01/30 05:00:52 tom_henderson 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_4csmaca_h
00054 #define p802_15_4csmaca_h
00055 
00056 #include "p802_15_4timer.h"
00057 #include "p802_15_4phy.h"
00058 #include "p802_15_4mac.h"
00059 
00060 
00061 class CsmaCA802_15_4
00062 {
00063         friend class macBackoffTimer;
00064         friend class macWakeupTimer; //2.31 change: Timer to control node shutdown and wakeup
00065         friend class macBeaconOtherTimer;
00066         friend class macDeferCCATimer;
00067         friend class Mac802_15_4;
00068 public:
00069         CsmaCA802_15_4(Phy802_15_4 *p, Mac802_15_4 *m);
00070         ~CsmaCA802_15_4();
00071 
00072 protected:
00073         void    reset(void);
00074         double  adjustTime(double wtime);
00075         bool    canProceed(double wtime, bool afterCCA = false);
00076         void    newBeacon(char trx);
00077         void    start(bool firsttime,Packet *pkt = 0,bool ackreq = 0);
00078         void    cancel(void);
00079         void    backoffHandler(void);
00080         void    RX_ON_confirm(PHYenum status);
00081         void    bcnOtherHandler(void);
00082         void    deferCCAHandler(void);
00083         void    CCA_confirm(PHYenum status);
00084 
00085 private:
00086         //timers
00087         macBackoffTimer         *backoffT;
00088         macBeaconOtherTimer     *bcnOtherT;
00089         macDeferCCATimer        *deferCCAT;
00090 
00091         Phy802_15_4 *phy;
00092         Mac802_15_4 *mac;
00093         UINT_8 NB;
00094         UINT_8 CW;
00095         UINT_8 BE;
00096 
00097         bool ackReq;
00098         bool beaconEnabled,beaconOther;
00099         bool waitNextBeacon;
00100         double bcnTxTime,bcnRxTime;
00101         double bPeriod;                         //backoff periods
00102         int bPeriodsLeft;                       //backoff periods left for next superframe (negative value means no backoff)
00103         Packet *txPkt;
00104 };
00105 
00106 #endif
00107 
00108 // End of file: p802_15_4csmaca.h

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