Three Way Handshake-
Before you go through this article, make sure that you have gone through the previous article on Three Way Handshake.
We have discussed-
- TCP uses Three Way Handshake to establish a connection between the sender and receiver.
- Connection establishment using Three Way Handshake involves the steps as shown-
In this article, we will discuss how a lost TCP segment is retransmitted.
After establishing the connection,
- Sender starts transmitting TCP segments to the receiver.
- A TCP segment sent by the sender may get lost on the way before reaching the receiver.
- This causes the receiver to send the acknowledgement with same ACK number to the sender.
- As a result, sender retransmits the same segment to the receiver.
- This is called as TCP retransmission.
When TCP Retransmission Occurs?
|When sender discovers that the segment sent by it is lost,|
it retransmits the same segment to the receiver.
Sender discovers that the TCP segment is lost when-
- Either Time Out Timer expires
- Or it receives three duplicate acknowledgements
1. Retransmission After Time Out Timer Expiry-
Each time sender transmits a TCP segment to the receiver, it starts a Time Out Timer.
Now, following two cases are possible-
- Sender receives an acknowledgement for the sent segment before the timer goes off.
- In this case, sender stops the timer.
- Sender does not receives any acknowledgement for the sent segment and the timer goes off.
- In this case, sender assumes that the sent segment is lost.
- Sender retransmits the same segment to the receiver and resets the timer.
Also Read- Time Out Timer
2. Retransmission After Receiving 3 Duplicate Acknowledgements-
- Consider sender receives three duplicate acknowledgements for a TCP segment sent by it.
- Then, sender assumes that the corresponding segment is lost.
- So, sender retransmits the same segment without waiting for its time out timer to expire.
- This is known as Early retransmission or Fast retransmission.
- Sender sends 5 TCP segments to the receiver.
- The second TCP segment gets lost before reaching the receiver.
The sequence of steps taking place are-
- On receiving segment-1, receiver sends acknowledgement asking for segment-2 next.
- On receiving segment-3, receiver sends acknowledgement asking for segment-2 next.
(1st duplicate ACK)
- On receiving segment-4, receiver sends acknowledgement asking for segment-2 next.
(2nd duplicate ACK)
- On receiving segment-5, receiver sends acknowledgement asking for segment-2 next.
(3rd duplicate ACK)
- Sender receives 3 duplicate acknowledgements for segment-2 in total.
- So, sender assumes that the segment-2 is lost.
- So, it retransmits segment-2 without waiting for its timer to go off.
After receiving the retransmitted segment-2,
- Consider time out timer expires before receiving the acknowledgement for a TCP segment.
- This case suggests the stronger possibility of congestion in the network.
- Consider sender receives 3 duplicate acknowledgements for the same TCP segment.
- This case suggests the weaker possibility of congestion in the network.
- Consider receiver does not receives 3 duplicate acknowledgements for the lost TCP segment.
- In such a case, retransmission occurs only after time out timer goes off.
- Retransmission on receiving 3 duplicate acknowledgements is a way to improve the performance over retransmission on time out.
Also Read- TCP Congestion Control
PRACTICE PROBLEM BASED ON TCP RETRANSMISSION-
Consider a TCP connection in a state where there are no outstanding ACKs. The sender sends two segments back to back. The sequence numbers of the first and second segments are 230 and 290 respectively. The first segment was lost but the second segment was received correctly by the receiver.
Let X be the amount of data carried in the first segment (in bytes) and Y be the ACK number sent by the receiver.
The values of X and Y are-
- 60 and 290
- 230 and 291
- 60 and 231
- 60 and 230
It is given that sender sends two segments where-
- 1st segment contains the sequence number 230 and gets lost.
- 2nd segment contains the sequence number 290 and is received correctly.
Amount Of Data Sent In First Segment-
- Sequence number of 1st segment = 230
- Sequence number of 2nd segment = 290
From here, range of sequence numbers contained in the 1st segment = [230,289].
- Total number of sequence numbers contained in the 1st segment = 289 – 230 + 1 = 60.
- TCP assigns one sequence number to each byte of data.
- Thus, Amount of data contained in the first segment = 60 bytes.
ACK Number Sent By Receiver-
On receiving the 2nd segment,
- Receiver sends the acknowledgement asking for the first segment only.
- This is because it expects the 1st segment first.
- Receiver keeps sending this ACK number until it receives the first segment correctly.
- Thus, Acknowledgement number = Sequence number of the 1st segment = 230.
Thus, Option (D) is correct.
Next Article- TCP Connection Termination
Get more notes and other study material of Computer Networks.
Watch video lectures by visiting our YouTube channel LearnVidFun.