Ping — Are You There Computer?

We talked about traceroute, that’s a way to see how your traffic gets to its destination.  Like putting a GPS tracker on someone and saying ‘now how did you get to the comic book store?’.  What if you want to know ‘is the other computer on the network’?  Not how do I get there, but just are you there?  There’s a command for that!  It’s called ping.

ping is a way of saying ‘are you alive?’ to another computer.  It doesn’t mean the computer is actually doing anything worthwhile, but it does mean that the computer is talking on the network.

It’s like playing ping pong.

One Person Ping Pong

One Person Ping Pong

Pretend that there’s a field that blocks your view of the other guy.   You hit the ball over to him and the only way you’re sure he’s over there is if he hits it back to you. He could be there and just not in the mood to hit, but you don’t know because you can’t see him.

Alpha:~ computerlamp$ ping www.google.com
PING www.google.com (216.58.217.132): 56 data bytes
64 bytes from 216.58.217.132: icmp_seq=0 ttl=54 time=16.306 ms
64 bytes from 216.58.217.132: icmp_seq=1 ttl=54 time=15.747 ms
64 bytes from 216.58.217.132: icmp_seq=2 ttl=54 time=15.769 ms
64 bytes from 216.58.217.132: icmp_seq=3 ttl=54 time=15.342 ms
64 bytes from 216.58.217.132: icmp_seq=4 ttl=54 time=16.163 ms

If you try it, you’ll see that it keeps pinging along and it’ll keep going until you hit control-C to stop it.  When you do that, you’ll see:

^C
--- www.google.com ping statistics ---
5 packets transmitted, 5 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 15.342/15.865/16.306/0.341 ms

It’s nice how it keeps up with the statistics, doesn’t it?  And it tells you how long the ping took in milliseconds.

Suppose we know we only want to ping a computer a couple of times.  There’s a flag for that!

Alpha:~ computerlamp$ ping -c 2 www.marvel.com PING www.marvel.com (72.32.138.96): 56 data bytes 64 bytes from 72.32.138.96: icmp_seq=0 ttl=242 time=51.122 ms 64 bytes from 72.32.138.96: icmp_seq=1 ttl=242 time=50.637 ms — www.marvel.com ping statistics — 2 packets transmitted, 2 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 50.637/50.880/51.122/0.243 ms

If your favorite website is down, or not responding to your polite web request, then a good first step is to ping it.  Maybe the entire computer is down and if it is, well, maybe you could try a traceroute next.  A traceroute might tell you if the computer is down or if there’s something down between you and the computer.

In other words, ping is a useful networking tool to keep in your Linux® bag of tricks.

 

Leave a Reply

Your email address will not be published. Required fields are marked *