Hi,
    Its not difficult to code such a Ping Agent which would send packets
without getting connected.  Actually when u call connect for agents, the
address gets associated (daddr, dport) so u dont need to set these values
when u create a new packet. When agents are connected, what u do is call
allocpkt(), set the ping header fields and call send. Address are already
associated and the IP header fields are set properly due to connect.

So if u dont want to connect the agents, first write a new command in the
ping.cc. I named it "sendto" and while calling this command you also need to
send the daddr and the dport values for the destination agent. Inside the
sendto code in ping.cc you can access these values using the argument vector
argv.

This time when u create a pkt using allocpkt, also create a pointer to the
IP header and set the values using the functions daddr(), dport(), saddr(),
sport() of the ip_header. When u send the packet now, it will be received by
the ping agent at node with the corresponding address and port.

Also u need to modify the recv function since the existing one doesnt
associate address. In the recv, you need to set the address for the reply
packet again using pointer to the ip headers. I mean the saddr() for reply
packet will be the daddr() of the received packet, daddr() for the reply
will be the saddr() of the received packet, and similarly for the port
fields..

This is relly a basic task and its not difficult.. still if u find any
problems with it... write it back..

Regards,
Sanjay Raghani
MTech CSE
Indian Institute of Technology, Roorkee
India
------------------------------

Message: 14
Date: Thu, 8 Jun 2006 01:09:08 +0330
From: "Saeed B" <[EMAIL PROTECTED]>
Subject: [ns] Sending Pings without connecting agents together
To: ns-users@ISI.EDU
Message-ID:
       <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=UTF-8; format=flowed

Dear All,
Hi,

I saw an email in ns-users mailing list (
http://mailman.isi.edu/pipermail/ns-users/2001-May/014861.html )
in which someone asked for the modified version of Marc Greis's Ping code
that could send pings simply using a code like:
'$pa send $node'
instead of making two instances of ping agent and connecting them together.
( Greis's code is available at:
http://www.isi.edu/nsnam/ns/tutorial/nsnew.html )

Does anyone know the answer? I need it as part of my thesis, and this will
help so much.
So, if you know how to do such a kind of task, it will be very kind of you
letting me know too.

Thanks in advance,

--Saeed.


------------------------------

Reply via email to