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.

$<strong>ns</strong> mrtproto ST;# specify shared tree mode to run on all nodesNotice in the above examples th<strong>at</strong> CtrMcast retur<strong>ns</strong> a h<strong>and</strong>le th<strong>at</strong> can be used for additional configur<strong>at</strong>ion of centralisedmulticast routing. <strong>The</strong> other routing protocols will return a null string. All the nodes in the topology will run i<strong>ns</strong>tances of thesame protocol.Multiple multicast routing protocols can be run <strong>at</strong> a node, but in this case the user must specify which protocol ow<strong>ns</strong> whichincoming interface. For this finer control mrtproto-iifs{} is used.New/unused multicast address are alloc<strong>at</strong>ed using the procedure allocaddr{}.<strong>The</strong> agents use the i<strong>ns</strong>tance procedures join-group{} <strong>and</strong> leave-group{}, in the class Node to join <strong>and</strong> leave multicastgroups. <strong>The</strong>se procedures take two m<strong>and</strong><strong>at</strong>ory arguments. <strong>The</strong> first argument identifies the corresponding agent <strong>and</strong> secondargument specifies the group address.An example of a rel<strong>at</strong>ively simple multicast configur<strong>at</strong>ion is:set <strong>ns</strong> [new Simul<strong>at</strong>or -multicast on]set group [Node allocaddr]set node0 [$<strong>ns</strong> node]set node1 [$<strong>ns</strong> node]$<strong>ns</strong> duplex-link $node0 $node1 1.5Mb 10ms DropTail;# enable multicast routing;# alloc<strong>at</strong>e a multicast address;# cre<strong>at</strong>e multicast capable nodesset mproto DM;# configure multicast protocolset mrth<strong>and</strong>le [$<strong>ns</strong> mrtproto $mproto] ;# all nodes will contain multicast protocol agentsset udp [new Agent/UDP] ;# cre<strong>at</strong>e a source agent <strong>at</strong> node 0$<strong>ns</strong> <strong>at</strong>tach-agent $node0 $udpset src [new Applic<strong>at</strong>ion/Traffic/CBR]$src <strong>at</strong>tach-agent $udp$udp set dst_addr_ $group$udp set dst_port_ 0set rcvr [new Agent/LossMonitor] ;# cre<strong>at</strong>e a receiver agent <strong>at</strong> node 1$<strong>ns</strong> <strong>at</strong>tach-agent $node1 $rcvr$<strong>ns</strong> <strong>at</strong> 0.3 "$node1 join-group $rcvr $group" ;# join the group <strong>at</strong> simul<strong>at</strong>ion time 0.3 (sec)30.1.1 Multicast Behavior Monitor Configur<strong>at</strong>ion<strong>ns</strong> supports a multicast monitor module th<strong>at</strong> can trace user-defined packet activity. <strong>The</strong> module counts the number of packetsin tra<strong>ns</strong>it periodically <strong>and</strong> prints the results to specified files. <strong>at</strong>tach{} enables a monitor module to print output to a file.trace-topo{} i<strong>ns</strong>ets monitor modules into all links. filter{} allows accounting on specified packet header, field inthe header), <strong>and</strong> value for the field). Calling filter{} repe<strong>at</strong>edly will result in an AND effect on the filtering condition.print-trace{} notifies the monitor module to begin dumping d<strong>at</strong>a. ptype() is a global arrary th<strong>at</strong> takes a packet typename (as seen in trace-all{} output) <strong>and</strong> maps it into the corresponding value. A simple configur<strong>at</strong>ion to filter cbr packetson a particular group is:set mcastmonitor [new McastMonitor]set chan [open cbr.tr w]$mmonitor <strong>at</strong>tach $chan1$mcastmonitor set period_ 0.02;# open trace file;# <strong>at</strong>tach trace file to McastMoniotor object;# default 0.03 (sec)262

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

Saved successfully!

Ooh no, something went wrong!