Measuring RTT and Setting the Retransmission Timeout
How TCP decides how long to wait before retransmitting: RTT samples, the smoothed RTT and RTT variance of RFC 6298, Karn's algorithm and timestamps, and how Linux's estimator and its 200 ms minimum behave, measured with ss while the lab path's delay changes.
kvi5hnuCode Sprout team member12 min readOn this page
TCP retransmits a segment if no acknowledgment arrives in time. The hard question is what "in time" means. Wait too little, and TCP resends data that was only delayed, wasting capacity and confusing congestion control. Wait too long, and a lost segment stalls the connection. The right waiting time depends on the path's round-trip time (RTT), which TCP doesn't know in advance and which changes during a connection.
So TCP measures. This article shows how RTT samples become a retransmission timeout (RTO), using a lab connection whose path delay changes while it runs. Article 65 then shows what happens when the timer actually fires.
RTT samples
An RTT sample is the time from sending a segment to receiving the ACK that covers it. Linux takes a sample from almost every ACK. With the timestamps option (article 60), it can use the echoed TSval; otherwise it times the oldest unacknowledged segment.
Linux reports its current estimates in ss -i. Here is a lab connection that sends a 1,000-byte request every 20 ms to an echo server, with 20 ms of delay each way:
ESTAB 0 1000 192.0.2.10:41784 198.51.100.10:7
cubic wscale:7,7 rto:246 rtt:45.469/3.459 ato:40 mss:1448 pmtu:1500 rcvmss:1000 advmss:1448 cwnd:10
bytes_sent:15000 bytes_acked:14001 bytes_received:14000 segs_out:18 segs_in:16 data_segs_out:15
data_segs_in:14 send 2547670bps lastrcv:23 lastack:23 pacing_rate 5095248bps delivery_rate 286376bps
delivered:15 app_limited busy:629ms unacked:1 rcv_rtt:44.125 rcv_space:14480 rcv_ssthresh:68120 minrtt:40.45
snd_wnd:68224 rcv_wnd:68224
rtt:45.469/3.459 is the smoothed RTT and its variation in milliseconds, minrtt the smallest RTT seen, and rto:246 the current retransmission timeout. The path's delay is 40 ms of netem (the lab's delay emulator) plus a few milliseconds of timer slack and processing. Fields such as cwnd and pacing_rate come up in later articles.
The classic estimator and its problem
The original TCP specification smoothed the samples into an average SRTT, giving each new sample a weight of 1/10 to 1/5 (a smoothing factor of 0.8 to 0.9), and set the RTO to a fixed multiple of SRTT, 1.3 to 2 times. That works when the RTT barely changes. But a fixed multiple can't follow a path whose RTT varies a lot: if samples swing between 50 and 300 ms, an RTO of 2 × the average fires on many segments that were merely slow.
The standard method: RFC 6298
The fix, due to Jacobson and Karels and standardized in RFC 6298, tracks how much the RTT varies as well as its average. For each new sample R:
RTTVAR = (1 - β) × RTTVAR + β × |SRTT - R| β = 1/4
SRTT = (1 - α) × SRTT + α × R α = 1/8
RTO = SRTT + max(G, 4 × RTTVAR) G = clock granularity
RTTVAR is a smoothed mean deviation, a cheap stand-in for the standard deviation. Adding 4 × RTTVAR puts the timeout well above nearly all normal samples, so it fires only for real losses. The first sample sets SRTT = R and RTTVAR = R/2. For example, a first sample of 40 ms gives SRTT = 40 ms, RTTVAR = 20 ms and RTO = 40 + 4 × 20 = 120 ms, before any minimum is applied. If the next sample is 48 ms, RTTVAR = 0.75 × 20 + 0.25 × |40 − 48| = 15 + 2 = 17 ms, SRTT = 0.875 × 40 + 0.125 × 48 = 35 + 6 = 41 ms, and RTO = 41 + 4 × 17 = 109 ms.
RFC 6298 adds four rules:
- Initial RTO of 1 second before any sample exists (it was 3 seconds before 2011). This is why the first SYN retransmission comes after 1 second (article 59). If the SYN or SYN-ACK was retransmitted, the RTO for data starts at 3 seconds.
- A minimum RTO of 1 second, which the RFC itself calls conservative. Most implementations use less, as the lab shows below.
- Exponential backoff: each time the timer expires, the RTO doubles (article 65).
- Karn's algorithm: don't take samples from retransmitted segments, and keep the backed-off RTO until a new sample arrives.
Karn's algorithm and the retransmission ambiguity
When a segment has been sent twice, an ACK for it could answer either transmission:

