diff options
author | Artem Titov <titovartem@google.com> | 2020-07-06 16:06:37 +0200 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-07-07 10:45:05 +0000 |
commit | fb6f975401972635a644c0db06c135b4c0aaef4a (patch) | |
tree | 40588067737b734697e38eada1a608fd90401549 /p2p | |
parent | 3444a49d77b094c7fa2aade8873288a55ac0b9e5 (diff) | |
download | webrtc-fb6f975401972635a644c0db06c135b4c0aaef4a.tar.gz |
Implement packets_(sent | received) for RTCTransportStats
Bug: webrtc:11756
Change-Id: Ic0caad6d4675969ef3ae886f50326e4a2e1cbfe7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178741
Reviewed-by: Tommi <tommi@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31643}
Diffstat (limited to 'p2p')
-rw-r--r-- | p2p/base/connection.cc | 1 | ||||
-rw-r--r-- | p2p/base/connection_info.cc | 1 | ||||
-rw-r--r-- | p2p/base/connection_info.h | 1 | ||||
-rw-r--r-- | p2p/base/p2p_transport_channel_unittest.cc | 2 |
4 files changed, 5 insertions, 0 deletions
diff --git a/p2p/base/connection.cc b/p2p/base/connection.cc index afb1457567..0863865a04 100644 --- a/p2p/base/connection.cc +++ b/p2p/base/connection.cc @@ -461,6 +461,7 @@ void Connection::OnReadPacket(const char* data, last_data_received_ = rtc::TimeMillis(); UpdateReceiving(last_data_received_); recv_rate_tracker_.AddSamples(size); + stats_.packets_received++; SignalReadPacket(this, data, size, packet_time_us); // If timed out sending writability checks, start up again diff --git a/p2p/base/connection_info.cc b/p2p/base/connection_info.cc index a4f8036769..ebea2ab5b0 100644 --- a/p2p/base/connection_info.cc +++ b/p2p/base/connection_info.cc @@ -28,6 +28,7 @@ ConnectionInfo::ConnectionInfo() sent_ping_responses(0), recv_total_bytes(0), recv_bytes_second(0), + packets_received(0), recv_ping_requests(0), recv_ping_responses(0), key(nullptr), diff --git a/p2p/base/connection_info.h b/p2p/base/connection_info.h index a62e8aec00..b5e1c14433 100644 --- a/p2p/base/connection_info.h +++ b/p2p/base/connection_info.h @@ -54,6 +54,7 @@ struct ConnectionInfo { size_t recv_total_bytes; // Total bytes received on this connection. size_t recv_bytes_second; // Bps over the last measurement interval. + size_t packets_received; // Number of packets that were received. size_t recv_ping_requests; // Number of STUN ping request received. size_t recv_ping_responses; // Number of STUN ping response received. Candidate local_candidate; // The local candidate for this connection. diff --git a/p2p/base/p2p_transport_channel_unittest.cc b/p2p/base/p2p_transport_channel_unittest.cc index 523e9e8bc6..cfdee81403 100644 --- a/p2p/base/p2p_transport_channel_unittest.cc +++ b/p2p/base/p2p_transport_channel_unittest.cc @@ -1284,6 +1284,7 @@ TEST_F(P2PTransportChannelTest, GetStats) { ep2_ch1()->receiving() && ep2_ch1()->writable(), kMediumTimeout, clock); + // Sends and receives 10 packets. TestSendRecv(&clock); IceTransportStats ice_transport_stats; ASSERT_TRUE(ep1_ch1()->GetStats(&ice_transport_stats)); @@ -1306,6 +1307,7 @@ TEST_F(P2PTransportChannelTest, GetStats) { EXPECT_EQ(0U, best_conn_info->sent_discarded_packets); EXPECT_EQ(10 * 36U, best_conn_info->sent_total_bytes); EXPECT_EQ(10 * 36U, best_conn_info->recv_total_bytes); + EXPECT_EQ(10U, best_conn_info->packets_received); DestroyChannels(); } |