Timeout-Based Retransmission and Exponential Backoff
What TCP does when its retransmission timer fires: resending the oldest unacknowledged segment, doubling the timeout each time, cutting the congestion window, and finally giving up after tcp_retries2 or TCP_USER_TIMEOUT, measured in the lab against a blocked path.
kvi5hnuCode Sprout team member11 min readOn this page
Article 64 showed how TCP picks its retransmission timeout (RTO). This article shows what happens when that timer actually fires: the segment is resent, the timer is doubled, and, if nothing ever comes back, the connection eventually gives up. Timer-based retransmission is TCP's last line of defense. It's slow, but it always works, even when every other loss-recovery mechanism has nothing to go on.
A segment that never gets acknowledged
In the lab, a client with a 40 ms RTT to its server sent a short request, got a reply, and then sent another one. Right before the second request, a firewall rule on the router started dropping everything from the client to the server. To keep the run short, the client's tcp_retries2 was lowered from 15 to 6:
net.ipv4.tcp_retries2 = 6
net.ipv4.tcp_retries1 = 3
The client's recv() failed after about half a minute:
recv() failed after 31.9 s: [Errno 110] Connection timed out
The capture at the client shows each transmission of the request:
# sent at gap kind
0 0.00 s original
1 0.25 s 0.25 s retransmission
2 0.49 s 0.25 s retransmission
3 0.99 s 0.50 s retransmission
4 2.03 s 1.04 s retransmission
5 4.01 s 1.98 s retransmission
6 7.98 s 3.97 s retransmission
7 15.98 s 8.00 s retransmission
The chart below draws the gaps from that table as bars.

Reading the gaps:
- The first resend came after 0.25 s. That's not the RTO firing but a tail loss probe (TLP, article 66): when the last segment sent isn't acknowledged within about two RTTs (plus extra time when only one segment is in flight), Linux resends it to provoke an ACK. Here the probe and the RTO had about the same deadline.
- The RTO fired at 0.49 s (about 245 ms after the probe, the RTO measured in article 64), and from then on each wait was twice the previous one: 0.5, 1, 2, 4 and 8 seconds. This is exponential backoff.
- After six RTO retransmissions, the connection gave up. It waited out one more doubled timeout and then reported
ETIMEDOUTto the application.
Why back off exponentially?
If a segment isn't acknowledged, either it was lost or the path is badly congested or broken. Retransmitting at a fixed rate into a congested network adds to the congestion, and if many connections do it at once, the network can collapse under retransmissions. Doubling the wait each time means that a connection facing a persistent problem quickly sends almost nothing, while one facing a brief glitch recovers within a few RTOs. RFC 6298 requires the doubling and allows a ceiling of at least 60 seconds. Linux caps the RTO at 120 seconds by default, and since Linux 6.15 the cap can be lowered (tcp_rto_max_ms or TCP_RTO_MAX_MS, article 64).
Backoff has a cost when the path recovers, too. In the lab, the path was blocked for about 2.5 seconds and then restored:
path restored 2.57 s after the data was sent
reply after 4.14 s: b'ack:are you there?'
The chart below shows the RTO growing during the outage, and the gap between the path coming back and the next retransmission.

