Prerequisite – Computer Network | TCP Timers
Calculating Time out timer (TOT) at transport layer is tricky as propagation delay is not constant i.e. path may change continuously and traffic is dynamic. So, static TOT cannot be used at TCP. And unnecessarily retransmitting the same data packet multiple times may cause congestion.
Solution for this is we need dynamic TOT which can adjust to changes in round trip time (RTT).
Algorithm for Dynamic TOT calculation:
- Basic algorithm
- Jacobson's algorithm
- Karn's modification
- better than static TOT.
- TOT is flexible to dynamic round trip time.
- It takes into consideration all packets to derive new PRTT.
- TOT = 2 * PRTT is used to allow a grace time for returning acknowledgement.
- It is wasteful.
1. Basic algorithm -
We assume initial round trip time i.e PRTT.
On sending out each packet TOT = 2 * PRTT.
The next round trip time is calculated using
PRTTn+1 = α PRTTn + (1 - α)ARTTn
where PRTT = predicted round trip time
ARTT = actual round trip time
α = smoothing factor such that 0<= α <=1
Example - Let PRTT1 = 10ms and α = 0.5
TOT = 2 * PRTT1 = 20ms Let ARTT1 = 15ms Then, PRTT2 = (0.5 * 10) + (0.5 * 15) = 12.5ms TOT = 2 * 12.5 = 25ms Let ARTT2 = 20ms PRTT3 = (0.5 * 12.5) + (0.5 * 20) = 16.25ms TOT = 2 * 16.25 = 32.5ms And so on TOT is calculated.Advantages -
2. Jacobson's algorithm -
Calculates TOT value more intuitively than basic algorithm.We assume initial round trip time i.e. PRTT. PRTTn+1 = α PRTTn + (1 - α)ARTTn PDn+1 = α PDn + (1 - α)ADn where ADn = |PRTTn - ARTTn| AD = Actual deviation PD = predicted deviation On sending out each packet, TOT = (4 * PD) + PRTT.Example -
Iteration 1
Given α = 0.5, PRTT1 = 10ms, PD1 = 5ms and ARTT1 = 20ms
TOT = (4 * 5) + 10 = 30ms
AD1 = |10 - 20| = 10ms
Iteration 2
PRTT2 = α PRTT1 + (1 - α)ARTT1
= (0.5 * 10) + (0.5 * 20) = 15ms
PD2 = α PD1 + (1 - α)AD1
= (0.5 * 5) + (0.5 * 10) = 7.5ms
TOT = (4 * 7.5) + 15 = 45ms
Given ARTT2 = 30ms
AD2 = |15 - 30| = 15ms
Iteration 3
PRTT3 = α PRTT2 + (1 - α)ARTT2
= (0.5 * 15) + (0.5 * 30) = 22.5ms
PD3 = α PD2 + (1 - α)AD2
= (0.5 * 7.5) + (0.5 * 15) = 11.25ms
TOT = (4 * 11.25) + 22.5 = 67.5ms
Given ARTT3 = 10ms
AD2 = |22.5 - 10| = 12.5ms
And so on TOT is calculated.
Problem with Basic and Jacobson's Algorithm
In both, PRTTn+1 = α PRTTn + (1 - α)ARTTn
i.e both depend on previous segment ARTT. But if initial time out timer times out then what next TOT will be chosen since the acknowledgement is delayed i.e its coming after time out so ARTT is not available.