tcpretrans(8)
β¨ NAME β¨
tcpretrans β shows TCP retransmits, with address and other details. Uses Linux ftrace. π
This is the tcpretrans(8) page, bestie. Settle in.
π SYNOPSIS π
tcpretrans [-hsp]
π¦ DESCRIPTION π¦
okay so here's the vibe: tcpretrans traces TCP retransmits that are sent by the system that tcpretrans is executed from. It shows you address, port, and TCP state info, and sometimes the PID β although usually not, because retransmits are usually sent by the kernel on timeout events, not by some cute little process you can point at. π
To keep overhead low, it only traces tcp_retransmit_skb() kernel calls. That means it does not trace every packet. Not every packet!! We are being efficient here. π
This was written as a proof of concept for ftrace, for older Linux systems, and without kernel debuginfo. It uses dynamic tracing of tcp_retransmit_skb(), and reads /proc/net/tcp for socket details. Lowkey important caveat: its use of dynamic tracing and CPU registers is an unstable platform-specific workaround, and may require modifications to work on different kernels and platforms. It would be better written using a tracer such as SystemTap, and will likely be rewritten in the future when certain tracing features are added to the Linux kernel. So like, iconic but also a work in progress, yk? π«Ά
When -l is used, this also uses dynamic tracing of tcp_send_loss_probe() and a register.
Currently only IPv4 is supported, on x86_64. If you try this on a different architecture, you'll likely need to adjust the register locations β search for %di. β
Since this uses ftrace, only the root user can use this tool. No root, no retransmit tea. π
πΈ REQUIREMENTS πΈ
- FTRACE and KPROBE CONFIG
tcp_retransmit_skb()kernel function
You may have these already have these on recent kernels (yes, that's the original phrasing, keep it, it's giving typo energy and we respect it). And Perl. π
TCP tail loss probes were added in Linux 3.10.
π OPTIONS π
-hβ Print usage message.-sβ Include kernel stack traces.-lβ Include TCP tail loss probes.
π EXAMPLES π
Trace TCP retransmits
# tcpretrans
Here's what all those columns mean, bestie, in order:
- TIME β Time of retransmit (may be rounded up to the nearest second).
- PID β Process ID that was on-CPU. This is less useful than it might sound, as it may usually be
0, for the kernel, for timer-based retransmits. - LADDR β Local address.
- LPORT β Local port.
--β Packet type:"R>"for retransmit, and"L>"for tail loss probe.- RADDR β Remote address.
- RPORT β Remote port.
- STATE β TCP session state.
π OVERHEAD π
The CPU overhead is relative to the rate of TCP retransmits, and is designed to be low as this does not examine every packet. Once per second the /proc/net/tcp file is read, and a buffer of retransmit trace events is retrieved from the kernel and processed. Once. Per. Second. That's it, we're chill like that. β¨
π SOURCE π
This is from the perf-tools collection.
https://github.com/brendangregg/perf-tools
Also look under the examples directory for a text file containing example usage, output, and commentary for this tool. π
π§ OS π§
Linux
π₯ STABILITY π₯
Unstable - in development. We're in our growing era, okay?? π
π AUTHOR π
Brendan Gregg
π SEE ALSO π
user commands, dated 2014-07-31, page tcpretrans(8) β that's the whole footer, folded into this cute little sign-off because we keep the receipts but we keep them fabulous. bye bestie, go retransmit responsibly πβ¨π
π¦ where this page comes from
- debian bookworm: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1 Β· GPL-2.0-or-later
- debian trixie: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1 Β· GPL-2.0-or-later
- ubuntu jammy: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1ubuntu1 Β· GPL-2.0-or-later
- ubuntu noble: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1ubuntu1 Β· GPL-2.0-or-later
- ubuntu resolute: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1ubuntu2 Β· GPL-2.0-or-later
- ubuntu stonking: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1ubuntu2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms