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
This commit is contained in:
parent
5f802bfc9f
commit
2510719736
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=83940
@ -32,7 +32,7 @@
|
|||||||
.\" @(#)ping.8 8.2 (Berkeley) 12/11/93
|
.\" @(#)ping.8 8.2 (Berkeley) 12/11/93
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd March 1, 1997
|
.Dd September 25, 2001
|
||||||
.Dt PING 8
|
.Dt PING 8
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -81,11 +81,14 @@ bytes used to fill out the packet. The options are as follows:
|
|||||||
.Bl -tag -width indent
|
.Bl -tag -width indent
|
||||||
.It Fl A
|
.It Fl A
|
||||||
Audible.
|
Audible.
|
||||||
Include a bell
|
Output a bell
|
||||||
.Tn ( ASCII
|
.Tn ( ASCII
|
||||||
0x07)
|
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.
|
is transmitted.
|
||||||
|
To cater for round-trip times that are longer than the interval
|
||||||
|
between transmissions, further missing packets cause a bell only
|
||||||
|
if the maximum number of unreceived packets has increased.
|
||||||
.It Fl a
|
.It Fl a
|
||||||
Audible.
|
Audible.
|
||||||
Include a bell
|
Include a bell
|
||||||
|
@ -163,6 +163,7 @@ long npackets; /* max packets to transmit */
|
|||||||
long nreceived; /* # of packets we got back */
|
long nreceived; /* # of packets we got back */
|
||||||
long nrepeats; /* number of duplicates */
|
long nrepeats; /* number of duplicates */
|
||||||
long ntransmitted; /* sequence # for outbound packets = #sent */
|
long ntransmitted; /* sequence # for outbound packets = #sent */
|
||||||
|
long nmissedmax; /* max value of ntransmitted - nreceived - 1 */
|
||||||
int interval = 1000; /* interval between packets, ms */
|
int interval = 1000; /* interval between packets, ms */
|
||||||
|
|
||||||
/* timing */
|
/* timing */
|
||||||
@ -706,8 +707,11 @@ main(argc, argv)
|
|||||||
}
|
}
|
||||||
(void)gettimeofday(&last, NULL);
|
(void)gettimeofday(&last, NULL);
|
||||||
|
|
||||||
if (ntransmitted != nreceived+1 && options & F_MISSED)
|
if (ntransmitted - nreceived - 1 > nmissedmax) {
|
||||||
(void)write(STDOUT_FILENO, &BBELL, 1);
|
nmissedmax = ntransmitted - nreceived - 1;
|
||||||
|
if (options & F_MISSED)
|
||||||
|
(void)write(STDOUT_FILENO, &BBELL, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finish();
|
finish();
|
||||||
|
Loading…
Reference in New Issue
Block a user