TCP Timestamp选项

简介: TCP Timestamp选项 Description Protocol suite: TCP/IP. Protocol type: Transport layer protocol.

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

目录
相关文章
|
网络协议
TCP状态转换
TCP状态转换
75 0
|
5月前
|
网络协议
TCP协议中TIME_WAIT状态的分析
`TIME_WAIT`状态是TCP协议设计中的一个重要组成部分,它通过确保数据传输的可靠性和连接的正确关闭来提升网络通信的稳定性。尽管 `TIME_WAIT`可能导致资源占用,适当的系统配置和网络编程实践可以最小化其潜在的负面影响。理解 `TIME_WAIT`状态及其背后的逻辑是每一位网络开发人员和系统管理员必须掌握的知识点。
269 1
|
9月前
|
网络协议 安全 Unix
聊聊TCP中的TIME_WAIT
【4月更文挑战第4天】 TIME_WAIT 的产生、作用以及优化
|
运维 网络协议 Linux
聊聊 IP packet 的 TTL 与 tcp segment 的 MSL
聊聊 IP packet 的 TTL 与 tcp segment 的 MSL
|
网络协议 安全 Unix
TCP MSS选项
本文档是 Internet 工程任务组 (IETF) 的产品。它代表了 IETF 社区的共识。它已接受公众审查,并已获互联网工程指导小组 (IESG) 批准出版。并非 IESG 批准的所有文件都适用于任何级别的互联网标准;请参阅 RFC 5741 的第 2 节。
230 0
|
网络协议 安全 Unix
TCP 选项和最大分片大小 (MSS)
本文档是 Internet 工程任务组 (IETF) 的产品。它代表了 IETF 社区的共识。它已接受公众审查,并已被互联网工程指导小组 (IESG) 批准出版。并非所有 IESG 批准的文件都适用于任何级别的互联网标准;请参阅 RFC 5741 的第 2 节。
689 0
|
网络协议 Linux PHP
TCP TIME_WAIT状态解析及问题解决
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhaobryant/article/details/80557158 一、TCP四次挥手过程 TCP在建立连接时需要握手,同理,在关闭连接的时候也需要握手。
2654 0

热门文章

最新文章