Linux TCP Retransmissions Troubleshooting: Diagnose Packet Loss and Slow Connections

Linux TCP Retransmissions Troubleshooting

Introduction

TCP retransmissions are an important indicator of network reliability and performance. When a Linux server repeatedly retransmits TCP segments, applications may experience slow connections, increased latency, interrupted file transfers, or inconsistent response times.

However, retransmissions do not automatically mean that a network link is failing. They can result from packet loss, network congestion, packet reordering, delayed acknowledgments, or problems along the return path.

Linux provides several tools for investigating these conditions without immediately changing network settings. Commands such as nstat, ss, and tcpdump help administrators identify retransmission activity, inspect individual TCP connections, and investigate what is happening between endpoints.

This guide explains how TCP retransmissions work and provides a practical troubleshooting workflow for Linux servers.

1. What Are TCP Retransmissions?

TCP is a connection-oriented protocol that uses sequence numbers and acknowledgments to provide reliable data delivery.

When a sender transmits a TCP segment, it expects the receiving endpoint to acknowledge the transmitted data. If the sender cannot determine that the data was successfully received, it may retransmit the segment.

For example:

  1. A Linux client sends TCP data to a remote server.
  2. The server receives the segment and sends an acknowledgment.
  3. The acknowledgment does not reach the client, or the original segment is lost.
  4. The client detects a potential loss.
  5. TCP retransmits the unacknowledged data.

Retransmission allows TCP to recover from packet loss without requiring the application to restart the entire connection.

The retransmission timer and its calculation are described in RFC 6298 – Computing TCP’s Retransmission Timer.

TCP retransmission timeout (RTO)

The Retransmission Timeout, or RTO, determines how long TCP waits before retransmitting data when it has not received the expected acknowledgment.

TCP estimates the round-trip time (RTT) and its variation to calculate an appropriate timeout.

If the RTO expires, TCP retransmits the earliest unacknowledged segment. When repeated timeouts occur, the retransmission timeout is backed off, normally by doubling its value.

This behavior prevents TCP from continuously sending data into a potentially congested network.

Fast retransmission

TCP does not always need to wait for the RTO to expire.

When a receiver receives segments beyond a missing sequence range, it can send duplicate acknowledgments indicating the sequence number it is still expecting.

Under the traditional fast retransmit algorithm, three duplicate ACKs can trigger retransmission before the RTO expires.

The relevant congestion-control and fast-retransmit behavior is described in RFC 5681 – TCP Congestion Control.

2. Common Causes of TCP Retransmissions

Identifying the underlying cause is more important than simply counting retransmitted segments.

The most common causes include:

2.1 Packet loss

A packet can disappear at different points along its path:

  • Network interface errors.
  • Congested switches or routers.
  • Dropped packets in firewalls.
  • Overloaded virtual network interfaces.
  • Unstable wireless connections.
  • Problems with network tunnels.

If the receiver does not receive a segment, it cannot acknowledge that segment’s data. The sender may eventually retransmit it.

2.2 Network congestion

Congestion occurs when network devices receive more traffic than they can efficiently forward.

Common symptoms include:

  • Increased latency.
  • Packet drops.
  • Variable throughput.
  • Repeated retransmissions during traffic peaks.

Congestion can occur on a server’s network interface, an uplink, a virtual switch, or an intermediate router.

TCP congestion-control algorithms respond to signs of loss by adjusting the sending rate and congestion window.

2.3 Packet reordering

Not every duplicate ACK indicates that a packet was lost.

For example, a network may deliver TCP segments in a different order from the order in which they were transmitted.

The receiver may acknowledge the last contiguous sequence range repeatedly while waiting for an earlier segment.

This can cause the sender to interpret the situation as a potential loss and initiate recovery.

Packet reordering can occur with:

  • Multipath routing.
  • Link aggregation.
  • Load balancing.
  • Different network paths with different latency.
  • Virtualized network infrastructure.

2.4 MTU and Path MTU Discovery problems

Incorrect MTU settings can create connectivity problems, particularly across VPNs, tunnels, and networks with different encapsulation overhead.

A connection may establish successfully but experience problems when transferring larger amounts of data.

Investigate MTU and Path MTU Discovery when retransmissions occur alongside symptoms such as stalled transfers or failures with larger packets.

See the related guide: Linux MTU Troubleshooting: Fix MTU and PMTUD Issues.

2.5 Firewall and asymmetric routing problems

