ping

Broken Code
3 min readJan 18, 2022

In computer networking, ping is a command line utility used to test the two way reachability of a host on an IP network. Simply put, it is used to verify whether two hosts can communicate with each other over an IP network. Ping is available on any operating system with network connectivity.

According to the author of the ping utility the name of the program comes from sonar terminology. In sonar, a ping is an audible sound wave sent out to find an object (the sound waves reflect or echo back to the source on hitting an object). However, others believe that PING is an acronym for Packet InterNet Groper.

fig(A): Ping

Working:

When a ping command is issued, as shown in fig(A), an ICMP echo request packet is sent to the address specified. When the remote host receives the echo request, it responds with an ICMP echo reply packet. If a response is received by the source from the destination, it means the devices have two way connectivity and can communicate with each other over an IP network.

On the other hand, if the source fails to receive a response from the destination then there is a connectivity issue between the source and the destination.

Message format:

The ICMP echo request and the ICMP echo reply messages are known as ping messages. In ICMP echo request the type is set to 8 while in ICMP echo reply the type is set to 0.

Fig (B): ICMP echo request
Fig (C): ICMP echo reply
Fig(D): Wireshark capture showing ping (ICMP echo request)

Syntax:

ping [options] <destination>

<destination> = domain name or IP address

Example: ping -c 4 localhost

c = <count> = No. of echo requests to send (linux)

Note that the syntax of the ping utility and its output varies between the numerous implementations. For example, in case of windows n = <count>. So, the above command is given as: ping -n 4 localhost

--

--