Overview

Ping is often used to verify end-to-end communication using ICMP. Ping is a very commonly used command to verify that communication to a specified destination IP address is possible. Ping is an essential command in network installation and operation management.

How Ping works

The ping works in a very simple way.Sends an ICMP echo request message to the specified IP address. This message says, “Please send back the data as it was sent. When an ICMP echo request message is received, the data is sent back as is as an ICMP echo response message; if an ICMP echo response message is returned, the ping is successful.You can see that round-trip end-to-end communication is established with the specified IP address, with the data you sent being replied to properly.

 Figure: How Ping works
Figure: How Ping works

Ping command (Windows)

To execute Ping command on a Windows OS PC, use the following command from the command prompt.

Ping command (Windows)

C:\ping <IP address of hostname>

If a hostname is specified instead of an IP address, the ICMP echo request message is sent after automatically using DNS to find the IP address.

The following is an example of pinging to a Google web server(www.google.co.jp).

 Figure: Ping command sample
Figure: Ping command sample

Ping command sample (text)

C:\Users\gene>ping www.google.co.jp

Pinging www.google.co.jp [142.251.42.163] with 32 bytes of data:
Reply from 142.251.42.163: bytes=32 time=5ms TTL=59
Reply from 142.251.42.163: bytes=32 time=4ms TTL=59
Reply from 142.251.42.163: bytes=32 time=4ms TTL=59
Reply from 142.251.42.163: bytes=32 time=4ms TTL=59

Ping statistics for 142.251.42.163:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 4ms, Maximum = 5ms, Average = 4ms

The Ping command also provides a simple network performance measurement. It shows the round trip time to a specified IP address.

Note that just because a ping response is not returned does not necessarily mean that end-to-end communication is not possible. For security reasons, some devices are configured not to respond to pings.

Ping command (Cisco)

To execute the Ping command on Cisco devices, run the following command from the command line.

Ping command (Cisco)

#ping <ip-address|host>

A sample result of the Ping command on Cisco is shown below.

Ping command sample(Cisco)

Router#ping 172.16.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/36/56 ms

“!” means that a Ping response, i.e., an ICMP echo reply, has been received. Other meanings of the results of the Ping command are as follows.

Display ResultMeaning
! Echo response received.
. Timeout.
U Unable to reach destination
Q Source quench message received
M Cannot fragment
? Unknown packet type
& Packet TTL exceeded
Table Ping command display results (Cisco)

Then, by typing only “ping” and executing the command, an extended ping can be performed. Extended ping allows flexibility in specifying various parameters of the ICMP packets to be sent. For example, you can specify various parameters such as the number of ICMP packets, data size, source IP address or interface.

The following is an example of executing the extended ping command.

Extended Ping sample(Cisco)

R2#ping
Protocol [ip]:
Target IP address: 10.3.3.3
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface:
Type of service [0]:
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.3.3.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/22/24 ms

The following table summarizes the meaning of each parameter specified in the extended Ping command.

ParameterMeaning
Protocol [ip] Layer 3 Protocol
Repeat count [5] Packet number
Datagrame size [100] Data Size
Timeout in seconds [2] Time out in second
Extended commands [n] Specify additional parameters
Source address or interface Source IP address of Interface
Type of service [0] Tos value of IP header
Set DF bit in IP header? [no] Adding DF bits in IP header
Validate reply data? [no] Verification of ICMP echo response data
Data pattern [0xABCD] Data Pattern
Loose,Strict, Record, Timestamp, Verbose [none] Specifying IP header options
Sweep range of sizes [n] Continuous packet sending within a specified size range
Table Parameters for Extended Ping

Values in [] are default values

Summary

Points

  • Ping is a very commonly used command to verify that communication to a specified destination IP address is possible.
  • When the Ping command is executed, an ICMP echo request message is sent to the specified IP address. Then, when you receive an ICMP echo response message in reply, you will know that the round-trip communication was successful.
  • When you run the command on Cisco IOS by typing only “ping”, you execute an extended ping. Extended Ping allows you to specify various parameters for the ICMP message to be sent.