Date: Sun, 23 Sep 2001 13:27:29 +0100 From: Ian Dowse <iedowse@maths.tcd.ie> To: freebsd-audit@freebsd.org Subject: ping -A Message-ID: <200109231327.aa81352@salmon.maths.tcd.ie>
next in thread | raw e-mail | index | archive | help
Some time ago, a '-A' (audible beep when packets are dropped) option
was added to ping in -current only. The logic in its implementation
isn't quite right; once one packet is dropped, it beeps after every
transmission.
Here is a patch that should make it work in a more useful way. It
only outputs a bell when there is an increase in the maximum number
of unreceived packets. This has the benefit that for very long
round-trip times, ping -A will do the right thing after a few
inital false-positives.
Any comments?
Ian
Index: ping.8
===================================================================
RCS file: /dump/FreeBSD-CVS/src/sbin/ping/ping.8,v
retrieving revision 1.32
diff -u -r1.32 ping.8
--- ping.8 7 Aug 2001 15:48:36 -0000 1.32
+++ ping.8 23 Sep 2001 12:11:37 -0000
@@ -32,7 +32,7 @@
.\" @(#)ping.8 8.2 (Berkeley) 12/11/93
.\" $FreeBSD: src/sbin/ping/ping.8,v 1.32 2001/08/07 15:48:36 ru Exp $
.\"
-.Dd March 1, 1997
+.Dd September 23, 2001
.Dt PING 8
.Os
.Sh NAME
@@ -81,11 +81,14 @@
.Bl -tag -width indent
.It Fl A
Audible.
-Include a bell
+Output a bell
.Tn ( ASCII
0x07)
-character in the output when no packet is received before the next packet
+character when no packet is received before the next packet
is transmitted.
+To cater for round-trip times that are longer than the transmitting
+interval, further missing packets cause a bell only if the maximum
+number of unreceived packets has increased.
.It Fl a
Audible.
Include a bell
Index: ping.c
===================================================================
RCS file: /dump/FreeBSD-CVS/src/sbin/ping/ping.c,v
retrieving revision 1.59
diff -u -r1.59 ping.c
--- ping.c 7 Jul 2001 19:09:21 -0000 1.59
+++ ping.c 23 Sep 2001 11:12:05 -0000
@@ -163,6 +163,7 @@
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 @@
}
(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();
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200109231327.aa81352>
