Jan 25, 2006

Exercise 2 : Multicast

Create a network which looks like the following:



All links are 1 Mbps, 5 ms delay.

Choose DM (instead of CtrMcast) as the multicast routing protocol for the experiment. Node 0 is a UDP source for group 0 and node 2 is the source for group 1. The sources will start transmission at time 0.05. Nodes 3 and 4 will join the multicast group0 at times 0.10 and 0.12, respectively. Node 3 will leave the multicast group at 0.5, and then join group1 at 0.6. The execution will terminate at 0.8 sec.

Answer :

Tcl script :

set ns [new Simulator -multicast on]

# Dense Mode Multicast Protocol
set mproto DM
set mrthandle [$ns mrtproto $mproto {}]

# allocate a multicast address;
set group0 [Node allocaddr]
set group1 [Node allocaddr]

# Open nam tracefile
set nf [open prob1.nam w]

# Open tracefile
set nt [open trace.tr w]

$ns namtrace-all $nf
$ns trace-all $nt

$ns color 1 red
# the nam colors for the prune packets
$ns color 30 purple
# the nam colors for the graft packets
$ns color 31 green

#Define a 'finish' procedure
proc finish {} {
global ns nf nt
$ns flush-trace
close $nf
close $nt
puts "running nam..."
exec nam -a prob1.nam &
exit 0
}

# create 5 nodes
puts "create 5 nodes now....."

set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]

puts "create connections now....."

# Create connection
$ns duplex-link $n1 $n2 1Mb 5ms DropTail
$ns duplex-link $n2 $n3 1Mb 5ms DropTail
$ns duplex-link $n3 $n4 1Mb 5ms DropTail
$ns duplex-link $n2 $n4 1Mb 5ms DropTail
$ns duplex-link $n2 $n5 1Mb 5ms DropTail

# Node orientation
$ns duplex-link-op $n1 $n2 orient right
$ns duplex-link-op $n2 $n3 orient right
$ns duplex-link-op $n3 $n4 orient right
$ns duplex-link-op $n2 $n4 orient down
$ns duplex-link-op $n2 $n5 orient up

puts "Create agents and attach to appropriate nodes..."

# Create agents and attach to appropriate nodes
set udp0 [new Agent/UDP]
$ns attach-agent $n1 $udp0
$udp0 set dst_addr_ $group0
$udp0 set dst_port_ 0
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0

set udp1 [new Agent/UDP]
$ns attach-agent $n3 $udp1
$udp1 set dst_addr_ $group1
$udp1 set dst_port_ 1
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1

puts "schedule transmitting packets..."
# create receiver agents
set rcvr0 [new Agent/LossMonitor]
set rcvr1 [new Agent/LossMonitor]

$ns attach-agent $n4 $rcvr0
$ns attach-agent $n5 $rcvr1

# joining and leaving the group;
$ns at 0.10 "$n4 join-group $rcvr0 $group0"
$ns at 0.12 "$n5 join-group $rcvr1 $group0"
$ns at 0.50 "$n4 leave-group $rcvr0 $group0"
$ns at 0.60 "$n4 join-group $rcvr0 $group1"

$ns at 0.05 "$cbr0 start"
$ns at 0.05 "$cbr1 start"
$ns at 0.80 "finish"
$ns run


** Problem :

Unfortunately I ran into problem..still configuring what's wrong with the script :-( everything looks ok to me.. need to do some debugging!


Error :

ns: _o15 new-group 0 -2147483648 -1 cache-miss: can't read "protocols_(-1)": no
such variable
while executing
"$protocols_($iface) upcall $code $source $group $iface"
(procedure "_o16" line 9)
(mrtObject upcall line 9)
invoked from within
"$mrtObject_ upcall $code $src $group $iface"
(procedure "_o10" line 3)
(Node new-group line 3)
invoked from within
"$node_ new-group $src $group $iface $code"
(procedure "_o15" line 3)
(Classifier/Multicast new-group line 3)
invoked from within
"_o15 new-group 0 -2147483648 -1 cache-miss"


1 comment:

Mana Chetah said...

The problem is you start sending data to the group even before the routing information has been exchanged. Start the CBR source at a later time say 2.0