From owner-freebsd-net@FreeBSD.ORG Sun Oct 31 09:47:55 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B441816A4CE for ; Sun, 31 Oct 2004 09:47:55 +0000 (GMT) Received: from mail.trippynames.com (mail.trippynames.com [38.113.223.19]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8965943D2D for ; Sun, 31 Oct 2004 09:47:55 +0000 (GMT) (envelope-from sean@chittenden.org) Received: from localhost (localhost [127.0.0.1]) by mail.trippynames.com (Postfix) with ESMTP id 7BB95A6CDE for ; Sun, 31 Oct 2004 01:47:54 -0800 (PST) Received: from mail.trippynames.com ([127.0.0.1]) by localhost (rand.nxad.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 07469-06 for ; Sun, 31 Oct 2004 01:47:53 -0800 (PST) Received: from [192.168.1.3] (dsl081-069-073.sfo1.dsl.speakeasy.net [64.81.69.73]) by mail.trippynames.com (Postfix) with ESMTP id 02FABA6CE3 for ; Sun, 31 Oct 2004 01:47:52 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v619) To: freebsd-net@freebsd.org Message-Id: Content-Type: multipart/mixed; boundary=Apple-Mail-2-649787049 From: Sean Chittenden Date: Sun, 31 Oct 2004 01:47:51 -0800 X-Mailer: Apple Mail (2.619) Subject: Irritation regarding precision of ping(8)... X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Oct 2004 09:47:55 -0000 --Apple-Mail-2-649787049 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed This has long bugged me and tonight I finally snapped and had to do something about it. Example output: 64 bytes from a.b.c.d: icmp_seq=935 ttl=126 time=33.824 ms 64 bytes from a.b.c.d: icmp_seq=936 ttl=126 time=29.138 ms 64 bytes from a.b.c.d: icmp_seq=937 ttl=126 time=28.262 ms 64 bytes from a.b.c.d: icmp_seq=938 ttl=126 time=29.67 ms 64 bytes from a.b.c.d: icmp_seq=939 ttl=126 time=30.963 ms 64 bytes from a.b.c.d: icmp_seq=940 ttl=126 time=30.283 ms 64 bytes from a.b.c.d: icmp_seq=941 ttl=126 time=29.455 ms The source of irritation being line seq 930. The time should be 29.670 since we are accurately measuring the precision to the thousands place. On a less scientific basis (and the actual reason this bothered me), not having the trailing zero disrupts the continuity of a stream of ping times. The attached patch simply fixes the various formatting statements introduced in version 1.2(!!!!) to use %.30f instead of %.3f. It's now possible to see '28.200' ms ping times instead of just '28.2 ms'. Anyone mind if I commit the attached patch? I'm sure I'm not the only one who's wanted to commit the following. -sc --Apple-Mail-2-649787049 Content-Transfer-Encoding: 7bit Content-Type: text/plain; x-unix-mode=0644; name="patch.txt" Content-Disposition: attachment; filename=patch.txt Index: ping.c =================================================================== RCS file: /home/ncvs/src/sbin/ping/ping.c,v retrieving revision 1.106 diff -u -r1.106 ping.c --- ping.c 30 Sep 2004 07:35:56 -0000 1.106 +++ ping.c 31 Oct 2004 09:40:35 -0000 @@ -998,7 +998,7 @@ seq); (void)printf(" ttl=%d", ip->ip_ttl); if (timing) - (void)printf(" time=%.3f ms", triptime); + (void)printf(" time=%.30f ms", triptime); if (dupflag) (void)printf(" (DUP!)"); if (options & F_AUDIBLE) @@ -1293,7 +1293,7 @@ double avg = tsum / n; double vari = tsumsq / n - avg * avg; (void)printf( - "round-trip min/avg/max/stddev = %.3f/%.3f/%.3f/%.3f ms\n", + "round-trip min/avg/max/stddev = %.30f/%.30f/%.30f/%.30f ms\n", tmin, avg, tmax, sqrt(vari)); } --Apple-Mail-2-649787049 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed -- Sean Chittenden --Apple-Mail-2-649787049--