Firewalls may drop packets or acknowledgments because of incorrect state tracking, filtering rules, or resource limitations.

Asymmetric routing can also complicate troubleshooting when outbound and return traffic follow different paths.

Investigate both directions of the connection rather than assuming that the problem exists on the sending interface.

3. TCP Retransmissions vs. Packet Loss

TCP retransmissions and packet loss are closely related, but they are not identical measurements.

A retransmission means that TCP sent data again because it considered previously transmitted data unacknowledged or potentially lost.

Packet loss means that a packet did not reach its intended destination.

There are several reasons why the two measurements may differ:

  • A packet can be delayed and arrive after the sender has already retransmitted it.
  • Packet reordering can trigger recovery behavior without permanent packet loss.
  • An acknowledgment can be lost even when the original data segment arrives.
  • A packet capture may miss packets because of capture location or limitations.

For this reason, a retransmission counter should be treated as a troubleshooting indicator, not a direct measurement of the percentage of packets physically lost across the network.

A useful starting point is to compare retransmission counters with total TCP traffic and investigate changes over time.

4. Monitor TCP Retransmissions with nstat

The nstat command is part of the iproute2 networking utilities. It displays Linux kernel network statistics, including TCP counters.

It is useful for determining whether retransmission activity is increasing on a server.

Display TCP retransmission statistics

Run:

nstat | grep -i retrans

You may see output similar to:

TcpRetransSegs                  125
TcpExtTCPFastRetrans             18
TcpExtTCPSlowStartRetrans         7
TcpExtTCPSynRetrans               3

The exact counters available depend on the Linux kernel version.

Important counters include:

CounterMeaning
TcpRetransSegsTCP segments retransmitted
TcpExtTCPFastRetransFast retransmission events
TcpExtTCPSlowStartRetransRetransmissions associated with slow-start recovery
TcpExtTCPSynRetransRetransmitted SYN segments

These counters help identify whether retransmission activity is occurring during established connections or connection establishment.

Display absolute counter values

To inspect the absolute values rather than increments since the previous nstat invocation, use:

nstat -az | grep -i retrans

The -a option displays absolute counter values, while -z includes counters with zero values.

Monitor retransmissions over time

Take an initial snapshot:

nstat -az TcpRetransSegs

Wait for a defined observation period:

sleep 60

Take another snapshot:

nstat -az TcpRetransSegs

Compare the two values to determine how much the counter increased during the observation period.

For example:

Initial value:  1200
After 60 sec:   1260
Difference:       60

This indicates that the host’s TCP retransmission counter increased by 60 during that period.

Important: TcpRetransSegs is a host-level cumulative counter, not a per-connection measurement. It can include activity from multiple TCP connections. Also, it is not a direct packet-loss percentage.

For more precise interpretation, compare it with traffic volume and inspect individual connections.

The Linux kernel SNMP counter documentation provides additional information about network statistics and TCP counters.

5. Identify Retransmissions with ss

The ss command provides detailed information about Linux network sockets.

Unlike host-wide statistics, ss helps investigate individual TCP connections.

Display established TCP connections

Run:

ss -tn state established

This displays established TCP connections using numeric addresses and ports.

Display detailed TCP information

Run:

ss -tin

The -i option displays internal TCP information.

Depending on the kernel and iproute2 version, output may contain fields such as:

ESTAB 0 0 192.168.1.10:443 192.168.1.20:52144
    rto:204 rtt:12.5/3.2
    backoff:1
    mss:1448
    cwnd:10
    retrans:1/3

This is an illustrative example; actual output varies by system and kernel version.

Important fields include:

FieldMeaning
rtoCurrent retransmission timeout, in milliseconds
rttEstimated round-trip time and variation
backoffRetransmission timeout backoff value
retransRetransmission information for the connection
cwndTCP congestion window
mssMaximum Segment Size
pmtuPath MTU information, when available

A rising retransmission count, increasing RTT, or growing backoff value can indicate that a connection is experiencing delivery problems.

Monitor a specific destination

To inspect connections involving a particular remote IP address:

ss -tin dst 192.168.1.20

To inspect connections using a particular destination port:

ss -tin dst :443

You can also inspect the process using a socket:

ss -tinp

This is useful when you need to identify which application owns a problematic connection.

For additional command details, see the Linux ss manual.

6. Capture TCP Retransmissions with tcpdump

Statistics indicate that retransmissions are occurring, but they do not explain exactly what is happening in a particular TCP flow.

A packet capture provides a closer look at sequence numbers, acknowledgments, timing, and traffic direction.

