Tracing FreeBSD TCP Retransmits

Viewed 24

Brendan Gregg has developed a great tool, "tcpretrans" based on the Dynamic Tracing feature of the Linux kernel. He explained it here: https://www.brendangregg.com/blog/2014-09-06/linux-ftrace-tcp-retransmit-tracing.html

The tool utilizes a low overhead approach to demonstrate TCP-retransmits happened. I wonder to know if there is a similar tool or DTrace script that could be utilized for such a purpose.

I am stuck in a situation where need to know what the retransmits are so I can dig more.

1 Answers

Try this from FreeBSD DTrace Network Stack:

#!/usr/sbin/dtrace -s
#pragma D option quiet
#pragma D option switchrate=10Hz
dtrace:::BEGIN
{
printf(" %30s %-6s %30s %-6s %-6s %s\n\n", "SADDR", "SPORT",
"DADDR", "DPORT", "BYTES", "FLAGS");
}
tcp:::receive,
tcp:::send
{
printf(" %30s %-6u %30s %-6u %-6u (%s%s%s%s%s%s\b)\n",
args[2]->ip_saddr, args[4]->tcp_sport,
args[2]->ip_daddr, args[4]->tcp_dport,
args[2]->ip_plength - args[4]->tcp_offset,
(args[4]->tcp_flags & TH_FIN) ? "FIN|" : "",
(args[4]->tcp_flags & TH_SYN) ? "SYN|" : "",
(args[4]->tcp_flags & TH_RST) ? "RST|" : "",
(args[4]->tcp_flags & TH_PUSH) ? "PSH|" : "",
(args[4]->tcp_flags & TH_ACK) ? "ACK|" : "",
(args[4]->tcp_flags & TH_URG) ? "URG|" : "");
}
Related