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
### 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

**PRTT**where PRTT = predicted round trip time ARTT = actual round trip time α = smoothing factor such that 0<= α <=1_{n+1}= α PRTT_{n}+ (1 - α)ARTT_{n}**Example –**Let PRTT_{1}= 10ms and α = 0.5TOT = 2 * PRTT

_{1}= 20ms Let ARTT_{1}= 15ms Then, PRTT_{2}= (0.5 * 10) + (0.5 * 15) = 12.5ms TOT = 2 * 12.5 = 25ms Let ARTT_{2}= 20ms PRTT_{3}= (0.5 * 12.5) + (0.5 * 20) = 16.25ms TOT = 2 * 16.25 = 32.5ms And so on TOT is calculated.**Advantages –**- better than static TOT.
- TOT is flexible to dynamic round trip time.
- It takes into consideration all packets to derive new PRTT.

**Disadvantages –**- TOT = 2 * PRTT is used to allow a grace time for returning acknowledgement.
- It is wasteful.

### 2. Jacobson’s algorithm –

Calculates TOT value more intuitively than basic algorithm.

We assume initial round trip time i.e. PRTT.

**PRTT**_{n+1}= α PRTT_{n}+ (1 - α)ARTT_{n}**PD**where_{n+1}= α PD_{n}+ (1 - α)AD_{n}**AD**AD = Actual deviation PD = predicted deviation On sending out each packet,_{n}= |PRTT_{n}- ARTT_{n}|**TOT = (4 * PD) + PRTT.****Example –****Iteration 1**Given α = 0.5, PRTT_{1}= 10ms, PD_{1}= 5ms and ARTT_{1}= 20ms TOT = (4 * 5) + 10 = 30ms AD_{1}= |10 - 20| = 10ms**Iteration 2**PRTT_{2}= α PRTT_{1}+ (1 - α)ARTT_{1}= (0.5 * 10) + (0.5 * 20) = 15ms PD_{2}= α PD_{1}+ (1 - α)AD_{1}= (0.5 * 5) + (0.5 * 10) = 7.5ms TOT = (4 * 7.5) + 15 = 45ms Given ARTT_{2}= 30ms AD_{2}= |15 - 30| = 15ms**Iteration 3**PRTT_{3}= α PRTT_{2}+ (1 - α)ARTT_{2}= (0.5 * 15) + (0.5 * 30) = 22.5ms PD_{3}= α PD_{2}+ (1 - α)AD_{2}= (0.5 * 7.5) + (0.5 * 15) = 11.25ms TOT = (4 * 11.25) + 22.5 = 67.5ms Given ARTT_{3}= 10ms AD_{2}= |22.5 - 10| = 12.5ms And so on TOT is calculated.**Problem with Basic and Jacobson’s Algorithm**

In both,**PRTT**_{n+1}= α PRTT_{n}+ (1 – α)ARTT_{n}

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.### 3. Karn’s Modification –

Whenever the timer times out do not apply either of Basic or Jacobson algorithm as ARTT is not available instead double the time out timer(TOT) whenever the timer times out and a retransmission is made.

GATE | Gate IT 2007 | Question 13

Attention reader! Don’t stop learning now. Learn all

**GATE CS concepts with Free Live Classes**on our youtube channel.