getsockopt(x,IPPROTO_TCP, TCP_TIMESTAMP, x, x)
获取tcp时间戳,并在netinet / tcp.h中定义了TCP_TIMESTAMP,但在使用centOS6时我无法找到它。
所有人都在centOS6上成功做到了吗? 非常感谢!
答案 0 :(得分:0)
rfc-1323,这是引入tcp时间戳的地方,在第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的时间戳可以通过将精确的时间戳附加到段并确定从一侧到另一侧的往返时间来精确地确定重传TimeOut间隔。
因此,通常情况下您没有看到socket api访问来获取这些时间戳(或插入它们),因为它们与用户空间无关,您无法确定何时放置它们以及何时连接它们分段。这些通常见于SYN
初始化段,以确定初始往返时间,然后在连接时定期确定变化或网络拥塞。
此外,作为TCP协议定义后引入的选项,它被认为是可选的,您可能会遇到不支持它的实现。