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, during data transfer, there could be packet losses/garbled 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 the source to the next hope, a frame may be errored due to noise. The receiver recognizes the error and drops the frame. Most of the errors at the frame level are handled and recovered by the data link layer. But still, it’s optimization as TCP anyway has error control.
Another major reason for IP packet drop is congestion. When a transit router detects the congestion on the outgoing link. It starts dropping the packets and informs the sender node of the current capacity. TCP retransmission occurs for a dropped message, once the retransmission timer times out.
How frequently does a packet loss occur in a network?
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 is 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. The sender removes messages from the retransmission queue till the ack sequence number.
TCP Duplicate and Selective Acknowledgments
Both are optimizations for the retransmission mechanism. If the first sender sends a lost packet earlier than the normal retransmit time, the latter 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 the next packet).
- When the receiver receives packet 5. it sends ACK with sequence number 3 (Expecting the next packet).
- When the receiver receives packet 6. it sends ACK with sequence number 3 (Expecting the 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 packets 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.