Section 7.9. TCP Statistics


7.9. TCP Statistics

The TCP code maintains a large number of statistics for MIB-II, which is used by SNMP. These counters track details such as the number of established connections and the total number of segments sent, received, and retransmitted.

They could be used as an indicator of activity, although you must remember that these statistics usually include loopback traffic. You could also use them when you are troubleshooting networking issues: A large number of retransmissions may be a sign that a network fault is causing packet loss.

TCP statistics can be found in the following places:

  • TCP MIB-II statistics, listed in /etc/sma/snmp/mibs/TCP-MIB.txt on Solaris 10 or in RFC 2012; available from both the SNMP daemon and Kstat.

  • Solaris additions to TCP MIB-II, listed in /usr/include/inet/mib2.h and available from Kstat.

  • Extra Kstat collections maintained by the module.

7.9.1. TCP Statistics Internals

To explain how the TCP MIB statistics are maintained, we show tcp.c code that updates two of these statistics.

static int tcp_snmp_get(queue_t *q, mblk_t *mpctl) { ...                         tcp = connp->conn_tcp;                         UPDATE_MIB(&tcp_mib, tcpInSegs, tcp->tcp_ibsegs);                         tcp->tcp_ibsegs = 0;                         UPDATE_MIB(&tcp_mib, tcpOutSegs, tcp->tcp_obsegs);                         tcp->tcp_obsegs = 0; ...                                                               See uts/common/inet/tcp/tcp.c 


UPDATE_MIB increases the statistic by the argument specified. Here the tcpInSegs and tcpOutSegs statistics are updated. These are from standard TCP MIBII statistics that the Solaris 10 SNMP daemon[8] makes available; they are defined on Solaris 10 in the TCP-MIB.txt[9] file.

[8] The SNMP daemon is based on Net-SNMP.

[9] This file from RFC 2012 defines updated TCP statistics for SNMPv2. Also of interest is RFC 1213, the original MIB-II statistics, which include TCP.

The tcp.c code also maintains additional MIB statistics. For example,

void tcp_rput_data(void *arg, mblk_t *mp, void *arg2) { ...                 BUMP_MIB(&tcp_mib, tcpInDataInorderSegs);                 UPDATE_MIB(&tcp_mib, tcpInDataInorderBytes, seg_len); ...                                                           See uts/common/inet/tcp/tcp.c 


BUMP_MIB incremented the tcpInDataInorderSegs statistic by 1, then tcpInDataInorderBytes was updated. These are not standard statistics that are RFC defined, and as such they are not currently made available by the SNMP daemon. They are some of many extra and useful statistics maintained by the Solaris code.

A list of these extra statistics is in mib2.h after the comment that reads /* In addition to MIB-II */.

typedef struct mib2_tcp { ... /* In addition to MIB-II */ ...         /* total # of data segments received in order */         Counter tcpInDataInorderSegs;         /* total # of data bytes received in order */         Counter tcpInDataInorderBytes; ...                                                            See /usr/include/inet/mib2.h 


Table 7.2 lists all the extra statistics. The kstat view of TCP statistics (see Section 7.7.2) is copied from these MIB counters during each kstat update.

Table 7.2. TCP Kstat/MIB-II Statistics

Statistic

Description

tcpRtoAlgorithm

Algorithm used for transmit timeout value

tcpRtoMin

Minimum retransmit timeout (ms)

tcpRtoMax

Maximum retransmit timeout (ms)

tcpMaxConn

Maximum # of connections supported

tcpActiveOpens

# of direct transitions CLOSED -> SYN-SENT

tcpPassiveOpens

# of direct transitions LISTEN -> SYN-RCVD

tcpAttemptFails

# of direct SIN-SENT/RCVD -> CLOSED/LISTEN

tcpEstabResets

# of direct ESTABLISHED/CLOSE-WAIT -> CLOSED

tcpCurrEstab

# of connections ESTABLISHED or CLOSE-WAIT

tcpInSegs

Total # of segments received

tcpOutSegs

Total # of segments sent

tcpRetransSegs

Total # of segments retransmitted

tcpConnTableSize

Size of tcpConnEntry_t

tcpOutRsts

# of segments sent with RST flag

...

/* In addition to MIB-II */

tcpOutDataSegs

Total # of data segments sent

tcpOutDataBytes

Total # of bytes in data segments sent

tcpRetransBytes

Total # of bytes in segments retransmitted

tcpOutAck

Total of ACKs sent

tcpOutAckDelayed

Total # of delayed ACKs sent

tcpOutUrg

Total of segments sent with the urg flag on

tcpOutWinUpdate

Total # of window updates sent

tcpOutWinProbe

Total # of zero window probes sent

tcpOutControl

Total # of control segments sent (syn, fin, rst)

tcpOutFastRetrans

Total # of segments sent due to "fast retransmit"

tcpInAckSegs

Total # of ACK segments received

tcpInAckBytes

Total # of bytes ACKed

tcpInDupAck

Total # of duplicate ACKs

tcpInAckUnsent

Total # of ACKs acknowledging unsent data

tcpInDataInorderSegs

Total # of data segments received in order

tcpInDataInorderBytes

Total # of data bytes received in order

tcpInDataUnorderSegs

Total # of data segments received out of order

tcpInDataUnorderBytes

Total # of data bytes received out of order

tcpInDataDupSegs

Total # of complete duplicate data segments received

tcpInDataDupBytes

Total # of bytes in the complete duplicate data segments received

tcpInDataPartDupSegs

Total # of partial duplicate data segments received

tcpInDataPartDupBytes

Total # of bytes in the partial duplicate data segments received

tcpInDataPastWinSegs

Total # of data segments received past the window

tcpInDataPastWinBytes

Total # of data bytes received past the window

tcpInWinProbe

Total # of zero window probes received

tcpInWinUpdate

Total # of window updates received

tcpInClosed

Total # of data segments received after the connection has closed

tcpRttNoUpdate

Total # of failed attempts to update the rtt estimate

tcpRttUpdate

Total # of successful attempts to update the rtt estimate

tcpTimRetrans

Total # of retransmit timeouts

tcpTimRetransDrop

Total # of retransmit timeouts dropping the connection

tcpTimKeepalive

Total # of keepalive timeouts

tcpTimKeepaliveProbe

Total # of keepalive timeouts sending a probe

tcpTimKeepaliveDrop

Total # of keepalive timeouts dropping the connection

tcpListenDrop

Total # of connections refused because backlog is full on listen

tcpListenDropQ0

Total # of connections refused because half-open queue (q0) is full

tcpHalfOpenDrop

Total # of connections dropped from a full half-open queue (q0)

tcpOutSackRetransSegs

Total # of retransmitted segments by SACK retransmission

tcp6ConnTableSize

Size of tcp6ConnEntry_t


This behavior leads to an interesting situation: Since kstat provides a copy of all the MIB statistics that Solaris maintains, kstat provides a greater number of statistics than does SNMP. So to delve into TCP statistics in greater detail, use Kstat commands such as kstat and netstat -s.

7.9.2. TCP Statistics from Kstat

The kstat command can fetch all the TCP MIB statistics.

$ kstat -n tcp module: tcp                             instance: 0 name:   tcp                             class:    mib2         activeOpens                     812         attemptFails                    312         connTableSize                   56         connTableSize6                  84         crtime                          3.203529053         currEstab                       5         estabResets                     2 ... 


You can print all statistics from the TCP module by specifying -m instead of -n; -m, includes tcpstat, a collection of extra kstats that are not contained in the Solaris TCP MIB. And you can print individual statistics by using -s.

7.9.3. TCP Statistics Reference

Table 7.2 lists all the TCP MIB-II statistics and the Solaris additions. This list was taken from mib2.h. See TCP-MIB.txt for more information about some of these statistics.

7.9.4. TCP Statistics from DTrace

DTrace can probe TCP MIB statistics as they are incremented, as the BUMP_MIB and UPDATE_MIB macros were modified to do. The following command lists the TCP MIB statistics from DTrace.

# dtrace -ln 'mib:ip::tcp*'    ID   PROVIDER            MODULE                          FUNCTION NAME   789        mib                ip                  tcp_find_pktinfo tcpInErrs   790        mib                ip                   ip_rput_data_v6 tcpInErrs   791        mib                ip                      ip_tcp_input tcpInErrs  1163        mib                ip                     tcp_ack_timer tcpOutAckDelayed  1164        mib                ip              tcp_xmit_early_reset tcpOutRsts  1165        mib                ip                      tcp_xmit_ctl tcpOutRsts ... 


While it can be useful to trace these counters as they are incremented, some needs are still unfulfilled. For example, tracking network activity by PID, UID, project, or zone is not possible with these probes alone: There is no guarantee that they will fire in the context of the responsible thread, so DTrace's variables such as execname and pid sometimes match the wrong process.

DTrace can be useful to capture these statistics during an interval of your choice. The following one-liner does this until you press Ctrl-C.

# dtrace -n 'mib:::tcp* { @[probename] = sum(arg0); }' dtrace: description 'mib:::tcp* ' matched 93 probes ^C   tcpInDataInorderSegs                                              7   tcpInAckSegs                                                     14   tcpRttUpdate                                                     14   tcpInDataInorderBytes                                            16   tcpOutDataSegs                                                   16   tcpOutDataBytes                                                4889   tcpInAckBytes                                                  4934 





Solaris Performance and Tools(c) Dtrace and Mdb Techniques for Solaris 10 and Opensolaris
Solaris Performance and Tools: DTrace and MDB Techniques for Solaris 10 and OpenSolaris
ISBN: 0131568191
EAN: 2147483647
Year: 2007
Pages: 180

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net