首页 tcpstates
文章
取消

tcpstates

Tcpstates prints TCP state change information, including the duration in each state as milliseconds

Run eBPF program in a line

1
sudo ecli run tcpstates

origin

origin from:

https://github.com/iovisor/bcc/blob/master/libbpf-tools/tcpconnlat.bpf.c

Compile and Run

Compile:

1
docker run -it -v `pwd`/:/src/ yunwei37/ebpm:latest

Run:

1
sudo ./ecli run package.json

details in bcc

Demonstrations of tcpstates, the Linux BPF/bcc version.

tcpstates prints TCP state change information, including the duration in each state as milliseconds. For example, a single TCP session:

1
2
3
4
5
6
7
8
# tcpstates
SKADDR           C-PID C-COMM     LADDR           LPORT RADDR           RPORT OLDSTATE    -> NEWSTATE    MS
ffff9fd7e8192000 22384 curl       100.66.100.185  0     52.33.159.26    80    CLOSE       -> SYN_SENT    0.000
ffff9fd7e8192000 0     swapper/5  100.66.100.185  63446 52.33.159.26    80    SYN_SENT    -> ESTABLISHED 1.373
ffff9fd7e8192000 22384 curl       100.66.100.185  63446 52.33.159.26    80    ESTABLISHED -> FIN_WAIT1   176.042
ffff9fd7e8192000 0     swapper/5  100.66.100.185  63446 52.33.159.26    80    FIN_WAIT1   -> FIN_WAIT2   0.536
ffff9fd7e8192000 0     swapper/5  100.66.100.185  63446 52.33.159.26    80    FIN_WAIT2   -> CLOSE       0.006
^C

This showed that the most time was spent in the ESTABLISHED state (which then transitioned to FIN_WAIT1), which was 176.042 milliseconds.

The first column is the socked address, as the output may include lines from different sessions interleaved. The next two columns show the current on-CPU process ID and command name: these may show the process that owns the TCP session, depending on whether the state change executes synchronously in process context. If that’s not the case, they may show kernel details.

本文由作者按照 CC BY 4.0 进行授权