The tcpdump utility can capture traffic directly from a Linux interface.

Capture traffic for a specific host

Replace the example address with the actual remote server IP:

sudo tcpdump -i any -nn -s 0 \
  'host 203.0.113.20 and tcp port 443' \
  -w /tmp/tcp-retransmissions.pcap

This command:

  • Uses all available interfaces through -i any.
  • Disables DNS and service-name resolution with -nn.
  • Captures complete packets with -s 0.
  • Limits the capture to the selected host and TCP port.
  • Saves packets to a file for later analysis.

Stop the capture with Ctrl+C after collecting enough traffic.

Read the capture

You can inspect the saved capture using:

sudo tcpdump -nn -tttt \
  -r /tmp/tcp-retransmissions.pcap

Look for repeated TCP sequence ranges, duplicate acknowledgments, missing expected traffic, and unusual delays.

A repeated sequence range can be evidence of retransmission, but packet timing and reverse-direction ACKs must also be considered.

Use Wireshark for deeper analysis

For a visual analysis, open the capture file in Wireshark.

Useful display filters include:

tcp.analysis.retransmission
tcp.analysis.fast_retransmission
tcp.analysis.duplicate_ack
tcp.analysis.out_of_order

These filters help identify retransmission candidates, duplicate ACKs, and out-of-order segments.

Wireshark’s TCP analysis is based on its interpretation of the captured packet sequence. Its labels are analysis results, not TCP flags transmitted over the network.

Read the Wireshark TCP Analysis documentation for details about how these classifications are generated.

For a broader introduction to packet capture and filtering, see Wireshark Explained: Packet Capture, Filters and Network Analysis.

Capture limitation: Capturing traffic on a Linux endpoint does not always show the exact packets transmitted on the physical network. Features such as GRO, GSO, and TSO can affect how packets appear in host-level captures. Check the capture point and, when necessary, compare captures from both endpoints or a network tap.

7. Diagnose RTO and Duplicate ACKs

Two important indicators during TCP troubleshooting are retransmission timeouts and duplicate acknowledgments.

They provide different clues about how TCP is recovering from potential data loss.

Retransmission timeout symptoms

A retransmission timeout occurs when TCP does not receive the expected acknowledgment within the current RTO.

Look for:

  • Increasing rto values in ss -ti.
  • A nonzero or increasing backoff value.
  • Repeated retransmissions in packet captures.
  • Long pauses during data transfers.
  • Increasing application response times.

Repeated RTO events can indicate serious packet delivery problems, but they do not identify the exact network device responsible.

Duplicate ACK symptoms

Duplicate ACKs occur when a receiver continues acknowledging the same contiguous sequence range.

For example:

ACK 5001
ACK 5001
ACK 5001
ACK 5001

This may indicate that a segment beyond sequence number 5000 arrived while an earlier segment was still missing.

However, duplicate ACKs can also result from packet reordering or packet duplication.

Therefore, investigate the sequence numbers and packet arrival times before concluding that a specific packet was lost.

Compare the two recovery patterns

ObservationPossible interpretation
Duplicate ACKs followed by retransmissionFast retransmit or another loss-recovery mechanism
Long delay followed by retransmissionPossible RTO expiration
Repeated RTO backoffPersistent lack of acknowledgment
Out-of-order packets without repeated RTOsPossible packet reordering
Retransmissions during traffic peaksPossible congestion or queue drops

TCP recovery behavior is more complex than these simplified examples, so always correlate the observations with the actual packet trace.

8. Investigate Network Congestion and MTU Problems

After identifying retransmission activity, investigate the network path instead of immediately changing TCP parameters.

Check interface statistics

Use:

ip -s link

Inspect the relevant network interface for:

  • RX errors.
  • TX errors.
  • Dropped packets.
  • Increasing error counters.

You can also inspect interface details:

ip -details link show

If interface counters increase during the problem, investigate the NIC, driver, virtual switch, physical link, and upstream network devices.

Check interface throughput

Use:

ip -s link show dev eth0

Replace eth0 with the actual interface name.

Compare transmitted and received byte and packet counters over time.

High traffic levels combined with retransmissions and increased latency may indicate congestion, but interface utilization alone does not prove that congestion is the cause.

Check MTU and Path MTU Discovery

Display the interface MTU:

ip link show dev eth0

For a basic IPv4 path MTU test, use:

ping -M do -s 1472 192.168.1.1

