TCP Timers
Before you go through this article, make sure that you have gone through the previous article on TCP Timers.
We have discussed
 TCP Timers are used to avoid excessive delays during communication.
 Several timers used in a TCP implementation are
 Time Out Timer
 Time Wait Timer
 Keep Alive Timer
 Persistent Timer
In this article, we will discuss about Time Out Timer and its Computation.
Time Out Timer
TCP uses a time out timer for retransmission of lost segments. 
 Sender starts a time out timer after transmitting a TCP segment to the receiver.
 If sender receives an ACK before the timer goes off, it stops the timer.
 If sender does not receives any ACK and the timer goes off, then TCP Retransmission occurs.
 Sender retransmits the same segment and resets the timer.
 The value of time out timer is dynamic and changes with the amount of traffic in the network.
Network Traffic And Time Out Timer
Consider
 Receiver has sent the ACK to the sender.
 The ACK is on its way through the network.
Now, following two cases are possible
Case01: High traffic
If there is high traffic in the network
 The time taken by the ACK to reach the sender will be more.
 So, as per the high traffic, the value of time out timer should be kept large.
If the value is kept small, then
 Timer will time out soon.
 It causes the sender to assume that the segment is lost before reaching the receiver.
 However, in actual the ACK is delayed due to high traffic.
 Sender keeps retransmitting the same segment.
 This overburdens the network and might lead to congestion.
Case02: Low traffic
If there is low traffic in the network
 The time taken by the ACK to reach the sender will be less.
 So, as per the low traffic, the value of time out timer should be kept small.
If the value is kept large,
 Timer will not time out soon.
 Sender keeps waiting for the ACK even when it is actually lost.
 This causes excessive delay.
Conclusion
The value of time out timer should be such that
 It decreases when there is low traffic traffic in the network.
 It increases when there is high traffic in the network.
Algorithms For Computing Time Out Timer Value
The algorithms used for computing the value of time out timer dynamically are
 Basic Algorithm
 Jacobson’s Algorithm
 Karn’s modification
Rules
All the above algorithms work on the following rules
Rule01:
The value of time out timer for the next segment is increased when
Rule02:
The value of time out timer for the next segment is decreased when

Now, let us see all the algorithms one by one.
Basic Algorithm
The steps followed under Basic Algorithm are
Step01: Sending 1st Segment
While sending the 1st segment,
 Sender assumes any random value of initial RTT say IRTT_{1}.
 So after sending the 1st segment, sender expects its ACK to arrive in time IRTT_{1}.
 Sender sets time out timer value (TOT) for the 1st segment to be
TOT_{1} = 2 X IRTT_{1} 
 Suppose ACK for the 1st segment arrives in time ARTT_{1}.
 Here, ARTT_{1} = Actual Round Trip Time for the 1st segment.
Step02: Sending 2nd Segment
While sending the 2nd segment,
 Sender computes the value of initial RTT for the 2nd segment using the relation
IRTT_{n+1} = α IRTT_{n} + (1 – α)ARTT_{n} 
Here, α is called smoothing factor where 0 <= α <= 1
(Its value will be given in questions)
Now,
 Substituting n=1, sender gets IRTT_{2} = α IRTT_{1} + (1 – α)ARTT_{1}.
 So after sending the 2nd segment, sender expects its ACK to arrive in time IRTT_{2}.
 Sender sets time out timer value (TOT) for the 2nd segment to be
TOT_{2} = 2 X IRTT_{2} 
 Suppose ACK for the 2nd segment arrives in time ARTT_{2}.
 Here, ARTT_{2} = Actual Round Trip Time for the 2nd segment.
In the similar manner, algorithm computes the time out timer value for all the further segments.
Advantages
The advantages of Basic Algorithm are
 Time out timer value is flexible to dynamic round trip time.
 It takes into consideration all the previously sent segments to derive the initial RTT for the current segment.
Disadvantage
The disadvantage of Basic Algorithm is
 It always considers Time out timer value = 2 x Initial round trip time.
 There is no logic behind using the number 2.
2. Jacobson’s Algorithm
 Jacobson’s Algorithm is a modified version of the basic algorithm.
 It gives better performance than Basic Algorithm.
