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

FW: [ns] group allocation and assignment question



> I'd really like to be able to allocate and assign a group inside of c++,
> so to do this I'm using tcl commands like tcl.evalc("Node allocaddr")
> and grabbing the string. I wanted to assign that address to something
> useful, but it looks like all of the addressing in ns is done with an
> ns_addr_t object, built into the config.h file. How do I take my string
> (Usually a negative number!? like -34399384) and make it an ns_addr_t
> object? I tried declaring and binding one inside my c++ so I could bind
> in tcl, but the bind command doesn't take a ns_addr_t as an arg either.
> So basically, 1) are the numbers supposed to be negative, and 2) how do
> I convert from a string to an ns address? 

All multicast addresses have the first bit set to 1, that's why you have
these negative numbers.

They are considered as node addresses (i.e., the addr_ part in ns_addr_t), 
but do not have any port address. 
When you attach a protocol agent to a node, a port address is automatically
assigned. That's where the port_ in ns_addr_t comes from.

Given this, you can assign your mcast address to the addr_ part. Without 
knowing your context I don't know how you can get port_ out of blue...

Hope this helps. Correct me if I'm wrong.