TCP control (sliding window)

TCP control (sliding window)

 In TCP communication, communication is performed while gradually sliding the window, which is the range of data that can be sent until an ACK (acknowledgement) is received. This method is called "sliding window".

It's hard to understand with text alone, so I'll use the diagram below to explain.

explanation

First, let us explain the symbols used in the figure.

SEND(x): Send segment. X is the sequence number.
ACK(y,z): Acknowledgment. y is the ACK number, z is the window size.

Prior to TCP communication, a connection is established with "window size = 3000" and "MSS = 1000".

(1) Sending side
● Sending SEND(1), SEND(1001), SEND(2001)
"Window size = 3000", so 3 segments are sent at once.

( 2) Receiving side ● Receive segment 1 (1 to 1000)
of SEND(1) .
"Window size = 2000".

●The transmission empty buffer size for ACK(1001,2000)
is 2000 bytes. It responds with "ACK=1001" and "window size=2000".

( 3) Receiving side
● Receive
segment 2 (1001 to 2000) of SEND (1001). "Window size = 1000".

●The transmission empty buffer size for ACK(2001,1000)
is 1000 bytes. Respond with "ACK=2001" and "window size=1000".

( 4) Receiving side
●Processing of segment 1 (1 to 1000) and segment 2 (1001 to 2000) in the buffer is completed.
Now that the segments in the buffer have been processed, "window size = 3000".

( 5) Receiving side ● Receive segment 3 (2001 to 3000)
of SEND (2001) .
"Window size = 2000".

●The transmission empty buffer size for ACK(3001,2000)
is 2000 bytes. Respond with "ACK=3001" and "Window size=2000".

(6) Sending side
● Reception of ACK (1001, 2000)
 "Window size = 2000". You can see that segment 1 (1 to 1000) has arrived safely from "ACK=1001". We don't need to resend segment 1, so change it to "window=2000". Segment 2 (1001 to 2000) and segment 3 (2001 to 3000) have already been sent and there are no more segments to send, so they will not be sent.

(7) Sending side
● Reception of ACK (2001, 1000)
 "Window size = 1000". You can see that segment 2 (1001-2000) has arrived safely from "ACK=2001". Change it to "window=1000" and slide the window one position to the right.

 Segment 3 (2001-3000), which is in the window, has already been sent, but has not yet received an acknowledgment. No more segments to send, no more to send.

⑧Transmitting side
●Receive ACK(3001,2000)
 "Window size = 2000". You can see that segment 3 (2001-3000) has arrived safely from "ACK=3001". Change it to "window=2000" and slide the window 2 to the right.
● Segment 4 (3001 to 4000) and segment 5 (4001 to 5000) within the send window of SEND (3001) and SEND (4001)
 have not yet been sent. So we send segment 4 and segment 5.

(9) Receiving side
● Processing of segment 3 (2001 to 3000) in the buffer is completed.
Now that the segments in the buffer have been processed, "window size = 3000".

(10) Receiving side ● Receive segment 4 (3001 to 4000)
of SEND (3001) .
"Window size = 2000".
●The transmission empty buffer size for ACK(4001,2000)
is 2000 bytes. Respond with "ACK=4001" and "window size=2000".

(11) Receiving side
● Receive
segment 5 (4001 to 5000) of SEND (4001). "Window size = 1000".
●The transmission empty buffer size for ACK(5001,1000)
is 1000 bytes. Respond with "ACK=5001" and "window size=1000".

(12) Sending side
● Receiving ACK (4001, 2000)
 "Window size = 2000". Segment 4 (3001 to 4000) can be seen to have arrived safely from "ACK=4001". Change it to "window=2000" and slide the window one position to the right.
●Segment 5 (4001 to 5000) within the send window of SEND(5001)
 has already been sent. Segment 6 (5001-6000) has not yet been sent. So, send segment 6.

summary

 In this way, the increase or decrease of the window size is notified by the receiving side to the transmitting side using an ACK segment. By doing so, you can change the window size dynamically.

 This situation is called a sliding window because it looks as if the window has slid on the sequence number. A window is a window through which you can only see the data that is currently being sent.