As more and more people are creating small or home offices, there’s greater need than ever to go over some basic networking tools you can run from Windows client machines. In this Daily Feature, I’ll explain the venerable ping command.

History of ping
It’s been said that the command ping is an acronym for Packet Internet Groper, which more or less accurately describes what the command does. However, the author of the original ping program for UNIX, Mike Muuss, says that the name was inspired by the fact that the ping program uses the same echo-location technique that submarine sonar uses, so he named his program after that sound—ping. Mike designed ping in 1983, and it has since been ported to just about every operating system. For more information on the origins of the ping command, check out Mike Muuss’s Web page.

How it works
Ping has one simple job to perform, which is to find out whether a specific IP address is working. In order to do so, the ping command sends a special packet of information to a specific IP address and then listens for a reply. This special packet is called the Internet Control Message Protocol (ICMP) echo request packet. ICMP packets are IP control messages that two systems on a TCP/IP network use to communicate various needs. When a system receives an echo request, it answers back with an echo reply, which includes the original echo request packet in the data field of the echo reply.

To use ping in Windows, open an MS-DOS prompt (Windows 9x/Me) or command prompt (Windows 2000/NT). Type ping followed by the name or IP address of the computer whose network connectivity you are testing. For example, if a computer on your network has the IP address, at the command prompt, type:

If that computer were assigned the name Bart, you would simply type:
Ping Bart

The Windows version of ping sends the specified computer four packets, each one containing 32 bytes of data, and compiles statistics for each one as the packets return. When the ping command receives an echo reply, it displays the results on the screen in the format:
Pinging [] with 32 bytes of data
Reply from bytes=32 time=761ms TTL=127
Reply from bytes=32 time=761ms TTL=127
Reply from bytes=32 time=761ms TTL=127
Reply from bytes=32 time=761ms TTL=127

The first piece of information in this display is the IP address of the responding system, the second is the number of bytes in the reply, the third is the number of milliseconds it took to get a reply, and the last piece of information is the Time To Live (TTL) field.

The first two pieces of information are very simple. The responding system sends back its address as a confirmation, and the number of bytes sent back is the same as the number of bytes sent.

The time field tells you how long, in milliseconds, it took the packet to get to the remote system and back. The rule of thumb here is that for optimal network performance, this round-trip time should be under 200 milliseconds.

The TTL field provides important information in a roundabout way. When the ping command sends out an ICMP echo request packet, the packet has a limited lifetime. This lifetime value is used so that if the packet doesn’t find its target, it won’t bounce around the network forever—it will eventually cease to exist. More specifically, the ping command initially gives the packet a TTL value of 255. As the packet zooms out across the network, one is subtracted from the TTL value each time the packet passes, or hops, through a router. Thus, when the packet returns, you can look at the TTL value and determine how many router hops the packet went through on its trip—just subtract the returned value from 255.

Following the main reply, the ping command will display some statistics about the operation. The statistics include the number of packets sent and lost, as well as a rundown of the round trip times. It appears in the following format:
Ping statistics for
  Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
  Minimum = 0ms, Maximum = 1ms, Average = 0ms

As you can see, the ping command is useful for testing the condition of your network. You can ping an address that exists within your LAN or over the Internet. Sometimes, when your Internet or LAN connection seems to be down, pinging can tell you whether or not the problem concerns the name resolution or whether or not that computer can be reached at all. For example, if pinging Bart returned this message:
Unknown host Bart

but pinging Bart’s IP address returned results, you know that the computer is on the network, but for some reason the name Bart is not being recognized.

Command-line switches
Ping has a few useful command-line switches. For example, if you know a computer’s IP address but want to find out its name, you can type:
Ping –a

Ping will resolve the IP address into a name and include the name in its report. The table below lists some of ping’s more helpful command-line switches. The switches are the same for Windows 9x, Me, 2000, and NT. As with many other commands, you can combine command-line switches. You can always get ping to list these for you by typing (at the command prompt):
Ping -?

Ping command-line switches
Switch Description
-a Resolves IP addresses to hostnames
-i Lets you set Time To Live (TTL)
-l Lets you set the packet size
-n Lets you set the number of echo requests
(the default is 4)
-t Pings the computer you specified until you
type Control-C (While ping is running, typing
Control-Break inserts statistics.)
-w Lets you set the number of milliseconds to wait
before each reply times out

Ping is one of the most important basic commands to learn if you’re maintaining a network of any size. Once you’re familiar with this tool, you’ll find it easier to diagnose network and Internet problems.
For more information about ping, read the following TechRepublic and TechProGuild articles:

The authors and editors have taken care in preparation of the content contained herein but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for any damages. Always have a verified backup before making any changes.