The steps involved in Jacobson’s Algorithm are
Step01: Sending 1st Segment
While sending the 1st segment,
 Sender assumes any random value of initial RTT say IRTT_{1}.
 So after sending the 1st segment, sender expects its ACK to arrive in time IRTT_{1}.
 Sender assumes any random value of initial deviation say ID_{1}.
 So after sending the 1st segment, sender expects there will be a deviation of ID_{1} time from IRTT_{1}.
 Sender sets time out timer value (TOT) for the 1st segment to be
TOT_{1} = 4 x ID_{1} + IRTT_{1} 
 Suppose ACK for the 1st segment arrives in time ARTT_{1}.
 Here, ARTT_{1} = Actual Round Trip Time for the 1st segment.
 Then, Actual deviation from IRTT_{1} is given by
AD_{1} =  IRTT_{1} – ARTT_{1} 
Step02: Sending 2nd Segment
While sending the 2nd segment,
 Sender computes the value of initial RTT for the 2nd segment using the relation
IRTT_{n+1} = α IRTT_{n} + (1 – α)ARTT_{n} 
Here, α is called smoothing factor where 0 <= α <= 1
(Its value will be given in questions)
 Sender computes the value of initial deviation for the 2nd segment using the relation
ID_{n+1} = α ID_{n} + (1 – α)AD_{n} 
Here, α is called smoothing factor where 0 <= α <= 1
(Its value will be given in questions)
 Substituting n=1, sender gets
IRTT_{2} = α IRTT_{1} + (1 – α)ARTT_{1}
ID_{2} = α ID_{1} + (1 – α)AD_{1}
 So after sending the 2nd segment, sender expects its ACK to arrive in time IRTT_{2} with deviation of ID_{2 }time.
 Sender sets time out timer value (TOT) for the 2nd segment to be
TOT_{2} = 4 x ID_{2} + IRTT_{2} 
 Suppose ACK for the 2nd segment arrives in time ARTT_{2}.
 Here, ARTT_{2} = Actual Round Trip Time for the 2nd segment.
 Then, Actual deviation from IRTT_{2} is given by
AD_{2} =  IRTT_{2} – ARTT_{2} 
In the similar manner, algorithm computes the time out timer value for all the further segments.
Problems with Basic Algorithm and Jacobson’s Algorithm
To calculate initial round trip time, both the algorithms depend on the actual round trip time of the previous segment through the relation
IRTT_{n+1} = α IRTT_{n} + (1 – α)ARTT_{n} 
Now,
 Consider ACK of some segment arrives to the sender after its initial time out timer goes off.
 Then, sender will have to re transmit the segment.
 Now for the segment being re transmitted, what should be the initial time out timer value is the concern.
 This is because the ACK is delayed and will arrive after time out.
 So, ARTT is not available.
This problem is resolved by Karn’s modification.
3. Karn’s Modification
Karn’s modification states
 Whenever a segment has to be re transmitted, do not apply either of Basic or Jacobson’s algorithm since actual RTT is not available.
 Instead, double the time out timer (TOT) whenever the timer times out and make a retransmission.
NOTEIn the above discussion, Initial time out timer value may also be called as the estimated time out timer value for the segment being sent. 
PRACTICE PROBLEMS BASED ON CALCULATING TIME OUT TIMER VALUE
Problem01:
In TCP, the initial RTT is 10 msec. The acknowledgements for the first three segments are received in time 15 msec, 20 msec and 10 msec.
Find the time out timer value for the first four segments using basic algorithm. Use α = 0.5.
Solution
For 1st Segment
Initial round trip time (IRTT_{1}) = 10 msec
So, Time out timer value (TOT_{1})
= 2 x IRTT_{1}
= 2 x 10
= 20 msec
Now,
 ACK for the 1st segment is received after 15 msec.
 So, Actual round trip time (ARTT_{1}) = 15 msec.
For 2nd Segment
Initial round trip time (IRTT_{2})
= α x IRTT_{1} + (1α) x ARTT_{1}
= 0.5 x 10 + (10.5) x 15
= 5 + 7.5
= 12.5 msec
So, Time out timer value (TOT_{2})
= 2 x IRTT_{2}
= 2 x 12.5
= 25 msec
Now,
 ACK for the 2nd segment is received after 20 msec.
 So, Actual round trip time (ARTT_{2}) = 20 msec.
