The goal would be to send enough packets so that the first acknowledgement arrives just as the sender has sent the packet that fills up its buffer space, and then you would continue to send messages and receive acknowledgements continuously. The channel is completely utilized except for the packet overhead. Unfortunately there are a number of reasons why this won't happen:
Typically, if we assume that the sender has an unlimited source of messages to send, the sender has insufficient buffer space to completely fill the channel, so it sends as many messages as it can and this group is called a flight. These messages arrive at the receiver and several ACK's are sent (depending on the arrival times and piggybacking options) which arrive back at the sender at about the same time. As the sender responds with more messages, they will again be grouped together. This process continues, interrupted of course by the need to send duplicates for one reason or another.
Although most of the examples show SWP's with a sender and a receiver, they are almost always duplex, with both sides having a sender and a receiver. This is the source of piggybacking for ACKs anyway.
Since SWP's have acknowledgements and sequence numbers, they resolve all of the reliability issues except delayed packets. No matter what you do, you can't remove this completely as a problem. One method is to use large sequence numbers (32 or 64 bits) so that a sequence number can't be repeated for a long time. Then, an old packet (as indicated by a time stamp) can be identified and thrown away before it causes a problem. The reality is that this problem continues in very widely used protocols, such as TCP.
where
and
L = Message Length M = Data length C = Network latency Y = Resend cost R = Data rate T = Timeout value E = Probability of an error
What changes in the sliding window protocol is that instead of sending one message, the sender can send a window full, so if we ignore errors for the moment and let W be the window size in message-size buffers, the utilization is:
The amount of data sent is multiplied by the number of messages in a flight. The time between flights is simply the latency - the time for the first acknowledgement to arrive. For example, if L = 1000 bytes, B = 100 bytes, D = 0.2 s, 100 MBps (bytes per second) and W = 4 buffers:
If we increase the number of buffers we will get higher utilizations until we reach the point where the time to send a flight is exactly the network latency and utilization will be at a maximum. For example, if the number of buffers in the window is raised to 16:
If we take possible errors into account, we will want to find some sort of simple average to reduce the complexity of the calculations. If we use the approach used above, we simple calculate some cost of a resend, but is that accurate? Suppose one packet in a flight is lost; all of the others will be acknowledged, and it is possible that more messages will be sent as the ACK's arrive, but eventually, the sending stops waiting for the missing acknowledgement. Remember that the window can't move forward until all messages in the window are acknowledged. The sender will stop sending until the timer expires; it will send the duplicate, and it will wait for the ACK before going one. The pipeline can then be restarted.
While there are many possible scenarios, it is reasonable to assume that all errors result in a restart of the pipeline, which has a cost of sending the duplicate, waiting for the ACK and then resending an entire flight. If the probability of an error is E:
For any given flight, there is the probability of an error which has a particular cost. This expected cost can be included as a part of the expected total time or capacity to get the expected utilization, which is:
For example, suppose that in the previous example T is 0.3 s (somewhat larger than the latency) and that the probability of an error is 0.01. Then,
and the utilization is:
and for a window size of 16, the utilization is:
As with other SWP's there is a pointer for the beginning and end of the window on each end, with the window size equal maximum distance allowed between the pointers. The sender can send up to window-size bytes and then it is blocked until acknowledgements come in for the outstanding bytes. Similarly, the receiver can have up to the window size of the receiver bytes that have been received but not processed or acknowledged and then it is blocked.
Messages are not single bytes, but blocks of bytes that are efficient for network conditions. The sequence number is counted from the beginning of the connection, so if the sender was currently sending the 10,000th byte, the sequence number would be 10,000 more than the initial sequence number. If the message was 1000 bytes long, then the next message would be sequence number 11,000. As with buffer-based SWP's, the receiver ACKs with the next byte is expects to get.