Ping (networking utility)

Last updated

Ping
Original author(s) Mike Muuss
Developer(s) Various open-source and commercial developers
Initial release1983;41 years ago (1983)
Platform Cross-platform
Type Command
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.

Contents

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. [1]

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.

History

DOS version of ping Cmd-ping.png
DOS version of ping

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. [1] The author named it after the sound that sonar makes, since its methodology is analogous to sonar's echolocation. [1] [2] The backronym Packet InterNet Groper for PING has been used for over 30 years,[ timeframe? ] 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. [1] [3] 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. [4] The FreeDOS version was developed by Erick Engelke and is licensed under the GPL. [5] Tim Crawford developed the ReactOS version. It is licensed under the MIT License. [6]

RFC 1122 prescribes that any host must process ICMP echo requests and issue echo replies in return. [7]

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-c5www.example.com  PING www.example.com (93.184.216.34): 56 data bytes64 bytes from 93.184.216.34: icmp_seq=0 ttl=56 time=11.632 ms64 bytes from 93.184.216.34: icmp_seq=1 ttl=56 time=11.726 ms64 bytes from 93.184.216.34: icmp_seq=2 ttl=56 time=10.683 ms64 bytes from 93.184.216.34: icmp_seq=3 ttl=56 time=9.674 ms64 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 lossround-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.

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:

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. [8]

Message format

ICMP packet

IPv4 datagram
 Bits 07Bits 815Bits 1623Bits 2431
Header
(20 bytes)
Version/IHLType of service (ToS)Length
Identificationflags and offset
Time to live (TTL)ProtocolHeader checksum
Source IP address
Destination IP address
ICMP header
(8 bytes)
Type of messageCodeChecksum
Header data
ICMP payload
(optional)
Payload data
IPv6 datagram
 Bits 03Bits 47Bits 811Bits 1215Bits 1623Bits 2431
Header
(40 bytes)
VersionTraffic classFlow label
Payload lengthNext headerHop limit
Source address (128 bits)
Destination address (128 bits)
ICMP6 header
(8 bytes)
Type of messageCodeChecksum
Header data
ICMP6 payload
(optional)
Payload data

Generic composition of an ICMP packet: [9]

  • 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 ones' complement of the ones' complement sum of the packet. For IPv4, this is calculated from the ICMP message starting with the Type field [10] (the IP header is not included). For IPv6 this is calculated from the ICMP message, prepended with an IPv6 pseudo-header. [11]
    • 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.

0001020304050607080910111213141516171819202122232425262728293031
Type = 8(IPv4, ICMP) 128(IPv6,ICMP6)Code = 0Checksum
IdentifierSequence Number
Payload

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.

0001020304050607080910111213141516171819202122232425262728293031
Type = 0(IPv4,ICMP) 129(IPv6,ICMP6)Code = 0Checksum
IdentifierSequence Number
Payload

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):

16:24:47.966461IP(tos0x0,ttl128,id15103,offset0,flags[none],proto:ICMP(1),length:60)192.168.146.22>192.168.144.5:ICMPechorequest,id1,seq38,length400x0000:4500003c3aff000080015c55c0a89216E..<:.....\U....0x0010:c0a8900508004d350001002661626364......M5...&abcd0x0020:65666768696a6b6c6d6e6f7071727374efghijklmnopqrst0x0030:757677616263646566676869        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.[ citation needed ]

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. [12]

Ping requests to multiple addresses, ping sweeps, may be used to obtain a list of all hosts on a network.

See also

Related Research Articles

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 communicating with another IP address. For example, an error is indicated when a requested service is not available or that a host or router could not be reached. ICMP differs from transport protocols such as TCP and UDP in that it is not typically used to exchange data between systems, nor is it regularly employed by end-user network applications.

<span class="mw-page-title-main">Internet Protocol version 4</span> Fourth version of the Internet Protocol

Internet Protocol version 4 (IPv4) is the fourth version of the Internet Protocol (IP). It is one of the core protocols of standards-based internetworking methods in the Internet and other packet-switched networks. IPv4 was the first version deployed for production on SATNET in 1982 and on the ARPANET in January 1983. It is still used to route most Internet traffic today, even with the ongoing deployment of Internet Protocol version 6 (IPv6), its successor.

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.

