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

Re: about target_ variable!!!



Saehoon:
	As I understood, ns2 uses the following scheme to send 
packet:
	1) In ns2 Packet header, there were two fields "src" and" dst"
which are the "source node" and "destination node" copied from
corresponding "addr_" and "dst_" fields of Class agent when
allocating and sending packet from agent.
	2) "target_" is used to pass packet from higher
layor protocol to lower layro protocol, e.g.,  Tcp Application (App.
layor) pass the packet to Tcp Agent (Transport Layor) by calling
"target_->recv(p)" in Tcp Application.
	3)  At the "bottom" of protocol stack is "connector", so
when connector is called "recv(p)", it will demultiplex the
packet by it "dst_" field in header (maybe "src_" field also
in some demultiplexer), and then send the packet to corresponding
"link" which is composed by some components like queue, monitor,...,
so on...  finally the packet will arrive the connector of next
hop(node), and be passed from bottom of protocol stack to top.
		
		....

	So about your qeustion, if you want to send a packet back
to the sender from receiver, you first decide on which layor to
do that. And you need to make sure the two end-points have 
corresponding layor of protocol to communicate with each other.
If you use existing protocol like TCP, just go ahead use the
Tcp's sending function  "sendmsg" (or something similar) to send 
back the message,  if you want to send something from IP layor,
maybe you can call the "connector::send()" to do that; if you
even want to bypass "routing" and "queueing" stuff and want
to the other end to get a packet "directly", you can figure
out the sender's node by looking at "src" field of packet header,
and call src node's "recv" although this is ugly.

 
	hope this help


Kaichuan He
		

On Wed, 30 Jun 1999, Saehoon Kang wrote:

> hi ns-users,
> 
> I want to make a node send some message packets to the sender when the
> node receives a packet.
> In ns-c++ example files, I think they are using target_ ->recv(p)  to
> send packet.
> what is target_ and where is the value of target_  determined?
> 
> Best Regards,
> 
> Saehoon Kang
> 
>