#include <SlottedAloha.h>
Inherits DESystem.
Inheritance diagram for SysSAloha:
Public Member Functions | |
SysSAloha (ParamManager *_Param, GlobalProbeManager *_Results, ProbeManager *_ProbeMg) | |
the DESystem subclass constructor must have those 3 parameters. NePSing will provide the right values. | |
void | Initialize () |
the DESystem subclass Initialize() must be here. | |
virtual | ~SysSAloha () |
the subclass destructor is optional. | |
Static Public Member Functions | |
void | setup (ParamManager *Param, GlobalProbeManager *Results) |
the DESystem subclass setup() must have those 2 parameters. NePSing will provide the right values. |
This class is a subclass of DESystem. It does nothing but:
In a simulator there must be only one class derived by DESystem and it should looks like this one.
NePSing will create only one intance of this class at the simulation start and will destroy it when the simulation will end.
All the simulation elements should be dynamically created or there should be a cleanup system in the respectives Initalize() functions, as a simulation could be used in multirun mode.
Definition at line 38 of file SlottedAloha.h.
|
the DESystem subclass constructor must have those 3 parameters. NePSing will provide the right values. In the contructor we will only have to set up the default value of the various variables. The main due-to of this function is to propagate its 3 parameters to the DESystem constructor and to feed the DESystem constructor with the DETime construction paramteres, i.e.:
note here the use of the stringToULL() function to convert the time length of a Step form a 'natural' format (i.e., in seconds) to the needed format, as is expanded according to the TimeResolution. Since in this simulator we will only use the Step structure, we will pass 1 to the last 2 parameters.
Definition at line 26 of file SlottedAloha.cpp. References stringToULL(). 00027 : DESystem(_Param, 00028 _Results, 00029 _ProbeMgr, 00030 get<IntParameter,int>(_Param, "TimeResolution", "SAloha", ""), 00031 stringToULL( get<StringParameter,string>(_Param, "SlotTime", "SAloha", ""), 00032 get<IntParameter,int>(_Param, "TimeResolution", "SAloha", "") ), 00033 1, 00034 1) 00035 { 00036 // remember to clean the pointers to dynamical objects AND 00037 // to instantiate them in the Initialize() function, NOT here! 00038 ap = 0; 00039 PktGen = 0; 00040 }
|
Here is the call graph for this function:
|
the subclass destructor is optional. Your O.S. sould take care of this, as this destuctor is only called when the program exits, but... Definition at line 102 of file SlottedAloha.cpp. 00103 { 00104 if( ap ) 00105 delete ap; 00106 00107 if( PktGen ) 00108 delete PktGen; 00109 }
|
|
the DESystem subclass Initialize() must be here. Initialize() is the core of this class, as here you'll want to create your first objects. The only thing you must do is to call the DESystem::Initialize() function. Sorry but I haven't found any reliable way to do it outside of here. Reimplemented from DESystem. Definition at line 80 of file SlottedAloha.cpp. References DevPktGen::Initialize(), DevAP::Initialize(), and DESystem::Initialize(). 00081 { 00082 DESystem::Initialize(); 00083 00084 // the Access Point is created here. Remember that Initialize() could be called multiple times, 00085 // so you need to destroy old objects before creating a new one. 00086 if( ap ) 00087 delete ap; 00088 ap = new DevAP(this); 00089 ap->Initialize(); 00090 00091 // the Packets Manager. 00092 // Since Pkts are created dynamically, a manager is the obvious choice. 00093 if( PktGen ) 00094 delete PktGen; 00095 PktGen = new DevPktGen(this, ap); 00096 PktGen->Initialize(); 00097 }
|
Here is the call graph for this function:
|
the DESystem subclass setup() must have those 2 parameters. NePSing will provide the right values. Setup function should only do 3 things (rather important, indeed):
Point 2 is of paramount importance, as noone will call those funtions if you don't do it here.
Definition at line 50 of file SlottedAloha.cpp. References ParamManager::addClass(), ParamManager::addParameter(), ParamManager::setDefault(), DevAP::setup(), DevPktGen::setup(), and DevPkt::setup(). 00051 { 00052 // general parameters, remember that the division between classes is only for your own convenience, 00053 // as you can read any parameter from any class if you want. 00054 Param->addClass ("SAloha", "SAloha system"); 00055 00056 Param->addParameter ("SAloha", new IntParameter("TimeResolution", "Risoluzione temporale", "-6", "(0,inf)" )); 00057 Param->addParameter ("SAloha", new StringParameter("SlotTime", "Length of a slot", "1", "(0,inf)" )); 00058 Param->addParameter ("SAloha", new DETimeParameter("RoundTripDelay", "Round trip delay", "1.1", "(0,inf)" )); 00059 00060 // remember to call you classes Setup() functions ! 00061 DevPkt::setup(Param, Results); 00062 DevPktGen::setup(Param, Results); 00063 DevAP::setup(Param, Results); 00064 00065 // this is optional, but sometimes very useful :) 00066 Param->setDefault("BaseFileName", "results/"); 00067 Param->setDefault("TimeResolution", "-6"); 00068 Param->setDefault("SimulationTime", "100000"); 00069 Param->setDefault("WriteStatsInterval", "10000"); 00070 Param->setDefault("DebugPrintInterval", "10000"); 00071 }
|
Here is the call graph for this function: