Friday 9 June 2017

Retransmissions in TCP

  No comments

Whenever you send a packet, there is no guarantee that packet will be delivered to the destined node. The concept of retransmission comes into picture when you send a packet and you don't receive any acknowledgement for it.
But the question comes in when do you decide that our packet is lost and is not delivered to the destined host? When do you retransmit the lost packet? This is where two concepts of TCP comes into play.
  • Retransmission after the timeout.
  • Retransmission after 3 duplicate acknowledgements.

Retransmission after the timeout:

Since TCP is a connection-oriented protocol whenever it sends any packet, it waits for the acknowledgement of the sent packet. But for how long? For that, it uses timeout timer. The timeout timer is started as soon as the packet is transmitted. If the acknowledgement is not received within this time, the sender retransmits the packet.
The following diagram shows the retransmission when the timeout occurs.

If this kind of scenario occurs, it means there is severe congestion in the network.

Retransmission after 3-duplicate acknowledgements:

Let's say host A wants to send 5 packets to host B. Also assume that it can transmit all the packets one after the other continuously. The following diagram shows the complete scenario. 

Once all the packets are transmitted the timeout timer is started for each and individual packet. In the above scenario packet 1, 3, 4 and 5 are safely delivered to B. But packet 2 is lost on the way. So the receiver when gets packet 1, it sends back an acknowledgement by sending the next sequence number i.e 2. 
Now on receiving packet 3 it again sends back sequence number 2. Remember it cannot send sequence number 4 or 5 because TCP uses cumulative acknowledgement (As it is 75% SR and 25% Go Back N). If it sends sequence number 4 it means that we have received all the packets till sequence number 3. And now we want sequence number 4.

The same thing happens for packet 4 and packet 5. For these packets, the receiver sends back the acknowledgements with sequence number 2. Now at the sender side, we have received three duplicate acknowledgements from the receiver. The acknowledgement of the first packet is not counted in this.

Now if we receive three duplicate acknowledgement and timeout timer has also not expired, then we don't wait for the completion of timeout timer. We immediately retransmit packet 2. 

When we receive 3-duplicate acknowledgements it means congestion is not there but it's about to get congested.

This was all about this topic. As always if you like the post, share it. If you have any queries, or you want to suggest something you can always ping me on Facebook or mention in the comments section below. I will be happy to help. You can follow me on Facebook and google+. Don't forget to follow the blog post.

No comments :

Post a Comment