CSMAMacLayer.h

00001 #ifndef CSMAMAC_LAYER_H
00002 #define CSMAMAC_LAYER_H
00003 
00004 #include <list>
00005 #include <PhyUtils.h>
00006 #include <BaseMacLayer.h>
00007 #include <BaseUtility.h>
00008 #include <MacPkt_m.h>
00009 #include <SimpleAddress.h>
00010 #include <MacToPhyInterface.h>
00011 
00012 
00051 class  CSMAMacLayer : public BaseMacLayer
00052 {
00053   public:
00054   virtual ~CSMAMacLayer();
00055 
00056   protected:
00058     typedef std::list<cPacket*> MacQueue;
00059 
00066     enum States {
00068         RX,
00070         CCA,
00072         TX,
00073     };
00074 
00076     States macState;
00077 
00085     double slotDuration;
00086 
00092     double difs;
00093 
00096     MacQueue macQueue;
00097 
00099     unsigned queueLength;
00100 
00102     cMessage* backoffTimer;
00103 
00109     cMessage* minorMsg;
00110 
00117     unsigned txAttempts;
00118 
00123     unsigned maxTxAttempts;
00124 
00126     double bitrate;
00127 
00129     double txPower;
00130 
00132     unsigned initialCW;
00133 
00135     double nbBackoffs;
00136 
00138     double backoffValues;
00139 
00141     unsigned long nbTxFrames;
00142 
00144     //DroppedPacket droppedPacket;
00145 
00147     //int catDroppedPacket;
00148 
00150     //int nicId;
00151 
00152 protected:
00154     virtual void initialize(int);
00155 
00157     virtual void finish();
00158 
00160     virtual void handleLowerMsg(cMessage*);
00161 
00163     virtual void handleUpperMsg(cMessage*);
00164 
00166     virtual void handleSelfMsg(cMessage*);
00167 
00169     virtual void handleLowerControl(cMessage *msg);
00170 
00180     virtual void scheduleBackoff();
00181 
00185     virtual MacPkt* encapsMsg(cPacket* pkt);
00186 };
00187 
00188 #endif
00189