What is retransmission in TCP? Error control and Duplicate Acknowledgement.
In other articles, we have covered how the TCP setup and closes a connection. After connection establishment, while data transfer, there could be packet losses due to various reasons. Being a reliable protocol, TCP has retransmission functionality for error recovery. In this tutorial, we will learn why and when packets are retransmitted over an active connection.
What are the reasons for packet loss?
The network is built upon processing nodes such as routers and physical channels called wires. When a frame traverses from source to the next hope, a frame may be errored due to noise. The receiver recognizes the error and drops the frame. Mosty the errors at the frame level are handled and recovered by the data link layer. But still, its an optimization as TCP any way has error control.
Another major reason for IP packet drop is the congestion. When a transit router detects the congestion on the outgoing link. It starts dropping the packets and informs the sender node for the current capacity. TCP retransmission occurs for a dropped message, once the retransmission timer times out.
How frequently a packet loss occurs?
There is no fixed pattern. These days the network becomes much faster with very high bandwidth. But still, there are packet losses. The major reason is when the traffic comes in bursts and network capacity exhausted.
TCP Retransmission for error recovery:
Data in TCP flows in a byte stream. Each bye in the stream has a sequence number. After receiving a message, the receiver sends the acknowledgment for the last accepted sequence number. Sender removes messages from the retransmission queue till the ack sequence number.
TCP Duplicate and Selective Acknowledgments
Both ae an optimization for the retransmit process. If the first sender sends a lost packet earlier than the normal retransmit time, while in later sends only the selective packets.
While analyzing a TCP capture an analyzer may show duplicate acknowledgment where two ACK will have the same sequence numbers. Following is an example sequence;
- The sender sends 6 segments.
- Segment number 3 is lost. When the receiver receives packet 4. it sends ACK with sequence number 3 (Expecting next packet).
- When the receiver receives the packet 5. it sends ACK with sequence number 3 (Expecting next packet).
- When the receiver receives the packet 6. it sends ACK with sequence number 3 (Expecting next packet).
- After seeing duplicate ACK, the sender knows that 3 is lost and sends packet 3 again immediately.
- The receiver receives ACK with sequence number 7.
Selective ACK or SACK:
SACK is an option in TCP, which enables the receiver to send an acknowledgment packet with the range (block) of sequence numbers over a connection. There could be multiple ranges in a SACK message. Each block start sequence number is Left Edge and the last is Right Edge.
- The sender sends 6 segments.
- Segment number 3 is lost.
- When the receiver receives the packet 4, 5, and 6.
- The receiver sends selective acknowledgment with the ranges of sequence numbers for 4, 5, and 6.
- The sender retransmits packet 3 only.