In computer networking, the maximum transmission unit (MTU) is the size of the largest protocol data unit (PDU) that can be communicated in a single network layer transaction. The MTU relates to, but is not identical to the maximum frame size that can be transported on the data link layer, e.g., Ethernet frame.

The Transmission Control Protocol (TCP) is one of the main protocols of the Internet protocol suite. It originated in the initial network implementation in which it complemented the Internet Protocol (IP). Therefore, the entire suite is commonly referred to as TCP/IP. TCP provides reliable, ordered, and error-checked delivery of a stream of octets (bytes) between applications running on hosts communicating via an IP network. Major internet applications such as the World Wide Web, email, remote administration, and file transfer rely on TCP, which is part of the Transport layer of the TCP/IP suite. SSL/TLS often runs on top of TCP.

In computing, traceroute and tracert are computer network diagnostic commands for displaying possible routes (paths) and measuring transit delays of packets across an Internet Protocol (IP) network. The history of the route is recorded as the round-trip times of the packets received from each successive host in the route (path); the sum of the mean times in each hop is a measure of the total time spent to establish the connection. Traceroute proceeds unless all sent packets are lost more than twice; then the connection is lost and the route cannot be evaluated. Ping, on the other hand, only computes the final round-trip times from the destination point.

Time to live (TTL) or hop limit is a mechanism which limits the lifespan or lifetime of data in a computer or network. TTL may be implemented as a counter or timestamp attached to or embedded in the data. Once the prescribed event count or timespan has elapsed, data is discarded or revalidated. In computer networking, TTL prevents a data packet from circulating indefinitely. In computing applications, TTL is commonly used to improve the performance and manage the caching of data.

In computer networking, the User Datagram Protocol (UDP) is one of the core communication protocols of the Internet protocol suite used to send messages to other hosts on an Internet Protocol (IP) network. Within an IP network, UDP does not require prior communication to set up communication channels or data paths.

In computing, Internet Protocol Security (IPsec) is a secure network protocol suite that authenticates and encrypts packets of data to provide secure encrypted communication between two computers over an Internet Protocol network. It is used in virtual private networks (VPNs).

<span class="mw-page-title-main">IP over Avian Carriers</span> Proposal to carry IP traffic by birds

In computer networking, IP over Avian Carriers (IPoAC) is a joke proposal to carry Internet Protocol (IP) traffic by birds such as homing pigeons. IP over Avian Carriers was initially described in RFC 1149 issued by the Internet Engineering Task Force, written by David Waitzman, and released on April 1, 1990. It is one of several April Fools' Day Request for Comments.

The Address Resolution Protocol (ARP) is a communication protocol used for discovering the link layer address, such as a MAC address, associated with a given internet layer address, typically an IPv4 address. This mapping is a critical function in the Internet protocol suite. ARP was defined in 1982 by RFC 826, which is Internet Standard STD 37.

A Smurf attack is a distributed denial-of-service attack in which large numbers of Internet Control Message Protocol (ICMP) packets with the intended victim's spoofed source IP are broadcast to a computer network using an IP broadcast address. Most devices on a network will, by default, respond to this by sending a reply to the source IP address. If the number of machines on the network that receive and respond to these packets is very large, the victim's computer will be flooded with traffic. This can slow down the victim's computer to the point where it becomes impossible to work on.

<span class="mw-page-title-main">IP fragmentation</span> Process that breaks IP packets into smaller pieces

IP fragmentation is an Internet Protocol (IP) process that breaks packets into smaller pieces (fragments), so that the resulting pieces can pass through a link with a smaller maximum transmission unit (MTU) than the original packet size. The fragments are reassembled by the receiving host.

A ping of death is a type of attack on a computer system that involves sending a malformed or otherwise malicious ping to a computer. In this attack, a host sends hundreds of ping requests with a packet size that is large or illegal to another host to try to take it offline or to keep it preoccupied responding with ICMP Echo replies.

In computer networking, the multicast DNS (mDNS) protocol resolves hostnames to IP addresses within small networks that do not include a local name server. It is a zero-configuration service, using essentially the same programming interfaces, packet formats and operating semantics as unicast Domain Name System (DNS). It was designed to work as either a stand-alone protocol or compatibly with standard DNS servers. It uses IP multicast User Datagram Protocol (UDP) packets and is implemented by the Apple Bonjour and open-source Avahi software packages, included in most Linux distributions. Although the Windows 10 implementation was limited to discovering networked printers, subsequent releases resolved hostnames as well. mDNS can work in conjunction with DNS Service Discovery (DNS-SD), a companion zero-configuration networking technique specified separately in RFC 6763.

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 functions.

Path MTU Discovery (PMTUD) is a standardized technique in computer networking for determining the maximum transmission unit (MTU) size on the network path between two Internet Protocol (IP) hosts, usually with the goal of avoiding IP fragmentation. PMTUD was originally intended for routers in Internet Protocol Version 4 (IPv4). However, all modern operating systems use it on endpoints. In IPv6, this function has been explicitly delegated to the end points of a communications session. As an extension to the standard path MTU discovery, a technique called Packetization Layer Path MTU Discovery works without support from ICMP.

The Internet checksum, also called the IPv4 header checksum is a checksum used in version 4 of the Internet Protocol (IPv4) to detect corruption in the header of IPv4 packets. It is carried in the IP packet header, and represents the 16-bit result of summation of the header words.

BWPing is a tool to measure bandwidth and response times between two hosts using Internet Control Message Protocol (ICMP) echo request/echo reply mechanism. It does not require any special software on the remote host. The only requirement is the ability to respond on ICMP echo request messages. BWPing supports both IPv4 and IPv6 networks.

An IPv6 packet is the smallest message entity exchanged using Internet Protocol version 6 (IPv6). Packets consist of control information for addressing and routing and a payload of user data. The control information in IPv6 packets is subdivided into a mandatory fixed header and optional extension headers. The payload of an IPv6 packet is typically a datagram or segment of the higher-level transport layer protocol, but may be data for an internet layer or link layer instead.

References

  1. 1 2 3 4 Mike Muuss. "The Story of the PING Program". U.S. Army Research Laboratory. Archived from the original on 25 October 2019. Retrieved 8 September 2010. 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.
  2. Salus, Peter (1994). A Quarter Century of UNIX. Addison-Wesley. ISBN   978-0-201-54777-1.
  3. Mills, D.L. (December 1983). Internet Delay Experiments. IETF. doi: 10.17487/RFC0889 . RFC 889 . Retrieved 26 November 2019.
  4. "man page ping section 8". www.manpagez.com.
  5. "ibiblio.org FreeDOS Package -- ping (Networking)". www.ibiblio.org.
  6. "GitHub - reactos/reactos: A free Windows-compatible Operating System". 8 August 2019 via GitHub.
  7. Braden, Robert T. (October 1989). Requirements for Internet Hosts -- Communication Layers. p. 42. doi: 10.17487/RFC1122 . RFC 1122. Every host MUST implement an ICMP Echo server function that receives Echo Requests and sends corresponding Echo Replies.
  8. "ICMP: Internet Control Message Protocol". repo.hackerzvoice.net. 13 January 2000. Archived from the original on 4 August 2016. Retrieved 4 December 2014.
  9. Postel, J. (September 1981). "RFC 792 - Internet Control Message Protocol". Tools.ietf.org. doi:10.17487/RFC0792 . Retrieved 2 February 2014.{{cite journal}}: Cite journal requires |journal= (help)
  10. "RFC Sourcebook's page on ICMP". Archived from the original on 6 July 2018. Retrieved 20 December 2010.
  11. Gupta, Mukesh; Conta, Alex (March 2006). Gupta, M (ed.). "RFC 4443 - Internet Control Message Protocol (ICMPv6) for the Internet Protocol Version 6 (IPv6) Specification". doi:10.17487/RFC4443 . Retrieved 10 April 2020.{{cite journal}}: Cite journal requires |journal= (help)
  12. "What is a Ping Flood | ICMP Flood | DDoS Attack Glossary | Imperva". Learning Center. Retrieved 26 July 2021.

Further reading