The TCP/IP Guide - Version 3.0 (Contents) ` 933 _ © 2001-2005 Charles M. Kozierok. All Rights Reserved.
One window size management matter is related to just how quickly a device reduces the
size of its receive window when it gets busy. Let's say the server starts with a 360 byte
receive window, as in the aforementioned example, and receives 140 bytes of data that it
acknowledges, but cannot remove from the buffer immediately. The server can respond by
reducing the size of the window it advertises back to the client. We even discussed in the
previous topic the case where no bytes can be removed from the buffer at all, so the
window size is reduced by the same 140 bytes that were added to the buffer. This “freezes”
the right edge of the client's send window so it cannot send any additional data when it gets
an acknowledgment.
What if the server were so overloaded that we actually needed to reduce the size of the
buffer itself? Say memory was short and the operating system said “I know you have 360
bytes allocated for the receive buffer for this connection, but I need to free up memory so
now you only have 240”. The server still can't immediately process the 140 bytes it
received, so it would need to drop the window size it sent back to the client all the way from
360 bytes down to 100 (240 in the total buffer less the 140 already received).
In effect, doing this actually moves the right edge of the client's send window back to the
left. It says “not only can't you send more data when you receive this acknowledgment, but
you now can send less”. In TCP parlance, this is called shrinking the window.
There's a very serious problem with doing this, however: while the original 140 bytes were
in transit from the client to the server, the client still thought it had 360 bytes of total window,
of which 220 bytes were usable (360 less 140). The client may well have already sent some
of that 220 bytes of data to the server before it gets notification that the server has shrunk
the window! If so, and the server reduces its buffer to 240 bytes with 140 used, when those
220 bytes show up at the server, only 100 will fit and any additional ones will need to be
discarded. This will force the client to have to retransmit that data, which is inefficient.
Figure 227 illustrates graphically how this situation would play out.
Reducing Buffer Size Without "Shrinking" the Window
To prevent this from occurring, TCP adds a simple rule to the basic sliding window
mechanism: a device is not allowed to shrink the window. Note that there is a potential
terminology ambiguity here. The words “shrinking” and “reducing” are sometimes used
synonymously in colloquial discussions. As we've seen, there's nothing wrong with
reducing the size of the window. The problem of “shrinking the window” only refers to the
case where we reduce the window size so much that we contradict a prior window adver-
tisement by taking back permission to send a certain number of bytes.
Another way of looking at this is that shrinking occurs whenever the server sends back a
window size advertisement smaller than what the client considers its usable window size to
be at that time. In this case, the server shrunk the window because at the time it was
acknowledging the 140 bytes, it sent back a window size of 100, which is less than the 220-
byte usable window the client had then.