窗口扩大选项使TCP的窗口定义从16bit增加到32bit。这并不是通过修改TCP首部来实现的,TCP首部仍然使用16bit,而是通过定义一个选项实现对16bit的扩大操作来完成的。于是TCP在内部将实际的窗口大小维持为32bit的值;

窗口扩大选项的取值范围为0<=shif.cnt<=14;最大值为14的原因如下:

【这段内容为本人理解,非书中原文】TCP需要保留一半的序号用于判断是否是以前的旧数据段,(2^32-1)/2<2^31,也就是现在用于处理新数据段小于2^31个;假如窗口大小为wnd,发送方第一次发送[0,wnd-1]一个窗口的数据,这时接收方收到数据,并统一发送一个ack确认这个窗口的数据,确认完之后,窗口移动准备接收[wnd, 2wnd-1]段的数据;若发送方如果没有收到这个ack,需要重传[0, wnd-1]的数据,若收到了ack,则发送[wnd, 2wnd-1]的数据,这两种情况下,接收方都需要满足序号,也就是序号需要满足2*wnd;前面说了序号的一半用于新数据,也就是2*wnd<2^31,wnd<2^30,即(2^16-1)*2^shif < 2^30,得出shift<=14,即除了TCP首部的16bit,这里最多也就是30-16=14bit;

【这段是找到的RFC原文】大概意思是发送和接收窗口,一个窗口的左边沿到另外一个窗口的右边沿最大不能超过2^31,如果超过这个值就与保留的旧序号重叠了,也就是2*wnd < 2^31,wnd  < 2^30,得出shift<=14;

      RFC1323
TCP determines if a data segment is "old" or "new" by testing
whether its sequence number is within ** 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
** 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 * the max window size
must be less than **, or max window < ** Since the max window is **S (where S is the scaling shift count)
times at most ** - (the maximum unscaled window), the maximum
window is guaranteed to be < * if S <= . Thus, the shift
count must be limited to (which allows windows of ** =
Gbyte). If a Window Scale option is received with a shift.cnt
value exceeding , the TCP should log the error but use
instead of the specified value.

这个选项只能出现在SYN报文段中,因此当连接建立起来后,每个方向上的扩大因子是固定的。为了使用窗口扩大,两端必须在他们的SYN报文段中发送该选项。主动建立连接的一方在其SYN中发送这个选项,但是被动建立连接的一方只能够在接收到带这个选项的SYN之后才可以发送这个选项。每个方向上的扩大因此可以不同;

如果主动连接的一方发送一个非零的扩大因子,但是没有从另一端收到一个扩大选项,它就将发送和接收的移位计数器设置为0。这就允许较新的系统能够与较旧的系统进行互相操作;

假定我们正在使用窗口扩大选项,发送移位计数为S,而接收到的移位计数为R。于是我们从另一端接收到的16bit的通告窗口将被左移R位以获得实际的通告窗口大小。每次当我们向对方发送一个窗口通告的时候,我们将实际的32bit窗口大小右移S位,然后用它来替换TCP首部中的16bit窗口值;

TCP根据接收缓存的大小自动选择位移技术。这个大小是由系统设置的,但是通常向应用程序提供了修改途径;

文章来源: <TCP/IP详解>

TCP窗口扩大选项Window Scale的更多相关文章

  1. TCP窗口扩大选项

    TCP窗口扩大选项(TCP Window Scale Option) TCP窗口扩大选项 TCP Window Scale Option (WSopt) 窗口扩大选项用于扩大TCP通告窗口,使TCP的 ...

  2. TCP 协议中的 Window Size与吞吐量

    原地址:http://blog.sina.com.cn/s/blog_c5c2d6690102wpxl.html TCP协议中影响实际业务流量的参数很多,这里主要分析一下窗口的影响. ​TCP窗口目的 ...

  3. winform错误提示 :窗口类名无效(Window class name is not valid)

    winfrom 程序在 xp 操作系统上报错提示 窗口类名无效(Window class name is not valid) 解决方法 注释 Program类 里 这句 Application.En ...

  4. Android窗口管理服务WindowManagerService显示Activity组件的启动窗口(Starting Window)的过程分析

    文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/8577789 在Android系统中,Activ ...

  5. 机器人局部避障的动态窗口法(dynamic window approach) (转)

    源:机器人局部避障的动态窗口法(dynamic window approach) 首先在V_m∩V_d的范围内采样速度: allowable_v = generateWindow(robotV, ro ...

  6. 学习笔记:javascript 窗口对象(window)

    1.窗口对象属性 属性 描述 closed 返回窗口是否已被关闭. defaultStatus 设置或返回窗口状态栏中的默认文本. document 对 Document 对象的只读引用.请参阅 Do ...

  7. tcp窗口机制(写的最简单精炼的文章)

    tcp窗口机制(写的最简单精炼的文章) http://blog.csdn.net/occupy8/article/details/48468445

  8. 滑动窗口(Sliding Window)技巧总结

    什么是滑动窗口(Sliding Window) The Sliding Problem contains a sliding window which is a sub – list that run ...

  9. 一站式学习Wireshark(五):TCP窗口与拥塞处理

    https://community.emc.com/message/821593#821593 介绍 TCP通过滑动窗口机制检测丢包,并在丢包发生时调整数据传输速率.滑动窗口机制利用数据接收端的接收窗 ...

随机推荐

  1. Redis之淘汰策略

    Redis 内存数据集大小上升到一定大小的时候,就会进行数据淘汰策略. Redis 提供了 6 种数据淘汰策略: 1. volatile-lru:从已设置过期时间的数据集中挑选最近最少使用的数据淘汰. ...

  2. 页面加载时调用js函数方法

    方法一:在html的body中加入onload=""事件 <body onload='queryServer()'> </body> 方法二:jquery ...

  3. 第二十四篇 jQuery 学习6 删除元素

    jQuery 学习6 删除元素   上节课我们做了添加元素,模拟的是楼主发的文章,路人评论,那么同学们这节课学了删除之后,去之前的代码上添加一个删除,模拟一个楼主删除路人的评论. jQuery的删除方 ...

  4. HBuilderX 打包

    新建 - 云打包 (密钥 密码看不到 - 回车)    (  ) BlueStacks蓝叠 模拟器看效果

  5. 十三,k8s集群web端管理工具dashboard部署

    目录 部署 dashboard 由于会被墙, 所以要加一步拉取镜像 正式开始安装dashboard 查看 开放访问 配置dashboard用户 1. token 令牌认证 创建一个 serviceAc ...

  6. OSG入坑之路[转]

    转载自:https://segmentfault.com/a/1190000010506374?utm_source=tag-newest osg插件原理:https://blog.csdn.net/ ...

  7. linux获取某一个网卡的ipv4地址

    ip a show ens33 | grep inet | grep -v inet6 | awk '{print $2}' | awk -F '/' '{print $1}'

  8. PAT Basic 1094 谷歌的招聘 (20 分)

    20 5 23654987725541023819 输出样例 1: 49877 输入样例 2: 10 3 2468024680 输出样例 2: 404 #include <iostream> ...

  9. js遍历数组随机返回指定的数组结果

    ////随机生成数组中自定义的个数返回一个字符串数组    function getArrayItems(arr, num) {        //新建一个数组,将传入的数组复制过来,用于运算,而不要 ...

  10. Linux之top 监视系统任务的工具

    top 监视系统任务的工具: 和ps 相比,top是动态监视系统任务的工具,top 输出的结果是连续的:  top 命令用法及参数: top 调用方法: top 选择参数 参数: -b  以批量模式运 ...