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

Re: [ns] communication between agents.



Hi,
I have the same problem and I think  that the solution is the seguent: every
agent has a pointer, called target_ in C++ or target in OTcl, that points to
next NsObject that receives the packets from the agent
( target_::recv(p,h)) ). In example, in a classical comunication between a
sender A and a receiver B, the OTcl statement "$ns connect $A $B" sets
A::target_ to B and B::target_ to A. So, if you have another agent C, you
can write the OTcl statement "$A set target $C": in this manner, agent A
delivers its packets to C instead to B.
Naturally, if agent C has to deliver received packets to A, you need another
pointer, such as C::uptarget_, that points from C to A and you have to set
this pointer, by "$C set uptarget $A". So, you should modify the C++ source
code of the class Agent (or the derived class that you utilize for the agent
C), introducing the new pointer uptarget_.

I hope that my solution is right; if not, I hope that someone can tell me
where I'm wrong. Thanks
Regars

Sandro Petrizzelli - Politecnico di Bari (Italy)
(http://users.iol.it/sandry)
([email protected])


----- Original Message -----
From: Alexander Rasin <[email protected]>
To: <[email protected]>
Sent: Tuesday, May 01, 2001 8:34 PM
Subject: [ns] communication between agents.


>
> Hi,
>
> I am trying to find out how to pass a message string between two agents
> attached to the same node.
> I've looked at the documentation and at some examples but can not figure
> it out by myself.  I am sorry to be bothering you, but I honestly can't
> figure this out as I don't have any experience using C++ or tcl...
>
> As my mailing has been ignored, I assume that I am violating some
> unwritten rules of this list.  Please, at least tell me what exactly am I
> doing wrong?  I _have_ looked at documentation and some examples...
>
> set tcp_src1 [new Agent/TCP]
> set tcp_snk1 [new Agent/TCPSink]
>
> $ns_ attach-agent $n0 $tcp_src1
> $ns_ attach-agent $n0 $tcp_snk1
>
> In the actual source code of TCPSink, how would one go about passing a
> message to the TCP agent when something is received
> (in Agent/TCPSink::recv(Packet* pkt, Handler*) function)
>
> Please do not ignore this request as my (undergraduate) thesis is going to
> burn if I don't figure this out soon.
>
> Thank you very much
> Alex.
>