Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

devAP.cpp

Go to the documentation of this file.
00001 #include <list>
00002 
00003 #include "devAP.h"
00004 
00017 DevAP::DevAP(DESystem *_System)
00018 : DEDevice(_System)
00019 {
00020   theBandProbe = 0;
00021   theBandSliceProbe = 0;
00022 
00023   halfSlot = DETime(time_int(1), time_int(0), time_int(0)) / 2;
00024 
00025 };
00026 
00027 void DevAP::setup(ParamManager *Param, GlobalProbeManager *Results)
00028 {
00029   Param->addClass ("AccessPoint", "Slotted Aloha access point");  
00030 }
00031 
00037 void DevAP::Initialize()
00038 {
00039 
00040   RoundTripDelay = get<DETimeParameter,DETime>(Param, "RoundTripDelay",  "SAloha", "");
00041   
00042   queue.clear();
00043   
00044   if( theBandProbe )
00045     delete( theBandProbe );
00046   theBandProbe = new ProbeBand( "theBand" );
00047 
00048   if( theBandSliceProbe )
00049     delete( theBandSliceProbe );
00050   theBandSliceProbe = new ProbeBandSlice( "theBandSlice" );
00051 }
00052 
00058 void DevAP::HEv_AP_Packet_Arrival(DevPkt* sender)
00059 {
00060   if( queue.empty() )
00061     newEvent(new Ev_AP_SelfCheck(this), halfSlot );
00062   
00063   queue.push_back(sender);
00064 }
00065 
00066 
00071 void DevAP::HEv_AP_SelfCheck()
00072 {
00073   if( queue.size() == 1 ) {
00074     // no collision
00075     newEvent(new Ev_Pkt_Feedback(queue.front(), 0), RoundTripDelay );
00076     theBandProbe->Observe(1.0);
00077     theBandSliceProbe->Observe(1.0);
00078   }
00079   else {
00080     // collisions
00081     list<DevPkt*>::iterator dtListIter;
00082     for(  dtListIter=queue.begin(); dtListIter!=queue.end(); dtListIter++)
00083       newEvent(new Ev_Pkt_Feedback(*dtListIter, 1), RoundTripDelay ); 
00084   }
00085   queue.clear();
00086 }
00087 
00088 

Generated on Wed Dec 22 23:26:43 2004 for NePSing Slotted Aloha example by doxygen 1.3.9.1 ---- Hosted by SourceForge.net Logo