- 论坛徽章:
- 1
|
大家好,我在内核栏目发了此贴,结果没有达人能给我帮助,在此我将那个帖子修改了下,发表在这里,希望能有人帮助我,谢谢!
我在继续研读Stevens的“TCPIP协议详解卷1”中,又遇到了关于window scale option的一个问题,望大家不吝赐教,下面是问题描述。
在24.4 Window Scale Option中有如下文字:
We saw an example of this option in Figure 18.20. The 1-byte shift count is between 0 (no scaling performed) and 14. This maximum value of 14 is a window of 1,073,725,440 bytes (65535 × 2^14).
这里我没有懂的是为啥scale的最大范围是左移14位,即2^14次幂,这个14是如何得到的?
我查阅了下rfc1323,其中有针对这个14的计算来由,但是不幸的是,该rfc中和14有关的地方我仍然没有明白,所以非常郁闷,请大家帮帮我,下面是rfc1323中有关的内容:
2.3 Using the Window Scale Option
...
TCP determines if a data segment is "old" or "new" by testing
whether its sequence number is within 2**31 bytes of the left edge
of the window, and if it is not, discarding the data as "old". To
insure that new data is never mistakenly considered old and vice-
versa, the left edge of the sender's window has to be at most
2**31 away from the right edge of the receiver's window.
这里rfc1323在推导14这个数时,有上面一段话,其中说明了一个数据分段的序号如果距滑动窗口左边沿2**31次幂之内,则都不是old数据,这里我不明白这个31是如何得到的
此外,我把rfc1323中如何计算出14为最大伸缩因子的文字列出,请大家帮忙看看
--------------------------------------------------------------------------------------
TCP determines if a data segment is "old" or "new" by testing
whether its sequence number is within 2**31 bytes of the left edge
of the window, and if it is not, discarding the data as "old". To
insure that new data is never mistakenly considered old and vice-
versa, the left edge of the sender's window has to be at most
2**31 away from the right edge of the receiver's window.
Similarly with the sender's right edge and receiver's left edge.
Since the right and left edges of either the sender's or
receiver's window differ by the window size, and since the sender
and receiver windows can be out of phase by at most the window
size, the above constraints imply that 2 * the max window size
must be less than 2**31, or
max window < 2**30
Since the max window is 2**S (where S is the scaling shift count)
times at most 2**16 - 1 (the maximum unscaled window), the maximum
window is guaranteed to be < 2**30 if S <= 14. Thus, the shift
count must be limited to 14 (which allows windows of 2**30 = 1
Gbyte). If a Window Scale option is received with a shift.cnt
value exceeding 14, the TCP should log the error but use 14
instead of the specified value.
可以看出2**31次幂的结果是最关键的地方,这个明白了,后面的好像就说得通了,我就是看不懂这个地方,我的疑问是既然tcp的序号空间范围是32bit,超过后会回绕序号,那么2**31次幂的意思就是将该范围划分为相等的2部分,即2**32/2=2**31,为啥是这样呢?
再有,另外一篇和此问题相关的文字也列出,请大家帮忙看看
--------------------------------------------------------------------------------------
Even though a 32-bit space is now allowed for the actual window size, the maximum data size is not 4 GB (2**32 ), but rather 1 GB (2**30 ). This is done so that a TCP receiver can uniquely identify an incoming data segment as a new segment. There is no possibility of old and new segments with the same sequence number arriving out of turn and confusing the receiver, as sequence numbers themselves are in the 32-bit space.
为啥这样只利用原来的4G范围的四分之一,即1G,就能保证接收方不会混淆老数据和新数据? 难道1/2或3/4就不行吗? |
|