Ping (networking utility)
   HOME

TheInfoList



OR:

ping is a
computer network A computer network is a set of computers sharing resources located on or provided by network nodes. The computers use common communication protocols over digital interconnections to communicate with each other. These interconnections are ...
administration software utility used to test the reachability of a host on an
Internet Protocol The Internet Protocol (IP) is the network layer communications protocol in the Internet protocol suite for relaying datagrams across network boundaries. Its routing function enables internetworking, and essentially establishes the Internet. ...
(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 Sonar (sound navigation and ranging or sonic navigation and ranging) is a technique that uses sound propagation (usually underwater, as in submarine navigation) to navigate, measure distances (ranging), communicate with or detect objects on or ...
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 The Internet Control Message Protocol (ICMP) is a supporting protocol in the Internet protocol suite. It is used by network devices, including routers, to send error messages and operational information indicating success or failure when commun ...
(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 Packet loss occurs when one or more packets of data travelling across a computer network fail to reach their destination. Packet loss is either caused by errors in data transmission, typically across wireless networks, or network congestion.Ku ...
, and a statistical summary of the results, typically including the minimum, maximum, the
mean There are several kinds of mean in mathematics, especially in statistics. Each mean serves to summarize a given group of data, often to better understand the overall value ( magnitude and sign) of a given data set. For a data set, the '' ar ...
round-trip times, and
standard deviation In statistics, the standard deviation is a measure of the amount of variation or dispersion of a set of values. A low standard deviation indicates that the values tend to be close to the mean (also called the expected value) of the set, whil ...
of the mean. The
command-line option A command-line interpreter or command-line processor uses a command-line interface (CLI) to receive commands from a user in the form of lines of text. This provides a means of setting parameters for the environment, invoking executables and pro ...
s 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 Internet Protocol version 6 (IPv6) is the most recent version of the Internet Protocol (IP), the communications protocol that provides an identification and location system for computers on networks and routes traffic across the Internet. IP ...
(IPv6) networks, which implement
ICMPv6 Internet Control Message Protocol version 6 (ICMPv6) is the implementation of the Internet Control Message Protocol (ICMP) for Internet Protocol version 6 (IPv6). ICMPv6 is an integral part of IPv6 and performs error reporting and diagnostic fun ...
.


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 Sonar (sound navigation and ranging or sonic navigation and ranging) is a technique that uses sound propagation (usually underwater, as in submarine navigation) to navigate, measure distances (ranging), communicate with or detect objects on o ...
makes, since its methodology is analogous to sonar's echolocation. The
backronym A backronym is an acronym formed from an already existing word by expanding its letters into the words of a phrase. Backronyms may be invented with either serious or humorous intent, or they may be a type of false etymology or folk etymology. The ...
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 Public-domain software is software that has been placed in the public domain, in other words, software for which there is absolutely no ownership such as copyright, trademark, or patent. Software in the public domain can be modified, distribute ...
; 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 ReactOS is a free and open-source operating system for amd64/i686 personal computers intended to be binary-compatible with computer programs and device drivers made for Windows Server 2003 and later versions of Windows. ReactOS has been not ...
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.


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'': $ ping -c 5 www.example.com PING www.example.com (93.184.216.34): 56 data bytes 64 bytes from 93.184.216.34: icmp_seq=0 ttl=56 time=11.632 ms 64 bytes from 93.184.216.34: icmp_seq=1 ttl=56 time=11.726 ms 64 bytes from 93.184.216.34: icmp_seq=2 ttl=56 time=10.683 ms 64 bytes from 93.184.216.34: icmp_seq=3 ttl=56 time=9.674 ms 64 bytes from 93.184.216.34: 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 In statistics, the standard deviation is a measure of the amount of variation or dispersion of a set of values. A low standard deviation indicates that the values tend to be close to the mean (also called the expected value) of the set, whil ...
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: * or host, network or protocol unreachable * source route failed * fragmentation needed * or destination network/host unknown * source host is isolated * communication with destination network administratively prohibited * communication with destination host administratively prohibited * for this ToS the destination network is unreachable * for this ToS the destination host is unreachable * communication administratively prohibited * host precedence violation * 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

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.


Echo request

The ''echo request'' (''ping'') is an ICMP/ ICMP6 message. 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.


Echo reply

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. * The ''identifier'' and ''sequence number'' can be used by the client to associate each echo request with its reply.


Payload

The payload of the packet is generally filled with
ASCII ASCII ( ), abbreviated from American Standard Code for Information Interchange, is a character encoding standard for electronic communication. ASCII codes represent text in computers, telecommunications equipment, and other devices. Because ...
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 ): 16:24:47.966461 IP (tos 0x0, ttl 128, id 15103, offset 0, flags
one 1 (one, unit, unity) is a number representing a single or the only entity. 1 is also a numerical digit and represents a single unit of counting or measurement. For example, a line segment of ''unit length'' is a line segment of length 1. I ...
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.


Security loopholes

To conduct a
denial-of-service attack In computing, a denial-of-service attack (DoS attack) is a cyber-attack in which the perpetrator seeks to make a machine or network resource unavailable to its intended users by temporarily or indefinitely disrupting services of a host conne ...
, 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 A ping flood is a simple denial-of-service attack where the attacker overwhelms the victim with ICMP "echo request" (ping) packets. This is most effective by using the flood option of ping which sends ICMP packets as fast as possible without wait ...
. Ping requests to multiple addresses,
ping sweep In computing, a ping sweep is a method that can establish a range of IP addresses which map to live hosts. The classic tool used for ping sweeps is ,Stuart McClure, Joel Scambray, George Kurtz, ''Hacking Exposed: Network Security Secrets & Solutio ...
s, may be used to obtain a list of all hosts on a network.


See also

*
fping In computing, a ping sweep is a method that can establish a range of IP addresses which map to live hosts. The classic tool used for ping sweeps is ,Stuart McClure, Joel Scambray, George Kurtz, ''Hacking Exposed: Network Security Secrets & Solutio ...
* hping *
Keepalive A keepalive (KA) is a message sent by one device to another to check that the link between the two is operating, or to prevent the link from being broken. Description Once a TCP connection has been established, that connection is defined to be v ...
* nping * Ping of death * Ping-pong scheme * Security through obscurity * Smurf attack * Traceroute


References


Further reading

* * *


External links

* * *
ping , Microsoft Docs
{{Windows commands Free network management software Internet Protocol based network software Network analyzers OS/2 commands Unix network-related software Windows administration Windows communication and services