Understanding TCP receive window [closed]

Closed. This question is off-topic. It is not currently accepting answers.

Questions on Server Fault must be about managing information technology systems in a business environment. Home and end-user computing questions may be asked on Super User, and questions about development, testing and development tools may be asked on Stack Overflow.

Closed 2 years ago .

I'm currently learning about TCP, particularly the receive window aspect. I've read from several sources about it, and there's something I want to make sure I understand. From what I've learnt, the receiver advertises a "receive window", which is - and this is where I get confused - the number of bytes that the sender is allowed to send without being acknowledged for, or in other words, the data in flight. Now, if I try to think about it, our main goal in flow control is to make sure that the sender will not send more than the receiver can process, i.e., we want to prevent a situation in which a sender sends data that the receiver will have to discard since it won't have where to store it ! Going with this logic, I come to believe that the receive window should be corresponding to the size of the receive buffer (don't know if exactly the same, but the window size should be a derivative of the receive buffer anyhow), and the reason that we are limiting the data in flight sent by the sender is that - if the sender will send more than the window size (which, again is a derivative of the receive buffer), and the receiver hasn't acknowledged some of the data (updating the window size), there may be a situation in which the receiving end will not keep up - i.e., it will get the data faster than the application consuming it can process it, resulting in segments being discarded (hope that's clear). But, reading this post, @DavidShwartz is saying that the aim of data in flight is NOT to avoid overfilling the buffer, rather is to handle the delay introduced by the communication channel. Which I don't quite understand. The problem is that every source talking about this subject is not explaining the connection between the general aim of flow control and the thing with data in flight. Can someone explain this in more detail?