blob: aa698b9c71dc9768016a327d47ae00ddc8cf39a7 [file] [log] [blame]
Brendan Gregg553f2aa2016-02-14 18:15:24 -08001Demonstrations of tcpretrans, the Linux eBPF/bcc version.
2
3
4This tool traces the kernel TCP retransmit function to show details of these
5retransmits. For example:
6
Michael Gugino7abd77a2021-09-01 18:07:33 -04007# ./tcpretrans
Brendan Gregg553f2aa2016-02-14 18:15:24 -08008TIME PID IP LADDR:LPORT T> RADDR:RPORT STATE
901:55:05 0 4 10.153.223.157:22 R> 69.53.245.40:34619 ESTABLISHED
1001:55:05 0 4 10.153.223.157:22 R> 69.53.245.40:34619 ESTABLISHED
1101:55:17 0 4 10.153.223.157:22 R> 69.53.245.40:22957 ESTABLISHED
12[...]
13
14This output shows three TCP retransmits, the first two were for an IPv4
15connection from 10.153.223.157 port 22 to 69.53.245.40 port 34619. The TCP
16state was "ESTABLISHED" at the time of the retransmit. The on-CPU PID at the
17time of the retransmit is printed, in this case 0 (the kernel, which will
18be the case most of the time).
19
20Retransmits are usually a sign of poor network health, and this tool is
21useful for their investigation. Unlike using tcpdump, this tool has very
22low overhead, as it only traces the retransmit function. It also prints
23additional kernel details: the state of the TCP session at the time of the
24retransmit.
25
26
27A -l option will include TCP tail loss probe attempts:
28
29# ./tcpretrans -l
30TIME PID IP LADDR:LPORT T> RADDR:RPORT STATE
3101:55:45 0 4 10.153.223.157:22 R> 69.53.245.40:51601 ESTABLISHED
3201:55:46 0 4 10.153.223.157:22 R> 69.53.245.40:51601 ESTABLISHED
3301:55:46 0 4 10.153.223.157:22 R> 69.53.245.40:51601 ESTABLISHED
3401:55:53 0 4 10.153.223.157:22 L> 69.53.245.40:46444 ESTABLISHED
3501:56:06 0 4 10.153.223.157:22 R> 69.53.245.40:46444 ESTABLISHED
3601:56:06 0 4 10.153.223.157:22 R> 69.53.245.40:46444 ESTABLISHED
3701:56:08 0 4 10.153.223.157:22 R> 69.53.245.40:46444 ESTABLISHED
3801:56:08 0 4 10.153.223.157:22 R> 69.53.245.40:46444 ESTABLISHED
3901:56:08 1938 4 10.153.223.157:22 R> 69.53.245.40:46444 ESTABLISHED
4001:56:08 0 4 10.153.223.157:22 R> 69.53.245.40:46444 ESTABLISHED
4101:56:08 0 4 10.153.223.157:22 R> 69.53.245.40:46444 ESTABLISHED
42[...]
43
44See the "L>" in the "T>" column. These are attempts: the kernel probably
45sent a TLP, but in some cases it might not have been ultimately sent.
46
Matthias Tafelmeier1e9467f2017-12-13 18:50:22 +010047To spot heavily retransmitting flows quickly one can use the -c flag. It will
Michael Gugino7abd77a2021-09-01 18:07:33 -040048count occurring retransmits per flow.
Matthias Tafelmeier1e9467f2017-12-13 18:50:22 +010049
50# ./tcpretrans.py -c
51Tracing retransmits ... Hit Ctrl-C to end
52^C
53LADDR:LPORT RADDR:RPORT RETRANSMITS
54192.168.10.50:60366 <-> 172.217.21.194:443 700
Michael Gugino7abd77a2021-09-01 18:07:33 -040055192.168.10.50:666 <-> 172.213.11.195:443 345
Matthias Tafelmeier1e9467f2017-12-13 18:50:22 +010056192.168.10.50:366 <-> 172.212.22.194:443 211
57[...]
58
59This can ease to quickly isolate congested or otherwise awry network paths
60responsible for clamping tcp performance.
Brendan Gregg553f2aa2016-02-14 18:15:24 -080061
Michael Gugino7abd77a2021-09-01 18:07:33 -040062TCP sequence numbers can be included via -s, except in count mode. These numbers
63are useful for identifying specific retransmissions in large packet caputes.
64Note, lossprobe -l output will display 0 for the sequence number for L type.
65
66# ./tcpretrans.py -s
67TIME PID IP LADDR:LPORT T> RADDR:RPORT STATE SEQ
6818:03:46 0 4 192.168.10.50:41976 R> 172.217.21.194:443 SYN_SENT 2879306108
6918:03:49 0 4 192.168.10.50:41976 R> 172.217.21.194:443 SYN_SENT 2879306108
70
Brendan Gregg553f2aa2016-02-14 18:15:24 -080071USAGE message:
72
73# ./tcpretrans -h
Michael Gugino7abd77a2021-09-01 18:07:33 -040074usage: tcpretrans.py [-h] [-s] [-l] [-c] [-4 | -6]
Brendan Gregg553f2aa2016-02-14 18:15:24 -080075
76Trace TCP retransmits
77
78optional arguments:
79 -h, --help show this help message and exit
Michael Gugino7abd77a2021-09-01 18:07:33 -040080 -s, --sequence display TCP sequence numbers
Brendan Gregg553f2aa2016-02-14 18:15:24 -080081 -l, --lossprobe include tail loss probe attempts
Matthias Tafelmeier1e9467f2017-12-13 18:50:22 +010082 -c, --count count occurred retransmits per flow
Hariharan Ananthakrishnan04893e32021-08-12 05:55:21 -070083 -4, --ipv4 trace IPv4 family only
84 -6, --ipv6 trace IPv6 family only
Brendan Gregg553f2aa2016-02-14 18:15:24 -080085
86examples:
87 ./tcpretrans # trace TCP retransmits
88 ./tcpretrans -l # include TLP attempts
Hariharan Ananthakrishnan04893e32021-08-12 05:55:21 -070089 ./tcpretrans -4 # trace IPv4 family only
90 ./tcpretrans -6 # trace IPv6 family only