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.

11.2 OTcl Timer classA simple timer class is defined in ~<strong>ns</strong>/tcl/mcast/timer.tcl. Subclasses of Timer can be defined as needed. Unlike the C++timer API, where a sched() aborts if the timer is already set, sched() <strong>and</strong> resched() are the same; i.e., no st<strong>at</strong>e is kept forthe OTcl timers. <strong>The</strong> following methods are defined in the Timer base class:$self sched $delay$self resched $delay$self cancel$self destroy$self expire;# causes "$self timeout" to be called $delay seconds in the future;# same as "$self sched $delay";# cancels any pending scheduled callback;# same as "$self cancel";# calls "$self timeout" immedi<strong>at</strong>ely11.3 Comm<strong>and</strong>s <strong>at</strong> a glanceFollowing is a list of methods for the class Timer. Note th<strong>at</strong> many different types of timers have been derived from this baseclass (viz. LogTimer, Timer/Iface, Timer/Iface/Prune, CacheTimer, Timer/Scuba etc).$timer sched This comm<strong>and</strong> cancels any other event th<strong>at</strong> may have been scheduled <strong>and</strong> re-schedules another event after time .$timer resched Similar to "sched" described above. Added to have similar APIs as th<strong>at</strong> of the C++ timers.$timer cancelThis cancels any scheduled event.$timer destroyThis is similar to cancel. Cancels any scheduled event.$timer expireThis comm<strong>and</strong> calls for a time-out. However the time-out procedure needs to be defined in the sub-classes.All these procedures can be found in <strong>ns</strong>/tcl/mcast/timer.tcl.115

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

Saved successfully!

Ooh no, something went wrong!