标签:
Sliding window is an interesting concept. In terms of TCP, receiver’s window represents the amount of data that the receiver is willing to accept.
In this article, we will cover TCP sliding window concept and aspects related to it.
Before learning the sliding window concept, lets first discuss a scenario where sender is quick to send data while receiver is a bit slow to accept it. Suppose sender sends three data segments (seg1, seg2 and seg3) each of 4096 bytes and starts waiting for the acknowledgement from the receiver.
Now, if these 3 segments fill up all the TCP buffers of the receiver then receiver will advertise a window size of 0. The window size zero means that receiver cannot accept any more data at this moment. Whenever buffers are available, a non zero window size would be advertised by the receiver.
The process described in last section is good on receiver’s part but sender has to maintain a window on its side too. This window covers unacknowledged data and the data it can send keeping in mind the window size advertised by the receiver.
Following figure should give you an idea about how a sliding window looks like :
In the figure shown above :
The available window advertised by the receiver is 6. This means that receiver can accept 6 bytes as of now.
The window at sender side covers bytes ranging from 13 to 18 (I.e. 6 bytes in total).
Out of this range, 13-15 are the bytes which have been sent but no acknowledgement is yet received for them.
Bytes 16-18 are the bytes that sender can send as soon as possible.
If sender starts receiving acknowledgement for bytes 13 to 15, the left end of the window starts closing in.
The right end starts opening up as more and more window size is advertised by the receiver.
This window slides towards right depending upon how fast receiver consumes data and sends acknowledgement and hence known as sliding window.
On a related note, it is also helpful for you to understand how TCP attacks andARP cache poisoning works.
Some more points related to sliding windows :
The receiver can send acknowledgement even before its window fills up completely.
The left edge of the window can move towards right.
Neither left edge should move towards left nor right edge should move towards left.
标签:
原文地址:http://my.oschina.net/robinyao/blog/530563