As a WISP manager always experiencing spaced-but-repeated packet-loss
mayhem, I'm loving it.

El vie, 19 feb 2021 a las 16:22, Stuart Henderson
(<s...@spacehopper.org>) escribió:
>
> This diff adds something similar to cisco's ping display, giving a
> visual display of good/dropped pings. Any interest in it? Example
> output (with a couple of ^T during the run):
>
> $ ping -g 192.168.41.21
> PING 192.168.41.21 (192.168.41.21): 56 data bytes
> ....................................................................................................................................................................................................................load:
>  0.04  cmd: ping 8312 [running] 0.00u 0.00s 0% 117k
>
> --- 192.168.41.21 ping statistics ---
> 212 packets transmitted, 212 packets received, 0.0% packet loss
> round-trip min/avg/max/std-dev = 0.342/0.636/28.579/1.940 ms
> .................................!!...........................!!!...........................!!!!!!!!!.....................!!!...........................!!!...........................!!!!!!!!!.....................!!!...........................!!!!..........................!!!!!!!!!.....................!!!...........................!!!!..........................!!!!!!!!!.....................!!!...........................!!!!..........................!!!!!!!!!!....................!!!!..........................!!!!..........................!!!!!!!!!!....................!!!!..........................!!!!..........................!!!!!!!!!!....................!!!!..........................!!!!!..............load:
>  0.00  cmd: ping 8312 [running] 0.00u 0.00s 0% 118k
>
> --- 192.168.41.21 ping statistics ---
> 924 packets transmitted, 800 packets received, 13.4% packet loss
> round-trip min/avg/max/std-dev = 0.304/0.618/41.986/1.933 ms
>
> (and while I'm there, if anyone has an idea why this one machine being
> pinged, which is a 6.8 box with em(4), might periodically stop receiving
> packets from a couple of hosts in the subnet while things are working
> ok for others, I'm all ears ;) no interface errors, netlivelocks, etc.)
>
>
> Index: ping.8
> ===================================================================
> RCS file: /cvs/src/sbin/ping/ping.8,v
> retrieving revision 1.63
> diff -u -p -r1.63 ping.8
> --- ping.8      11 Feb 2020 18:41:39 -0000      1.63
> +++ ping.8      19 Feb 2021 15:11:19 -0000
> @@ -66,7 +66,7 @@
>  .Nd send ICMP ECHO_REQUEST packets to network hosts
>  .Sh SYNOPSIS
>  .Nm ping
> -.Op Fl DdEefHLnqRv
> +.Op Fl DdEefgHLnqRv
>  .Op Fl c Ar count
>  .Op Fl I Ar sourceaddr
>  .Op Fl i Ar interval
> @@ -79,7 +79,7 @@
>  .Op Fl w Ar maxwait
>  .Ar host
>  .Nm ping6
> -.Op Fl DdEefHLmnqv
> +.Op Fl DdEefgHLmnqv
>  .Op Fl c Ar count
>  .Op Fl h Ar hoplimit
>  .Op Fl I Ar sourceaddr
> @@ -151,6 +151,21 @@ Only the superuser may use this option.
>  .Bf -emphasis
>  This can be very hard on a network and should be used with caution.
>  .Ef
> +.It Fl g
> +Graphic display.
> +This provides a quick visual display of packets received and lost.
> +For every
> +.Dv ECHO_REPLY
> +received, a period
> +.Sq \&.
> +is printed, while for every missed packet an exclamation mark
> +.Sq !
> +is printed.
> +Duplicate and truncated replies are indicated with
> +.Sq D
> +and
> +.Sq T
> +respectively.
>  .It Fl H
>  Try reverse lookups for addresses.
>  .It Fl h Ar hoplimit
> Index: ping.c
> ===================================================================
> RCS file: /cvs/src/sbin/ping/ping.c,v
> retrieving revision 1.243
> diff -u -p -r1.243 ping.c
> --- ping.c      29 Dec 2020 16:40:47 -0000      1.243
> +++ ping.c      19 Feb 2021 15:11:19 -0000
> @@ -145,7 +145,7 @@ int options;
>  #define        F_QUIET         0x0010
>  #define        F_RROUTE        0x0020
>  #define        F_SO_DEBUG      0x0040
> -/*                     0x0080 */
> +#define        F_GRAPHIC       0x0080
>  #define        F_VERBOSE       0x0100
>  /*                     0x0200 */
>  #define        F_HDRINCL       0x0400
> @@ -297,8 +297,8 @@ main(int argc, char *argv[])
>         preload = 0;
>         datap = &outpack[ECHOLEN + ECHOTMLEN];
>         while ((ch = getopt(argc, argv, v6flag ?
> -           "c:DdEefHh:I:i:Ll:mNnp:qS:s:T:V:vw:" :
> -           "DEI:LRS:c:defHi:l:np:qs:T:t:V:vw:")) != -1) {
> +           "c:DdEefgHh:I:i:Ll:mNnp:qS:s:T:V:vw:" :
> +           "DEI:LRS:c:defgHi:l:np:qs:T:t:V:vw:")) != -1) {
>                 switch(ch) {
>                 case 'c':
>                         npackets = strtonum(optarg, 0, INT64_MAX, &errstr);
> @@ -326,6 +326,9 @@ main(int argc, char *argv[])
>                         options |= F_FLOOD;
>                         setvbuf(stdout, NULL, _IONBF, 0);
>                         break;
> +               case 'g':
> +                       options |= F_GRAPHIC;
> +                       break;
>                 case 'H':
>                         options |= F_HOSTNAME;
>                         break;
> @@ -879,6 +882,11 @@ main(int argc, char *argv[])
>                                 if (!(options & F_FLOOD) &&
>                                     (options & F_AUD_MISS))
>                                         fputc('\a', stderr);
> +                               if ((options & F_GRAPHIC) &&
> +                                   !(options & F_FLOOD)) {
> +                                       putchar('!');
> +                                       fflush(stdout);
> +                               }
>                         }
>                         continue;
>                 }
> @@ -1329,7 +1337,14 @@ pr_pack(u_char *buf, int cc, struct msgh
>
>                 if (options & F_FLOOD)
>                         write(STDOUT_FILENO, &BSPACE, 1);
> -               else {
> +               else if (options & F_GRAPHIC) {
> +                       if (dupflag)
> +                               putchar('D');
> +                       else if (cc - ECHOLEN < datalen)
> +                               putchar('T');
> +                       else
> +                               putchar('.');
> +               } else {
>                         printf("%d bytes from %s: icmp_seq=%u", cc,
>                             pr_addr(from, fromlen), ntohs(seq));
>                         if (v6flag)
> @@ -1386,9 +1401,11 @@ pr_pack(u_char *buf, int cc, struct msgh
>                 pr_ipopt(hlen, buf);
>
>         if (!(options & F_FLOOD)) {
> -               putchar('\n');
> -               if (v6flag && (options & F_VERBOSE))
> -                       pr_exthdrs(mhdr);
> +               if (!(options & F_GRAPHIC)) {
> +                       putchar('\n');
> +                       if (v6flag && (options & F_VERBOSE))
> +                               pr_exthdrs(mhdr);
> +               }
>                 fflush(stdout);
>                 if (options & F_AUD_RECV)
>                         fputc('\a', stderr);
>

Reply via email to