# # AN ACTIVE NETWORKING MULTICAST SIMULATION # # DESCRIPTION # This script creates Active Agents at ns nodes which are enabled by # default upon creation of the nodes. The Active Agents at the end nodes # are disabled and the Active Agents at routing nodes function as # repair servers for reliable multicasting. The script demonstrates # repair server functionality as Active Agents are disabled. # # ACTIVE AGENT BASIC FUNCTIONALITY: # The only functionality in the basic # Active Agents consists of initialization and disabling. Initialization # registers the Active Agent with the active classifier in the node. # Active Agents can be disabled to prevent any packets from reaching the # Active Agent. This supports a fast path through the router. # # ACTIVE AGENT MULTICAST FUNCTIONALITY: # Additional functionality added to the active agents include the processing # of NAK packets from receivers and in response to the NAK packets, the # transmission of repair packets. NAK packets are passed to the next # upstream node and ultimately on to the sender if no Active Agents are # encountered in the upstream path. In this script, Active Agents do not # cache incoming data packets but enabled Active Agents are assumed to # have cached packets requested in a NAK. # # HOW PACKETS REACH THE ACTIVE AGENT: # Packets are directed to the Active Agent if the Active Agent in the node # has not been disabled, if the ANbit_ in the common header (hdr_cmn) has # been set to 1 and if the ANlocal_ bit is false. If the Active Agent # in the node has been disabled, packets are passed to the next node along # the transmission route. Packets passing through # or originating from the Active Agent have the ANlocal_ bit set to true # to allow the packets to proceed to the next hop in their route. # # HOW TO RUN THIS SCRIPT: # In order to run this script, ns must be recompiled with the following # files found in the anRMpkg.tar: # * classifier.cc # * classifier.h # * classifier-addr.cc # * packet.h # classifier-an.cc # classifier-switch.cc # ANAgent.cc # ANAgent.h # ANActive.cc # ANActive.h # ANSndr.h # ANSndr.cc # ANRcvr.h # ANRcvr.cc # * tcl/lib/ns-default.tcl # * tcl/lib/ns-node.tcl # * tcl/lib/ns-packet.tcl # The files marked with * are found in the original ns distribution but # have been modified to support Active Agents. # # NS2 MODIFICATIONS: # 1. Load the above files into the ns2 directory. # 2. In the ns2 Makefile.in, add this line to the OBJ_CC definition: # ANAgent.o ANActive.o ANRcvr.o ANSndr.o classifier-an.o classifier-switch.o # # /TCL/ FILE MODIFICATIONS: # 1. Place ANtest_rm.tcl in /tcl/ex/ # 2. In /tcl/lib/ replace the original ns-default.tcl, ns-node.tcl and ns-packet.tcl files with those in this package. # # # When the above changes have been made, ns is ready to be recompiled and # this script can be run to demonstrate the creation and disabling of # Active Agents. The tcl script of this file demonstrates that Active # Agents do not interfere in non-active simulation runs. A more complete # description of this tcl script follows. # # ############################################################################# ## PROBLEMS: ## ## For further information or to report problems with this package, please ## send email to: dkiwior@tasc.com ## ############################################################################# # # # File: ANtest_rm.tcl # # This program creates a 12 node topology. # (4) (5) # | / # | / # (3) ---- (6) # / \ # / \ # / (7) # (0) ---------- (1) # \ (8) # \ / # \ / # (2)---(9) # | \ # | \ # (11) (10) # # All nodes are created with Active Agents (green) by default. # The Active Agents at the end nodes are disabled (signified # by a change from green to black) at time 0.2. As the script runs, # the Active Agent at node 3 is disabled at time 1.0 and at time 1.4 # the Active Agent at node 1 is disabled. The Active Agents are # disabled in the tcl script in this example but may also be disabled # by packets from a sender. # # This script demonstrates an Active Sender which multicasts active data # packets (blue) to all members of the multicast group. The packets # are encoded with the proper bits to indicate that Active Agents en # route should cache these packets to provide repairs if needed. This # script does not simulate the caching function of the Active Agents. # An Active Receiver at node 4 responds to packet loss by transmitting # a NAK (red) with the missing sequence number upstream toward the # sender. # A retransmission (green) of the missing sequence number packet will be # initiated by an enabled Active Agent along the upstream path # # ############################################################################# set ns [new Simulator -multicast on] global numNodes set NumNodes 12 for {set i 0} {$i < $NumNodes} {incr i} { set node($i) [$ns node] } set f [open andemo.tr w] $ns trace-all $f set nf [open andemo.nam w] $ns namtrace-all $nf $ns color 1 blue # data pkt $ns color 2 white $ns color 3 red # nak pkt $ns color 4 yellow # start of block $ns color 5 black # end of block $ns color 6 green # repair pkt #distinction added for prune/join messages $ns color 30 purple $ns color 31 orange proc makelinks { bw delay pairs } { global ns node foreach p $pairs { set src $node([lindex $p 0]) set dst $node([lindex $p 1]) $ns duplex-link $src $dst $bw $delay DropTail $ns duplex-link-op $src $dst orient [lindex $p 2] } } makelinks 1Mb 30ms { { 1 3 right-up } { 1 2 right-down } } makelinks 1.5Mb 30ms { { 0 1 right } } makelinks 1.5Mb 20ms { { 3 4 up } { 3 5 right-up} { 3 6 right} { 3 7 right-down} { 2 8 right-up} { 2 9 right} { 2 10 right-down} { 2 11 down } } $ns duplex-link-op $node(1) $node(3) queuePos 0.5 $ns duplex-link-op $node(3) $node(4) queuePos 1.5 $ns duplex-link-op $node(1) $node(2) queuePos 1.5 global group set group 0x8002 set mproto CtrMcast set mrthandle [$ns mrtproto $mproto {}] if {$mrthandle != ""} { $ns at 0.01 "$mrthandle switch-treetype 0x8002" } ############################################################# Agent/AN/Sndr instproc start_session {} { $self set class_ 4 $self start session } Agent/AN/Sndr instproc send_data {} { $self set class_ 1 $self send data } Agent/AN/Sndr instproc send_block {} { $self set class_ 1 $self send block } Agent/AN/Sndr instproc send_blockend {} { $self set class_ 5 $self send blockend } ############################################################# Agent/AN/Rcvr set blockSize_ 10 Agent/AN/Rcvr set mydst_ 1 ########################################################## Agent/AN set class_ 6 Agent/AN set packetSize_ 500 Agent/AN set dst_ $group Agent/AN instproc get_addr {} { set addr [expr [[$self set node_] id] << 8 | [$self set portID_]] return $addr } Agent/AN instproc get_node {} { set addr [expr [[$self set node_] id] << 8 | [$self set portID_]] set nodertn [expr $addr >> 8] return $nodertn } ########################################################### Agent/AN/Active set dst_ $group Agent/AN/Active instproc send_init {} { global group $self set dst_ $self $self send init $self set dst_ $group } Agent/AN/Active instproc disable {} { global group $self set dst_ $self $self send disable $self set dst_ $group } ############################################################## set sndr [new Agent/AN/Sndr] $ns attach-agent $node(0) $sndr $node(0) color blue $sndr set packetSize_ 1000 $sndr set dst_ $group # change anagent($i) which works below to anagent to allow easier access to agent within C++ for {set i 0} {$i < $NumNodes} {incr i} { global ana_addr set anagent($i) [new Agent/AN/Active] $ns attach-agent $node($i) $anagent($i) $node($i) color green } # initialize the Active Agents for {set i 0} {$i < $NumNodes} {incr i} { $anagent($i) send_init } set rcvr(4) [new Agent/AN/Rcvr] $ns attach-agent $node(4) $rcvr(4) $rcvr(4) set class_ 3 $rcvr(4) set dst_ $sndr set rcvr(5) [new Agent/AN/Rcvr] $ns attach-agent $node(5) $rcvr(5) $rcvr(5) set class_ 3 $rcvr(5) set dst_ $sndr set rcvr(7) [new Agent/AN/Rcvr] $ns attach-agent $node(7) $rcvr(7) $rcvr(7) set class_ 3 $rcvr(7) set dst_ $sndr #set rcvr(10) [new Agent/AN/Rcvr] #$ns attach-agent $node(10) $rcvr(10) #$rcvr(10) set class_ 3 #$rcvr(10) set dst_ $sndr $ns at 0.2 { for {set i 4} { $i < $NumNodes} {incr i} { $anagent($i) disable $node($i) color black } $anagent(0) disable $node(0) color black } $ns at 0.4 { $node(5) join-group $rcvr(5) $group $node(5) color red # $node(10) join-group $rcvr(10) $group # $node(10) color red } $ns at 0.5 { $node(4) join-group $rcvr(4) $group $node(4) color red } $ns at 0.6 { $node(7) join-group $rcvr(7) $group $node(7) color red } $ns at 0.7 "$sndr start_session" $ns at 0.75 "$ns queue-limit $node(3) $node(4) 1" $ns at 0.8 { for {set i 0} {$i < 10} {incr i} { $sndr send_data } } $ns at 0.85 "$ns queue-limit $node(3) $node(4) 2" $ns at 0.9 "$sndr send_data" $ns at 1.0 { $anagent(3) disable $node(3) color black $anagent(2) disable $node(2) color black $ns queue-limit $node(3) $node(4) 3 $ns queue-limit $node(1) $node(3) 4 $ns queue-limit $node(1) $node(2) 4 } $ns at 1.1 { for {set i 0} {$i < 12} {incr i} { $sndr send_data } } $ns at 1.3 "$sndr send_data" $ns at 1.6 { $anagent(1) disable $node(1) color black } $ns at 1.7 "$sndr send_data" $ns at 1.9 { for {set i 0} {$i < 12} {incr i} { $sndr send_data } } $ns at 2.6 "finish" proc finish {} { global ns f $ns flush-trace close $f puts "running nam..." exec nam andemo.nam & exit 0 } $ns run $ns clear-mcast