Software:ping (networking utility)
Linux version of ping
|Original author(s)||Mike Muuss|
|Developer(s)||Various open-source and commercial developers|
|License||Public-domain, BSD, GPL, MIT|
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 for virtually all operating systems that have networking capability, 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.
The command-line options of the ping utility and its output vary between the numerous implementations. 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.
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.
RFC 1122 prescribes that any host must process ICMP echo requests and issue echo replies in return.
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:
$ ping -c 5 www.example.com PING www.example.com (18.104.22.168): 56 data bytes 64 bytes from 22.214.171.124: icmp_seq=0 ttl=56 time=11.632 ms 64 bytes from 126.96.36.199: icmp_seq=1 ttl=56 time=11.726 ms 64 bytes from 188.8.131.52: icmp_seq=2 ttl=56 time=10.683 ms 64 bytes from 184.108.40.206: icmp_seq=3 ttl=56 time=9.674 ms 64 bytes from 220.127.116.11: icmp_seq=4 ttl=56 time=11.127 ms --- www.example.com ping statistics --- 5 packets transmitted, 5 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 9.674/10.968/11.726/0.748 ms
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.
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.
|Bits 0–7||Bits 8–15||Bits 16–23||Bits 24–31|
|Version/IHL||Type of service (ToS)||Length|
|Identification||flags and offset|
|Time to live (TTL)||Protocol||Header checksum|
|Source IP address|
|Destination IP address|
|Type of message||Code||Checksum|
|Bits 0–3||Bits 4–7||Bits 8–11||Bits 12–15||Bits 16–23||Bits 24–31|
|Version||Traffic class||Flow label|
|Payload length||Next header||Hop limit|
|Source address (128 bits)|
|Destination address (128 bits)|
|Type of message||Code||Checksum|
Generic composition of an ICMP packet:
- IPv4 Header (in blue): protocol set to 1 (ICMP) and Type of Service set to 0.
- IPv6 Header (in blue): Next Header set to 58 (ICMP6)
- ICMP Header (in red):
- Type of ICMP message (8 bits)
- Code (8 bits)
- Checksum (16 bits), the 16-bit one's complement of the one's complement sum of the packet. For IPv4, this is calculated from the ICMP message starting with the Type field (the IP header is not included). For IPv6 this is calculated from the ICMP message, prepended with an IPv6 pseudo-header.
- Header Data (32 bits) field, which in this case (ICMP echo request and replies), will be composed of an identifier (16 bits) and sequence number (16 bits).
- ICMP Payload: payload for the different kind of answers; can be an arbitrary length, left to implementation detail. However, the packet including IP and ICMP headers must be less than the maximum transmission unit of the network or risk being fragmented.
The echo request (ping) is an ICMP/ICMP6 message.
|Type = 8(IPv4, ICMP) 128(IPv6,ICMP6)||Code = 0||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 echo reply is an ICMP message generated in response to an echo request; it is mandatory for all hosts and must include the exact payload received in the request.
|Type = 0(IPv4,ICMP) 129(IPv6,ICMP6)||Code = 0||Checksum|
- The identifier and sequence number can be used by the client to associate each echo request with its reply.
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):
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 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.
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.
- ↑ 1.0 1.1 1.2 1.3 Mike Muuss. "The Story of the PING Program". U.S. Army Research Laboratory. https://ftp.arl.army.mil/~mike/ping.html. "My original impetus for writing PING for 4.2a BSD UNIX came from an offhand remark in July 1983 by Dr. Dave Mills ... I named it after the sound that a sonar makes, inspired by the whole principle of echo-location ... From my point of view PING is not an acronym standing for Packet InterNet Grouper, it's a sonar analogy. However, I've heard second-hand that Dave Mills offered this expansion of the name, so perhaps we're both right."
- ↑ Salus, Peter (1994). A Quarter Century of UNIX. Addison-Wesley. ISBN 978-0-201-54777-1.
- ↑ Mills, D.L. (December 1983), Internet Delay Experiments, IETF, doi:10.17487/RFC0889, RFC 889, https://tools.ietf.org/html/rfc889, retrieved 26 November 2019
- ↑ "man page ping section 8". http://www.manpagez.com/man/8/ping/.
- ↑ "ibiblio.org FreeDOS Package -- ping (Networking)". http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos/pkg-html/ping.html.
- ↑ "GitHub - reactos/reactos: A free Windows-compatible Operating System.". 8 August 2019. https://github.com/reactos/reactos.
- ↑ Braden, Robert T. (October 1989), Requirements for Internet Hosts -- Communication Layers, p. 42, doi:10.17487/RFC1122, RFC 1122, https://tools.ietf.org/html/rfc1122#page-42, "Every host MUST implement an ICMP Echo server function that receives Echo Requests and sends corresponding Echo Replies."
- ↑ "ICMP: Internet Control Message Protocol". 13 January 2000. http://repo.hackerzvoice.net/depot_madchat/ebooks/TCP-IP_Illustrated/icmp_int.htm.
- ↑ Postel, J. (September 1981). RFC 792 - Internet Control Message Protocol. Tools.ietf.org. doi:10.17487/RFC0792. http://tools.ietf.org/html/rfc792. Retrieved 2014-02-02.
- ↑ "RFC Sourcebook's page on ICMP". http://www.networksorcery.com/enp/protocol/icmp.htm#ICMP%20Header%20Checksum.
- ↑ Gupta, Mukesh; Conta, Alex (March 2006). RFC 4443 - Internet Control Message Protocol (ICMPv6) for the Internet Protocol Version 6 (IPv6) Specification. doi:10.17487/RFC4443. https://tools.ietf.org/html/rfc4443. Retrieved 10 April 2020.
- ↑ "What is a Ping Flood | ICMP Flood | DDoS Attack Glossary | Imperva" (in en-US). https://www.imperva.com/learn/ddos/ping-icmp-flood/.
- Mastering OS/2 Warp. Sybex. 1995. ISBN 978-0782116632.
- John Paul Mueller (2007). Windows Administration at the Command Line for Windows Vista, Windows 2003, Windows XP, and Windows 2000. John Wiley & Sons. ISBN 978-0470165799.
- The Mac OS X Command Line: Unix Under the Hood. John Wiley & Sons. 2006. ISBN 978-0470113851.
ping(1M)– Solaris 10 System Administration Commands Reference Manual
ping(8)– FreeBSD System Manager's Manual
ping(8)– Linux Programmer's Manual – Administration and Privileged Commands
- ping | Microsoft Docs
Original source: https://en.wikipedia.org/wiki/Ping (networking utility). Read more