How to Use the Ping Command

Affiliate Disclosure: As an Amazon Associate I earn from qualifying purchases.

There are many tools and utilities built within your operating system, with the ping command being one of the most useful, especially when it comes to testing and troubleshooting your home network.

The Ping command allows you to test the reachability of a device on a network; it works by using the echo request and echo reply messages within the Internet Control Message Protocol (ICMP) protocol and is considered to be one of the most useful tools when testing or troubleshooting a network.

Here is a guide on how to use it within your own home network.

What Is the Ping Command?

Ping was first developed by Michael Muuss back in 1983 and allows you to test the reachability of a networked device.

Ping is a command-line based utility that is built into your operating system and is one of the most commonly used tools for testing and troubleshooting network-related problems.

The ping command involves sending a request over the network to a specific device or address. If the ping is successful, a response will be received.

Some people will say that ping is an acronym for Packet InterNet Groper, yet Michael Muuss himself said that the name ping comes from sonar terminology.

In sonar, a ping refers to the audible sound that is sent out to find an object. Should the sound reach the object, the sound waves will echo back to the source.

Both the distance and location of the object can be found by measuring the direction and time of the echoing sound wave.

How Does the Ping Command Work?

Ping works by using the echo request and echo reply messages within the Internet Control Message Protocol (ICMP) protocol.

When the ping command is run, an echo request packet is sent to the address or device you are trying to contact. When the echo request gets received at its destination, the response will be an echo reply packet.

Ping can be used as part of a troubleshooting step to both test connectivity and determine response time.

The distance between your computer and the object you are trying to contact can be measured by the number of hops, as well as the conditions in-between in the form of packet loss and response times.

In a nutshell, the ping command allows you to test whether your computer can reach another device connected to your local network, or a device on the Internet.

It is an invaluable tool that will help greatly in determining whether there is a fault on your local network, or elsewhere.

How to Use the Ping Command

The majority of Windows users will use the ping command through the Windows Command Prompt, however, Windows Powershell can also be used.

If you are a MacOS user, you will need to use Terminal.

In this tutorial, we will cover how to access both the Command Prompt in Windows and Terminal in MacOS, and then on how to use the Ping command itself on the Windows platform.

How to Access Command Prompt in Windows

1. Press the Windows key + R to access the Run window

Run

2. Type cmd into the field and click on OK

cmd

3. The Command Prompt window will open

command prompt

How to Access Terminal in MacOS

1. Press Command + Spacebar to launch Spotlight

spotlight

2. Type in terminal and press Enter

3. The Terminal window will open

Using the Ping Command

Once you have Command Prompt or Terminal open, you can begin using the ping command.

Simply type ping followed by the URL for a website or an IP address you want to test connectivity will and then press the Enter key.

In the above example, we sent a ping to this very website and got a normal response, which we would expect.

Quite a lot of information is received from running the ping command, so let’s take a look at what we are actually being told by these results.

On the first line, we can see the URL of the website, the IP address associated with the site, and the size of the packets that were sent.

The following four lines show the reply from each of the individual packets along with the time it took for the response to be received.

TTL found at the end of each line is the time-to-live. This is the amount of time that must pass before that particular packet is discarded.

At the bottom of the results, we see a brief summary that describes how many packets were sent and received, or lost in transit, in addition to the minimum, maximum and average response times.

This concludes the Ping command being run, with this example confirming that the site you are reading this very article on is online and accessible.

When you are finished, you can simply close the Command Prompt or Terminal window.

How to Use Switches With the Ping Command

If you want to see more than just whether a device can be reached and how long it takes for the packet to be sent and received, you will be pleased to know there are many advanced switches that can be used with the ping command.

Here is a list of the most commonly used, and useful, switches available to use:

SwitchDescription
-aWill resolve the hostname of an IP address, if possible
-fPrevents ICMP Echo Requests from being fragmented by routers between your computer and the target
-i TTLSets the time-to-live value; the maximum is 255
-l sizeSets the packet size, in bytes, that is sent from 32 to 65,527. 32 bytes is the default packet size and is used if you don’t use the -l switch
-n countSets the number of how many requests to send. You can choose between 1 and 4294967295. 4 requests are sent if you don’t use the -n switch
-r countSpecifies the number of hops between you and the target you would like to be recorded and displayed. The maximum that can be used is 9
-s countReports the time in Internet Timestamp format that a request is sent and a reply received. Only the first 4 hops can be timestamped
-tContinues to ping the target until you forcibly stop it by pressing CTRL + C
-w timeoutSpecifies the time in milliseconds that ping will wait for each reply. The default timeout is 4000 (4 seconds) if the -w switch is not used
-rTells ping to trace the round trip path
-s srcaddrUsed to specify the source address
-4Forces ping to use IPv4 only, but only needs to be used when targeting a hostname, not an IP address
-6Forces ping to use IPv6 only, but only needs to be used when targeting a hostname, not an IP address
/?The most useful switch; shows detailed help for all of ping’s multiple switches

Note: The -f, -r and -s, switches only work when pinging IPv4 addresses, whereas the -R and -S switches only work when pinging IPv6 address.

What Can Do You Do With the Ping Command?

There are so many different ways to make use of the ping command. Here are a few examples along with the use of some of the switches we described above.

This successful response confirms that the many network devices between my computer and Home Network Geek are working. This includes the network card in my computer, my router, and any other Internet-based device that sits between me and the site.

Ping your router

If I couldn’t ping an Internet-based target, I would next ping my router to see if it is reachable. I got a successful response which confirms that my local network is working OK and that the issue is, unfortunately, out of my control.

If I didn’t get a response from my router, despite it being powered on and appears to be working, I would next Ping the loopback address.

The address will always be 127.0.0.1 and getting a successful response confirms that the network card in my computer is working properly.

I knew the IP address of a device, but not the hostname. Using the -a switch resolves the IP address 192.168.1.252 to my iPhone.

I wanted to continuously ping an IP address just to make sure there isn’t any packet loss over an extended period of time. To stop the Ping, I pressed CTRL + C.

Conclusion

The ping command is an incredibly useful network utility that is available on all operating systems; it is invaluable when you need to perform some testing or troubleshooting on your home network.

I hope you found this article on the ping command and the tutorials on how to use it helpful. If you take anything from it, let it be that ping /? is the only command you need to remember; this gives guidance on how to use the ping command along with its various different switches.