Jan 26, 2006

Exercise 2 : Multicast - Problem Solved

I managed to solve the problem of multicasting with multi group.. I guess the main problem is to have simultaneous CBR to start at the same time. I changed the starting time to 0.01 sec difference and the script work. I tested again the script and found out the problem was actually due to the allocation of the group address. It's required that group1 [Node allocaddr] to be called after creation nodes and links.

Here's the script :

set ns [new Simulator -multicast on]

# 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]

..
..
..

$ns attach-agent $n4 $rcvr4
$ns attach-agent $n5 $rcvr5

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

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

puts "Starting Simulation..."
$ns run

No comments: