zoukankan      html  css  js  c++  java
  • TCP四个定时器时间长度设置的依据——RTT往返时间

    RTT Round-Trip Time

    比如重传定时器,那么到底多长时间没接到ACK才重传呢?

    测量的RTT

    RTT的测量可以采用两种方法:

    (1)重传队列中数据包的TCP控制块
    在TCP重传队列中保存着发送而未被确认的数据包,数据包skb中的TCP控制块包含着一个变量,
    tcp_skb_cb->when,记录了该数据包的第一次发送时间。
    RTT = 当前时间 – when

    image

     

     

    (2)TCP Timestamp选项
    在前面的blog中有详细的介绍过这个选项,TCP时间戳选项可以用来精确的测量RTT。
    RTT = 当前时间 -  数据包中Timestamp选项的回显时间
    这个回显时间是该数据包发出去的时间,知道了数据包的接收时间(当前时间)和发送时间
    (回显时间),就可以轻松的得到RTT的一个测量值。

    为什么用时间戳选项测量RTT?

    既然不用时间戳选项就可以实现RTT测量,为何还增加时间戳选项呢?看下面解释:

    “TCP must use Karn's algorithm for taking RTT samples. That is, RTT samples MUST NOT be made using segments that were retransmitted (and thus for which it is ambiguious whether the reply was for the first instance of the packet or a later instance). The only case when TCP can safely take RTT samples from retransmitted segments is when the TCP timestamp option is employed, since the timestamp option removes the ambiguity regarding which instance of the data segment triggered the acknowledgement.”

    上面这段话的意思是,不能确定ACK是对原包的回复还是对重传包的回复。

    画个图就明白了,如下

    image

    平滑的RTT

    (Smoothed RTT): 因为RTT对不同的往返有不同的数值,而且其起伏比较大,以致不能为重传超时做标准,所以需要平滑的RTT,记为SRTT它对和前一个SRTT加权平均。
    即SRTT=αSRTT+(1-α)*MRTT  α推荐为0.9.
     
     
  • 相关阅读:
    【转载】Java嵌入Pig编程
    【转载】Pig语法进阶
    【转载】各种SQL在PIG中实现
    机器学习简易入门(三)
    机器学习简易入门(一)
    在Centos7上安装漏洞扫描软件Nessus
    R简易入门(二)
    R简易入门(一)
    Mysql主从同步(复制)
    Mysql备份与恢复
  • 原文地址:https://www.cnblogs.com/helloweworld/p/3034019.html
Copyright © 2011-2022 走看看