Jan 24, 2006

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)
** Ns-2 is an event-driven simulator, therefore scheduler is a crucial component for simulation to determine all the events to be simulated accordingly.

There are 4 different types of scheduler that is created by using a different data structure:

  1. a simple linked-list,
  2. heap,
  3. calendar queue (default)
  4. and a special type called "real-time".
The actual definition of event is found is ~ns/scheduler.h

class Event {
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 {
virtual void handle(Event* event);

No comments: