zoukankan      html  css  js  c++  java
  • tcp timestamp

    Description

    Protocol suite: TCP/IP.

    Protocol type: Transport layer protocol.

    Option length: 10 bytes.

    The TCP Timestamp option obsoletes the TCP Echo request and Echo reply options.

    RFC 1323:

    The timestamps are used for two distinct mechanisms: RTTM (Round Trip Time Measurement) and PAWS (Protected Against Wrapped Squences).

    结构图

    wps_clip_image-2301

    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.

    Linux内核中的使用

    如果支持Timestamp选项,那么可以用此选项来计算RTT

    static void tcp_ack_saw_tstamp(struct sock *sk , int flag)

    {

    /* RTTM Rule: A TSecr value received in a segment is used to

    * update the averaged RTT measurement only if the segment

    * acknowledges some new data, i.e., only if it advances the

    * left edge of the send window.

    *

    * Changed: reset backoff as soon as we see the first valid

    * sample. If we do not, we get strongly overestimated rto.

    * With timestamps samples are accepted even from very

    * old segments: f.e., when rtt=1 increases to 8, we retransmit

    * 5 times and after 8 seconds delayed answer arrives rto

    * becomes 120 seconds!

    */

    struct tcp_sock *tp = tcp_sk(sk);

    tcp_valid_rtt_meas(sk, tcp_time_stamp - tp->rx_opt.rcv_tsecr);

    }

    rtt即等于现在的时间tcp_time_stamp减去Timestamp Echo Reply,即tp->rx_opt.rcv_tsecr

    TCP timestamp option的作用:

    1)allow more accurate round-trip time measurements for deriving the retransmission timeout estimator.

    2)protect against old segments from the previous incarnations of the TCP connection.

    3)allow detection of unnecessary retransmissions.

    tcp_tw_recycle/tcp_timestamps都开启的条件下,60s内同一源ip主机的socket connect请求中的timestamp必须是递增的。

    原文

    http://blog.csdn.net/zhangskd/article/details/7195795

    tcp_tw_recycletcp_timestamps导致connect失败问题

    http://blog.sina.com.cn/s/blog_781b0c850100znjd.html

  • 相关阅读:
    Android -- Camera2(Android5.0)
    Android -- Camera.ShutterCallback
    Android -- selector&&StateListDrawable
    Centos安装FTP服务器和配置
    Android -- setWillNotDraw()
    Android -- ViewPager切换动画,PageTransformer
    关于通信的关键词UDP/(TCP/IP)/IPC/RPC/.NET Remoting/WebService/WCF/Http 系列
    已禁用对分布式事务管理器(MSDTC)的网络访问。请使用组件服务管理工具启用 DTC 以便在 MSDTC 安全配置中进行网络访问。
    JavaScript的NaN-唯一 一个自己不等于自己的对象!!
    【ShoppingPeeker】-基于Webkit内核的爬虫蜘蛛引擎 ShoppingWebCrawler的姊妹篇-可视化任务Web管理
  • 原文地址:https://www.cnblogs.com/zlingh/p/4181918.html
Copyright © 2011-2022 走看看