Timing from the first send would inflate the estimate whenever the original was lost. Timing from the retransmission would shrink it whenever the original was only slow, possibly enough to cause more spurious timeouts. Karn's answer is to take no sample at all from ambiguous ACKs.
Timestamps remove the ambiguity. Each transmission carries its own TSval, and the ACK echoes the one it answers, so every ACK yields a correct sample. RFC 7323 lets senders use these samples freely.
Watching the estimators in the lab
The lab connection ran for 26 seconds while the delay toward the server changed: 20 ms, then 100 ms, then back to 20 ms, then 20 ms with ±15 ms of random jitter, then steady again. The client sampled ss every 50 ms, and a capture provided the individual RTT samples. The same samples were also fed into the RFC 6298 formulas:
6.0 s delay toward the server 20 -> 100 ms
12.0 s delay toward the server back to 20 ms
17.0 s jitter: 20 ms +/- 15 ms toward the server
23.1 s jitter off
The chart below plots the RTT samples, Linux's smoothed RTT and RTO, and the RTO the RFC 6298 formulas give for the same samples.

The values at the end of each phase:
phase samples: median Linux srtt rttvar Linux rto RFC 6298 rto
20 ms each way 43.7 ms 44.4 ms 1.6 ms 245 ms 1000 ms
100 ms toward server 123.8 ms 124.5 ms 2.6 ms 325 ms 1000 ms
back to 20 ms 43.4 ms 45.0 ms 2.9 ms 246 ms 1000 ms
20 ms +/- 15 ms jitter 44.6 ms 47.0 ms 7.7 ms 247 ms 1000 ms
jitter off 43.4 ms 44.2 ms 2.4 ms 245 ms 1000 ms
Four things stand out:
- SRTT lags behind changes. With a gain of 1/8 and only a few samples per second (each request waited for its echo), Linux's smoothed RTT took a few seconds to reach 124 ms after the delay rose. RTTVAR jumped during the change, which is exactly what protects against spurious timeouts while SRTT catches up.
- RFC 6298's RTO, without its 1 s minimum, swings widely. It jumped to about 260 ms when the delay rose. It jumped again when the delay dropped, because a sudden decrease looks just like a sudden increase to the mean-deviation formula. Its full version, with the minimum, sits at 1,000 ms throughout.
- Linux's RTO is SRTT plus about 200 ms. Linux keeps its own variant of RTTVAR, never lets the variance term fall below 200 ms (
tcp_rto_min), and reacts less strongly when the RTT falls. So its RTO didn't spike when the delay dropped at 12 s. - Jitter barely moved Linux's RTO, because ±15 ms of variation is small compared with the 200 ms floor.
Linux's estimator
Linux follows RFC 6298's structure with some changes:
- Minimum RTO of 200 ms, not 1 second. It can be changed system-wide with
net.ipv4.tcp_rto_min_us(Linux 6.11 and later), or per route with therto_minroute attribute. - A floor on the variance term. The deviation used for the RTO is the largest deviation seen over the last round trip, and never less than a quarter of
tcp_rto_min, so RTO ≥ SRTT + 200 ms by default. - Smaller weight for decreasing samples. When a sample is well below SRTT, it updates the deviation much less, so a path getting faster doesn't make the timer jumpy.
- Maximum RTO of 120 seconds (
TCP_RTO_MAX). Linux 6.15 and later (newer than the lab's 6.12) let this be lowered with thenet.ipv4.tcp_rto_max_mssysctl or theTCP_RTO_MAX_MSsocket option.
The lab changed the minimum both ways:
net.ipv4.tcp_rto_min_us = 200000
rto:244 rtt:43.384/1.935 minrtt:41.379
198.51.100.0/24 via 192.0.2.1 dev eth0 rto_min lock 20ms
rto:63 rtt:42.396/0.911 minrtt:40.903
net.ipv4.tcp_rto_min_us = 50000
rto:93 rtt:42.735/1.706 minrtt:40.475
In the route line, lock marks the metric as fixed for that route; Linux applies a route's rto_min only when it's locked this way, and ip route adds the lock for rto_min automatically, so you don't need to type it. A per-route rto_min 20ms dropped the RTO to 63 ms, and tcp_rto_min_us = 50000 to 93 ms. Data centers sometimes lower the minimum, where RTTs are tens of microseconds and a 200 ms stall after a loss is enormous. On the Internet, the default is safer: a too-small minimum causes spurious retransmissions when delays spike.
Robustness to loss and reordering
RTT samples aren't perfectly clean. When ACKs are delayed (article 68), samples include the receiver's waiting time. When ACKs are lost, a later cumulative ACK covers several segments, and timing from the oldest one inflates the sample. Reordering can make ACKs arrive in bunches. The smoothing and the generous variance term absorb most of this. Timestamps help further by letting every ACK give a sample, so a few odd ones carry less weight.
Common questions
Why does ss show an RTO of about 200 ms on a LAN with 0.1 ms RTT?
Because Linux's minimum RTO is 200 ms. The RTO is SRTT plus a variance term that's never less than 200 ms.
Does a smaller RTO make TCP faster?
Only when the timer actually fires, which is rare on a healthy connection: most losses are repaired by fast retransmit (article 66) long before any timeout. Too small an RTO causes spurious retransmissions. Lower it only on networks you control.
What's minrtt for?
It's the smallest RTT seen recently (over a window of tcp_min_rtt_wlen, 300 s by default). It approximates the path's propagation delay without queueing, and Linux uses it for loss detection (RACK, article 66) and congestion control (BBR, article 76).
Why was RTTVAR multiplied by 4?
To make the timeout land beyond almost every normal sample. If RTT samples were normally distributed, 4 mean deviations would cover more than 99% of them. It's an engineering choice that worked well in practice, not a deep law.
Does TCP measure RTT if the connection is idle?
No. Samples come only from ACKs of data. After a long idle period, SRTT may be stale. Keepalive probes (article 71) don't update it in the usual way.
Summary
- TCP sets its retransmission timeout from measured RTT samples. Linux takes a sample from nearly every ACK.
- RFC 6298: SRTT is a smoothed average (gain 1/8), RTTVAR a smoothed mean deviation (gain 1/4), and RTO = SRTT + 4 × RTTVAR, with an initial RTO of 1 s, a 1 s minimum and doubling on each timeout.
- Karn's algorithm skips samples from retransmitted segments, because the ACK is ambiguous. Timestamps remove the ambiguity.
- Linux uses a 200 ms minimum, so its RTO is about SRTT + 200 ms. The lab measured 245 ms at a 44 ms RTT and 325 ms at 124 ms, and Linux's estimator didn't overreact when the RTT fell.
- The minimum can be changed per route (
rto_min) or system-wide (tcp_rto_min_us). In the lab, these gave RTOs of 63 ms and 93 ms.
Practice questions
1. SRTT is 100 ms and RTTVAR is 10 ms. A sample of 140 ms arrives. Compute the new RTTVAR, SRTT and RTO using RFC 6298 (ignore the minimum).
Answer
RTTVAR = 0.75 × 10 + 0.25 × |100 − 140| = 7.5 + 10 = 17.5 ms. SRTT = 0.875 × 100 + 0.125 × 140 = 105 ms. RTO = 105 + 4 × 17.5 = 175 ms. RTTVAR is updated first, using the old SRTT.
2. A connection has an RTT of 2 ms. What RTO does Linux use by default, and what would RFC 6298 use?
Answer
Linux: about 202 ms, SRTT plus the 200 ms minimum variance term. RFC 6298: 1 second, its minimum.
3. A segment is retransmitted after a timeout, and then an ACK arrives 30 ms after the retransmission. Without timestamps, should the sender use 30 ms as an RTT sample? Why not?
Answer
No. The ACK might answer the original transmission, which was delayed, not the retransmission. In that case, 30 ms underestimates the RTT. Karn's algorithm says to take no sample until a segment that was sent only once is acknowledged.
4. In the lab, why did the RFC 6298 RTO (without its minimum) spike when the delay dropped from 100 ms to 20 ms?
Answer
RTTVAR uses the absolute difference |SRTT − R|. When samples suddenly fell to 44 ms while SRTT was still near 124 ms, the differences were about 80 ms, the same size as during the increase, so RTTVAR and the RTO jumped. Linux gives less weight to samples well below SRTT, so its RTO didn't spike.
5. A data center operator lowers rto_min to 5 ms on routes inside the data center. What do they gain, and what's the risk?
Answer
They gain fast recovery when a loss needs a timeout, for example when a whole window is lost or the last segment of a response is lost: the stall drops from about 200 ms to a few milliseconds. The risk is spurious timeouts when delay temporarily spikes (a congested switch queue or a paused host), causing unnecessary retransmissions and congestion window cuts.
Previous: TCP Servers: Listening Sockets, Binding, the Accept Queue, SYN Cookies and SYN Floods

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.