Ping is a network management software utility used to test the reachability of a host on an Internet Protocol (IP) network. It is available in a wide range of operating systems. Ping measures the round-trip time for messages sent from the originating host to a destination computer that are echoed back to the source. The name comes from active sonar terminology that sends a pulse of sound and listens for the echo to detect objects under water. Ping operates by means of Internet Control Message Protocol (ICMP) packets. Pinging involves sending an ICMP echo request to the target host and waiting for an ICMP echo reply. The program reports errors, packet loss, and a statistical summary of the results, typically including the minimum, maximum, the mean round-trip times, and standard deviation of the mean. Command-line options and terminal output vary by implementation. Options may include the size of the payload, count of tests, limits for the number of network hops (TTL) that probes traverse, interval between the requests and time to wait for a response. Many systems provide a companion utility ping6, for testing on Internet Protocol version 6 (IPv6) networks, which uses ICMPv6.
History
The ping utility was written by Mike Muuss in December 1983 during his employment at the Ballistic Research Laboratory, now the US Army Research Laboratory. A remark by David Mills on using ICMP echo packets for IP network diagnosis and measurements prompted Muuss to create the utility to troubleshoot network problems. The author named it after the sound that sonar makes since its methodology is analogous to sonar's echolocation. The backronym Packet Internet Groper for ping has been used for over 30 years. Muuss says that, from his point of view, ping was not intended as an acronym but he has acknowledged Mills's expansion of the name. The first released version was public domain software; all subsequent versions have been licensed under the BSD license. Ping was first included in 4.3BSD. The FreeDOS version was developed by Erick Engelke and is licensed under the GPL. Tim Crawford developed the ReactOS version. It is licensed under the MIT License. Any host must process ICMP echo requests and issue echo replies in return.
Invocation example The following is the output of running ping on Linux for sending five probes (1-second interval by default, configurable via -i option) to the target host www.example.com:
The output lists each probe message and the results obtained. Finally, it lists the statistics of the entire test. In this example, the shortest round-trip time was 9.674 ms, the average was 10.968 ms, and the maximum value was 11.726 ms. The measurement had a standard deviation of 0.748 ms.
Error indications In cases of no response from the target host, most implementations display either nothing or periodically print notifications about timing out. Possible ping results indicating a problem include the following:
H, !N or !P – host, network or protocol unreachable S – source route failed F – fragmentation needed U or !W – destination network/host unknown I – source host is isolated A – communication with destination network administratively prohibited Z – communication with destination host administratively prohibited Q – for this ToS the destination network is unreachable T – for this ToS the destination host is unreachable X – communication administratively prohibited V – host precedence violation C – precedence cutoff in effect In case of error, the target host or an intermediate router sends back an ICMP error message, for example host unreachable or TTL exceeded in transit. In addition, these messages include the first eight bytes of the original message (in this case, the header of the ICMP echo request, including the quench value), so the ping utility can match responses to originating queries.
Message format
ICMP packet transported with IPv4 An ICMP packet transported with IPv4 looks like this.
Type: 8 bits Set to 8 to indicate 'Echo Request'. Checksum: 16 bits Checksum is the 16-bit ones' complement of the ones' complement sum of the ICMP packet, starting with the Type field, including the Payload. The IP header is not included. Identifier: 16 bits Can be used by the client to match the reply with the request that caused the reply. Sequence number: 16 bits Can be used by the client to match the reply with the request that caused the reply. Payload: variable length Optional. Payload for the different kind of answers; can be an arbitrary length, left to implementation detail. Most Linux systems use a unique Identifier for every ping process, and Sequence number is an increasing number within that process. Windows uses a fixed Identifier, which varies between Windows versions, and a Sequence number that is only reset at boot time. The Echo Reply is returned as:
Type: 8 bits Set to 0 to indicate 'Echo Reply'. Identifier: 16 bits Copied from the Echo Request and returned. Sequence number: 16 bits Copied from the Echo Request and returned. Payload: variable length Optional. Payload is copied from the Echo Request and returned.
ICMPv6 packet transported with IPv6 An ICMP packet transported with IPv6 looks like this.
Type: 8 bits Set to 128 to indicate 'Echo Request'. Identifier: 16 bits Can be used by the client to match the reply with the request that caused the reply. Sequence number: 16 bits Can be used by the client to match the reply with the request that caused the reply. Checksum: 16 bits The checksum is calculated from the ICMP message (starting with the Type field), prepended with an IPv6 pseudo-header. Payload: variable length Optional. Payload for the different kind of answers; can be an arbitrary length, left to implementation detail. Most Linux systems use a unique Identifier for every ping process, and Sequence number is an increasing number within that process. Windows uses a fixed Identifier, which varies between Windows versions, and a Sequence number that is only reset at boot time. The Echo Reply is returned as:
Type: 8 bits Set to 129 to indicate 'Echo Reply'. Identifier: 16 bits Copied from the Echo Request and returned. Sequence number: 16 bits Copied from the Echo Request and returned. Payload: variable length Optional. Payload is copied from the Echo Request and returned.
… excerpt ends here. Continue reading the full article.



