← all topics

2 · TCP RTT estimation and timeout ★

Slides 3-48 → 3-50, 3-51 → 3-52 · HW4 P32, P33 · Sample midterm 1.4

Why the timeout is hard to pick (3-48)

EstimatedRTT: an EWMA (3-49)

EstimatedRTT = (1 − α)·EstimatedRTT + α·SampleRTT        typical α = 0.125 = 1/8

DevRTT and TimeoutInterval (3-50)

DevRTT          = (1 − β)·DevRTT + β·|SampleRTT − EstimatedRTT|    typical β = 0.25
TimeoutInterval = EstimatedRTT + 4·DevRTT
                  (estimated RTT)  ("safety margin")

Karn's rule: ignore retransmissions (3-48, HW4 P33, sample 1.4)

Q (HW4 P33): In Section 3.5.3 we discussed TCP's estimation of RTT.

  1. Why do you think TCP avoids measuring the SampleRTT for retransmitted segments?

Q (sample midterm 1.4):

  1. Does TCP use the retransmitted packet to measure the round-trip time? Why?

Timer events in the sender (3-51, 3-52)

How to solve: RTT and timeout updates

  1. Write down α (0.125), β (0.25), and the starting EstimatedRTT and DevRTT.
  2. EstimatedRTT ← 0.875·EstimatedRTT + 0.125·SampleRTT.
  3. DevRTT ← 0.75·DevRTT + 0.25·|SampleRTT − EstimatedRTT| (new EstimatedRTT).
  4. TimeoutInterval = EstimatedRTT + 4·DevRTT.
  5. Carry the new EstimatedRTT and DevRTT to the next sample. Skip any sample from a retransmitted segment.

Worked example: EstimatedRTT = 100 ms, DevRTT = 5 ms. Samples arrive: 120, 80, 110 ms.

Sample 1: SampleRTT = 120
  Est = 0.875·100   + 0.125·120 = 87.5      + 15    = 102.5
  Dev = 0.75·5      + 0.25·|120 − 102.5|
      = 3.75        + 0.25·17.5  = 3.75      + 4.375 = 8.125
  TO  = 102.5 + 4·8.125 = 102.5 + 32.5               = 135 ms

Sample 2: SampleRTT = 80
  Est = 0.875·102.5 + 0.125·80  = 89.6875   + 10    = 99.6875
  Dev = 0.75·8.125  + 0.25·|80 − 99.6875|
      = 6.09375     + 0.25·19.6875 = 6.09375 + 4.921875 = 11.015625
  TO  = 99.6875 + 4·11.015625 = 99.6875 + 44.0625    = 143.75 ms

Sample 3: SampleRTT = 110
  Est = 0.875·99.6875 + 0.125·110 = 87.2265625 + 13.75 = 100.9765625
  Dev = 0.75·11.015625 + 0.25·|110 − 100.9765625|
      = 8.26171875  + 0.25·9.0234375 = 8.26171875 + 2.255859375 = 10.517578125
  TO  = 100.9765625 + 4·10.517578125 = 100.9765625 + 42.0703125 ≈ 143.05 ms
SampleSampleRTTEstimatedRTTDevRTTTimeoutInterval
start–1005120
1120102.58.125135
28099.6911.02143.75
3110100.9810.52143.05

The estimate barely moves (100 → 101) while the swings push DevRTT up, so the timeout grows from 120 to about 143 ms.

How to solve: expand the EWMA (HW4 P32)

  1. Write the recursion with α = x. SampleRTT1 is the most recent, SampleRTTn the oldest.
  2. Substitute the previous estimate into itself repeatedly.
  3. The oldest sample acts as the starting estimate, so it gets weight (1 − x)n−1 with no extra x.

Q (HW4 P32): Consider TCP's procedure for estimating RTT, with α = 0.1. Let SampleRTT1 be the most recent sample RTT, SampleRTT2 the next most recent, and so on.

  1. (a) For a given TCP connection, four ACKs have returned with sample RTTs SampleRTT4, SampleRTT3, SampleRTT2 and SampleRTT1. Express EstimatedRTT in terms of the four sample RTTs.
  2. (b) Generalize your formula for n sample RTTs.
(a) EstimatedRTT(4) = x·S1 + (1−x)[ x·S2 + (1−x)[ x·S3 + (1−x)·S4 ] ]
                    = x·S1 + (1−x)x·S2 + (1−x)²x·S3 + (1−x)³·S4

    with x = 0.1:
                    = 0.1·S1 + 0.09·S2 + 0.081·S3 + 0.729·S4
    check: 0.1 + 0.09 + 0.081 + 0.729 = 1 ✓
$$\text{(b)}\quad \text{EstimatedRTT}(n) = x\sum_{j=1}^{n-1}(1-x)^{j-1}\,\text{SampleRTT}_j \;+\; (1-x)^{n-1}\,\text{SampleRTT}_n$$

