The problem is that the packets that you are sending to A3 have an incorrect port address.
When you use $ns connect $a1 $a2 then automatically all normal control packets sent by a1 have the destination port of a2; as a1 is not connected to a3 in TCL, you must set the port by hand in C++, as NS will not do this for you, eg: void myAgent::recv(Packet* p, Handler *h) { hdr_ip *iph = hdr_ip::access(p); hdr_cmn *ch = hdr_cmn::access(p); ... iph->saddr() = addr(); // (set my IP address) iph->sport() = port(); // (set my source port) iph->daddr() = nextHop_iaddr; // iaddr of n3 iph->dport() = nextHop_iaddr; // port of a3 regarding the iaddr comment: check http://tagus.inesc-id.pt/~pestrela/ns2/ns2_haddr_tips.html In my ns2_shared_procs.tcl "utils" tcl file, I introduce procs for all possible conversions of each form, using the procs "handle2iaddr", "handle2haddr", "handle2id", etc. -------- you could also have debug this problem by: - redefining the no-slot handler to invoke the run-time TCL debugger; - use the mash inspector to find exactly who are _o153, _o158, etc (http://tagus.inesc-id.pt/~pestrela/ns2/ns2_debugging2.html) If this helps you, please contribute the description of the problem and the solution, in your own words, to the NS2 wiki. Pedro Vale Estrela > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf > Of Brad Montgomery > Sent: segunda-feira, 3 de Julho de 2006 19:25 > To: ns-users@isi.edu > Subject: Re: [ns] Multiple connections to a single agent > > > I'm not sure I understand, and perhaps I've not adequately described what > I'm trying to do, so I'll try again using a semi-hypothetical scenario: > (Please keep in mind I'm new to ns!) > > Suppose I've got the following topology: > > N1 - N2 - N3 > > And three "different" agents, (A1,A2,A3) which have all been implemented > differently in C++. The basic idea is that I want these agents to > automatically communicate with each other... > > In C++ I've written an A1::command() function that will 'send' sends an IP > packet to the A2 agent. When the A2 agent receives this packet, it then > sends a packet back to A1, which then gets returned to A2 (basically a 3- > way > handshake). A2 should then automatically send another packet to the A3 > agent by creating a packet, and inserting N3's address in the IP header. > (I'm assuming all of my agents and nodes know about the topology) > > In TCL I've done this: > ------------------------------------ > set n1 [$ns node] > set n2 [$ns node] > set n3 [$ns node] > > set a1 [new Agent/A1] > set a2 [new Agent/A2] > set a3 [new Agent/A3] > > $ns attach-agent $n1 $a1 > $ns attach-agent $n2 $a2 > $ns attach-agent $n3 $a3 > > $ns connect $a1 $a2 > #$ns connect $a2 $a3 ;# if I do this, the handshake doesn't work > > $ns at 0.0 $a1 send > ------------------------------------ > > When I run this, ns gives me this error: > > --- Classfier::no-slot{} default handler (tcl/lib/ns-lib.tcl) --- > _o158: no target for slot 3 > _o158 type: Classifier/Port > content dump: > classifier _o158 > 0 offset > 0 shift > 2147483647 mask > 1 slots > slot 0: _o153 (Agent/A3) > ---------- Finished standard no-slot{} default handler ---------- > > > Basically I want A3 to look at any or all packets send to N3. How can I > force this? > > I'm using ns-2.29 on Mac OS X 10.4.7. > > Thanks in advance! > > Brad > > > On 7/2/06 6:10 PM, "Mark Shifrin" <[EMAIL PROTECTED]> wrote: > > > no problem with tcp > > you can do attach agent as many time as you want to a single node. > > you must first define it as tcp-source. and then to choose the > application > > which runs over this > > tcp, for example i did it with FTP. moreover you can do it for n, within > a > > loop > > > > --- Brad Montgomery <[EMAIL PROTECTED]> wrote: > > > >> > >> Hello All, > >> > >> I'm wondering if it's possible to have a single Agent connected to 2 or > more > >> other Agents. I have a topology similar to this: > >> > >> N2 > >> | > >> N0 -- N1 -- N3 -- N4 > >> > >> I have an agents A0, A2, A3 connected to N0, N2, N3 respectively, and I > >> would like A0 to send a packet to A2, which would then in turn send a > packet > >> to A3. Is this possible? > >> > >>> From reading the mailing list archives, it seems like this may not be > >> possible, so my second question would be this: > >> > >> Is it possible to attach an agent to a Node, and force that agent's > recv > >> function to get executed for every packet that passes through that > node? > >> For example: Could N2 send a packet to N4, so that A3's recv function > >> processes that packet before sending it onward. > >> > >> Any help is GREATLY appreciated! > >> > >> Brad > >> > >> > > > > > > enjoy the life - > > Mark > > > > __________________________________________________ > > Do You Yahoo!? > > Tired of spam? Yahoo! Mail has the best spam protection around > > http://mail.yahoo.com