- Each buffer in the TCP has some maximum size: MaxSendBuffer, MaxRcvBuffer.
- Recall that in sliding window, the size of the window sets the amount of data that can be sent without waiting for acknowledgment from the receiver.
- The receiver throttles the sender by advertising a window that is no larger than the amount of data that it can buffer. i.e., it set the advertised window to:
AdvertisedWindow = MaxRcvBuffer - ((NextByteExpected -1) - LastByteRead)
- It can happen that the advertised window shrinks if the application processing on the receiver doesn't read received data as the data is being received.
- The sender computes an EffectiveWindow based on the equation:
EffectiveWindow = AdvertisedWindow - (LastByteSent - LastByteAcked)
- This is how much data the sender can still send. If it gets to 0, the sender must wait for more ACK's.
- The TCP send side must also block the sending application process if it tries to write too much to its buffer.
- That is, whenever this app tries to write y bytes to the buffer, TCP checks if:
(LastByteWritten - LastByteAcked) + y > MaxSendBuffer.
If so, it blocks the app.
- The receiver side does not spontaneously send non-data segments; it only send them in response to an arriving data segment.
-
If the receiver advertises a window of 0, the sender still sends periodic 1-byte segments to see if any will be accepted. It does this to prevent the situation that the sender hangs because of the 0 byte advertisement.