The sliding window protocol that we observed in the previous section can be visualized as shown in Figure 20.4.
In this figure we have numbered the bytes 1 through 11. The window advertised by the receiver is called the offered window and covers bytes 4 through 9, meaning that the receiver has acknowledged all bytes up through and including number 3, and has advertised a window size of 6. Recall from Chapter 17 that the window size is relative to the acknowledged sequence number. The sender computes its usable window, which is how much data it can send immediately.
Over time this sliding window moves to the right, as the receiver acknowledges data. The relative motion of the two ends of the window increases or decreases the size of the window. Three terms are used to describe the movement of the right and left edges of the window.
The window closes as the left edge advances to the right. This happens when data is sent and acknowledged.
The window opens when the right edge moves to the right, allowing more data to be sent. This happens when the receiving process on the other end reads acknowledged data, freeing up space in its TCP receive buffer.
The window shrinks when the right edge moves to the left. The Host Requirements RFC strongly discourages this, but TCP must be able to cope with a peer that does this. Section 22.3 shows an example when one side would like to shrink the window by moving the right edge to the left, but cannot.
Figure 20.5 shows these three terms. The left edge of the window cannot move to the left, because this edge is controlled by the acknowledgment number received from the other end. If an ACK were received that implied moving the left edge to the left, it is a duplicate ACK, and discarded.
If the left edge reaches the right edge, it is called a zero window. This stops the sender from transmitting any data.
Figure 20.6 shows the dynamics of TCP's sliding window protocol for the data transfer in Figure 20.1.
There are numerous points that we can summarize using this figure as an example.
The sender does not have to transmit a full window's worth of data.
One segment from the receiver acknowledges data and slides the window to the right. This is because the window size is relative to the acknowledged sequence number.
The size of the window can decrease, as shown by the change from segment 7 to segment 8, but the right edge of the window must not move leftward.
The receiver does not have to wait for the window to fill before sending an ACK. We saw earlier that many implementations send an ACK for every two segments that are received.
We'll see more examples of the dynamics of the sliding window protocol in later examples.