# Computer Network | Algorithm for Dynamic Time out timer Calculation

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.
- Computer Network | EIGRP cost calculation
- Computer Network | Dynamic NAT (on ASA)
- Computer Network | Dynamic Trunking Protocol (DTP)
- Computer Network | Dynamic Host Configuration Protocol (DHCP)
- Computer Network | RC4 Encryption Algorithm
- Computer Network | HMAC Algorithm
- Computer Network | RC5 Encryption Algorithm
- Computer Network | Leaky bucket algorithm
- Computer Network | Time based access-list
- Computer Network | Frequency division and Time division multiplexing
- Computer Network | Simple network management protocol (SNMP)
- Computer Network | Integrated services digital network (ISDN)
- Computer Network | Types of Network address translation (NAT)
- Computer Network | Synchronous Optical Network (SONET)
- Computer Network | Packet flow in different network

### 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 usingPRTTwhere 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.5

TOT = 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 –**

**Disadvantages –**

### 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}PDwhere_{n+1}= α PD_{n}+ (1 - α)AD_{n}ADAD = Actual deviation PD = predicted deviation On sending out each packet,_{n}= |PRTT_{n}- ARTT_{n}|TOT = (4 * PD) + PRTT.

**Example –**

Iteration 1Given α = 0.5, PRTT_{1}= 10ms, PD_{1}= 5ms and ARTT_{1}= 20ms TOT = (4 * 5) + 10 = 30ms AD_{1}= |10 - 20| = 10msIteration 2PRTT_{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| = 15msIteration 3PRTT_{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

## Recommended Posts:

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.