Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am just wondering if it is possible to ping the same ip address from the same source multiple times (ie fast enough so they get pipelined) and still get a valid result. By a valid result, I mean that you record a valid round trip time for all ping packets.

What I am getting at is that is there a possibility that packets could get mixed so the receiver does not know which packet is which, and thus the recorded round trip time not be accurate. Are there any mechanisms with ICMP or IP that number ping packets so they are distinguishable from the other pings to the same address.

share|improve this question

migrated from stackoverflow.com Apr 5 '11 at 9:37

This question came from our site for professional and enthusiast programmers.

2 Answers 2

In the ICMP header there is an Identifier and a Sequence number, used for exactly this purpose. They occupy bytes 5-7.

See RFC792 page 15:

The identifier and sequence number may be used by the echo sender to aid in matching the replies with the requests. For example, the identifier might be used like a port in TCP or UDP to identify a session, and the sequence number might be incremented on each request sent. The destination returns these same values in the reply.

share|improve this answer
    
o awesome!! Thansk –  Anonymous Apr 5 '11 at 8:14

The standard ping(1) command even includes a -f flood argument, that asks for sending the ping packets as quickly as possible; ping tries to as fast as possible without losing packets. (Neat tool for making sure your network isn't in awful shape, just don't do it between OS X machines, they rate limit ICMP replies, and you'll wonder about the horrible packet loss rates.)

The ICMP header includes enough information to keep track of 2^16 outstanding ICMP packets between two hosts. From my /usr/include/linux/icmp.h:

struct icmphdr {
  __u8          type;
  __u8          code;
  __sum16       checksum;
  union {
        struct {
                __be16  id;
                __be16  sequence;
        } echo;
        __be32  gateway;
        struct {
                __be16  __unused;
                __be16  mtu;
        } frag;
  } un;
};
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.