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.

42.3 InternalsThis section describes the internals of Session-level Packet Distribution. We first describe the OTcl primitives to configure asession level simul<strong>at</strong>ion (Section 42.3.1); we conclude with a brief note on hos packet forwarding is achieved (Section 42.3.2).42.3.1 Object LinkageWe describe three aspects of co<strong>ns</strong>tructing a session level simul<strong>at</strong>ion in <strong>ns</strong>: the modified topology routines th<strong>at</strong> permit thecre<strong>at</strong>ion of abstract nodes <strong>and</strong> links, establish the session helper for each active source, add receivers to the session byi<strong>ns</strong>erting the appropri<strong>at</strong>e loss <strong>and</strong> delay models when th<strong>at</strong> receiver joi<strong>ns</strong> the appropri<strong>at</strong>e group.Nodes <strong>and</strong> Links <strong>The</strong> node contai<strong>ns</strong> only its node id <strong>and</strong> the port number for the next agent. A link only contai<strong>ns</strong> the valuesof its b<strong>and</strong>width <strong>and</strong> delay.SessionNode i<strong>ns</strong>tproc init {} {$self i<strong>ns</strong>tvar id_ np_set id_ [Node getid]set np_ 0}SessionSim i<strong>ns</strong>tproc simplex-link { n1 n2 bw delay type } {$self i<strong>ns</strong>tvar bw_ delay_set sid [$n1 id]set did [$n2 id]}set bw_($sid:$did) [expr [string trimright $bw Mb] * 1000000]set delay_($sid:$did) [expr [string trimright $delay ms] * 0.001]Session Helper Each active source in a session requires a “session helper”. <strong>The</strong> session helper in <strong>ns</strong> is realised througha replic<strong>at</strong>or. This session helper is cre<strong>at</strong>ed when the user issues a cre<strong>at</strong>e-session{} to identify the source agent. <strong>The</strong>simul<strong>at</strong>or itself keeps a reference to the session helper in its i<strong>ns</strong>tance variable array, session_, indexed by the source <strong>and</strong>destin<strong>at</strong>ion address of the source.Note th<strong>at</strong> the destin<strong>at</strong>ion of source agent must be set before calling cre<strong>at</strong>e-session{}.SessionSim i<strong>ns</strong>tproc cre<strong>at</strong>e-session { node agent } {$self i<strong>ns</strong>tvar session_}set nid [$node id]set dst [$agent set dst_]set session_($nid:$dst) [new Classifier/Replic<strong>at</strong>or/Demuxer]$agent target $session_($nid:$dst);# <strong>at</strong>tach the replic<strong>at</strong>or to the sourcereturn $session_($nid:$dst) ;# keep the replic<strong>at</strong>or in the SessionSim i<strong>ns</strong>tance variable array session_375

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

Saved successfully!

Ooh no, something went wrong!