1. Introduction

Ping is a utility available on most operating systems. Commonly, it’s used to check if a network device is reachable.

The name derives from the operating mode, which involves sending (echo request) and receiving (echo reply) of information packets, in a way vaguely similar to sonar. Some authors consider the name to be an acronym for Packet InterNet Groper.

As we’ll see in this tutorial, ping can be used to measure the bandwidth of a network connection.

There are slight implementation differences depending on the operating system. In the examples below, we will use the ping command available on Linux systems.

2. Anatomy of the Ping Command: the ICMP Protocol

2.1. General Features

The ping utility uses the echo request, and echo reply messages within the Internet Control Message Protocol (ICMP), an integral part of any IP network. When a ping command is issued, an echo-request packet is sent to the address specified. When the remote host receives the echo request, it responds with an echo reply packet.

The ping command sends several echo requests. The result of each echo request is displayed, showing whether the request received a successful response, how many bytes were received in response, the Time to Live (TTL), and how long the response took to receive, along with statistics about packet loss and round trip times.

The ping command allows us to:

  • Test our internet connection.
  • Check if a remote machine is online.
  • Analyze if there are network issues, such as dropped packages or high latency.

2.2. The ICMP Protocol

The ICMP protocol is located in the Network Layer of the Open Systems Interconnection (OSI) model, as shown in the following figure:

ICMP in OSI model

The structure of each ICMP packet, with an MTU of 1500 bytes, is as follows:

ICMP packet

For different MTUs, the size of the ICMP payload changes, which can therefore be generally variable.

3. Checking Reachability of the Host