The path was working again at about 2.6 s, but the connection didn't know. Its timer, now nearly 2 seconds, still had to expire before the next retransmission, which then got through at once. The longer an outage lasts, the longer this idle wait after it: after a 1-minute outage, a connection may sit silent for up to another minute. When an ACK finally arrives, Linux takes a fresh RTT sample, and the RTO drops straight back to its normal value. The ss view during the outage:
0.1 s rto:252 ms backoff:0
0.8 s rto:504 ms backoff:1
1.6 s rto:1008 ms backoff:2
2.3 s rto:2016 ms backoff:3
3.1 s rto:2016 ms backoff:3
3.8 s rto:2016 ms backoff:3
backoff:3 means the timer has been doubled three times. ss shows the backed-off RTO directly.
What a timeout does to sending
A timeout is TCP's strongest signal that something is wrong, and it reacts strongly:
- It resends only the oldest unacknowledged segment first, not the whole window.
- Congestion control treats a timeout as severe congestion. The congestion window drops to 1 segment, and the slow start threshold (ssthresh, the point where fast initial growth stops, article 72) to half of what was in flight with Reno, the classic algorithm, or 0.7 times it with CUBIC, Linux's default congestion control algorithm (articles 72 and 75). Even after recovery, the connection starts sending slowly again.
- Every segment that was in flight is marked as lost and will be resent as the window grows again, unless SACK information shows it arrived.
- Linux checks after the fact whether a timeout was spurious (article 67). If the original segment's ACK arrives soon after the retransmission, it can undo the congestion window cut.
Because timeouts are so expensive, modern TCP tries hard to repair losses before the timer fires: fast retransmit, SACK recovery and RACK-TLP (article 66) handle almost all losses on a busy connection. Timeouts remain for the cases those can't handle: a lost retransmission, a lost last segment that TLP doesn't fix, or a path that's simply down.
When TCP gives up
Two sysctls bound how long Linux keeps retransmitting on an established connection:
| Setting | Default | Effect |
|---|---|---|
net.ipv4.tcp_retries1 | 3 | After this many retransmissions, ask the IP layer to recheck its route to the peer (RFC 1122's threshold R1) |
net.ipv4.tcp_retries2 | 15 | Give up after the time that this many doubling retransmissions would take (threshold R2) |
Linux doesn't actually count retransmissions for tcp_retries2. It converts the number into a time budget, computed as if the RTO started at 200 ms and doubled each time, capped at 120 seconds. For the default of 15, there are 16 terms. The first ten, 0.2 + 0.4 + ... + 102.4, add up to 0.2 × 1023 = 204.6 seconds; the next doubling, 204.8, is over the cap, so the remaining six terms count 120 seconds each, 720 seconds. The total is 204.6 + 720 = 924.6 seconds, a little over 15 minutes. With 6, as in the lab, the budget is 0.2 + 0.4 + 0.8 + 1.6 + 3.2 + 6.4 + 12.8 = 0.2 × 127 = 25.4 seconds. The connection checks the budget whenever its timer fires, which is why the lab connection failed at its next timer expiry after the budget ran out, at about 32 seconds.
RFC 1122 requires R2 to correspond to at least 100 seconds. For SYNs, the separate tcp_syn_retries applies (article 59), and for orphaned connections that the application has already closed, tcp_orphan_retries.
TCP_USER_TIMEOUT
Fifteen minutes is far too long for many applications. A program can set its own limit per socket with TCP_USER_TIMEOUT, in milliseconds: the connection fails if data stays unacknowledged for that long. In the lab, with 3,000 ms:
TCP_USER_TIMEOUT = 3000 ms
recv() failed after 3.5 s: [Errno 110] Connection timed out
# sent at gap kind
0 0.00 s original
1 0.25 s 0.25 s retransmission
2 0.50 s 0.25 s retransmission
3 0.99 s 0.49 s retransmission
4 2.00 s 1.02 s retransmission
Only four retransmissions went out before the connection failed at about 3.5 seconds, the first timer expiry after the 3-second limit. Databases, message brokers and RPC (remote procedure call) frameworks set TCP_USER_TIMEOUT so a dead peer is detected in seconds, not minutes. It also applies to keepalive probes (article 71).
Thin streams
An interactive application that sends small messages occasionally (a game, a chat, a trading client) rarely has enough data in flight for fast retransmit to work, so its losses are usually repaired by timeouts. Linux has an option for such "thin streams": net.ipv4.tcp_thin_linear_timeouts, which keeps the RTO from doubling for the first few retransmissions when a connection has very little data in flight. It's off by default. Modern Linux relies more on tail loss probes and RACK to avoid timeouts in the first place.
Common questions
Why did the first two retransmissions in the lab come only 0.25 s apart?
The first was a tail loss probe, not an RTO. TLP fires on its own timer, roughly two RTTs plus a margin, to provoke an ACK for the last segment sent. The real RTO fired next, and the doubling started from there.
Does the backoff reset after a successful retransmission?
Yes, once an ACK for new data brings a valid RTT sample. Linux then recomputes the RTO from SRTT and RTTVAR and clears the backoff count. With timestamps, the ACK of a retransmission gives such a sample at once. Without them, Karn's rule (article 64) keeps the backed-off RTO until a segment that was sent only once is acknowledged.
Does TCP run a separate timer for every segment?
No. RFC 6298 uses one retransmission timer per connection. It's started when data is sent and no timer is running, restarted with the current RTO whenever an ACK acknowledges new data, and stopped when everything is acknowledged. When it fires, the oldest unacknowledged segment is resent first. Linux also runs its tail loss probe and RACK reordering timeouts (article 66) on this same per-connection timer.
How long until a Linux connection to a crashed server fails?
It depends on whether data is unacknowledged. If the application has sent data, about 15 minutes with defaults (sooner with TCP_USER_TIMEOUT). If the connection is idle, never, unless keepalives are on. A rebooted server, by contrast, answers with a reset as soon as data arrives (article 62).
What's the difference between tcp_retries2 and TCP_USER_TIMEOUT?
tcp_retries2 is system-wide and expressed as a number of doublings that Linux turns into a time budget. TCP_USER_TIMEOUT is per socket and expressed directly in milliseconds. When set, the user timeout takes precedence.
Is a timeout always caused by loss?
No. A sudden delay increase longer than the RTO, for example when a wireless link pauses, also triggers a timeout, even though nothing was lost. That's a spurious timeout, covered in article 67.
Summary
- When the retransmission timer fires, TCP resends the oldest unacknowledged segment and doubles the RTO, up to 120 seconds on Linux.
- In the lab, after a tail loss probe at 0.25 s, the waits were 0.25, 0.5, 1, 2, 4 and 8 seconds.
- Backoff keeps broken or congested paths from being flooded, but after an outage the connection may sit idle until its long timer expires.
- A timeout cuts the congestion window to one segment, which is why TCP tries hard to repair losses with fast retransmit, SACK and RACK-TLP first.
- Linux gives up after the time budget implied by
tcp_retries2(default 15, about 924.6 s).TCP_USER_TIMEOUTsets a per-socket limit: 3,000 ms failed the lab connection at about 3.5 s.
Practice questions
1. A connection's RTO is 300 ms when a segment is lost and stays lost. At what times after the original transmission are the first four RTO retransmissions sent, ignoring tail loss probes?
Answer
At 0.3 s, then 0.3 + 0.6 = 0.9 s, then 0.9 + 1.2 = 2.1 s, then 2.1 + 2.4 = 4.5 s. Each wait doubles the previous RTO.
2. With tcp_retries2 = 8, what time budget does Linux allow before giving up?
Answer
0.2 × (1 + 2 + 4 + ... + 256) = 0.2 × 511 = 102.2 seconds, since none of the terms reaches the 120 s cap.
3. A path goes down for 30 seconds while a connection has unacknowledged data. Roughly how long after the path recovers does the connection resume?
Answer
Up to about as long as the outage. After 30 seconds of backoff, the RTO has grown to about 16 to 32 seconds, so the next retransmission may come up to that long after the path recovers. The exact delay depends on where in the current timeout period the path came back.
4. Why does a timeout cut the congestion window to one segment, while fast retransmit (article 66) only reduces it (to half with Reno, to 0.7 with CUBIC)?
Answer
Fast retransmit is triggered by duplicate ACKs or SACKs, which prove that later segments are still getting through, so the network is congested but working. A timeout means nothing has been acknowledged for a whole RTO, so TCP has no evidence that anything is getting through and restarts cautiously from one segment.
5. A service must detect a dead database connection within 10 seconds, even when a query was sent and no reply came. What socket option should it set, and why isn't keepalive enough on its own?
Answer
TCP_USER_TIMEOUT of 10,000 ms. Keepalive probes are sent only when the connection is idle, with no unacknowledged data. Once a query is outstanding, the connection is retransmitting, and only the retransmission limits (tcp_retries2 or TCP_USER_TIMEOUT) decide when it fails.
Previous: Measuring RTT and Setting the Retransmission Timeout

More in TCP/IP Course
Quiz: TCP/IP Delicate Details
Twenty-five questions on the details that catch out experienced engineers: sequence numbers for SYN and FIN, TIME_WAIT versus tcp_fin_timeout, Karn's algorithm, socket buffer doubling, even and odd ephemeral ports, IPv6 checksums and fragmentation, negative DNS caching, and capture filter traps.
Quiz: TCP/IP Interview Questions
Thirty-three networking questions of the kind asked in developer, SRE and network engineering interviews: what happens when you load a URL, TCP versus UDP, handshakes, closing and TIME_WAIT, subnetting, NAT, DNS, MTU problems, congestion, TLS and QUIC, and debugging slow or failing connections.
Quiz: TCP/IP Course Final Exam (All Parts)
The final exam for the TCP/IP course: thirty questions across all fourteen parts, from packets and addressing through Ethernet, ARP, IP, DHCP, NAT, ICMP, UDP, DNS, TCP connections, reliability, congestion control, security, QUIC and troubleshooting.
Quiz: Modern Transports and Troubleshooting (TCP/IP Part 14)
Review modern transports and troubleshooting: QUIC packets, handshakes, 0-RTT, streams and connection migration, HTTP/3, Multipath TCP, SCTP multihoming, and a layered method for diagnosing real network faults.
Discussion
Sign in to ask a question or share what you learned.