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.

<strong>The</strong> monitor-queue function is co<strong>ns</strong>tructed similarly to trace-queue. By calling the link’s init-monitor procedure,it arranges for the cre<strong>at</strong>ion of objects (SnoopQueue <strong>and</strong> QueueMonitor objects) which can, in turn, be used toascertain time-aggreg<strong>at</strong>ed queue st<strong>at</strong>istics.<strong>The</strong> drop-trace function provides a way to specify a Queue’s drop target without having a direct h<strong>and</strong>le of the queue.26.2 Library support <strong>and</strong> examples<strong>The</strong> Simul<strong>at</strong>or procedures described above require the trace <strong>and</strong> init-monitor methods associ<strong>at</strong>ed with the OTclLink class. Several subclasses of link are defined, the most common of which is called SimpleLink. Thus, the trace<strong>and</strong> init-monitor methods are actually part of the SimpleLink class r<strong>at</strong>her than the Link base class. <strong>The</strong> tracefunction is defined as follows (in <strong>ns</strong>-link.tcl):## Build trace objects for this link <strong>and</strong># upd<strong>at</strong>e the object linkage#SimpleLink i<strong>ns</strong>tproc trace { <strong>ns</strong> f } {$self i<strong>ns</strong>tvar enqT_ deqT_ drpT_ queue_ link_ head_ fromNode_ toNode_$self i<strong>ns</strong>tvar drophead_set enqT_ [$<strong>ns</strong> cre<strong>at</strong>e-trace Enque $f $fromNode_ $toNode_]set deqT_ [$<strong>ns</strong> cre<strong>at</strong>e-trace Deque $f $fromNode_ $toNode_]set drpT_ [$<strong>ns</strong> cre<strong>at</strong>e-trace Drop $f $fromNode_ $toNode_]$drpT_ target [$drophead_ target]$drophead_ target $drpT_$queue_ drop-target $drpT_$deqT_ target [$queue_ target]$queue_ target $deqT_}if { [$head_ info class] == "networkinterface" } {$enqT_ target [$head_ target]$head_ target $enqT_# puts "head is i/f"} else {$enqT_ target $head_set head_ $enqT_# puts "head is not i/f"}This function establishes Enque, Deque, <strong>and</strong> Drop traces in the simul<strong>at</strong>or $<strong>ns</strong> <strong>and</strong> directs their output to I/O h<strong>and</strong>le $f.<strong>The</strong> function assumes a queue has been associ<strong>at</strong>ed with the link. It oper<strong>at</strong>es by first cre<strong>at</strong>ing three new trace objects <strong>and</strong>i<strong>ns</strong>erting the Enque object before the queue, the Deque object after the queue, <strong>and</strong> the Drop object between the queue <strong>and</strong>its previous drop target. Note th<strong>at</strong> all trace output is directed to the same I/O h<strong>and</strong>le.This function performs one other additional tasks. It checks to see if a link contai<strong>ns</strong> a network interface, <strong>and</strong> if so, leaves it asthe first object in the chain of objects in the link, but otherwise i<strong>ns</strong>erts the Enque object as the first one.232

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

Saved successfully!

Ooh no, something went wrong!