Showing posts with label event. Show all posts
Showing posts with label event. Show all posts

Dec 8, 2006

how events are scheduled

Hi,

In OTcl when you write any statement like
$ns at $stop "finish_proc"

then in scheduler.cc, it schedules the the 'finish_proc' (or anything u
want) to execute/run at time 'stop'.

In C++, you have to call the schedule method with the parameters (a handler,
a packet and delay), like here

Scheduler::instance().schedule(handler, packet, delay);

Basically, scheduler.cc is the main file that does all the scheduling
whenever called and then running one after other.

Hope it will help.

Shafiq


----- Original Message -----
From: "Savitri P. Pandharikar"
To:
Sent: Tuesday, December 05, 2006 10:30 PM
Subject: [ns] how events are scheduled


>
> Hi,
>
> I want to know more about NS-2 but I am still confused only about the
> event
> scheduler.I studied the NS manual also.But then also its not clear.Can
> please explain how events are scheduled one after another.
>
> Thanks
> Savitri P

tags :

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 {
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);
};