Jump to content

Web Science/Part1: Foundations of the web/Transmission Control Protocol/Sliding window and flow control

From Wikiversity

Sliding window and flow control

Learning goals

  1. understand the concept of windowsize and sliding window
  2. understand how flow control can prevent TCP connections to overload link layer protocols and slow networks

Video

Script

TCP – sliding window and flow control

Let’s imagine that sender wants transfer a data packet of 8kB (8192) to the recipient. According to the three-way handshake, he sends a SYN segment to establish a connection. He states his receiving buffer size in the TCP header as the window size. In our case – 4096. Additionally he sends his maximum segment size in the TCP header- 1460. The recipient acknowledges the SYN (his own SYN) and states buffer size with 4096 as well as his maximum segment size – 1024.
Let’s assume that sender will always send data segments of 1024 bytes. This means that he will send (8192/1024=8) 8 segments. He acknowledges the SYN of the recipient of another ACK. The connection is now open with the buffer size of 4096 and the maximum segment size of 1024. That’s how we know (4096/1024=4) that the sender is allowed to sent 4 data packets before he has to receive an acknowledgment from the recipient.
After receiving 4 packets the recipient buffer is completely full. So the window is closed. Data has not been retrieved from the buffer yet. That’s why the recipient will set the window size 0, meaning that he cannot receive any data yet. The recipient acknowledges the retrieval by sending an ACK with the sequence number + 4097. In this way he states that he successfully received 4096 bytes and that he now expect the next bytes to be the byte number 4097.
As soon as the recipient has processed some of the received data, he will open it’s window by sliding it. In our case 3 segments have been processed and ARK is send to the sender in which he acknowledges the received segments but also states his window size to be 3072. The sender will transmit the next 3 elements. The recipient will acknowledges this with an ACK and a window size 0 since no further data has been processed from the buffer yet.
After processing an additional 2 segments he will open his window again by sliding and transmitting another ACK to the sender acknowledging that byte 7169 is expected ext and his window size is 2048. The sender transits the last segment and also sets a FIN flag in a TCP header to state that he wants to close the connection. . The recipient acknowledges the last packet with an ACK that is open at window size 4096. Finally he also sends the FIN flag. The last FIN segment will be acknowledged so that the connection is closed.
--Jane Kruch (discusscontribs) 19:11, 3 November 2013 (UTC)

Quiz

1 How do you calculate the maximum number of different packets you are allowed to send on a TCP connection without acknowledgement assuming the packet size exceeds the maximum segment size (mss)?

the window size header field corresponds to the maximum number of packets
window size divided by the mss of the receiver
window size divided by the mss of the sender
window size divided by the minimum mss of the sender and receiver.

2 What is the purpose of sliding windows in TCP?

to protect slow network interfaces to be overload with traffic from fast network interfaces
to decrease the latency while using the Stop and Wait heuristic
to reassemble files in the correct order
to ensure the reliability of the protocol


Discussion