For 3rd Segment
Initial round trip time (IRTT_{3})
= α x IRTT_{2} + (1α) x ARTT_{2}
= 0.5 x 12.5 + (10.5) x 20
= 6.25 + 10
= 16.25 msec
So, Time out timer value (TOT_{3})
= 2 x IRTT_{3}
= 2 x 16.25
= 32.5 msec
Now,
 ACK for the 3rd segment is received after 10 msec.
 So, Actual round trip time (ARTT_{3}) = 10 msec.
For 4th Segment
Initial round trip time (IRTT_{4})
= α x IRTT_{3} + (1α) x ARTT_{3}
= 0.5 x 16.25 + (10.5) x 10
= 8.125 + 5
= 13.125 msec
So, Time out timer value (TOT_{4})
= 2 x IRTT_{4}
= 2 x 13.125
= 26.25 msec
Problem02:
In TCP, the initial RTT is 10 msec and the initial deviation is 5 msec. The acknowledgements for the first three segments are received in time 20 msec, 30 msec and 10 msec.
Find the time out timer value for the first four segments using Jacobson’s Algorithm. Use α = 0.5.
Solution
For 1st Segment
 Initial round trip time (IRTT_{1}) = 10 msec
 Initial deviation (ID_{1}) = 5 msec
So,
Time out timer value (TOT_{1})
= 4 x ID_{1} + IRTT_{1}
= 4 x 5 + 10
= 30 msec
Now, ACK for the 1st segment is received after 20 msec. So,
 Actual round trip time (ARTT_{1}) = 20 msec
 Actual deviation (AD_{1}) =  IRTT_{1} – ARTT_{1}  =  10 – 20  = 10 msec
For 2nd Segment
Initial round trip time (IRTT_{2})
= α x IRTT_{1} + (1α) x ARTT_{1}
= 0.5 x 10 + (10.5) x 20
= 5 + 10
= 15 msec
Initial deviation (ID_{2})
= α x ID_{1} + (1α) x AD_{1}
= 0.5 x 5 + (10.5) x 10
= 2.5 + 5
= 7.5 msec
So, Time out timer value (TOT_{2})
= 4 x ID_{2} + IRTT_{2}
= 4 x 7.5 + 15
= 45 msec
Now, ACK for the 2nd segment is received after 30 msec. So,
 Actual round trip time (ARTT_{2}) = 30 msec
 Actual deviation (AD_{2}) =  IRTT_{2} – ARTT_{2}  =  15 – 30  = 15 msec
For 3rd Segment
Initial round trip time (IRTT_{3})
= α x IRTT_{2} + (1α) x ARTT_{2}
= 0.5 x 15 + (10.5) x 30
= 7.5 + 15
= 22.5 msec
Initial deviation (ID_{3})
= α x ID_{2} + (1α) x AD_{2}
= 0.5 x 7.5 + (10.5) x 15
= 3.75 + 7.5
= 11.25 msec
So, Time out timer value (TOT_{3})
= 4 x ID_{3} + IRTT_{3}
= 4 x 11.25 + 22.5
= 67.5 msec
Now, ACK for the 3rd segment is received after 10 msec. So,
 Actual round trip time (ARTT_{3}) = 10 msec
 Actual deviation (AD_{3}) =  IRTT_{3} – ARTT_{3}  =  22.5 – 10  = 12.5 msec
For 4th Segment
Initial round trip time (IRTT_{4})
= α x IRTT_{3} + (1α) x ARTT_{3}
= 0.5 x 22.5 + (10.5) x 10
= 11.25 + 5
= 16.25 msec
Initial deviation (ID_{3})
= α x ID_{3} + (1α) x AD_{3}
= 0.5 x 11.25 + (10.5) x 12.5
= 5.625 + 6.25
= 11.875 msec
So, Time out timer value (TOT_{4})
= 4 x ID_{4} + IRTT_{4}
= 4 x 11.875 + 16.25
= 63.75 msec
Next ArticleSilly Window Syndrome
Get more notes and other study material of Computer Networks.
Watch video lectures by visiting our YouTube channel LearnVidFun.