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.
- Factorial calculation using fork() in C for Linux
- EIGRP Cost Calculation
- How to handle multiple numeric datasets for calculation using JavaScript ?
- Calculation of TCP Checksum
- Calculation of Serial and Non-Serial Schedules in DBMS
- Dynamic Frequency Scaling and Dynamic Voltage Scaling
- How To Create A Countdown Timer Using JavaScript
- Timer in C++ using system calls
- Infix to Postfix using different Precedence Values for In-Stack and Out-Stack
- How to reverse an animation on mouse out after hover?
- Longest Remaining Time First (LRTF) CPU Scheduling Algorithm
- One Time Password (OTP) algorithm in Cryptography
- Introduction of Shortest Remaining Time First (SRTF) algorithm
- Difference between Turn Around Time (TAT) and Waiting Time (WT) in CPU Scheduling
- Difference between Compile Time and Load Time address Binding
- Difference between Load Time and Execution Time address binding
- Difference between Compile Time and Execution Time address binding
- Difference between Seek Time and Disk Access Time in Disk Scheduling
- Difference between Seek Time and Transfer Time in Disk Scheduling
- Difference between Transfer Time and Disk Access Time in Disk Scheduling

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

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

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