Ping (networking utility)
|This article needs additional citations for verification. (December 2011)|
Ping is a computer network administration utility used to test the reachability of a host on an Internet Protocol (IP) network and to measure the round-trip time for messages sent from the originating host to a destination computer. The name comes from active sonar terminology which sends a pulse of sound and listens for the echo to detect objects underwater.
Ping operates by sending Internet Control Message Protocol (ICMP) echo request packets to the target host and waiting for an ICMP response. In the process it measures the time from transmission to reception (round-trip time) and records any packet loss. The results of the test are printed in the form of a statistical summary of the response packets received, including the minimum, maximum, and the mean round-trip times, and sometimes the standard deviation of the mean. Ping does not evaluate or compute the time to establish the connection; it only gives the mean round-trip times of an established connection with an open session.
Depending on the implementation, the ping command can be run with various command line switches to enable special operational modes. Example options include: specifying the packet size used as the probe, automatic repeated operation for sending a specified count of probes, and time stamping.
The ping utility was authored by Mike Muuss in December 1983 as a tool to troubleshoot problems in an IP network. He was inspired by a remark by David Mills on using ICMP echo packets for IP network diagnosis and measurements.  Mike named it after the sound that sonar makes, since its methodology is similar to sonar's echo location. 
|Bit 0 - 7||Bit 8 - 15||Bit 16 - 23||Bit 24 - 31|
|Version/IHL||Type of service||Length|
|Identification||flags and offset|
|Time To Live (TTL)||Protocol||Checksum|
|Source IP address|
|Destination IP address|
|Type of message||Code||Checksum|
Generic composition of an ICMP 32-byte packet
- IP Header (in blue):
- Protocol set to 1 (ICMP) and Type of Service set to 0.
- ICMP Header (in red):
- Type of ICMP message (8 bits)
- Code (8 bits)
- Checksum (16 bits), calculated with the ICMP part of the packet (the IP header is not used). It is the 16-bit one's complement of the one's complement sum of the ICMP message starting with the Type field
- Header Data (32 bits) field, which in this case (ICMP echo request and replies), will be composed of identifier (16 bits) and sequence number (16 bits).
- ICMP Payload
- Data Transportation
Sample ping test
The following is the output of running ping with the target www.example.com for five probes.
$ ping -n 5 www.example.com PING www.example.com (220.127.116.11) 56(84) bytes of data. 64 bytes from 43-10.any.icann.org (18.104.22.168): icmp_seq=1 ttl=250 time=80.5 ms 64 bytes from 43-10.any.icann.org (22.214.171.124): icmp_seq=2 ttl=250 time=80.4 ms 64 bytes from 43-10.any.icann.org (126.96.36.199): icmp_seq=3 ttl=250 time=80.3 ms 64 bytes from 43-10.any.icann.org (188.8.131.52): icmp_seq=4 ttl=250 time=80.3 ms 64 bytes from 43-10.any.icann.org (184.108.40.206): icmp_seq=5 ttl=250 time=80.4 ms --- www.example.com ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4006ms rtt min/avg/max/mdev = 80.393/80.444/80.521/0.187 ms
The utility summarizes its results after completing the ping probes. The shortest round trip time was 80.393 ms, the average was 80.444 ms, and the maximum value was 80.521 ms. The measurement had a standard deviation of 0.187 ms.
The echo request ("ping") is an ICMP message whose data is expected to be received back in an echo reply ("pong"). The host must respond to all echo requests with an echo reply containing the exact data received in the request message.
|Type = 8||Code = 0||Header Checksum|
- The Identifier and Sequence Number can be used by the client to match the reply with the request that caused the reply. In practice, 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 data received in the Echo Request must be entirely included in the Echo Reply.
The echo reply ("pong") is an ICMP message generated in response to an echo request, and is mandatory for all hosts and routers.
|Type = 0||Code = 0||Header Checksum|
- Type and code must be set to 0.
- The identifier and sequence number can be used by the client to determine which echo requests are associated with the echo replies.
- The data received in the echo request must be entirely included in the echo reply.
Possible reply messages include 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)If <num> (ICMP unreachable code <num>)
In case of error, destination host or intermediate router will send back an ICMP error message, i.e. host unreachable or TTL exceeded in transit. In addition these messages include the first 8 bytes of original message (in this case header of ICMP echo request, including quench value), so ping utility can match it to originating query.
16:24:47.966461 IP (tos 0x0, ttl 128, id 15103, offset 0, flags [none], proto: ICMP (1), length: 60) 192.168.146.22 > 192.168.144.5: ICMP echo request, id 1, seq 38, length 40 0x0000: 4500 003c 3aff 0000 8001 5c55 c0a8 9216 E..<:.....\U.... 0x0010: c0a8 9005 0800 4d35 0001 0026 6162 6364 ......M5...&abcd 0x0020: 6566 6768 696a 6b6c 6d6e 6f70 7172 7374 efghijklmnopqrst 0x0030: 7576 7761 6263 6465 6667 6869 uvwabcdefghi
The payload includes a timestamp of when the message was sent, as well a sequence number. This allows ping to compute the round trip time in a stateless manner without needing to record when packets were sent. In cases of no answer and no error message, most implementations of ping display nothing, or periodically print notifications about timing out.
Other types of pinging
|This section needs additional citations for verification. (July 2011)|
The term ping is commonly used to describe the transmission of any message or signal for the purpose of locating or testing network services or features. For example, a ping may be sent using the User Datagram Protocol (UDP) to a device located behind a network address translator (NAT) to keep the port binding on the NAT from timing out and removing the mapping. Other examples are short or empty instant messages, emails, voice mails, or missed-call notification to indicate availability.
In various network multi-player games, a video game ping performs a similar function as the ping program for Internet traffic. The game server measures the time required for a game packet to reach a client and a response to be received. This round-trip time is usually reported as the player's ping. It is an effective measurement of the player's latency, with lower ping times being desirable. This style of ping typically does not use ICMP packets.
- List of DOS commands
- List of Unix utilities
- Ping of death
- Ping-pong scheme
- Smurf attack
- Mike Muuss. "The Story of the PING Program". Adelphi, MD, USA: U.S. Army Research Laboratory. Archived from the original on 8 September 2010. Retrieved 8 September 2010. "I named it after the sound that a sonar makes, inspired by the whole principle of echo-location."
- "The Story of the PING Program", Mike Muuss
- Salus, Peter (1994). A Quarter Century of UNIX. Addison-Wesley. ISBN 0-201-54777-5.
- "RFC 1122 - Requirements for Internet Hosts -- Communication Layers". p. 42. Retrieved 2012-03-19. "Every host MUST implement an ICMP Echo server function that receives Echo Requests and sends corresponding Echo Replies."
- "Shields Up, Firewall Test". Retrieved 4 June 2010. "[text shown if your computer replies to ping requests] "Ping" is among the oldest and most common methods used to locate systems prior to further exploitation."
- RFC 792
- "RFC Sourcebook's page on ICMP". Retrieved 20 December 2010.
- Online ping tool Web based ping utility.
- FreeBSD System Manager's Manual : Ping man page –
- Linux Administration and Privileged Commands Manual(dead link) : send ICMP ECHO_REQUEST to network hosts –
- Check what hosts on a network are active using Ping Use ping to find active hosts on your network.
- Online Ping check from multiple locations: Locations in Netherlands, Hong Kong, USA, Croatia, UK, Ukraine, Malaysia, Russia, India, Turkey.
- Graphical Ping Monitor