18 #include <sys/types.h> 22 using std::chrono::microseconds;
29 #if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) 30 if (!TransportInfo::readTcpInfo(&tcpinfo, sock)) {
35 rtt = microseconds(tcpinfo.tcpi_srtt * 1000);
36 rtt_var = tcpinfo.tcpi_rttvar * 1000;
37 rto = tcpinfo.tcpi_rto * 1000;
39 mss = tcpinfo.tcpi_maxseg;
45 rtt = microseconds(tcpinfo.tcpi_rtt);
47 rto = tcpinfo.tcpi_rto;
48 rtx_tm = tcpinfo.tcpi_retransmits;
49 mss = tcpinfo.tcpi_snd_mss;
50 cwnd = tcpinfo.tcpi_snd_cwnd;
53 ssthresh = tcpinfo.tcpi_snd_ssthresh;
54 #if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 17 55 rtx = tcpinfo.tcpi_total_retrans;
58 #endif // __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 17 62 rtt = microseconds(-1);
75 #if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) 77 if (!TransportInfo::readTcpInfo(&tcpinfo, sock)) {
81 #if defined(__linux__) || defined(__FreeBSD__) 82 return tcpinfo.tcpi_rtt;
83 #elif defined(__APPLE__) 84 return tcpinfo.tcpi_srtt;
91 #define TCP_INFO TCP_CONNECTION_INFO 94 #if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) 95 bool TransportInfo::readTcpInfo(tcp_info* tcpinfo,
97 socklen_t len =
sizeof(tcp_info);
102 TCP_INFO, (
void*) tcpinfo, &len) < 0) {
103 VLOG(4) <<
"Error calling getsockopt(): " << strerror(errno);
static int64_t readRTT(const folly::AsyncSocket *sock)
bool initWithSocket(const folly::AsyncSocket *sock)
int getsockopt(NetworkSocket s, int level, int optname, void *optval, socklen_t *optlen)
virtual int getFd() const
std::chrono::microseconds rtt