# Ping (networking utility)

Ping is a computer network administration 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 – including most embedded network administration software.
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 implement 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, and although Muuss says that from his point of view, PING was not intended as an acronym, he has acknowledged Mills' 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 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.
IPv4 datagram :
| Offset | Octet | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 |
| Octet | Bit | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
| 0 | 0 | Version (4) | Version (4) | Version (4) | Version (4) | IHL (5) | IHL (5) | IHL (5) | IHL (5) | DSCP (0) | DSCP (0) | DSCP (0) | DSCP (0) | DSCP (0) | DSCP (0) | ECN (0) | ECN (0) | Total length | Total length | Total length | Total length | Total length | Total length | Total length | Total length | Total length | Total length | Total length | Total length | Total length | Total length | Total length | Total length |
| 4 | 32 | Identification | Identification | Identification | Identification | Identification | Identification | Identification | Identification | Identification | Identification | Identification | Identification | Identification | Identification | Identification | Identification | Flags | Flags | Flags | Fragment offset | Fragment offset | Fragment offset | Fragment offset | Fragment offset | Fragment offset | Fragment offset | Fragment offset | Fragment offset | Fragment offset | Fragment offset | Fragment offset | Fragment offset |
| 8 | 64 | Time to live | Time to live | Time to live | Time to live | Time to live | Time to live | Time to live | Time to live | Protocol (1) | Protocol (1) | Protocol (1) | Protocol (1) | Protocol (1) | Protocol (1) | Protocol (1) | Protocol (1) | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum |
| 12 | 96 | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address |
| 16 | 128 | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address |
ICMP Echo Request packet :
| 20 | 160 | Type (8) | Type (8) | Type (8) | Type (8) | Type (8) | Type (8) | Type (8) | Type (8) | Code (0) | Code (0) | Code (0) | Code (0) | Code (0) | Code (0) | Code (0) | Code (0) | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum |
| 24 | 192 | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number |
| 28 | 224 | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) |
| 32 | 256 | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) |
| ⋮ | ⋮ | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) |

#### 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:
ICMP Echo Reply packet :
| 20 | 160 | Type (0) | Type (0) | Type (0) | Type (0) | Type (0) | Type (0) | Type (0) | Type (0) | Code (0) | Code (0) | Code (0) | Code (0) | Code (0) | Code (0) | Code (0) | Code (0) | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum |
| 24 | 192 | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number |
| 28 | 224 | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) |
| 32 | 256 | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) |
| ⋮ | ⋮ | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) |

#### 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.
IPv6 datagram :
| Offset | Octet | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 |
| Octet | Bit | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
| 0 | 0 | Version (6) | Version (6) | Version (6) | Version (6) | Traffic class | Traffic class | Traffic class | Traffic class | Traffic class | Traffic class | Traffic class | Traffic class | Flow label | Flow label | Flow label | Flow label | Flow label | Flow label | Flow label | Flow label | Flow label | Flow label | Flow label | Flow label | Flow label | Flow label | Flow label | Flow label | Flow label | Flow label | Flow label | Flow label |
| 4 | 32 | Payload length | Payload length | Payload length | Payload length | Payload length | Payload length | Payload length | Payload length | Payload length | Payload length | Payload length | Payload length | Payload length | Payload length | Payload length | Payload length | Next header (58) | Next header (58) | Next header (58) | Next header (58) | Next header (58) | Next header (58) | Next header (58) | Next header (58) | Hop limit | Hop limit | Hop limit | Hop limit | Hop limit | Hop limit | Hop limit | Hop limit |
| 8 | 64 | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address |
| 12 | 96 | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address |
| 16 | 128 | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address |
| 20 | 160 | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address |
| 24 | 192 | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address |
| 28 | 224 | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address |
| 32 | 256 | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address |
| 36 | 288 | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address |
ICMPv6 Echo Request packet :
| 40 | 320 | Type (128) | Type (128) | Type (128) | Type (128) | Type (128) | Type (128) | Type (128) | Type (128) | Code (0) | Code (0) | Code (0) | Code (0) | Code (0) | Code (0) | Code (0) | Code (0) | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum |
| 44 | 352 | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number |
| 48 | 384 | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) |
| 52 | 416 | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) |
| ⋮ | ⋮ | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) |

#### 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:
ICMPv6 Echo Reply packet :
| 40 | 320 | Type (129) | Type (129) | Type (129) | Type (129) | Type (129) | Type (129) | Type (129) | Type (129) | Code (0) | Code (0) | Code (0) | Code (0) | Code (0) | Code (0) | Code (0) | Code (0) | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum | Checksum |
| 44 | 352 | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Identifier | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number | Sequence number |
| 48 | 384 | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) |
| 52 | 416 | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) |
| ⋮ | ⋮ | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) | (Payload) |

#### Payload: variable length:Optional. Payload is copied from the Echo Request and returned.
### Payload

The payload of the packet is generally filled with ASCII characters, as the output of the tcpdump utility shows in the last 32 bytes of the following example (after the eight-byte ICMP header starting with 0x0800):
The payload may include a timestamp indicating the time of transmission and a sequence number, which are not found in this example. This allows ping to compute the round-trip time in a stateless manner without needing to record the time of transmission of each packet.
The payload may also include a magic packet for the Wake-on-LAN protocol, but the minimum payload, in that case, is longer than shown. The Echo Request typically does not receive any reply if the host was sleeping in hibernation state, but the host still wakes up from sleep state if its interface is configured to accept wakeup requests. If the host is already active and configured to allow replies to incoming ICMP Echo Request packets, the returned reply should include the same payload. This may be used to detect that the remote host was effectively woken up, by repeating a new request after some delay to allow the host to resume its network services. If the host was just sleeping in low power active state, a single request wakes up that host just enough to allow its Echo Reply service to reply instantly if that service was enabled. The host does not need to wake up all devices completely and may return to low-power mode after a short delay. Such configuration may be used to avoid a host to enter in hibernation state, with much longer wake-up delay, after some time passed in low power active mode.
A packet including IP and ICMP headers must not be greater than the maximum transmission unit of the network, or risk being fragmented.

## Security loopholes

To conduct a denial-of-service attack, an attacker may send ping requests as fast as possible, possibly overwhelming the victim with ICMP echo requests. This technique is called a ping flood.
Ping requests to multiple addresses, ping sweeps, may be used to obtain a list of all hosts on a network.