Learn through the super-clean Baeldung Pro experience:
>> Membership and Baeldung Pro.
No ads, dark-mode and 6 months free of IntelliJ Idea Ultimate to start with.
Last updated: March 18, 2024
Transmission Control Protocol (TCP) is a communications standard that enables application programs and computing devices to exchange messages over a network. It is designed to send packets across the internet and ensure the successful delivery of data and messages over networks.
In this tutorial, we’ll examine TCP retransmission: its definition, causes, and how it works.
TCP provides a reliable byte-stream transport service, building upon the best-effort datagram delivery service provided by the Internet Protocol. TCP achieves this by dividing data into TCP segments and transporting these segments in IP packets. As we know, unlike the User Datagram Protocol (UDP), TCP uses a three-way handshake process used to establish a TCP connection, as illustrated below:
After establishing the connection, the sender starts transmitting TCP segments to the receiver. However, one or some TCP segments sent by the sender may get lost on the way before reaching the receiver. This causes the receiver to send the acknowledgment (ACK) with the same ACK number to the sender. As a result, the sender retransmits the same segment to the receiver. This is called TCP retransmission. The retransmission of packets is one of the differences between TCP and UDP.
Not all packets sent to a link are necessarily received successfully by the receiver at the other end of the link. There are a number of possible causes of packet loss. These may occur as frames travel across a link, and include:
Other forms of packet loss are not related to channel conditions, but include:
The rate of loss and patterns of loss experienced are functions of the design of the physical and link layers. These vary significantly across different link configurations. The performance of a specific implementation may also vary considerably across the same link configuration when operated over different types of channels.
The sender discovers that the TCP segment is lost when
Each time the sender transmits a TCP segment to the receiver, it starts a time-out timer.
Now, the following two cases are possible:
The figure below illustrates an example of TCP retransmission after the time-out timer expiry:
When the sender receives three duplicate ACKs for a TCP segment sent by it, it will assume that the corresponding segment is lost. The sender then retransmits the same segment without waiting for its time-out timer to expire. This is known as early retransmission or fast retransmission.
Consider that the sender sends 5 TCP segments to the receiver, as depicted in the figure below:
The second TCP segment gets lost before reaching the receiver. The sequence of steps taking place are:
Now, the sender receives 3 duplicate ACKs for Segment 2 in total. So, the sender assumes that Segment 2 is lost. Retransmission is established for Segment 2 without waiting for the timer to go off.
It is noted that after receiving the retransmitted Segment 2, the receiver does not send the ACK asking for Segment 3, or 4, or 5, but sends the ACK asking for Segment 6 directly from the sender. This is because previous segments have already been received, and ACKs for them have already been sent (although wasted in asking for Segment 2).
In this article, we covered the concept and principles of TCP retransmission.
We have learned what are the reasons that cause packet loss on the network links. We also learned the two main rules for establishing TCP retransmission, which are the expiration of the time-out timer and the receipt of three duplicate ACKs at the sender. By employing the retransmission mechanism, the TCP protocol guarantees the delivery of packets from the sender to the receiver and thus provides reliable communication and increases the performance of the network.