The example assumes a 1500-byte IPv4 MTU and a 20-byte IPv4 header plus an 8-byte ICMP header.

If the path uses a smaller MTU, the test may fail. Adjust the payload size and investigate whether ICMP fragmentation-needed messages are being delivered correctly.

For a complete diagnostic workflow, see Linux MTU Troubleshooting.

Check routing and the return path

Display the route used to reach a remote address:

ip route get 203.0.113.20

Check whether the selected interface, gateway, and source address are expected.

When outbound and return traffic follow different paths, investigate routing policies, firewalls, and intermediate devices on both paths.

The guide Linux Traffic Uses Wrong Interface: Routing Troubleshooting Guide covers additional routing diagnostics.

9. Practical Linux TCP Retransmission Troubleshooting

Consider a Linux application server experiencing slow responses when communicating with a remote database server.

The application team reports intermittent delays, but the TCP connection remains established.

A systematic investigation can help narrow down the cause.

Step 1: Check host-wide retransmission counters

nstat | grep -i retrans

Record the current values and observe whether they increase during the reported issue.

Step 2: Inspect established TCP connections

ss -tin state established

Identify the database connection and inspect its RTT, RTO, congestion window, and retransmission information.

Step 3: Capture the affected TCP flow

sudo tcpdump -i any -nn -s 0 \
  'host 203.0.113.20 and tcp port 5432' \
  -w /tmp/database-connection.pcap

This example assumes the database listens on TCP port 5432.

Step 4: Inspect interface counters

ip -s link

Look for interface drops and errors, especially when the retransmission counter increases.

Step 5: Check the route

ip route get 203.0.113.20

Verify that traffic uses the expected interface and gateway.

Step 6: Analyze the packet capture

Open the capture in Wireshark and inspect:

  • Repeated TCP sequence ranges.
  • Duplicate ACKs.
  • Retransmission timing.
  • Out-of-order segments.
  • Delayed acknowledgments.
  • Traffic in both directions.

Step 7: Compare observations

Use the collected evidence to classify the likely cause.

EvidenceInvestigation direction
Interface drops increaseNIC, driver, virtual switch, or network path
Retransmissions and RTT rise during peak trafficCongestion and queueing
Repeated RTO and backoffMissing or delayed acknowledgments
Out-of-order traffic and duplicate ACKsPath reordering or possible packet loss
Large transfers stall while smaller ones workMTU and PMTUD
Outbound packets visible but return traffic absentReturn path, firewall, or remote endpoint

This workflow helps narrow down the problem before making configuration changes.

10. Prevention and Monitoring Best Practices

Preventing recurring TCP retransmissions requires continuous monitoring and a clear understanding of the network environment.

Recommended practices include:

Monitor retransmission counters

Collect TcpRetransSegs and related TCP counters periodically.

Analyze changes over time instead of relying on a single snapshot.

Monitor interface errors and drops

Track RX and TX errors, dropped packets, and interface utilization.

Correlate these measurements with application latency and retransmission activity.

Monitor latency

Track RTT and response-time trends for important services.

A sudden increase in latency can provide an early warning of network congestion or path changes.

Validate MTU across network paths

Pay particular attention to:

  • VPN connections.
  • GRE and IPsec tunnels.
  • Virtual machine networks.
  • Container networking.
  • Cloud networking.

Ensure that encapsulation overhead is accounted for and Path MTU Discovery works correctly.

Avoid changing TCP settings without evidence

Do not randomly modify:

  • TCP congestion-control algorithms.
  • Retransmission timeout settings.
  • TCP buffer sizes.
  • MTU values.
  • Offloading settings.

Such changes can hide symptoms, introduce new problems, or make performance worse.

First identify the source of retransmissions, then make a targeted change and measure its effect.

Conclusion

TCP retransmissions are valuable indicators when diagnosing slow or unreliable Linux network connections.

However, a high retransmission counter alone does not prove that a particular network device is dropping packets.

A reliable investigation combines several sources of evidence:

  • nstat for host-wide TCP statistics.
  • ss -ti for individual connection information.
  • tcpdump for packet-level inspection.
  • ip -s link for interface errors and drops.
  • ip route get for routing verification.

By correlating these measurements, Linux administrators can distinguish possible packet loss, congestion, packet reordering, MTU problems, and return-path issues.

The objective is not simply to reduce the retransmission counter. It is to identify why TCP is retransmitting data and correct the underlying network problem.

Leave a Reply

Your email address will not be published. Required fields are marked *