2

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 /sys/kernel/debug/tracing to dynamically trace the TCP-retransmits that happen. Is there a way to translate this to a DTrace script that could be utilized for such a purpose.

James Risner
  • 5,451
  • 11
  • 25
  • 47
Payam
  • 31
  • 1

1 Answers1

2

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|" : "");
}
spmzt
  • 86
  • 7