From owner-freebsd-bugs Sun Aug 3 02:50:51 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id CAA17193 for bugs-outgoing; Sun, 3 Aug 1997 02:50:51 -0700 (PDT) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id CAA17188 for ; Sun, 3 Aug 1997 02:50:48 -0700 (PDT) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.5/8.6.9) id TAA11171; Sun, 3 Aug 1997 19:49:07 +1000 Date: Sun, 3 Aug 1997 19:49:07 +1000 From: Bruce Evans Message-Id: <199708030949.TAA11171@godzilla.zeta.org.au> To: freebsd-bugs@hub.freebsd.org, j@uriah.heep.sax.de Subject: Re: bin/4218: change in ping behavior: -c now counts _received_ packets Sender: owner-freebsd-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > > /sbin/ping -c now pings until pings are _received_, > > not until pings are sent. > > I agree that this behaviour is not what one would usually expect from > -c, but it seems to be this way in all ping -c versions i've seen so > far. > > What makes you think this has been changed recently? You can easily Reviewing of recent changes, the cvs logs, and previous discussions of this problem :-). Except that the problem is actually that "sent" is now interpreted more strictly (packets for which sendto() fails are not counted as "sent"). Ping still doesn't necessarily wait until pings are _received_. > verify in CVS that it has been this way all the time for FreeBSD, at Nope. It has only been this way all the time in the FreeBSD man page :-). The original 4.4Lite code is: ... [in the main loop] if (npackets && nreceived >= npackets) break; ... [in the SIGALRM handler] if (!npackets || ntransmitted < npackets) alarm((u_int)interval); else { if (nreceived) { waittime = 2 * tmax / 1000; if (!waittime) waittime = 1; } else waittime = MAXWAIT; (void)signal(SIGALRM, finish); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (void)alarm((u_int)waittime); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ } Here npackets is the count for -c. The test against `nreceived' in the main loop is probably unnecessary, since nreceived should be <= ntransmitted and the underlined SIGALRM handling will abort ping after `ntransmitted' packets have been sent. Bruce