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...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

When using the emul<strong>at</strong>ion mode, a special version of the system scheduler is used: the RealTime scheduler. This scheduleruses the same underlying structure as the st<strong>and</strong>ard calendar-queue based scheduler, but ties the execution of events to realtime.It is described below.44.2 Real-Time Scheduler<strong>The</strong> real-time scheduler implements a soft real-time scheduler which ties event execution within the simul<strong>at</strong>or to real time.Provided sufficient CPU horsepower is available to keep up with arriving packets, the simul<strong>at</strong>or virtual time should closelytrack real-time. If the simul<strong>at</strong>or becomes too slow to keep up with elapsing real time, a warning is continually produced if theskew exceeds a pre-specified co<strong>ns</strong>tant “slop factor” (currently 10ms).<strong>The</strong> main disp<strong>at</strong>ch loop is found in the routine RealTimeScheduler::run(), in the file scheduler.cc. It followsessentially the following algorithm:• While simul<strong>at</strong>or is not halted– get current real time (“now”)– disp<strong>at</strong>ch all pending simul<strong>at</strong>or events prior to now– fetch next (future) event if there is one– delay until the next simul<strong>at</strong>or event is ready or a Tcl event occurs– if a tcl event occured, re-i<strong>ns</strong>ert next event in simul<strong>at</strong>or event queue <strong>and</strong> continue– otherwise, disp<strong>at</strong>ch simul<strong>at</strong>or event, continue– if there was no future even, check for Tcl events <strong>and</strong> continue<strong>The</strong> real-time scheduler should always be used with the emul<strong>at</strong>ion facility. Failure to do so may easily result in the simul<strong>at</strong>orrunning faster than real-time. In such cases, traffic passing through the simul<strong>at</strong>ed network will not be delayed by the properamount of time. Enabling the real-time scheduler requires the following specific<strong>at</strong>ion <strong>at</strong> the beginning of a simul<strong>at</strong>ion script:set <strong>ns</strong> [new Simul<strong>at</strong>or]$<strong>ns</strong> use-scheduler RealTime44.3 Tap Agents<strong>The</strong> class TapAgent is a simple class derived from the base Agent class. As such, it is able to gener<strong>at</strong>e simul<strong>at</strong>or packetscontaining arbitrarily-assigned values within the <strong>ns</strong> common header. <strong>The</strong> tap agent h<strong>and</strong>les the setting of the common headerpacket size field <strong>and</strong> the type field. It uses the packet type PT_LIVE for packets injected into the simul<strong>at</strong>or. Each tap agentcan have <strong>at</strong> most one associ<strong>at</strong>ed network object, although more than one tap agent may be i<strong>ns</strong>tanti<strong>at</strong>ed on a single simul<strong>at</strong>ornode.Configur<strong>at</strong>ion Tap agents are able to send <strong>and</strong> receive packets to/from an associ<strong>at</strong>ed Network object. Assuming a networkobject $netobj refers to a network object, a tap agent is configured using the network method:set a0 [new Agent/Tap]384

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

Saved successfully!

Ooh no, something went wrong!