diff options
author | George V. Neville-Neil <gnn@FreeBSD.org> | 2010-11-17 18:55:12 +0000 |
---|---|---|
committer | George V. Neville-Neil <gnn@FreeBSD.org> | 2010-11-17 18:55:12 +0000 |
commit | f5d34df525d0214cd98141d75e2ca7d89887d44c (patch) | |
tree | c215fe6cad187e004f1c275a1854ec9306dfb042 /usr.bin | |
parent | 2f4fcd485d93d3b8df17d21df33e430bce5e4674 (diff) | |
download | src-f5d34df525d0214cd98141d75e2ca7d89887d44c.tar.gz src-f5d34df525d0214cd98141d75e2ca7d89887d44c.zip |
Add new, per connection, statistics for TCP, including:
Retransmitted Packets
Zero Window Advertisements
Out of Order Receives
These statistics are available via the -T argument to
netstat(1).
MFC after: 2 weeks
Notes
Notes:
svn path=/head/; revision=215434
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/netstat/inet.c | 39 | ||||
-rw-r--r-- | usr.bin/netstat/main.c | 11 | ||||
-rw-r--r-- | usr.bin/netstat/netstat.1 | 6 | ||||
-rw-r--r-- | usr.bin/netstat/netstat.h | 1 |
4 files changed, 39 insertions, 18 deletions
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index a975287ce85f..01a02429f35d 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -411,25 +411,30 @@ protopr(u_long off, const char *name, int af1, int proto) if (Lflag) printf("%-5.5s %-14.14s %-22.22s\n", "Proto", "Listen", "Local Address"); - else { + if (Tflag) + printf((Aflag && !Wflag) ? + "%-5.5s %-6.6s %-6.6s %-6.6s %-18.18s %s\n" : + "%-5.5s %-6.6s %-6.6s %-6.6s %-22.22s %s\n", + "Proto", "Rexmit", "OOORcv", "0-win", + "Local Address", "Foreign Address"); + if (xflag) { + printf("%-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s ", + "R-MBUF", "S-MBUF", "R-CLUS", + "S-CLUS", "R-HIWA", "S-HIWA", + "R-LOWA", "S-LOWA", "R-BCNT", + "S-BCNT", "R-BMAX", "S-BMAX"); + printf("%7.7s %7.7s %7.7s %7.7s %7.7s %7.7s %s\n", + "rexmt", "persist", "keep", + "2msl", "delack", "rcvtime", + "(state)"); + } + if (!xflag && !Tflag) printf((Aflag && !Wflag) ? "%-5.5s %-6.6s %-6.6s %-18.18s %-18.18s" : "%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s", "Proto", "Recv-Q", "Send-Q", "Local Address", "Foreign Address"); - if (xflag) { - printf("%-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s ", - "R-MBUF", "S-MBUF", "R-CLUS", - "S-CLUS", "R-HIWA", "S-HIWA", - "R-LOWA", "S-LOWA", "R-BCNT", - "S-BCNT", "R-BMAX", "S-BMAX"); - printf("%7.7s %7.7s %7.7s %7.7s %7.7s %7.7s %s\n", - "rexmt", "persist", "keep", - "2msl", "delack", "rcvtime", - "(state)"); - } else - printf("(state)\n"); - } + first = 0; } if (Lflag && so->so_qlimit == 0) @@ -455,6 +460,10 @@ protopr(u_long off, const char *name, int af1, int proto) snprintf(buf1, 15, "%d/%d/%d", so->so_qlen, so->so_incqlen, so->so_qlimit); printf("%-14.14s ", buf1); + } else if (Tflag) { + if (istcp) + printf("%6u %6u %6u ", tp->t_sndrexmitpack, + tp->t_rcvoopack, tp->t_sndzerowin); } else { printf("%6u %6u ", so->so_rcv.sb_cc, so->so_snd.sb_cc); } @@ -540,7 +549,7 @@ protopr(u_long off, const char *name, int af1, int proto) timer->t_rcvtime / 1000, (timer->t_rcvtime % 1000) / 10); } } - if (istcp && !Lflag) { + if (istcp && !Lflag && !xflag && !Tflag) { if (tp->t_state < 0 || tp->t_state >= TCP_NSTATES) printf("%d", tp->t_state); else { diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index f54db4ee700f..43b3232fc56a 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -342,6 +342,7 @@ int Qflag; /* show netisr information */ int rflag; /* show routing tables (or routing stats) */ int sflag; /* show protocol statistics */ int Wflag; /* wide display */ +int Tflag; /* TCP Information */ int xflag; /* extra information, includes all socket buffer info */ int zflag; /* zero stats */ @@ -361,7 +362,7 @@ main(int argc, char *argv[]) af = AF_UNSPEC; - while ((ch = getopt(argc, argv, "AaBbdf:ghI:iLlM:mN:np:Qq:rSsuWw:xz")) + while ((ch = getopt(argc, argv, "AaBbdf:ghI:iLlM:mN:np:Qq:rSTsuWw:xz")) != -1) switch(ch) { case 'A': @@ -476,6 +477,9 @@ main(int argc, char *argv[]) interval = atoi(optarg); iflag = 1; break; + case 'T': + Tflag = 1; + break; case 'x': xflag = 1; break; @@ -515,6 +519,9 @@ main(int argc, char *argv[]) if (!live) setgid(getgid()); + if (xflag && Tflag) + errx(1, "-x and -T are incompatible, pick one."); + if (Bflag) { if (!live) usage(); @@ -794,7 +801,7 @@ static void usage(void) { (void)fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", -"usage: netstat [-AaLnSWx] [-f protocol_family | -p protocol]\n" +"usage: netstat [-AaLnSTWx] [-f protocol_family | -p protocol]\n" " [-M core] [-N system]", " netstat -i | -I interface [-abdhnW] [-f address_family]\n" " [-M core] [-N system]", diff --git a/usr.bin/netstat/netstat.1 b/usr.bin/netstat/netstat.1 index 6cf895b455a4..2214d4715493 100644 --- a/usr.bin/netstat/netstat.1 +++ b/usr.bin/netstat/netstat.1 @@ -49,7 +49,7 @@ depending on the options for the information presented. .It Xo .Bk -words .Nm -.Op Fl AaLnSWx +.Op Fl AaLnSTWx .Op Fl f Ar protocol_family | Fl p Ar protocol .Op Fl M Ar core .Op Fl N Ar system @@ -88,6 +88,10 @@ but show ports symbolically. If .Fl x is present, display socket buffer and tcp timer statistics for each internet socket. +When +.Fl T +is present, display information from the TCP control block, including +retransmits, out-of-order packets received, and zero-sized windows advertised. .It Xo .Bk -words .Nm diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h index da3f8f38d593..18608702e5fe 100644 --- a/usr.bin/netstat/netstat.h +++ b/usr.bin/netstat/netstat.h @@ -50,6 +50,7 @@ extern int numeric_addr; /* show addresses numerically */ extern int numeric_port; /* show ports numerically */ extern int rflag; /* show routing tables (or routing stats) */ extern int sflag; /* show protocol statistics */ +extern int Tflag; /* show TCP control block info */ extern int Wflag; /* wide display */ extern int xflag; /* extended display, includes all socket buffer info */ extern int zflag; /* zero stats */ |