next up previous

3.1.1 Testing Connections With `ping'

A useful network application is a simple program known as ping. It sends a sequence of control packets to another host. Control packets are used to establish communication between two systems, but carry no data themselves. Every system that implements the TCP/IP protocol will respond to these control packets. The most common use of ping is to see if you can reach a remote host. For example, you may not know whether your system is behind a firewall. One way to find out is to try reaching a system you know about, such as compsci at Vanderbilt.

To invoke ping from a Unix command line, just type ``ping'' and the name of the system you want to reach, e.g.

% ping compsci.cas.vanderbilt.edu
ping will start sending a sequence of control packets at a rate of one per second. As the remote host responds, ping prints information about the amount of time it took to send the original packet and receive the response. Type ^C to exit ping and return to the shell. Here is the output from a session that used ping to try to connect to compsci:
% ping compsci.cas.vanderbilt.edu 
PING compsci.cas.vanderbilt.edu: (129.59.130.21): 56 data bytes 
64 bytes from 129.59.130.21: icmp_seq=0 ttl=250 time=74 ms 
64 bytes from 129.59.130.21: icmp_seq=1 ttl=250 time=46 ms 
64 bytes from 129.59.130.21: icmp_seq=2 ttl=250 time=44 ms   
^C   
----compsci.cas.vanderbilt.edu PING Statistics----
3 packets transmitted, 3 packets received, 0% packet loss 
round-trip min/avg/max = 44/54/74 ms

If ping does note produce any output within five seconds or so it probably means it was not able to establish a connection. Type ^C to stop sending packets. ping will print its statistics about the number of packets sent and received. If it sent packets but received no responses then it failed to make a connection. Five seconds is probably enough time to wait. A host usually responds immediately to a control packet, and the round-trip time to Internet sites in Japan is around 250 ms, so if you do not see any output in five seconds it probably means you are not making a connection.