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).

 

结构图



 

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。

[java]  view plain copy
  1. static void tcp_ack_saw_tstamp(struct sock *sk , int flag)  
  2. {  
  3.         /* RTTM Rule: A TSecr value received in a segment is used to 
  4.          * update the averaged RTT measurement only if the segment 
  5.          * acknowledges some new data, i.e., only if it advances the 
  6.          * left edge of the send window. 
  7.          *  
  8.          * Changed: reset backoff as soon as we see the first valid 
  9.          * sample. If we do not, we get strongly overestimated rto. 
  10.          * With timestamps samples are accepted even from very 
  11.          * old segments: f.e., when rtt=1 increases to 8, we retransmit 
  12.          * 5 times and after 8 seconds delayed answer arrives rto 
  13.          * becomes 120 seconds!  
  14.          */  
  15.          struct tcp_sock *tp = tcp_sk(sk);  
  16.          tcp_valid_rtt_meas(sk, tcp_time_stamp - tp->rx_opt.rcv_tsecr);  
  17. }  

 

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.


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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值