Course contentsShow
← Computer Science
Lesson 1481 of 2,87234. Internet Protocol SuiteFree lesson

TCP Round-Trip Time Estimation

How TCP measures and estimates RTT to set appropriate retransmission timeout values dynamically.

TCP Round-Trip Time Estimation

You'll learn: How TCP dynamically measures and estimates round-trip time to set smart retransmission timeouts.

Why RTT Estimation Matters

Remember from lesson 1476 that TCP retransmits lost packets to ensure reliability. But when should it give up waiting and retransmit? Wait too long, and throughput suffers. Retransmit too quickly, and you create unnecessary duplicate packets that worsen congestion.

The answer depends on the Round-Trip Time (RTT)—how long it takes for a segment to reach the destination and for its acknowledgment to return.

How TCP Estimates RTT

TCP continuously measures RTT by timing how long it takes between sending a segment and receiving its ACK. But network conditions vary, so TCP can't just use the most recent measurement.

Instead, TCP maintains a smoothed RTT estimate using an exponentially weighted moving average (EWMA):

EstimatedRTT = (1 - α) × EstimatedRTT + α × SampleRTT

Where α is typically 0.125. This gives more weight to history while still responding to recent changes.

Accounting for Variation

Since RTT fluctuates, TCP also tracks the deviation from the estimate:

DevRTT = (1 - β) × DevRTT + β × |SampleRTT - EstimatedRTT|

Where β is typically 0.25.

Setting the Retransmission Timeout

Finally, TCP sets the Retransmission Timeout (RTO) as:

TimeoutInterval = EstimatedRTT + 4 × DevRTT

This margin accounts for typical variation. If an ACK doesn't arrive within this window, TCP assumes the segment was lost and retransmits.

Think of it like adjusting your alarm based on how long your commute usually takes, plus a safety buffer for unpredictable traffic.

Key Takeaway: TCP dynamically estimates RTT using weighted averages of samples and variation, then sets retransmission timeouts with appropriate safety margins to balance reliability and performance.