ping graphical display

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

ping graphical display

Stuart Henderson
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 | Threaded
Open this post in threaded view
|

Re: ping graphical display

Stuart Henderson
On 2021/02/19 15:19, Stuart Henderson wrote:
> 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):

(as is traditional I forgot to update usage(), I've fixed that locally)

Reply | Threaded
Open this post in threaded view
|

Re: ping graphical display

Landry Breuil-5
In reply to this post by Stuart Henderson
On Fri, Feb 19, 2021 at 03:19:49PM +0000, Stuart Henderson wrote:
> 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):

fwiw, noping from net/liboping in ports has this feature builtin.

Landry

Reply | Threaded
Open this post in threaded view
|

Re: ping graphical display

Daniel Gracia-2
In reply to this post by Stuart Henderson
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
(<[hidden email]>) 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 | Threaded
Open this post in threaded view
|

Re: ping graphical display

Stuart Henderson
In reply to this post by Stuart Henderson
On 2021/02/19 15:19, Stuart Henderson wrote:

> 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.)

I've tweaked the manpage change a bit.

It doesn't really make sense to combine with -F, should it just
err out like it does with -f and -i?


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 16:10:53 -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,20 @@ 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
+Provides a 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 16:10:53 -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);
@@ -2236,13 +2253,13 @@ usage(void)
 {
  if (v6flag) {
  fprintf(stderr,
-    "usage: ping6 [-DdEefHLmnqv] [-c count] [-h hoplimit] "
+    "usage: ping6 [-DdEefgHLmnqv] [-c count] [-h hoplimit] "
     "[-I sourceaddr]\n\t[-i interval] [-l preload] "
     "[-p pattern] [-s packetsize] [-T toskeyword]\n"
     "\t[-V rtable] [-w maxwait] host\n");
  } else {
  fprintf(stderr,
-    "usage: ping [-DdEefHLnqRv] [-c count] [-I sourceaddr] "
+    "usage: ping [-DdEefgHLnqRv] [-c count] [-I sourceaddr] "
     "[-i interval]\n\t[-l preload] [-p pattern] [-s packetsize]"
 #ifndef SMALL
     " [-T toskeyword]"

Reply | Threaded
Open this post in threaded view
|

Re: ping graphical display

Leo Unglaub-2
In reply to this post by Stuart Henderson
Hey,
i really like this representation of the results. Very usefull to keep
an eye on a lot of hosts during network related debugging.

Works fine for me. This just as feedback for you.
Greetings
Leo

Am 19.02.2021 um 16:19 schrieb Stuart Henderson:

> 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 | Threaded
Open this post in threaded view
|

Re: ping graphical display

Stuart Henderson
In reply to this post by Stuart Henderson
Canvassing opinions on having . and ! this way around. I'm using . for
response, ! for no response, which makes more sense to me but it's been
pointed out that it's the opposite of what cisco does so it might confuse
some people.

Reply | Threaded
Open this post in threaded view
|

Re: ping graphical display

Remi Locherer
On February 19, 2021 8:56:31 PM UTC, Stuart Henderson <[hidden email]> wrote:
>Canvassing opinions on having . and ! this way around. I'm using . for
>response, ! for no response, which makes more sense to me but it's been
>pointed out that it's the opposite of what cisco does so it might
>confuse
>some people.

Also Junos uses "!" for sucessfull pings and "." for no response.
https://kb.juniper.net/InfoCenter/index?page=content&id=KB25251

And if I remember it corectly then Brocade did it the same way as Cisco.

The "-g" flag is used differently in various ping implementations. From man pages:
* FreeBSD: - g is sweepmi size.
* NetBSD: -g is used to specify a gateway for loose source routing.
* Illumos: same as NetBSD
* Linux: no -g


I like the feature and think -g is fine. I would prefer if our ping would use "!" in the same way as Cisco. That is probably als consistent with -f where a "." also stands for a echo request.

Remi

Reply | Threaded
Open this post in threaded view
|

Re: ping graphical display

Stuart Henderson
On 2021/02/20 09:20, Remi Locherer wrote:

> On February 19, 2021 8:56:31 PM UTC, Stuart Henderson <[hidden email]> wrote:
> >Canvassing opinions on having . and ! this way around. I'm using . for
> >response, ! for no response, which makes more sense to me but it's been
> >pointed out that it's the opposite of what cisco does so it might
> >confuse
> >some people.
>
> Also Junos uses "!" for sucessfull pings and "." for no response.
> https://kb.juniper.net/InfoCenter/index?page=content&id=KB25251
>
> And if I remember it corectly then Brocade did it the same way as Cisco.
>
> The "-g" flag is used differently in various ping implementations. From man pages:
> * FreeBSD: - g is sweepmi size.
> * NetBSD: -g is used to specify a gateway for loose source routing.
> * Illumos: same as NetBSD
> * Linux: no -g
>
>
> I like the feature and think -g is fine. I would prefer if our ping would use "!" in the same way as Cisco. That is probably als consistent with -f where a "." also stands for a echo request.

That's a good point about -f. I was thinking . is similar to how
it looks in -f output, but really the "."s build up when there are no
replies and it prints a backspace for a received response.
I've had offlist replies in favour of both directions but let's
go with the same polarity as junos/cisco.

Any OKs?


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 20 Feb 2021 16:30:13 -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,20 @@ 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
+Provides a visual display of packets received and lost.
+For every
+.Dv ECHO_REPLY
+received, an exclamation mark
+.Sq !
+is printed, while for every missed packet a period
+.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 20 Feb 2021 16:30:13 -0000
@@ -145,7 +145,7 @@ int options;
 #define F_QUIET 0x0010
 #define F_RROUTE 0x0020
 #define F_SO_DEBUG 0x0040
-/* 0x0080 */
+#define F_SHOWCHAR 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_SHOWCHAR;
+ 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_SHOWCHAR) &&
+    !(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_SHOWCHAR) {
+ 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_SHOWCHAR)) {
+ putchar('\n');
+ if (v6flag && (options & F_VERBOSE))
+ pr_exthdrs(mhdr);
+ }
  fflush(stdout);
  if (options & F_AUD_RECV)
  fputc('\a', stderr);
@@ -2236,13 +2253,13 @@ usage(void)
 {
  if (v6flag) {
  fprintf(stderr,
-    "usage: ping6 [-DdEefHLmnqv] [-c count] [-h hoplimit] "
+    "usage: ping6 [-DdEefgHLmnqv] [-c count] [-h hoplimit] "
     "[-I sourceaddr]\n\t[-i interval] [-l preload] "
     "[-p pattern] [-s packetsize] [-T toskeyword]\n"
     "\t[-V rtable] [-w maxwait] host\n");
  } else {
  fprintf(stderr,
-    "usage: ping [-DdEefHLnqRv] [-c count] [-I sourceaddr] "
+    "usage: ping [-DdEefgHLnqRv] [-c count] [-I sourceaddr] "
     "[-i interval]\n\t[-l preload] [-p pattern] [-s packetsize]"
 #ifndef SMALL
     " [-T toskeyword]"

Reply | Threaded
Open this post in threaded view
|

Re: ping graphical display

Klemens Nanni-2
On Sat, Feb 20, 2021 at 04:32:24PM +0000, Stuart Henderson wrote:
> That's a good point about -f. I was thinking . is similar to how
> it looks in -f output, but really the "."s build up when there are no
> replies and it prints a backspace for a received response.
> I've had offlist replies in favour of both directions but let's
> go with the same polarity as junos/cisco.
>
> Any OKs?
OK kn

Reply | Threaded
Open this post in threaded view
|

Re: ping graphical display

Theo de Raadt-2
In reply to this post by Stuart Henderson
Stuart Henderson <[hidden email]> wrote:

> On 2021/02/20 09:20, Remi Locherer wrote:
> > On February 19, 2021 8:56:31 PM UTC, Stuart Henderson <[hidden email]> wrote:
> > >Canvassing opinions on having . and ! this way around. I'm using . for
> > >response, ! for no response, which makes more sense to me but it's been
> > >pointed out that it's the opposite of what cisco does so it might
> > >confuse
> > >some people.
> >
> > Also Junos uses "!" for sucessfull pings and "." for no response.
> > https://kb.juniper.net/InfoCenter/index?page=content&id=KB25251
> >
> > And if I remember it corectly then Brocade did it the same way as Cisco.
> >
> > The "-g" flag is used differently in various ping implementations. From man pages:
> > * FreeBSD: - g is sweepmi size.
> > * NetBSD: -g is used to specify a gateway for loose source routing.
> > * Illumos: same as NetBSD
> > * Linux: no -g
> >
> >
> > I like the feature and think -g is fine. I would prefer if our ping would use "!" in the same way as Cisco. That is probably als consistent with -f where a "." also stands for a echo request.
>
> That's a good point about -f. I was thinking . is similar to how
> it looks in -f output, but really the "."s build up when there are no
> replies and it prints a backspace for a received response.
> I've had offlist replies in favour of both directions but let's
> go with the same polarity as junos/cisco.

I don't think of if like -f.  It is different, and as long as it explains itself,
and speaks to what people are used to, then it is good.