How to Trace TCP Socket TCP_INFO tcpi_retrans_synack TCP Quickack Option Drops in Linux Using eBPF

In low-latency Linux socket programming, enabling TCP_QUICKACK instructs the kernel to disable delayed acknowledgments and immediately return ACKs upon receiving inbound traffic. However, during connection negotiation, if client sockets alternate between quickack and delayed ACK modes unpredictably or if intermediate middleboxes aggregate ACKs, server-side handshake timers may expire before completion ACKs arrive. The server triggers repeated SYN-ACK retransmissions, tracked inside tcpi_retrans_synack. Extended Berkeley Packet Filter (eBPF) provides kernel-level visibility into these handshake stalls.

Mechanisms of Delayed Handshake ACKs and Retransmissions

When an incoming SYN arrives, the server creates an inet_request_sock and transmits a SYN-ACK. If the client delays returning the completing ACK due to delayed acknowledgment timers (up to 200ms) or if the ACK packet encounters queue jitter, the server’s initial RTO timer may fire prematurely. The kernel increments tcpi_retrans_synack. Tracing kernel ACK processing routines isolates delayed ACK behavior from genuine network packet loss.

Constructing the bpftrace Quickack Monitor

The following bpftrace script captures late handshake ACK arrivals and correlates them with SYN-ACK retransmissions:

#!/usr/bin/env bpftrace

#include <net/sock.h>
#include <net/inet_connection_sock.h>
#include <linux/tcp.h>

BEGIN
{
  printf("Tracing delayed handshake ACKs and retransmissions... Hit Ctrl-C to finish.
");
}

kprobe:inet_rtx_syn_ack
{
  $req = (struct request_sock *)arg1;
  $daddr = ntop($req->ir_rmt_addr);
  $dport = bswap($req->ir_rmt_port);
  $retries = $req->num_retrans;

  if ($retries >= 1) {
    @synack_retries_under_quickack[$daddr] = count();
  }
}

interval:s:15
{
  time("%H:%M:%S ");
  printf("--- Handshake Retransmission Summary ---
");
  print(@synack_retries_under_quickack);
  clear(@synack_retries_under_quickack);
}

END
{
  clear(@synack_retries_under_quickack);
}

Running and Interpreting Kernel Diagnostics

Run the script on the target Linux host with administrative privileges:

sudo bpftrace synack_quickack_drops.bt

When delayed ACKs induce retransmissions, the diagnostic stream prints:

17:18:25 --- Handshake Retransmission Summary ---
@synack_retries_under_quickack[203.0.113.180]: 3

Remediation Strategies and Configuration Auditing

To optimize handshake timing and eliminate delayed ACK penalties:

  • Audit Initial RTO Setting: Ensure route RTO minimums accommodate delayed ACK intervals: ip route change default rto_min 250ms.
  • Enable Client Quickack: Ensure high-frequency RPC clients set setsockopt(fd, IPPROTO_TCP, TCP_QUICKACK, &val, sizeof(val)).
  • Monitor Network Jitter: Verify that intermediate switches are not buffering TCP packets in deep buffer queues.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.