Commit 366cd1ec authored by Cristian Lumezanu's avatar Cristian Lumezanu Committed by Facebook GitHub Bot

Add bytesAcked to TcpInfo

Summary: Added the bytesAcked field in TcpInfo to represent the number of acknowledged bytes in the connection.

Reviewed By: bschlinker

Differential Revision: D30511022

fbshipit-source-id: 6056c741399a058811fee0dbd94b1722c802db13
parent 1456b13d
...@@ -190,6 +190,18 @@ Optional<uint64_t> TcpInfo::bytesNotSent() const { ...@@ -190,6 +190,18 @@ Optional<uint64_t> TcpInfo::bytesNotSent() const {
#endif #endif
} }
Optional<uint64_t> TcpInfo::bytesAcked() const {
#ifndef FOLLY_HAVE_TCP_INFO
return folly::none;
#elif defined(__linux__)
return getFieldAsOptUInt64(&tcp_info::tcpi_bytes_acked);
#elif defined(__APPLE__)
return folly::none;
#else
return folly::none;
#endif
}
Optional<uint64_t> TcpInfo::packetsSent() const { Optional<uint64_t> TcpInfo::packetsSent() const {
#ifndef FOLLY_HAVE_TCP_INFO #ifndef FOLLY_HAVE_TCP_INFO
return folly::none; return folly::none;
......
...@@ -160,6 +160,7 @@ struct TcpInfo { ...@@ -160,6 +160,7 @@ struct TcpInfo {
Optional<uint64_t> bytesReceived() const; Optional<uint64_t> bytesReceived() const;
Optional<uint64_t> bytesRetransmitted() const; Optional<uint64_t> bytesRetransmitted() const;
Optional<uint64_t> bytesNotSent() const; Optional<uint64_t> bytesNotSent() const;
Optional<uint64_t> bytesAcked() const;
Optional<uint64_t> packetsSent() const; Optional<uint64_t> packetsSent() const;
Optional<uint64_t> packetsWithDataSent() const; Optional<uint64_t> packetsWithDataSent() const;
......
...@@ -225,6 +225,7 @@ class TcpInfoTest : public Test { ...@@ -225,6 +225,7 @@ class TcpInfoTest : public Test {
EXPECT_FALSE(wrappedTcpInfo.bytesSent()); EXPECT_FALSE(wrappedTcpInfo.bytesSent());
EXPECT_FALSE(wrappedTcpInfo.bytesReceived()); EXPECT_FALSE(wrappedTcpInfo.bytesReceived());
EXPECT_FALSE(wrappedTcpInfo.bytesRetransmitted()); EXPECT_FALSE(wrappedTcpInfo.bytesRetransmitted());
EXPECT_FALSE(wrappedTcpInfo.bytesAcked());
EXPECT_FALSE(wrappedTcpInfo.packetsSent()); EXPECT_FALSE(wrappedTcpInfo.packetsSent());
EXPECT_FALSE(wrappedTcpInfo.packetsWithDataSent()); EXPECT_FALSE(wrappedTcpInfo.packetsWithDataSent());
...@@ -277,6 +278,7 @@ class TcpInfoTest : public Test { ...@@ -277,6 +278,7 @@ class TcpInfoTest : public Test {
controlTcpInfo.tcpi_bytes_received, wrappedTcpInfo.bytesReceived()); controlTcpInfo.tcpi_bytes_received, wrappedTcpInfo.bytesReceived());
EXPECT_EQ( EXPECT_EQ(
controlTcpInfo.tcpi_bytes_retrans, wrappedTcpInfo.bytesRetransmitted()); controlTcpInfo.tcpi_bytes_retrans, wrappedTcpInfo.bytesRetransmitted());
EXPECT_EQ(controlTcpInfo.tcpi_bytes_acked, wrappedTcpInfo.bytesAcked());
EXPECT_EQ(controlTcpInfo.tcpi_segs_out, wrappedTcpInfo.packetsSent()); EXPECT_EQ(controlTcpInfo.tcpi_segs_out, wrappedTcpInfo.packetsSent());
EXPECT_EQ( EXPECT_EQ(
......
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