summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorgnn <gnn@FreeBSD.org>2010-11-17 18:55:12 +0000
committergnn <gnn@FreeBSD.org>2010-11-17 18:55:12 +0000
commit67b3b6b168c800611c4683cb81384e4a678517c6 (patch)
treec215fe6cad187e004f1c275a1854ec9306dfb042 /usr.bin
parentfa6fd32fc398ffee50fe04ddd692ad76c71ebfbf (diff)
downloadFreeBSD-src-67b3b6b168c800611c4683cb81384e4a678517c6.zip
FreeBSD-src-67b3b6b168c800611c4683cb81384e4a678517c6.tar.gz
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
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/netstat/inet.c39
-rw-r--r--usr.bin/netstat/main.c11
-rw-r--r--usr.bin/netstat/netstat.16
-rw-r--r--usr.bin/netstat/netstat.h1
4 files changed, 39 insertions, 18 deletions
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index a975287..01a0242 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 f54db4e..43b3232 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 6cf895b..2214d47 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 da3f8f3..1860870 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 */
OpenPOWER on IntegriCloud