The ping utility is used to quickly test connectivity between two devices on a network.

A ping, according to the dictionary, is a sharp, high-pitched, and somewhat musical tone. You might associate it with the sound you hear when you tap a spoon against a crystal glass. In the IT world, it has a very different meaning.

In this article, we will explain the basic concept of Ping, how the Ping utility works, and how it is utilized in the context of networking and network monitoring.

What Is a Ping?

A ping is a Command Prompt command that can be used to test a connection between one computer and another. Think of it in terms of sonar on a submarine. You’ve probably seen in the movies when the “ping” in the background as an audible signal is sent out to check a sub’s surroundings. When the ping strikes a nearby object, it will echo back. Operators can determine an object’s distance by the length of time it takes to return the echo.

How Does a Ping Work?

A ping is used to verify connectivity at an IP-level to a second TCP/IP device.  It does this by transmitting Internet Control Message Protocol (ICMP) Echo Request messages and waits for a return message. Unless modified, the ping command will send 4 requests by default in Windows. How many responses get returned and how long it takes for the round-trip provide important information, such as:

  • Bytes sent and received
  • Packets sent, received, and lost
  • Approximate round-trip time (in milliseconds)

The ping is initiated several times to test consistency in the connection.  Here's what a successful ping request would return when connecting to a router.

Why Would I Use Ping?

If you’re ever run a speed test on your computer or network, you’ve used the ping command whether you knew it or not. You’re bouncing a message off a remote server and testing the amount of time it takes to return.

Pings are useful for a variety of reasons, including troubleshooting connectivity, devices, and networks.

Troubleshooting Connectivity

Ping is used to troubleshoot connectivity. Most commonly, it’s used to verify the connection between two machines. You might use ping to test a network printer or copier connection to determine whether a device is offline or to verify you can connect to a router. If you’re having trouble with an application hosted over a network on a server, one of the first things you want to do is check the connection using a series of ping commands to help you narrow down the problem. If a ping comes back with fast response times, your connection is good so the problem likely lies with the server or application. 

You can also ping websites to see if they are operating and whether there’s a problem with the connection. 

Troubleshooting Networking Issues

Almost any network-connected device will respond to a ping which makes it incredibly valuable to check networking connections. Ping can be used to test routers or servers for throughput and speed. You can also ping across a range of addresses to find each attached device in a particular range. You can test computer names and addresses of computers. When you can ping an IP address, but not a computer name, there’s likely a name resolution issue. 

If a ping comes back showing a successful connection but has long response times, you’re likely facing a routing, congestion, or networking issue.

A ping command can be run manually or automated as a scheduled task for monitor network reliability. When a ping fails, there’s a problem.

Ping Error Messages

If the ping command does not get a response from the host, you will see either nothing returned or get a timeout notification. Since it's sending 4 requests, you'll likely see four time out notices.

The Ping command allows you to add modifiers or parameters (also called switches) to customize the command for troubleshooting. Here is a list of the commands and the proper syntax in which to use them for Windows, although you will find slight variations for Unix.

  • /t - ping continues sending Echo request messages to the destination until interrupted manually. To interrupt and display statistics, press CTRL + Break. To interrupt and quit the ping, press CTRL + C.
  • /a - the ping tries to resolve and show the hostname of an IP address that is entered as the target.
  • /n count - use this change the number of Echo request messages from 4 (the default) to something else. You can use any number from 1 to 4294967295.
  • /l size - sets the size (in bytes) of the Echo request message that is sent to the target, from 32 (the default) to something else. You can use any number from 1 to 65527.
  • /f - use this to send Echo request messages with a "Do Not Fragment" flag turned on so that the request is not fragmented by routers, on the way to the destination. This option works for IPv4 addresses only, and it is useful for troubleshooting path Maximum Transmission Unit (PMTU) problems.
  • /i TTL - sets the Time to Live (TTL) value for the Echo request, the maximum of which is 255. TTL limits the lifetime of the data being sent by the ping command. If the TTL value has elapsed and no reply was received, the data is discarded.
  • /v TOS - sets the Type of Service (TOS) used for the Echo request. The default value is 0, and the maximum is 255. This option works only for IPv4 addresses.
  • /r count - sets the number of hops between your PC and the target that you want be recorded and displayed by the ping command. The maximum value for the count is 9. It works only with IPv4 addresses.
  • /s count - reports the time (in Internet Timestamp format) when each Echo request is received and each reply is sent. The maximum value for the count is 4, meaning that only the first four hops can be time stamped. This option works just with IPv4 addresses.
  • /j host-list - uses the Loose Source Route specified in the host list. With this type of routing, successive intermediate destinations can be separated by one or multiple routers. The maximum number of addresses or names in the host list is 9. The host list is a series of IP addresses separated by spaces, and they have to be IPv4 addresses.
  • /k host-list - uses the Strict Source Route specified in the host list. With strict routing, the next intermediate destination must be reachable directly (and not separated by a router). The maximum number of addresses or names in the host list is 9. The host list is a series of IPv4 addresses separated by spaces.
  • /w timeout - the timeout value adjusts the amount of time, in milliseconds, that the ping waits for each reply. The default timeout value is 4000 or 4 seconds.
  • /r range - tells the ping command to trace the round-trip path, for a number of hops. It works only with IPv6 addresses. The range must be a number between 1 and 9.
  • /s srcaddr - specifies the source address to use when working with IPv6 addresses. The address must be entered after srcaddr.
  • /c compartments - specifies the routing compartment identifier.
  • /p - pings a Hyper-V Network Virtualization provider address.
  • /4 - forces the use of the IPv4 address and it is used in conjunction with hostnames, not IP addresses. For example, write "ping /4 www.WEBSITENAME.com" (without the quotation marks), and it returns the IPv4 address of the hostname.
  • /6 - forces the use of the IPv6 address and it is used in conjunction with hostnames, not IP addresses. For example, write "ping /6 www.WESBITENAME.com" and you see the IPv6 address of the hostname.

Proper Ping Syntax

The order in which you use these switches is important. Here’s is the proper syntax to use:

ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS] [-r count] [-s count] [-w timeout] [-R] [-S srcaddr] [-p] [-4] [-6] target [/?]

This article demonstrates how to use a ping test and traceroute tools to test network connectivity between two hosts. Ping performs a basic test to determine if a remote host is available, while traceroute tests the complete route network packets take from one host to another. Traceroute is especially helpful for diagnosing where network slowdowns and congestion occur.

For a general introduction to network troubleshooting, please read this article first.

Testing network connectivity

Many scenarios require you to test things locally on your computer using the command line. For example, if you are trying to test the connection between your computer and a remote host, a web-based tool cannot provide this information. It only tests the connection from its own server to the remote host.

The exact steps to use the ping and traceroute tools from the command line depend on your computer's operating system. Follow the appropriate procedures below for your operating system.

Check host availability with ping test

The basic ping test is one of the easiest things you can do to verify connectivity between your computer and a remote host. This test is easy to run from the command line.

Using ping test on Microsoft Windows

To use the ping program on Microsoft Windows, follow these steps:

  1. Open a DOS command window. To do this, click , click , type cmd, and then press Enter.
  2. At the command prompt, type the following command. Replace example.com with the domain that you want to test: ping example.com
  3. Interpret the output from ping:

    • If the remote host is active and configured to respond to ping requests, responses appear. For example, the following output shows ping responses from an A2 Hosting server: C:\Documents and Settings\user>ping a2s78.a2hosting.com Pinging a2s78.a2hosting.com [216.119.143.98] with 32 bytes of data: Reply from 216.119.143.98: bytes=32 time=46ms TTL=54 Reply from 216.119.143.98: bytes=32 time=45ms TTL=54 Reply from 216.119.143.98: bytes=32 time=47ms TTL=54 Ping statistics for 216.119.143.98:     Packets: Sent = 3, Received = 3, Lost = 0 (0% loss), Approximate round trip times in milli-seconds:     Minimum = 45ms, Maximum = 47ms, Average = 46ms
    • Alternatively, if the remote host is down, or not configured to respond to ping requests, you do not see any responses.

      Firewalls can be configured to block packets from ping. If a remote host does not respond to ping requests, it is possible that it is up and running normally, but ignoring ping requests.

Using ping test on Apple Mac OS X and Linux

To use the ping program on Mac OS X and Linux, follow these steps:

  1. Open a terminal window. The procedure to do this depends on your operating system and desktop environment:
    • On Mac OS X, click Applications, click Utilities, and then click Terminal.
    • On Linux, open a terminal window.
  2. At the command prompt, type the following command. Replace example.com with the domain that you want to test:

    ping example.com
  3. Press Ctrl+C to stop ping after a few tests run, and then interpret the output:

    • If the remote host is active and configured to respond to ping requests, responses appear. For example, the following output shows ping responses from an A2 Hosting server: [email protected]:~$ ping a2s78.a2hosting.com PING a2s78.a2hosting.com (216.119.143.98) 56(84) bytes of data. 64 bytes from a2s78.a2hosting.com (216.119.143.98): icmp_req=1 ttl=54 time=44.4 ms 64 bytes from a2s78.a2hosting.com (216.119.143.98): icmp_req=2 ttl=54 time=43.8 ms 64 bytes from a2s78.a2hosting.com (216.119.143.98): icmp_req=3 ttl=54 time=44.7 ms
    • On the other hand, if the remote host is down, or not configured to respond to ping requests, you do not see any responses.

      Firewalls can be configured to block packets from ping. If a remote host does not respond to ping requests, it is possible that it is up and running normally, but ignoring ping requests.

Testing the path to a remote host with traceroute

The traceroute program provides much more detailed information about a connection to a remote host than ping. Traceroute (or tracert on Microsoft Windows systems) displays information about each “hop” a packet takes from your computer to the remote host. It is often a good way to pinpoint possible ISP connection issues or network bottlenecks.

Using tracert on Microsoft Windows

On Windows-based systems, use the tracert program to test the path to a server. To do this, follow these steps:

  1. Open a DOS command window. To do this, click , click , type cmd, and then press Enter.
  2. At the command prompt, type the following command. Replace example.com with the domain that you want to test: tracert example.com
  3. Interpret the output from tracert:

    • Tracert displays each hop, indicated by a number in the left column. It also displays the domain and IP address at each hop, as well as the time spent. For example, the following output shows the path to an A2 Hosting server: C:\>tracert a2s78.a2hosting.com Tracing route to a2s78.a2hosting.com [216.119.143.98] over a maximum of 30 hops:   1     1 ms    <1 ms    <1 ms  Linksys [192.168.0.1] [Lines omitted for brevity]   8    45 ms    38 ms    38 ms  pos-1-6-0-0-pe01.350ecermak.il.ibone.comcast.net [68.86.87.130]   9    67 ms   150 ms    76 ms  cr-1.sfld-mi.123.net [66.208.233.62] 10    44 ms    63 ms    46 ms  gateway1.a2hosting.com [216.234.104.254] 11    72 ms    57 ms    63 ms  a2s78.a2hosting.com [216.119.143.98] Trace complete.

      You can examine the times between each hop to look for places where the connection “hangs”. In some cases, tracert may also time out, which is indicated by an asterisk (*).

Using traceroute on Apple Mac OS X and Linux

To use the traceroute program on Mac OS X and Linux, follow these steps:

  1. Open a terminal window. The procedure to do this depends on your operating system and desktop environment:
    • On Mac OS X, click Applications, click Utilities, and then click Terminal.
    • On Linux, open a terminal window.
  2. At the command prompt, type the following command. Replace example.com with the domain that you want to test:

    traceroute example.com
  3. Interpret the output from traceroute:

    • Traceroute displays each hop, indicated by a number in the left column. It also displays the domain and IP address at each hop, as well as the time spent. For example, the following output shows the path to an A2 Hosting server: [email protected]:~$ traceroute a2s78.a2hosting.com 1 Linksys (192.168.0.1) 0.315 ms  0.452 ms  0.472 ms [Lines omitted for brevity] 8  pos-1-6-0-0-pe01.350ecermak.il.ibone.comcast.net (68.86.87.130)  39.010 ms  38.054 ms  38.092 ms 9  cr-1.sfld-mi.123.net (66.208.233.62)  45.056 ms  44.335 ms  44.974 ms 10  gateway1.a2hosting.com (216.234.104.254)  45.274 ms  46.650 ms  46.089 ms 11  a2s78.a2hosting.com (216.119.143.98)  44.654 ms  46.028 ms  43.852 ms

      You can examine the times between each hop to look for places where the connection “hangs”. In some cases, traceroute may also time out, which is indicated by an asterisk (*).

Testing network connectivity with MTR

MTR (“My Traceroute”) is a network diagnostic tool that combines the functionality of the ping and traceroute programs described above. It is a good way to monitor in real-time the path network packets take to their destination.

Using MTR on Microsoft Windows

WinMTR is a version of MTR for computers running Microsoft Windows. To download WinMTR, use your web browser to go to https://sourceforge.net/projects/winmtr, and then install the program on your computer.

After you install WinMTR, follow these steps to run a network test:

  1. Start WinMTR.
  2. In the Host text box, type the name of the domain you want to test.
  3. Click Start. MTR continually tests connectivity to the host, displaying the packet route and total number of pings.
  4. To stop testing, click Stop.

    You can click Copy Text to clipboard to copy the MTR output. This enables you to paste it into another application, such as a text editor or e-mail client. For example, A2 Hosting's Guru Crew may ask to see the MTR output if you open a support ticket about network connectivity.

Using MTR on Linux

MTR may already be installed by your Linux distribution. If it is not installed, you can install it using your distribution's package manager (for example, apt-get or yum). After MTR is installed, follow these steps to run a network test:

  1. In Linux, open a terminal window.
  2. To begin a network test, type the following command. Replace example.com with the name of the domain you want to test: mtr --curses example.com

    The previous command starts MTR in text mode. If your Linux installation has a desktop environment installed, you can type the following command to start MTR with a GUI instead:

    mtr --gtk example.com

  3. MTR continually tests connectivity to the host, displaying the packet route and total number of pings:

    • To change the display mode, type d.
    • To restart the test, type r.
    • For additional help, type h.
  4. To stop testing, type q.

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.