[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns] Multicast on LAN
Hi Sencun Zhu,
I think this is a BUG in ns (or may be a feature). Thanks for your reply.
After looking at your mail, I looked at the previous version of ns
(ns-2.1b5) code and I suppose that is what you are using. I am using
ns-2.1b6 and I traced out why this group address is so weird. The problem
is in classifier-mcast.cc. There is a function called
MCastClassifier::classify(Packet *pkt) which tries to classify an incoming
packet. It calls lookup_str() and when there is nothing found, it calls
new-group instproc. The statement is like below in the newer version
if (p == 0) {
// Didn't find an entry.
tcl.evalf("%s new-group %ld %ld %d cache-miss",
name(), src, dst, iface);
and in the older version it is like
if (p == 0) {
// Didn't find an entry.
tcl.evalf("%s new-group %u %u %d cache-miss",
name(), src, dst, iface);
As you can see there is a difference in the format string (%ld in the new
version and %u in the old version). So, the group 0x8000 that you are
getting is same as -2147483648 if you print as %ld and this is what is
passed to the tcl procedure new-group.
Thanks,
Sarat
On Fri, 24 Mar 2000, Sencun Zhu wrote:
> I think the group address you got is quite strange, I ran your program and
> got :0x8000.
>
>
>
> On Fri, 24 Mar 2000, Sarat Babu Kamisetty wrote:
>
> > 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"
> >
> >
> >
>