Home > General > Ping Is Too Pessimistic

Ping Is Too Pessimistic

June 23rd, 2012

There are many billions of packets flying across the Internet every single second. The fact that a packet can get from one host in one part of the world to another host in another part of the world in a matter of milliseconds is absolutely amazing. The ping utility has long been used as a measure of checking if this awesomeness works… but unfortunately, it is very pessimistic.

To think that I can send 56 bytes of non-sense data from my machine to any Internet connected machine on the planet and have ping tell me “0% packets lost” seems rather depressing. Instead, ping should be happily exclaim “100% packets found!”

I wrote a little patch that makes the ping utility a happier utility program and the user benefits from seeing just how awesome the Internet is (unless of course, some packets were not found). ping should be a “glass is half-full” kinda program if you ask me.

eric@lolbuntu:/tmp/iputils-20071127.new$ sudo ./ping -c 3 www.google.com
PING www.l.google.com (74.125.45.147) 56(84) bytes of data.
64 bytes from yx-in-f147.1e100.net (74.125.45.147): icmp_seq=1 ttl=51 time=51.5 ms
64 bytes from yx-in-f147.1e100.net (74.125.45.147): icmp_seq=2 ttl=51 time=50.0 ms
64 bytes from yx-in-f147.1e100.net (74.125.45.147): icmp_seq=3 ttl=51 time=49.7 ms

--- www.l.google.com ping statistics ---
3 packets transmitted, 3 received, 100% packets found, time 2002ms
rtt min/avg/max/mdev = 49.792/50.433/51.504/0.762 ms

Here’s the patch:

--- iputils-20071127/ping_common.c	2007-12-09 20:56:22.000000000 -0700
+++ iputils-20071127.new/ping_common.c	2012-06-23 00:16:47.838210690 -0600
@@ -795,9 +795,9 @@
 	if (nerrors)
 		printf(", +%ld errors", nerrors);
 	if (ntransmitted) {
-		printf(", %d%% packet loss",
-		       (int) ((((long long)(ntransmitted - nreceived)) * 100) /
-			      ntransmitted));
+		printf(", %d%% packets found",
+		       (int) (100 - ((((long long)(ntransmitted - nreceived)) * 100) /
+			      ntransmitted)));
 		printf(", time %ldms", 1000*tv.tv_sec+tv.tv_usec/1000);
 	}
 	putchar('\n');

General

  1. No comments yet.
  1. No trackbacks yet.