[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NS Multicast address problem



Dear All,

I've been doing multicast research using NS version 2.1b5 on Linux (RedHat
5.2), and I am curious about the way that NS handles addresses, specifically
in the dst_ member variable of the "Agent" class.  It appears that sending
to multicast addresses with the most significant bit set doesn't work.  At
the end of this message, I have included an example TCL file with a simple,
two-node network.  There are two possible settings for the "group" variable,
one works (0x60008000) and the other does not (0xE0008000).  For the address
that does not work, NS runs, but NAM shows no packets traversing the link.
In addition, NAM reports joining a negative group (specifically -536838144).

I have a theory of why this happens: If you take a look to the agent.h file
(The Agent class header file) in the ns-2.1b5 directory, you will find that
the member variable named dst_ is declared in line 103 of being of type
nsaddr_t. This type is a typedef of the user type int32_t, as it is declared
in line 69 of the file config.h, under the same directory. In line 62 of the
same file, int32_t is a typedef of the primitive type int; In summary,
dst_is a signed integer. This may pose problems with the most significant
bit that determines the sign of the integer, and the dst_ field, especially
if this field is used as an index or a key in some types of search.

I traced the sending of a packet using gdb over linux, and I found this: In
line 71 of agent.h, we can see that whenever an agent sends a packet, it
really calls the receive function of the target_ that is declared as a
member pointer of type NSObject, as you can see in line 56 of connector.h
(The Connector class is superclass of Agent, and implements the agent's recv
function). This receive function is pure virtual in NSObject (line 48 of
object.h), but in runtime the target_ member is pointing to an object of
type Classifier that tries to use the packet to do a find (as you can see in
classifier.cc, line 126). I found that this find function fails, returning a
null value code that makes the classifier object drop the packet (lines 126
to 135 in classifier.cc), probably because of the negative value of the
signed integer dst_ address.

Are addresses with the MSb set simply illegal in NS?  Thanks for your
attention.

Greetings,

Daniel Hernandez
Graduate Student
http://cs.baylor.edu/~hernand

-----------------------------------------
set ns [new Simulator -multicast on]

set f [open out.tr w]
$ns trace-all $f
$ns namtrace-all [open out.nam w]

set group 0x60008000    # Address works
#set group 0xE0008000   # Address does not work

set n0 [$ns node]
set n1 [$ns node]
$ns duplex-link $n0 $n1 1Mb 10ms DropTail

set mproto DM
set mrthandle [$ns mrtproto $mproto {}]

set udp [new Agent/UDP]
$ns attach-agent $n0 $udp
set src [new Application/Traffic/CBR]
$src attach-agent $udp
$udp set dst_ $group

set rcvr [new Agent/LossMonitor]
$ns attach-agent $n1 $rcvr

$ns at 0.1 "$src start"
$ns at 0.11 "$n1 join-group $rcvr $group"
$ns at 0.5 "finish"

proc finish {} {
    global ns
    $ns flush-trace

    puts "running nam..."
    exec nam out.nam &
    exit 0
}

$ns run