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
This commit is contained in:
parent
fa6fd32fc3
commit
67b3b6b168
@ -225,9 +225,12 @@ struct tcp_info {
|
||||
u_int32_t tcpi_snd_nxt; /* Next egress seqno */
|
||||
u_int32_t tcpi_rcv_nxt; /* Next ingress seqno */
|
||||
u_int32_t tcpi_toe_tid; /* HWTID for TOE endpoints */
|
||||
u_int32_t tcpi_snd_rexmitpack; /* Retransmitted packets */
|
||||
u_int32_t tcpi_rcv_ooopack; /* Out-of-order packets */
|
||||
u_int32_t tcpi_snd_zerowin; /* Zero-sized windows sent */
|
||||
|
||||
/* Padding to grow without breaking ABI. */
|
||||
u_int32_t __tcpi_pad[29]; /* Padding. */
|
||||
u_int32_t __tcpi_pad[26]; /* Padding. */
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -803,6 +803,7 @@ tcp_output(struct tcpcb *tp)
|
||||
if ((tp->t_flags & TF_FORCEDATA) && len == 1)
|
||||
TCPSTAT_INC(tcps_sndprobe);
|
||||
else if (SEQ_LT(tp->snd_nxt, tp->snd_max) || sack_rxmit) {
|
||||
tp->t_sndrexmitpack++;
|
||||
TCPSTAT_INC(tcps_sndrexmitpack);
|
||||
TCPSTAT_ADD(tcps_sndrexmitbyte, len);
|
||||
} else {
|
||||
@ -1027,9 +1028,10 @@ tcp_output(struct tcpcb *tp)
|
||||
* to read more data than can be buffered prior to transmitting on
|
||||
* the connection.
|
||||
*/
|
||||
if (th->th_win == 0)
|
||||
if (th->th_win == 0) {
|
||||
tp->t_sndzerowin++;
|
||||
tp->t_flags |= TF_RXWIN0SENT;
|
||||
else
|
||||
} else
|
||||
tp->t_flags &= ~TF_RXWIN0SENT;
|
||||
if (SEQ_GT(tp->snd_up, tp->snd_nxt)) {
|
||||
th->th_urp = htons((u_short)(tp->snd_up - tp->snd_nxt));
|
||||
|
@ -266,6 +266,7 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tlenp, struct mbuf *m)
|
||||
th->th_seq += i;
|
||||
}
|
||||
}
|
||||
tp->t_rcvoopack++;
|
||||
TCPSTAT_INC(tcps_rcvoopack);
|
||||
TCPSTAT_ADD(tcps_rcvoobyte, *tlenp);
|
||||
|
||||
|
@ -1218,6 +1218,9 @@ tcp_fill_info(struct tcpcb *tp, struct tcp_info *ti)
|
||||
ti->tcpi_rcv_mss = tp->t_maxseg;
|
||||
if (tp->t_flags & TF_TOE)
|
||||
ti->tcpi_options |= TCPI_OPT_TOE;
|
||||
ti->tcpi_snd_rexmitpack = tp->t_sndrexmitpack;
|
||||
ti->tcpi_rcv_ooopack = tp->t_rcvoopack;
|
||||
ti->tcpi_snd_zerowin = tp->t_sndzerowin;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -177,6 +177,7 @@ struct tcpcb {
|
||||
u_long snd_cwnd_prev; /* cwnd prior to retransmit */
|
||||
u_long snd_ssthresh_prev; /* ssthresh prior to retransmit */
|
||||
tcp_seq snd_recover_prev; /* snd_recover prior to retransmit */
|
||||
int t_sndzerowin; /* zero-window updates sent */
|
||||
u_int t_badrxtwin; /* window for retransmit recovery */
|
||||
u_char snd_limited; /* segments limited transmitted */
|
||||
/* SACK related state */
|
||||
@ -193,6 +194,8 @@ struct tcpcb {
|
||||
u_int32_t rfbuf_ts; /* recv buffer autoscaling timestamp */
|
||||
int rfbuf_cnt; /* recv buffer autoscaling byte count */
|
||||
struct toe_usrreqs *t_tu; /* offload operations vector */
|
||||
int t_sndrexmitpack; /* retransmit packets sent */
|
||||
int t_rcvoopack; /* out-of-order packets received */
|
||||
void *t_toe; /* TOE pcb pointer */
|
||||
int t_bytes_acked; /* # bytes acked during current RTT */
|
||||
struct cc_algo *cc_algo; /* congestion control algorithm */
|
||||
|
@ -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 {
|
||||
|
@ -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]",
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user