diff options
author | iedowse <iedowse@FreeBSD.org> | 2001-09-25 20:22:33 +0000 |
---|---|---|
committer | iedowse <iedowse@FreeBSD.org> | 2001-09-25 20:22:33 +0000 |
commit | 2cba2e955a43aa51407b34fbec17c91a9b625161 (patch) | |
tree | 052f107fcf6402783cbfc60a23db9331e5e2c8a8 /sbin/ping/ping.c | |
parent | 3282be0059c853ebcc8ac74cf5afa4607cfa3230 (diff) | |
download | FreeBSD-src-2cba2e955a43aa51407b34fbec17c91a9b625161.zip FreeBSD-src-2cba2e955a43aa51407b34fbec17c91a9b625161.tar.gz |
The -A option (beep when packets are dropped) didn't work quite
right; after a single packet was dropped it beeped after every
transmission.
Change its implementation to only output a bell when there is an
increase in the maximum value of the number of packets that were
sent but not yet received. This has the benefit that even for very
long round-trip times, ping -A will do roughly the right thing
after a few inital false-positives.
Reviewed by: ru
Diffstat (limited to 'sbin/ping/ping.c')
-rw-r--r-- | sbin/ping/ping.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 5840b8f..0c6b3cb 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -163,6 +163,7 @@ long npackets; /* max packets to transmit */ long nreceived; /* # of packets we got back */ long nrepeats; /* number of duplicates */ long ntransmitted; /* sequence # for outbound packets = #sent */ +long nmissedmax; /* max value of ntransmitted - nreceived - 1 */ int interval = 1000; /* interval between packets, ms */ /* timing */ @@ -706,8 +707,11 @@ main(argc, argv) } (void)gettimeofday(&last, NULL); - if (ntransmitted != nreceived+1 && options & F_MISSED) - (void)write(STDOUT_FILENO, &BBELL, 1); + if (ntransmitted - nreceived - 1 > nmissedmax) { + nmissedmax = ntransmitted - nreceived - 1; + if (options & F_MISSED) + (void)write(STDOUT_FILENO, &BBELL, 1); + } } } finish(); |