c - 我如何在centOS6上获得 `tcp option timestamp`

标签 c linux tcp

在centOS7上,我可以使用 getsockopt(x,IPPROTO_TCP, TCP_TIMESTAMP, x, x) 获取tcp时间戳,在netinet/tcp.h中定义了TCP_TIMESTAMP,但是我用centOS6找不到。

那么有没有人在centOS6上成功的呢? 非常感谢!

最佳答案

rfc-1323 ,也就是引入tcp timestamp的地方,在第4页,指出:

(3) 往返测量

       TCP implements reliable data delivery by retransmitting
       segments that are not acknowledged within some retransmission
       timeout (RTO) interval.  Accurate dynamic determination of an
       appropriate RTO is essential to TCP performance.  RTO is
       determined by estimating the mean and variance of the
       measured round-trip time (RTT), i.e., the time interval
       between sending a segment and receiving an acknowledgment for
       it [Jacobson88a].

       Section 4 introduces a new TCP option, "Timestamps", and then
       defines a mechanism using this option that allows nearly
       every segment, including retransmissions, to be timed at
       negligible computational cost.  We use the mnemonic RTTM
       (Round Trip Time Measurement) for this mechanism, to
       distinguish it from other uses of the Timestamps option.

因此,为连接两端的 TCP 引入的时间戳可以通过将精确的时间戳附加到分段并确定从一侧到另一侧的往返时间来精确确定重传超时间隔。

因此,您看不到获取这些时间戳(或插入它们)的套接字 API 访问是正常的,因为它们与用户空间无关,您无法确定何时放置它们以及何时附加它们到一个段。这些通常出现在 SYN init 段中,以确定初始往返时间,然后随着连接的进行定期确定变化或网络拥塞。

此外,作为在 TCP 协议(protocol)定义之后引入的选项,它被认为是可选的,您可能会遇到不支持它的实现。

关于c - 我如何在centOS6上获得 `tcp option timestamp`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44110724/

相关文章:

c - 修改作为指针传递的缓冲区

c - 理解涉及进程的 C 代码

c - 如何将指向结构数组的指针传递给函数

c# - 强制关闭 TCP 客户端时服务器无法识别断开连接

c - 结构体类型数组的动态分配

c++ - 处理应该能够管理 linux 用户帐户的程序的用户权限的最佳实践是什么

Linux内核中断处理程序互斥保护?

c# - TCP/IP 监听器可变字节长度

sockets - SCTP 比 TCP 好在哪里? (交通场景)

linux - 通过示例应用程序学习 Linux 应用程序编程