zoukankan      html  css  js  c++  java
  • TCP中RTT的测量和RTO的计算

    https://blog.csdn.net/zhangskd/article/details/7196707

    •   tcp传输往返时间是指:发送方发送tcp断开时, 到发送方接收到改段立即响应的所耗费的时间。

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

    •   如果tcp支持时间戳选项。发送方可以再tcp option里面记录发送方发送的时间, 同时发送方记录在tcp opt选项的时间戳会被接收方反射回来, 这样就可以利用反射时间计算 往返RTT。

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

      每次确认都会产生一个RTT, 所以为了防止RTT随机抖动, 需要作出平滑处理。为了避免浮点运算,RTT---->SRTT = RTT << 3;

    发送方每接收到一个ACK,都会调用tcp_ack()来处理。
    tcp_ack()中会调用tcp_clean_rtx_queue()来删除重传队列中已经被确认的数据段。
    在tcp_clean_rtx_queue()中:
    如果ACK确认了重传的数据包,则不会更新;否则,seq_rtt = now - scb->when;
    然后调用 tcp_ack_update_rtt(sk, flag, seq_rtt_us, sack_rtt_us, ca_rtt_us);来更新RTT和RTO。

     Kind. 8 bits. Set to 8.
    Length. 8 bits. Set to 10.
    Timestamp Value (TSval). 32 bits.

    This field contains the current value of the timestamp clock of the TCP sending the option. TImestamp Echo Reply (TSecr). 32 bits.


    This field only valid if the ACK bit is set in the TCP header. If it is valid, it echos a timestamp value that was sent by the remote TCP in the TSval field of a Timestamps option. When TSecr is not valid,
    its value must be zero. The TSecr value will generally be from the most recent Timestamp option that was received; however, there are exceptions that are explained below. A TCP may send the
    Timestamp option in an initial SYN segment(i.e., segment containing a SYN bit and no ACK bit), and may send a TSopt in other segments only if it received a TSopt in the initial SYN segment for the connection.


  • 相关阅读:
    CORS 跨域问题, 以及作为api server 的正确配置, 后台 nginx 配置
    angular2 各种开发种遇到的问题和设置
    angular2 cli 无法正确安装使用解决
    inline-block text-align: justify 实现自适应布局, 当子inline-block之间没有空格时失效及原因
    rails active record 使用default_scope is evil, 记一次 order not work 的排查
    java class jar 的加载问题
    es6 匿名函数求阶乘
    ruby 一些基础的语法, 各种杂物箱
    ruby 给对象添加新的方法
    javascript 核心语言笔记 7
  • 原文地址:https://www.cnblogs.com/codestack/p/11919697.html
Copyright © 2011-2022 走看看