What is the TCP flow control?
Before discussing TCP flow control, it’s worth describing the flow control functionality in computer networks. When two network hosts start communicating, one sends packets, and the other receives them.
Both may have different hosting hardware, software design, and processing speed. If the receiver is fast enough to consume messages at a higher rate than those generated by the sender, all works well.
But what will happen if the receiver consumes slower than the sender produces? The messages will keep adding to the receiver’s queue. After some time, messages will start dropping once the receiver queue is full. To overcome a fast sender and a slow receiver problem, there is a concept known as flow control in Computer networks.
- Slow sender speedy receiver – No Flow Control required,
Fast sender, slow receiver – Flow control is needed.
The above diagram shows a slow receiver and a fast sender. Let’s understand how the messages will be overflown after a certain period.
- The sender is sending messages at the rate of 10 messages per second, while the receiver is receiving at the rate of 5 messages per second.
- When a sender sends a message, the network enqueues messages in the receiver queue.
- Once the user application reads a message, the message is clear from the line, and now again, one buffer space adds to the free space.
- With the mentioned speed for the sender and receiver, the receiver queue will keep shortening at the pace of 5 every second.
- Finally, after 40 seconds, there will be no space remaining for incoming messages, and messages will start dropping.
Why is TCP flow control required?
TCP is an example of a transport layer protocol as per the OSI reference model. It provides reliable and sequenced delivery of messages. Because of reliable delivery, TCP retries to send a lost segment if a packet is lost due to a slow receiver. If there is no flow control, TCP will keep resending repeatedly, and the situation will worsen over the network.
With the flow control, the TCP receiver keeps sending the available space capacity for the incoming messages to the sender during the communication. The sender updates the space information and reduces the outgoing message rate. The space is known as the receiver window size.
How does the TCP implement the flow control?
For implementing flow control, the sender should know how much free space is available on the receiver before sending further messages. In an earlier TCP header tutorial, we described various protocol parameters. One parameter is the window size. Both ends add their own window size in the header in each TCP segment.
During connection setup, the window size is the maximum capacity available. During packet transfer, the window size keeps updating. The window size value is zero when a TCP end can not accept further messages.
When the sender receives a window size of zero, it stops sending any further messages till it gets again a message with a window size of more than zero.
Flow control and TCP user:
Till now, all discussion was for the TCP layer. Here we will discuss the traffic source for TCP, which is the user of the layer.
Difference Between Flow Control and Congestion Control:
The flow control is from end to end. While congestion control is a node between the path from two nodes. For example, a router between two communicating nodes may get congested.
How does a TCP application know when to stop?
The purpose of flow control is to let the sender know that the receiver is slower. A sender application should be informed in case of a slow receiver. Generally, the TCP module informs the sender while sending data.