Matches the official solution. As n grows, (1 − x)n−1 → 0, so the oldest sample fades out. That is the "exponentially decreasing influence" on 3-49.

Traps
• α goes on the new sample, (1 − α) on the old estimate. Swapping them makes the estimate jump to each sample.
• Absolute value in DevRTT. Deviation is never negative.
• The timeout uses 4·DevRTT, not 4·EstimatedRTT and not 2·DevRTT.
• Carry the updated values into the next sample. Don't restart from the original numbers.
• State which EstimatedRTT you used in DevRTT (new, per the slide order).
• P32: the oldest sample has weight (1 − x)n−1, with no factor of x.
• Skip samples from retransmitted segments (Karn). After a timeout the interval doubles; it isn't recomputed from the formula.

Quick check

1. What are α and β typically, and what is the timeout formula? α = 0.125, β = 0.25. TimeoutInterval = EstimatedRTT + 4·DevRTT.
2. EstimatedRTT = 200 ms, DevRTT = 10 ms, SampleRTT = 240 ms. New EstimatedRTT, DevRTT, timeout?
Est = 0.875·200 + 0.125·240 = 175 + 30       = 205 ms
Dev = 0.75·10 + 0.25·|240 − 205| = 7.5 + 8.75 = 16.25 ms
TO  = 205 + 4·16.25 = 205 + 65                = 270 ms
3. EstimatedRTT = 80 ms, DevRTT = 8 ms, SampleRTT = 60 ms. New values and timeout?
Est = 0.875·80 + 0.125·60 = 70 + 7.5          = 77.5 ms
Dev = 0.75·8 + 0.25·|60 − 77.5| = 6 + 4.375   = 10.375 ms
TO  = 77.5 + 4·10.375 = 77.5 + 41.5           = 119 ms
4. EstimatedRTT = 100 ms, DevRTT = 10 ms. Samples 140 then 100 ms. Timeout after each?
S=140: Est = 87.5 + 17.5 = 105
       Dev = 7.5 + 0.25·35 = 7.5 + 8.75 = 16.25
       TO  = 105 + 65 = 170 ms
S=100: Est = 0.875·105 + 12.5 = 91.875 + 12.5 = 104.375
       Dev = 0.75·16.25 + 0.25·|100 − 104.375| = 12.1875 + 1.09375 = 13.28125
       TO  = 104.375 + 53.125 = 157.5 ms
5. EstimatedRTT = 40 ms, DevRTT = 4 ms. Samples 60 then 30 ms. Timeout after each?
S=60: Est = 35 + 7.5 = 42.5
      Dev = 3 + 0.25·17.5 = 3 + 4.375 = 7.375
      TO  = 42.5 + 29.5 = 72 ms
S=30: Est = 0.875·42.5 + 3.75 = 37.1875 + 3.75 = 40.9375
      Dev = 0.75·7.375 + 0.25·|30 − 40.9375| = 5.53125 + 2.734375 = 8.265625
      TO  = 40.9375 + 33.0625 = 74 ms
6. P32 variant: α = 0.2, four samples with S1 (newest) = 100, S2 = 120, S3 = 80, S4 (oldest) = 90 ms. EstimatedRTT? Weights: 0.2, 0.2·0.8 = 0.16, 0.2·0.8² = 0.128, 0.8³ = 0.512 (sum = 1).
0.2·100 + 0.16·120 + 0.128·80 + 0.512·90
= 20 + 19.2 + 10.24 + 46.08 = 95.52 ms
7. EstimatedRTT went from 100 ms to 105 ms after a SampleRTT of 140 ms. What α was used? 105 = 100 + α(140 − 100) → 5 = 40α → α = 0.125.
8. With α = 0.125, how much weight does a sample from 5 updates ago carry? α(1 − α)5 = 0.125 · 0.8755 ≈ 0.125 · 0.513 ≈ 0.064, about 6%.
9. TimeoutInterval is 143.75 ms. The segment times out twice in a row. What are the next two intervals? Doubling on each timeout: 287.5 ms, then 575 ms. It returns to EstimatedRTT + 4·DevRTT once new data is ACKed.
10. Does TCP use a retransmitted segment to measure RTT? Why? (sample 1.4, P33) No (Karn's rule). The ACK is ambiguous: it could be for the original or the retransmission. If the original's ACK arrives just after the retransmission, timing from the retransmission gives a SampleRTT that is far too small.
11. Why add 4·DevRTT instead of using EstimatedRTT alone? EstimatedRTT is an average, so many real RTTs exceed it and would cause premature timeouts. The margin grows when RTTs vary a lot and shrinks when they're steady.
12. Name the three sender events and what each does to the timer. Data from app: start the timer if it isn't running. Timeout: retransmit the oldest unACKed segment and restart the timer. ACK for new data: advance SendBase and restart the timer if unACKed segments remain (else stop it).

← prev · all topics · next →