OnCallReadyStart learning

tcplife-bpfcc: Trace the lifespan of TCP sessions and summarize

tcplife-bpfcc [-h] [-T] [-t] [-w] [-s] [-p PID] [-L LOCALPORT] [-D REMOTEPORT] [-4 | -6]

What it does

Trace the lifespan of TCP sessions and summarize. Part of the bcc tools (bpfcc-tools 0.35.0 on Ubuntu, installed as /usr/sbin/tcplife-bpfcc; upstream and other distributions call it tcplife). It loads an eBPF program, so it needs root.

Options you will use

-T, --time
include time column on output (HH:MM:SS)
-t, --timestamp
include timestamp on output (seconds)
-w, --wide
wide column output (fits IPv6 addresses)
-s, --csv
comma separated values output
-p, --pid PID
trace this PID only
-L, --localport LOCALPORT
comma-separated list of local ports to trace.
-D, --remoteport REMOTEPORT
comma-separated list of remote ports to trace.
-4, --ipv4
trace IPv4 family only
-6, --ipv6
trace IPv6 family only

Examples

$ sudo tcplife-bpfcc

trace all TCP connect()s

$ sudo tcplife-bpfcc -T

include time column (HH:MM:SS)

$ sudo tcplife-bpfcc -w

wider columns (fit IPv6)

$ sudo tcplife-bpfcc -stT

csv output, with times & timestamps

$ sudo tcplife-bpfcc -p 181

only trace PID 181

$ sudo tcplife-bpfcc -L 80

only trace local port 80

$ sudo tcplife-bpfcc -L 80,81

only trace local ports 80 and 81

$ sudo tcplife-bpfcc -D 80

only trace remote port 80

Gotchas

Try tcplife-bpfcc in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.