Commit d9e08fac authored by Woo Xie's avatar Woo Xie Committed by Noam Lerner

enrich network-quality HTTPHeader field with retransmission rate

Summary:
estimating tcp retransmission rate of the socket

Test Plan: unit tests

Reviewed By: afrind@fb.com

Subscribers: folly-diffs@, njormrod, bmatheny, trunkagent, chalfant, yfeldblum, jsedgwick

FB internal diff: D2097198

Tasks: 4888253

Signature: t1:2097198:1433196365:16db26dfd721514481497eddfc7820a453618d33
parent 1706959a
......@@ -26,10 +26,27 @@ bool TransportInfo::initWithSocket(const AsyncSocket* sock) {
return false;
}
rtt = microseconds(tcpinfo.tcpi_rtt);
/* The ratio of packet retransmission (rtx) is a good indicator of network
* bandwidth condition. Unfortunately, the number of segmentOut is not
* available in current tcpinfo. To workaround this limitation, totalBytes
* and MSS are used to estimate it.
*/
if (tcpinfo.tcpi_total_retrans == 0) {
rtx = 0;
} else if (tcpinfo.tcpi_total_retrans > 0 && tcpinfo.tcpi_snd_mss > 0 &&
totalBytes > 0) {
// numSegmentOut is the underestimation of the number of tcp packets sent
double numSegmentOut = double(totalBytes) / tcpinfo.tcpi_snd_mss;
// so rtx is the overestimation of actual packet retransmission rate
rtx = tcpinfo.tcpi_total_retrans / numSegmentOut;
} else {
rtx = -1;
}
validTcpinfo = true;
#else
tcpinfoErrno = EINVAL;
rtt = microseconds(-1);
rtx = -1;
#endif
return true;
}
......
......@@ -47,6 +47,11 @@ struct TransportInfo {
*/
std::chrono::microseconds rtt{0};
/*
* the estimated ratio of packet retransmisions in current socket
*/
double rtx{-1};
#if defined(__linux__) || defined(__FreeBSD__)
/*
* TCP information as fetched from getsockopt(2)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment