ping is one of the most basic, but also one of the most useful, tools for obtaining information about computer networks, including the Internet.
A main use of ping is to determine whether a specific IP address is accessible. An IP address is a unique numeric identifier for a computer or other device on the Internet or other TCP/IP (transmission control protocol/Internet protocol) network. In IPv4, the current standard protocol for the Internet, IP addresses consist of 32 bits, and they are expressed as four sets of numbers, each from 0 to 255, which are separated by periods.
ping can also report the length of time and the number of hops (i.e., passage between any two routers or other network devices) that a packet (i.e.,the most basic unit of data sent over the Internet) takes to make a complete round trip. Additionally, it can be used to test name resolution (i.e., conversion between IP addresses and URLs): if the packet bounces back when sent to the IP address but not when sent to that address's name, then the system is having a problem matching the name to the IP address. Moreover, ping can also provide data about packet duplication and packet loss.
ping works by sending ICMP (Internet control message protocol) packets to the target IP address and listening for returned packets. It is analogous to active sonar in submarines, in which an operator issues a pulse of energy at an unseen target; if the pulse hits the target, it is bounced back to the operator.
The syntax for ping is
ping is most typically used without any of its options. The destination can be expressed in terms of the numerical IP address or a URL. In the case of a LAN (local area network), it can also be an alias for a computer or other network device.ping sends one package per second by default, and it provides one line of output for every response received. Its output generally consists of the packet size, the host queried, the ICMP sequence number, the time to live, the round-trip time and packet loss. All times are given in milliseconds, and times below ten milliseconds often have a low accuracy.
To ping the same computer from which the ping command is being issued, either of the following can be used:
The former uses the loopback address, which is the default IP address of any computer when referring to itself. localhost is the default name associated with the loopback address.
The ttl (time to live) value represents the maximum number of routers that the packet can go through before being discarded. Each router through which a packet passes decrements the ttl field by exactly one. The default value of ttl will depend on the specific operating system.
The -c option tells ping to send out only the number of packets as specified by the integer(s) that follow it. For example, to send out only five packets to the IP address 126.96.36.199, the following would be used:
The -i option tells ping what interval (in seconds) to wait between sending each packet. The default is one second. Only the root (i.e., administrative) user is permitted set the interval to values of less than 0.2 seconds.
The -s option specifies the number of bytes of data to be sent. The default is 56, which results in a packet size of 64 bytes because of the mandatory eight bytes of ICMP header data.
The -w option specifies a timeout, in seconds, before ping exits regardless of how many packets have been sent or received. The -q (i.e., quiet) option tells ping to not display anything except the summary lines at startup time and when finished.
Because of the load ping can impose on a network, it is unwise to use it on the Internet during normal operations or from automated scripts. However, this caution is not always heeded, and it can result in harm to the system. Thus, some websites and ISPs (Internet service providers) block ping messages, thereby reducing its usefulness. However, ping remains a valuable tool, and it is particularly useful for setting up LANs and other private networks.
ping was created in a single day by Mike Muuss of the Army Research Laboratory in December 1983 in response to network difficulties he encountered. It is often believed that ping is an acronym for packet Internet groper, but its author stated that the name comes from the sound made by sonar.
Although ping was originally developed for use on Unix-like operating systems, versions of it are now available for most other operating systems as well.
Created September 21, 2005.