In: Computer Science
Describe the concept of flow control and briefly describe the mechanism/s implemented by the TCP protocol for this purpose.
Describe the concept of flow control and briefly describe the mechanism/s implemented by the TCP protocol for this purpose.
Flow control is the process of managing the rate at which data is transmitted. It prevents a fast sender from overwhelming a slow receiver. It provides a mechanism for the receiver to control the transmission speed, so that the receiving node is not overwhelmed with data from transmitting node.
When we need to send data over a network, the sender application writes data to a socket, the transport layer will wrap this data in a segment and hand it to the network layer that will somehow route this packet to the receiving node.
On the other side of this communication, the network layer will deliver this piece of data to TCP, that will make it available to the receiver application as an exact copy of the data sent, meaning if will not deliver packets out of order, and will wait for a retransmission in case it notices a gap in the byte stream.
TCP stores the data it needs to send in the send buffer, and the data it receives in the receive buffer. When the application is ready, it will then read data from the receive buffer.
Flow Control is all about making sure we don’t send more packets when the receive buffer is already full, as the receiver wouldn’t be able to handle them and would need to drop these packets.
Every time TCP receives a packet, it needs to send an ack message to the sender, acknowledging it received that packet correctly, and with this ack message it sends the value of the current receive window, so the sender knows if it can keep sending data.
TCP controls Flow Control by Sliding Window Mechanism
Sliding window is a general protocol used
with bit-oriented protocols. In this protocol, the transmitter
maintains a variable, S, which denotes the sequence number of the
next frame to be transmitted. Similarly, the receiver maintains a
variable, R, which denotes the sequence number of the next frame it
expects to receive. Both variables are restricted to a limited
range of values (e.g., 0 through 7) by using modulo arithmetic
(e.g., modulo 8).
A window denotes a continuous subrange
within the permitted range of values for the sequence numbers. For
example, the ranges 0-3 and 6-1 both represent windows of size 3.
Both the transmitter and the receiver have their own window:
* The transmitter window denotes the frames that have been
transmitted but remain unacknowledged. This window can vary in
size, from empty to the entire range. The transmitter must have
enough buffer space to store the maximum possible number of
unacknowledged frames.
* The receiver window denotes frames that are expected to be
received. The receiver window size is fixed. A receiver window size
of 1 means that frames must be received in transmission order.
Larger window sizes allow the receiver to receive as many frames
out of order. The receiver must have enough buffer space to store
the maximum possible number of frames that can be received out of
order.
The sliding window protocol operates as follows. When the
transmitter sends a frame, it increments S (and the upper bound of
its window). When the receiver receives a frame whose sequence
number falls within its window, it increments R and sends an ACK to
the transmitter. If the frame's sequence number matches any
position other than the lower bound of the window, it notes the
fact that the corresponding frame has now been received. If the
frame's sequence number matches the lower bound of the window, the
window is rotated clockwise by one position (or more positions if
succeeding frames within the window have already been
received).
When the transmitter receives an ACK for a
transmitted frame, it increments the lower bound of its window. It
should be now clear that flow control is straightforward in the
sliding window protocol. If the receiver withholds ACK frames, the
transmitter soon reaches its maximum window size and has to stop
transmitting. Once it receives further ACK frames, it can reduce
its window size and transmit more frames.