tcpstates(8) | System Manager's Manual | tcpstates(8) |
tcpstates - Trace TCP session state changes with durations. Uses Linux eBPF/bcc.
tcpstates [-h] [-T] [-t] [-w] [-s] [-D PORTS] [-L PORTS] [-Y]
This tool traces TCP session state changes while tracing, and prints details including the duration in each state. This can help explain the latency of TCP connections: whether the time is spent in the ESTABLISHED state (data transfer), or initialization state (SYN_SENT), etc.
This tool works using the sock:inet_sock_set_state tracepoint, which was added to Linux 4.16. Linux 4.16 also included extra state transitions so that all TCP transitions could be observed by this tracepoint.
Only TCP state changes are traced, so it is expected that the overhead of this tool is much lower than typical send/receive tracing.
Since this uses BPF, only the root user can use this tool.
CONFIG_BPF and bcc, and the sock:inet_sock_set_state tracepoint.
This traces the kernel TCP set state function, which should be called much less often than send/receive tracing, and therefore have lower overhead. The overhead of the tool is relative to the rate of new TCP sessions: if this is high, over 10,000 per second, then there may be noticeable overhead just to print out 10k lines of formatted output per second.
You can find out the rate of new TCP sessions using "sar -n TCP 1", and adding the active/s and passive/s columns.
As always, test and understand this tools overhead for your types of workloads before production use.
This is from bcc.
Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool.
Linux
Unstable - in development.
Brendan Gregg
2018-03-20 | USER COMMANDS |