Coder Coder - 1 month ago 18
C Question

On Linux/Mac/Windows, is it possible to access the TCP timestamp and/or RTT in user space of a connected TCP socket?

On Linux/Mac/Windows, is it possible to access the TCP timestamp and/or RTT in user space of a connected TCP socket? I'm referring to the TCP timestamp and associated RTT calculation enabled by RFC 1323. Obviously, I could utilize a raw socket, but the socket would neither be connected or capable of sending TCP packets on Windows (post XP Update 3, I believe).

Answer

On Windows (EstatsType = TcpConnectionEstatsFineRtt):
GetPerTcp6ConnectionEStats
GetPerTcpConnectionEStats

On Linux (tcp_info.tcpi_rtt):
Measuring TCP Congestion Windows (getsockopt)

On Mac (xtcpcb64.t_srtt):
sysctl TCPCTL_PCBLIST to acquire the xtcpcb64 struct