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.

global logtimer <strong>ns</strong>_ <strong>ns</strong>set <strong>ns</strong> $<strong>ns</strong>_source ../mobility/timer.tclClass LogTimer -superclass TimerLogTimer i<strong>ns</strong>tproc timeout {} {global opt node_;for {set i 0} {$i < $opt(nn)} {incr i} {$node_($i) log-movement}$self sched 0.1}}set logtimer [new LogTimer]$logtimer sched 0.1In this case, mobilenode positio<strong>ns</strong> would be logged every 0.1 sec.16.1.3 Network Components in a mobilenode<strong>The</strong> network stack for a mobilenode co<strong>ns</strong>ists of a link layer(LL), an ARP module connected to LL, an interface priorityqueue(IFq), a mac layer(MAC), a network interface(netIF), all connected to the channel. <strong>The</strong>se network components arecre<strong>at</strong>ed <strong>and</strong> plumbed together in OTcl. <strong>The</strong> relevant MobileNode method add-interface() in ~<strong>ns</strong>/tcl/lib/<strong>ns</strong>-mobilenode.tcl isshown below:## <strong>The</strong> following setups up link layer, mac layer, network interface# <strong>and</strong> physical layer structures for the mobile node.#Node/MobileNode i<strong>ns</strong>tproc add-interface { channel pmodellltype mactype qtype qlen iftype anttype } {$self i<strong>ns</strong>tvar arptable_ nifs_$self i<strong>ns</strong>tvar netif_ mac_ ifq_ ll_global <strong>ns</strong>_ MacTrace optset t $nifs_incr nifs_set netif_($t) [new $iftype] ;# net-interfaceset mac_($t) [new $mactype] ;# mac layerset ifq_($t) [new $qtype] ;# interface queueset ll_($t) [new $lltype] ;# link layerset ant_($t) [new $anttype]## Local Variables#set nullAgent_ [$<strong>ns</strong>_ set nullAgent_]149

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

Saved successfully!

Ooh no, something went wrong!