在Linux / Mac / Windows上,是否可以在连接的TCP套接字的用户空间中访问TCP时间戳和/或RTT?

在Linux / Mac / Windows上,是否可以在连接的TCP套接字的用户空间中访问TCP时间戳和/或RTT? 我指的是RFC 1323启用的TCP时间戳和相关的RTT计算。 显然,我可以使用原始套接字,但套接字既不会连接也不能在Windows上发送TCP数据包(我相信XP Update 3之后)。

在Windows上(EstatsType = TcpConnectionEstatsFineRtt):
GetPerTcp6ConnectionEStats
GetPerTcpConnectionEStats

在Linux上(tcp_info.tcpi_rtt):
测量TCP拥塞Windows(getsockopt)

在Mac上(xtcpcb64.t_srtt):
sysctl TCPCTL_PCBLIST获取xtcpcb64结构

我想补充更多信息。

对于iOS / MacOSX,我发现了另一种与Linux tcp_info非常相似的方法。 它是struct tcp_connection_info 。 您可以在iOS / MacOSX xcode sdk的usr/include/netinet/tcp.h中找到它。 您可以将其用作以下内容:

 int length = sizeof(struct tcp_connection_info); getsockopt(socket_fd, IPPROTO_TCP, TCP_CONNECTION_INFO, (void *)info, (socklen_t *)&length); 

我在iOS 10.2上测试过它。