[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] Multicast on LAN
Hi,
I am trying to use multicast on a LAN. In my simulation, all the nodes in
the LAN join a multicast group and one of them (called a Master node)
sends packets periodically to the multicast group and other listen. In
case of failure of the master, one of the remainig nodes become the Master
node according to some election protocol. I wrote a new Agent and use data
portion of the UDP packet to run my protocol. When I run my script,
initially the master is sending a packet to the multicast group, but at
the receiving end, I am getting the following error. The problem is that
the iface_ variable in the common packet header is -1 when the packet is
received. I have no idea why this is happening. I am pasting my script
(which is similar to ~ns/tcl/ex/mcast.tcl except that instead of creating
duplex links, I create a LAN consisting of all the nodes). Should I do
anything else other than enabling multicast, joining the multicast group,
setting the dst_addr_ and dst_port_ in the agent, creating a LAN
consisting of created nodes ? Should I explicitly create and attach
interface ? The examples in lantest.tcl, vlantest-mcast.tcl use other
nodes that are not part of the LAN itself but are directly linked to one
of the nodes in LAN. My scenario is a bit different in that there is no
outside node, all nodes are in the LAN. I would appreciate any help
regarding this. Please see the script and the error message below.
Thanks,
Sarat.
My Script:
set opt(tr) out.tr
set opt(namtr) "out.nam"
set opt(adv_interval) 3
set opt(bw) 10Mb
set opt(delay) 1ms
set opt(ll) LL
set opt(ifq) Queue/DropTail
set opt(mac) Mac/802_3
set opt(stop) 5
set opt(chan) Channel
set opt(nnodes) 4
## procedures
proc finish {} {
global ns opt trfd
$ns flush-trace
close $trfd
exec nam out.nam &
exit 0
}
proc create-local-net {} {
global ns opt agent group
# create the nodes for MHA and BHAs
puts "Creating the nodes ..."
set num $opt(nnodes)
for {set i 0} {$i < $num} {incr i} {
set node($i) [$ns node]
lappend nodelist $node($i)
}
# For each of the nodes, attach the Agent/UDP/VHA Agent
puts "Creating and attaching the agents ..."
for {set i 0} {$i < $num} {incr i} {
set agent($i) [new Agent/UDP/VHA]
$agent($i) set myprio_ $i
$agent($i) set adv_interval_ $opt(adv_interval)
$agent($i) set dst_addr_ $group
$agent($i) set dst_port_ 0
$ns attach-agent $node($i) $agent($i)
$node($i) join-group $agent($i) $group
lappend agentlist $agent($i)
}
puts "Configuring the Master ..."
$agent([expr $num-1]) set master_ 1
puts "Creating the LAN ..."
set lannode [$ns newLan $nodelist $opt(bw) $opt(delay) \
-llType $opt(ll) -ifqType $opt(ifq) \
-macType $opt(mac) -chanType $opt(chan)]
}
## MAIN
set ns [new Simulator -multicast on]
set trfd [open $opt(tr) w]
$ns trace-all $trfd
set namfd [open $opt(namtr) w]
$ns namtrace-all $namfd
#allocate a multicast address
puts "Allocating the multicast address"
set group [Node allocaddr]
puts "Group addr is $group"
set mproto DM
set mrthandle [$ns mrtproto $mproto {}]
#create nodes for the MHA and BHAs
create-local-net
#start the simulation
puts "Starting the simulation ..."
$ns at 0.0 "$agent([expr $opt(nnodes)-1]) start"
$ns at $opt(stop) "finish"
$ns run
Error I am getting:
>ns vha.tcl
Allocating the multicast address
Group addr is -2147483648
Creating the nodes ...
Creating and attaching the agents ...
Configuring the Master ...
Creating the LAN ...
Starting the simulation ...
_o36 sending an advertisement
ns: _o28 new-group 3 -2147483648 -1 cache-miss: can't read
"protocols_(-1)": no such variable
while executing
"$protocols_($iface) upcall $code $source $group $iface"
(procedure "_o29" line 9)
(mrtObject upcall line 9)
invoked from within
"$mrtObject_ upcall $code $src $group $iface"
(procedure "_o25" line 3)
(Node new-group line 3)
invoked from within
"$node_ new-group $src $group $iface $code"
(procedure "_o28" line 3)
(Classifier/Multicast new-group line 3)
invoked from within
"_o28 new-group 3 -2147483648 -1 cache-miss"