PDA

View Full Version : PING RFC


shiva
05-15-2003, 03:51 PM
Can any one explain the RFC involed in PING, and how the ICMP echo
message reaches the final destination. The reply which we are getting
is from our router or is it from the destination router.

Machine --->Our Router ----> nearest router ----> Destination machine
<--- <---- <-----

In the order of multiplexing.


Shiva

Loco
05-16-2003, 01:10 AM
Can any one explain the RFC involed in PING, and how the ICMP echo
message reaches the final destination. The reply which we are getting
is from our router or is it from the destination router.

Machine --->Our Router ----> nearest router ----> Destination machine
<--- <---- <-----

In the order of multiplexing.


Shiva

Basically your ICMP echo request packet travels all the way to the destination machine (assuming no filtering device drops it in its way). When the destination machine receives the packet, it creates an ICMP echo reply packet with the same payload and sends it back as a response.

Some things may happen in the way preventing the packets to reach their destination:

A filtering device might drop the packet, so the packet will never reach the destination host and no reply will ever come back
A filtering device might drop the response packet, so even if the detination host received the ping and sent a response, the originating host will never receive a reply
The packet TTL might reach 0, so the packet is silently dropped by the routing device and would never reach its destination
An overloaded device in the way might drop the packet
The destination host could also be overloaded and also drop the packet


Need more details???

shiva
05-16-2003, 09:15 AM
Thanx for yr reply,

I like to know how much time should wait in order to time out
in this scenario.

If I use sigjump..... even in the first read itself, it caught sigalarm signal and comes out returning host is not alive.

Moreover what sockoption do I need to set for implemention ICMP echo
protocol. I beleive no socket option will do.

Shiva

mlampkin
05-16-2003, 11:23 PM
The most frequently pointed to (from here) source code examples... from Richard Steven's books on network programming... the primary page is at :

http://www.kohala.com/start/unpv12e.html

The source code for pings and traceroutes (which actually is multiple pings with increasing ttls for the packets) can be found in that download...

The amount of time you wait for a response depends on what you are attempting to determine with the ping... e.g. what the acceptable network lag is etc. ...

A note on using jumps etc. for a timer... you CAN make it work... but I would personally suggest you don't... all sorts of odd things can happen, especially if you code is used in a threaded system... so I would probably suggest a different method... possibly encapsulating your code so it would be thread safe... then do a timed wait on select / poll or something similar to check when responses have been received...

Btw, since the ICMPs have timestamps on them... you can just compare those and get the transit time(s)... and do not have to worry about reading incoming packets immediately...

Michael

shiva
05-17-2003, 08:35 AM
Thanx for your reply,

Yes I removed all setjump....all those stuffs.
I just implemented select timeout to be more thread safe and keep on reading in the loop for say 5 - 10 attempts.

If I get the reply, it's OK otherwise the timeout shall take care.

Straight forward implementation.


Shiva