tcpretrans.bt(8)
π tcpretrans.bt β from the System Manager's Manual
okay bestie, gather round, because this one is literally a bop π It's tcpretrans.bt, and it's your girl for tracing (or counting!) TCP retransmits. Uses Linux bpftrace/eBPF, no cap. β¨
πΈ SYNOPSIS πΈ
tcpretrans.bt
That's it. That's the whole thing. She's low maintenance. π
β¨ DESCRIPTION β¨
So what does she actually do? She traces TCP retransmits, and shows you the address, the port, and the TCP state info β and sometimes the PID. Not usually though, because retransmits are normally sent by the kernel on timeouts, so don't get your hopes up on the PID front. π
The way she keeps overhead so low is that she only traces the TCP retransmit functions. She does not trace every single packet like tcpdump(8) or a packet sniffer would. She's not doing all that. π
And optionally? She can count retransmits over a user signalled interval, which is genuinely so useful for spotting potentially dropping network paths that your flows are traversing. iykyk. π₯
Under the hood she's doing dynamic tracing of the kernel's tcp_retransmit_skb() and tcp_send_loss_probe() functions β which means she'll need to be updated to match any kernel changes to those functions. Keep that in mind, bestie. π¦
Since this uses BPF, only the root user can use this tool. Root only, no exceptions, periodt. π
π§ REQUIREMENTS π§
CONFIG_BPFandbcc.CONFIG_BPFandbpftrace.
Both. You need both. That's the vibe check. β
π EXAMPLES π
Trace TCP retransmits:
# tcpretrans.bt
π FIELDS π
Here's the tea on every column you'll see:
- TIME β Time of the call, in
HH:MM:SSformat. π - PID β Process ID that was on-CPU. And ngl, this is less useful than it might sound, because it may usually be
0, for the kernel, for timer-based retransmits. So like... don't build your whole theory around it. π - LADDR β Local IP address.
- LPORT β Local port.
- RADDR β Remote IP address.
- RPORT β Remote port.
- STATE β TCP session state. π
π OVERHEAD π
Should be negligible, fr fr. TCP retransmit events should be low (under <1000/s), and the low overhead this tool adds to each event should make the cost negligible. She's light on her feet, she's not gonna tank your system. π«Ά
πΈ SOURCE πΈ
This is from bpftrace:
https://github.com/iovisor/bpftrace
Also β go look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. It's giving bonus content. β¨
And fyi, this is a bpftrace version of the bcc tool of the same name. The bcc tool may provide more options and customizations, so if you want more knobs to turn:
https://github.com/iovisor/bcc
π¦ OS π¦
Linux. Obviously. π
π STABILITY π
Unstable β in development. She's still growing, okay?? Be nice to her. π
π AUTHOR π
Brendan Gregg, adapted for bpftrace by Dale Hamel. Legends only. π
β SEE ALSO β
okay that's the whole page bestie, you ate that π this was a USER COMMANDS page, dated 2018-11-24 β go forth and trace those retransmits, mwah! πβ¨
π¦ where this page comes from
- debian bookworm: bpftrace 0.17.0-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms