World Library  
Flag as Inappropriate
Email this Article

Ping (networking utility)

Article Id: WHEBN0000024265
Reproduction Date:

Title: Ping (networking utility)  
Author: World Heritage Encyclopedia
Language: English
Subject: Internet Control Message Protocol, Traceroute, Hop (networking), Latency (engineering), Paping
Publisher: World Heritage Encyclopedia

Ping (networking utility)

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

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

Depending on actual implementation, the ping utility may be executed with various command-line switches to enable special operational modes. For example, options include specifying the packet size of the probe, automatic repeated operation for sending a specified count of probes, and time stamping. Many operating systems provide a companion utility, ping6, for probing Internet Protocol version 6 (IPv6) hosts, but some systems may include this capability within the ping utility.

Ping may be abused as a simple form of denial-of-service attack in the form of a ping flood, in which the attacker overwhelms the victim with ICMP echo request packets.


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.[2] Mike named it after the sound that sonar makes, since its methodology is similar to sonar's echo location.[1][3]

Host discovery or ping scanning or ping sweep is a feature of network scanning tools, such as nmap.

RFC 1122 prescribes that any host must process an echo-request and issue an echo-reply in return.[4] This has been characterized as a security risk[5] (see security through obscurity).

Sample ping test

The following is the output of running ping with the target for five probes.

$ ping -c 5
PING ( 56 data bytes
64 bytes from icmp_seq=0 ttl=56 time=11.632 ms
64 bytes from icmp_seq=1 ttl=56 time=11.726 ms
64 bytes from icmp_seq=2 ttl=56 time=10.683 ms
64 bytes from icmp_seq=3 ttl=56 time=9.674 ms
64 bytes from icmp_seq=4 ttl=56 time=11.127 ms

--- 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 utility summarizes its results after completing the ping probes. 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.

Message format

ICMP packet

IP Datagram
  Bits 0–7 Bits 8–15 Bits 16–23 Bits 24–31
IP Header
(20 bytes)
Version/IHL Type of service Length
Identification flags and offset
Time To Live (TTL) Protocol Checksum
Source IP address
Destination IP address
ICMP Header
(8 bytes)
Type of message Code Checksum
Header Data
ICMP Payload
Payload Data

Generic composition of an ICMP 32-byte packet:[6]

  • IP Header (in blue):
  • 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[7]
    • 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
    • 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.
  • Data Transportation

Echo request

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.

00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Type = 8 Code = 0 Header Checksum
Identifier Sequence Number
  • 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.

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.

00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Type = 0 Code = 0 Header Checksum
Identifier Sequence Number
  • 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 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.

Other replies

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 eight bytes of the original message (in this case header of the ICMP echo request, including the quench value), so ping utility can match responses to originating queries.[8]


The payload of the packet is generally filled with ASCII characters, as the output of the tcpdump utility shows:

16:24:47.966461 IP (tos 0x0, ttl 128, id 15103, offset 0, flags [none],
proto: ICMP (1), length: 60) > 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 and 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.

See also


  1. ^ a b c  
  2. ^ "The Story of the PING Program", Mike Muuss
  3. ^  
  4. ^ "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. 
  5. ^ "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. 
  6. ^ "RFC 792 - Internet Control Message Protocol". Retrieved 2014-02-02. 
  7. ^ "RFC Sourcebook's page on ICMP". Retrieved 20 December 2010. 
  8. ^ "ICMP: Internet Control Message Protocol". January 13, 2000. Retrieved December 4, 2014. 

External links

This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.

Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.