How to show network TCP statistics and counters
The nstat command can be used to retrieve information about network connection statistics and relevant counters.
Using the tool is easy, just run it without any parameters to see relevant counters.
# nstat
#kernel
IpInReceives 865 0.0
IpInDelivers 864 0.0
IpOutRequests 1073 0.0
TcpInSegs 864 0.0
TcpOutSegs 1074 0.0
Ip6InReceives 1 0.0
Ip6InMcastPkts 1 0.0
Ip6InOctets 382 0.0
Ip6InMcastOctets 382 0.0
Ip6InNoECTPkts 1 0.0
TcpExtTCPHPHits 490 0.0
TcpExtTCPPureAcks 30 0.0
TcpExtTCPHPAcks 451 0.0
TcpExtTCPSACKReorder 1 0.0
TcpExtTCPBacklogCoalesce 48 0.0
TcpExtTCPSackShiftFallback 1 0.0
TcpExtTCPRcvCoalesce 190 0.0
TcpExtTCPOFOQueue 8 0.0
TcpExtTCPAutoCorking 106 0.0
TcpExtTCPOrigDataSent 909 0.0
TcpExtTCPKeepAlive 22 0.0
TcpExtTCPDelivered 910 0.0
TcpExtTCPAckCompressed 1 0.0
IpExtInOctets 205502 0.0
IpExtOutOctets 285260 0.0
IpExtInNoECTPkts 866 0.0
Now there is something special with this tool, that is maintains history. So each time you run the tool, it will show you the difference between the current and the previous run. Also, if you are just interesting in information about the TCP connections, then we need to fine-tune the output. One could use grep for this, but it is better to perform the specific query right away.
Show TCP counters
Relevant counters can be shown by providing the --reset option. This resets the history, so that when you run the command again, all counters are shown. Or in other words, the cumulative values of the counters.
nstat --reset Tcp*
Show all TCP counters
To retrieve all counters, including those with a value of zero, add the --zeros option.
# nstat --reset --zeros Tcp*
#kernel
TcpActiveOpens 339 0.0
TcpPassiveOpens 4218 0.0
TcpAttemptFails 32 0.0
TcpEstabResets 29 0.0
TcpInSegs 2583671 0.0
TcpOutSegs 3480725 0.0
TcpRetransSegs 325 0.0
TcpInErrs 0 0.0
TcpOutRsts 178703 0.0
TcpInCsumErrors 0 0.0
TcpExtSyncookiesSent 0 0.0
TcpExtSyncookiesRecv 0 0.0
TcpExtSyncookiesFailed 0 0.0
TcpExtEmbryonicRsts 8 0.0
TcpExtPruneCalled 0 0.0
TcpExtRcvPruned 0 0.0
TcpExtOfoPruned 0 0.0
TcpExtOutOfWindowIcmps 0 0.0
TcpExtLockDroppedIcmps 0 0.0
TcpExtArpFilter 0 0.0
TcpExtTW 2989 0.0
Got another method to retrieve relevant information? Let it know!