Date: Sun, 3 Aug 1997 19:49:07 +1000 From: Bruce Evans <bde@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 Message-ID: <199708030949.TAA11171@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
> > /sbin/ping -c <count> now pings until <count> pings are _received_,
> > not until <count> 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 <count>
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199708030949.TAA11171>
