Initialization of network simulator event
Things to remember when initialization of network simulator, Ns-2
When a new simulation object is created in tcl, the initialization procedure performs the following operations:
- initialize the packet format (calls create_packetformat)
- create a scheduler (defaults to a calendar scheduler)
- create a "null agent" (a discard sink used in various places)
There are 4 different types of scheduler that is created by using a different data structure:
- a simple linked-list,
- heap,
- calendar queue (default)
- and a special type called "real-time".
class Event {
public;
Event* next_; /* event list */
Handler* handler_; /* handler to call when event ready */
double time_; /* time at which event is ready */
int uid_; /* unique ID */
Event() : time_(0), uid_(0) {}
};
/*
* The base class for all event handlers. When an event’s scheduled
* time arrives, it is passed to handle which must consume it.
* i.e., if it needs to be freed it, it must be freed by the handler.
*/
class Handler {
public:
virtual void handle(Event* event);
};
No comments:
Post a Comment