: report outstanding packets before sending next packet
Subsystems (2)
PATCH 1/1 : report outstanding packets before sending next packet
Hello,
please accept following patch to ping to let ping report outstanding packets before sending next packet. This is a sorely missed feature from the old sun ping. Very useful together with the -D option:
ping -DO 10.122.145.180 > file
# wait next day
^C
grep "no answer yet" file
[1325752664.026900] 64 bytes from 10.122.145.180: icmp_req=20 ttl=64 time=0.695 ms
[1325752665.026926] 64 bytes from 10.122.145.180: icmp_req=21 ttl=64 time=0.695 ms
[1325752666.026917] 64 bytes from 10.122.145.180: icmp_req=22 ttl=64 time=0.682 ms
[1325752667.026922] 64 bytes from 10.122.145.180: icmp_req=23 ttl=64 time=0.695 ms
[1325752669.026217] no answer yet for icmp_seq=24
[1325752670.026207] no answer yet for icmp_seq=25
...
[1325752697.026206] no answer yet for icmp_seq=52
[1325752698.026205] no answer yet for icmp_seq=53
[1325752698.026962] 64 bytes from 10.122.145.180: icmp_req=54 ttl=64 time=0.717 ms
[1325752699.026930] 64 bytes from 10.122.145.180: icmp_req=55 ttl=64 time=0.690 ms
[1325752700.026928] 64 bytes from 10.122.145.180: icmp_req=56 ttl=64 time=0.695 msKind regards,
Ole Bjorn Hessen,
Telenor
doc/ping.sgml renamed from iputils-s20101006/doc/ping.sgml +9 -1
@@ -14,7 +14,7 @@ <refsynopsisdiv> <cmdsynopsis> <command>ping</command> -<arg choice="opt"><option>-LRUbdfnqrvVaAB</option></arg> +<arg choice="opt"><option>-LRUbdfnqrvVaABDO</option></arg> <arg choice="opt">-c <replaceable/count/</arg> <arg choice="opt">-m <replaceable/mark/</arg> <arg choice="opt">-i <replaceable/interval/</arg>
@@ -246,6 +246,14 @@ </para></listitem> </varlistentry> <varlistentry> + <term><option/-O/</term> + <listitem><para> +Report outstanding ICMP ECHO reply before sending next packet. +This is useful together with the timestamp <option>-D</option> to +log output to a diagnostic file and search for missing answers. + </para></listitem> + </varlistentry> + <varlistentry> <term><option>-p <replaceable/pattern/</option></term> <listitem><para> You may specify up to 16 ``pad'' bytes to fill out the packet you send.
ping6.c renamed from iputils-s20101006/ping6.c +1 -1
@@ -1554,7 +1554,7 @@void usage (void ) {fprintf (stderr, -"Usage: ping6 [-LUdfnqrvVaAD] [-c count] [-i interval] [-w deadline]\n" +"Usage: ping6 [-LUdfnqrvVaADO] [-c count] [-i interval] [-w deadline]\n" " [-p pattern] [-s packetsize] [-t ttl] [-I interface]\n" " [-M pmtudisc-hint] [-S sndbuf] [-F flowlabel] [-Q tclass]\n" " [[-N nodeinfo-option] ...]\n"
ping.c renamed from iputils-s20101006/ping.c +1 -1
@@ -1232,7 +1232,7 @@void usage (void ) {fprintf (stderr, -"Usage: ping [-LRUbdfnqrvVaAD] [-c count] [-i interval] [-w deadline]\n" +"Usage: ping [-LRUbdfnqrvVaADO] [-c count] [-i interval] [-w deadline]\n" " [-p pattern] [-s packetsize] [-t ttl] [-I interface]\n" " [-M pmtudisc-hint] [-m mark] [-S sndbuf]\n" " [-T tstamp-options] [-Q tos] [hop1 ...] destination\n" );
ping_common.c renamed from iputils-s20101006/ping_common.c +11 -0
@@ -172,6 +172,9 @@exit (2 ); }break ; +case 'O' : + options |=F_OUTSTANDING ; +break ;case 'S' : sndbuf =atoi (optarg);if (sndbuf <=0 ) {
@@ -349,6 +352,14 @@ tokens = ntokens - interval; } +if (options &F_OUTSTANDING ) { +if (ntransmitted >0 && !TST (ntransmitted % mx_dup_ck)) { +print_timestamp (); +printf ("no answer yet for icmp_seq=%lu\n" , (ntransmitted % mx_dup_ck)); +fflush (stdout); + } + } + resend: i =send_probe ();
ping_common.h renamed from iputils-s20101006/ping_common.h +3 -2
@@ -62,6 +62,7 @@#define F_TTL 0x20000#define F_MARK 0x40000#define F_PTIMEOFDAY 0x80000 +#define F_OUTSTANDING 0x100000/* * MAX_DUP_CHK is the number of bits in received table, i.e. the maximum
@@ -121,9 +122,9 @@case 'S' :case 'n' :case 'p' :case 'q' : \case 'r' :case 's' :case 'v' :case 'L' : \case 't' :case 'A' :case 'W' :case 'B' :case 'm' : \ -case 'D' : +case 'D' :case 'O' : -#define COMMON_OPTSTR "h?VQ:I:M:aUc:dfi:w:l:S:np:qrs:vLt:AW:Bm:D" +#define COMMON_OPTSTR "h?VQ:I:M:aUc:dfi:w:l:S:np:qrs:vLt:AW:Bm:DO"/*
----------