What is the difference and connection between sliding window in flow control and congestion window in congestion control?
I think both are the control size for transmitting, but what are the difference? I do not quite get the difference between flow control and congestion control too.
Congestion window and flow-control are different features of TCP and their input is fed to the sliding window.
The congestion-window is based on an estimation of the network sending rate. It starts with a single MSS and grows using slow-start. Once it reaches a threshold, then it grows using congestion-avoidance. The value of this window represents the maximum amount (in bytes) that the sender can send.
The flow-control is run on the receive side and is communicated to the sender whenever the receiver sends a packet (usually, an ACK) to the sender. The receive window is the amount of space available in the receiver's buffer and the sender makes a note of it. When the sender has to send some data, then it chooses the minimum of the congestion window and the receiver's window and sends only that much data. The amount of data that can be sent represents the sliding window. Basically, the sliding window represents the amount of outstanding data that the sender has. If any of the windows (congestion or flow-control) opens up, then the window is stretched on the right.