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

Re: Agent Question...



Jeff,

The "address" in ns consists of an encoding of the node id and the agent port 
number.  A source agent can only send a message to a destination agent if it 
knows that agent's address.  If you simply used the node id, or some 
combination thereof, you may be lucky and get a message delivered, simply 
because the remaining components of the address turn out to be zero.  Lucky 
you :-)

Contrary to expectations, the "connect" method in the simulator class is not 
only for connection oriented traffic.  It takes as arguments, two agents,
and sets the source address of each agent to be the destination address of the 
other.  Roughly put, this is:

Simulator instproc connect { src dst } {
	$src set dst_ [$dst set addr_]
	$dst set dst_ [$src set addr_]
}

You may have to do something akin to this to send messages back and forth.
(BTW, do not peek into the current definition of the above instance 
procedure and copy it.  It is grossly broken, and changes are in the
works as we implement some scalable routing mechanisms.)

A good place to find examples, where destination addresses get dynamically
bound is in DV routing (~ns/tcl/rtglib/route-proto.tcl).  The init-all
function finds all the appropriate peer agents and their "addresses".
When one agent needs to send a route update to a peer agent, it finds the
correct destination address and sends to that address (which, as I just
peeked at the source code happends in C++, though it does not have to).


Kannan