How TCP Provides Reliability
TCP is called reliable because it does not simply send data and forget about it. It actively checks whether the receiver has acknowledged the transmitted data.
Reliability in TCP depends on multiple mechanisms working together:
Sequence numbers: Keep track of byte positions
Acknowledgments: Confirm received data
Retransmission: Lost data is sent again
Checksum: Detects corruption in the segment
Timers: Help the sender decide when data may have been lost
If a segment is lost, TCP does not assume everything is fine. It eventually retransmits the missing data so the receiver can reconstruct the complete stream.
This is why TCP works well for file transfer, web pages, and APIs, where missing information would cause problems.
Retransmission and Duplicate ACKs
TCP can detect loss in more than one way. The most common methods are timeout-based retransmission and duplicate acknowledgments.
If an acknowledgment does not arrive within the expected time, TCP assumes a loss may have occurred and retransmits the data. This is controlled through retransmission timers.
Another useful signal is the duplicate ACK. If the receiver keeps acknowledging the same byte number again and again, it usually means some later data arrived but one earlier segment is missing.
For example:
Segment with bytes
1000-1499is lostReceiver gets bytes
1500-1999Receiver cannot move forward in order
Receiver keeps sending ACK for
1000
When the sender sees repeated duplicate ACKs, it can infer that loss likely happened and react quickly.
Flow Control and Receive Window
Reliability is not the only problem TCP solves. It also protects the receiver from being overloaded. This is called flow control.
The receiver has a limited buffer. If the sender transmits too fast, the receiver may not be able to store or process the incoming data in time. To prevent that, the receiver advertises a receive window, often called rwnd.
The receive window tells the sender how much more unacknowledged data the receiver is currently ready to accept.
Large receive window: Receiver can accept more data
Small receive window: Sender should slow down
Zero window: Receiver cannot accept more data for the moment
This receiver-driven control helps keep communication stable and prevents buffer overflow at the destination.
TCP Flow Control
Sliding Window in TCP
The practical mechanism behind TCP flow control is the sliding window. Instead of sending only one small piece of data and waiting for one ACK every time, TCP allows multiple bytes of unacknowledged data to remain in transit.
This improves efficiency because the sender does not have to stop after every segment.
The window “slides” forward as acknowledgments arrive:
Data inside the send window can be transmitted
Acknowledged data leaves the window
New data enters the window
The sender continues moving forward smoothly
A simple way to think about it is this:
Left side of window: Already acknowledged data
Middle of window: Sent but not yet acknowledged data
Right side of window: Data that can be sent next
Sliding window makes TCP much more efficient than pure stop-and-wait communication.
TCP Sliding Window
Be the first to add a comment.