12.07.2015 Views

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Two i<strong>ns</strong>tance procedures in the base class , set-event{} <strong>and</strong> set-event-exact{}, can be used to scheduleevents in the route queue.set-event{interval, oper<strong>at</strong>ion} schedules oper<strong>at</strong>ion after interval seconds from the current time; it uses theprocedure set-event-exact{} below.set-event-exact{fireTime, oper<strong>at</strong>ion} schedules oper<strong>at</strong>ion to execute <strong>at</strong> fireTime.If the time for execution is gre<strong>at</strong>er than the finishTime_, then the only possible action is to take a failed link “up”.Finally, the base class provides the methods to take the links up{} or down{}. Each method invokes the appropri<strong>at</strong>eprocedure on each of the links in the i<strong>ns</strong>tance variable, links_.Exponential<strong>The</strong> model schedules its first event to take the links down <strong>at</strong> startTime_ + E(upInterval_);It also defines the procedures, up{} <strong>and</strong> down{}; each procedure invokes the base class procedure to perform the actualoper<strong>at</strong>ion. This routine then reschedules the next event <strong>at</strong> E(upInterval) or E(downInterval_) respectively.Deterministic <strong>The</strong> model defines the procedures, up{} <strong>and</strong> down{}; each procedure invokes the base class procedure toperform the actual oper<strong>at</strong>ion. This routine then reschedules the next event <strong>at</strong> upInterval or downInterval_ respectively.Trace<strong>The</strong> model redefines the i<strong>ns</strong>tance procedure set-parms{} to operan a trace file, <strong>and</strong> set events based on th<strong>at</strong> input.<strong>The</strong> i<strong>ns</strong>tance procedure get-next-event{} retur<strong>ns</strong> the next valid event from the trace file. A valid event is an event th<strong>at</strong>is applicable to one of the links in this object’s links_ variable.<strong>The</strong> i<strong>ns</strong>tance procedure set-trace-events{} uses get-next-event{} to schedule the next valid event.<strong>The</strong> model redefines set-first-event{}, up{}, <strong>and</strong> down{} to use set-trace-events{}.<strong>Manual</strong> <strong>The</strong> model is designed to fire exactly once. <strong>The</strong> i<strong>ns</strong>tance procedure set-parms{} takes an oper<strong>at</strong>ion <strong>and</strong> thetime to execute th<strong>at</strong> oper<strong>at</strong>ion as arguments. set-first-event{} will schedule the event <strong>at</strong> the appropri<strong>at</strong>e moment.This routine also redefines notify{} to delete the object i<strong>ns</strong>tance when the oper<strong>at</strong>ion is completed. This notion of the objectdeleting itself is fragile code.Since the object only fires once <strong>and</strong> does nto have to be rescheduled, it does not overload the procedures up{} or down{}.31.2.2 class rtQueue<strong>The</strong> simul<strong>at</strong>or needs to co-ordin<strong>at</strong>e multiple simultaneous network dynamics events, especially to e<strong>ns</strong>ure the right coherentbehaviour. Hence, the network dynamics models use their own internal route queue to schedule dynamics events. <strong>The</strong>re isone i<strong>ns</strong>tance of this object in the simul<strong>at</strong>or, in the class Simul<strong>at</strong>or i<strong>ns</strong>tance variable rtq_.<strong>The</strong> queue object stores an array of queued oper<strong>at</strong>io<strong>ns</strong> in its i<strong>ns</strong>tance variable, rtq_. <strong>The</strong> index is the time <strong>at</strong> which the eventwill execute. Each element is the list of oper<strong>at</strong>io<strong>ns</strong> th<strong>at</strong> will execute <strong>at</strong> th<strong>at</strong> time.<strong>The</strong> i<strong>ns</strong>tance procedures i<strong>ns</strong>q{} <strong>and</strong> i<strong>ns</strong>q-i{} can i<strong>ns</strong>ert an element into the queue.277

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!