diff options
author | Artem Titov <titovartem@webrtc.org> | 2020-07-21 15:46:08 +0200 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-07-21 16:17:02 +0000 |
commit | 1062cfee8daaabbaaa67da7485d49984e245fd78 (patch) | |
tree | 2d90f1c619e3f08b6d4073277c5b1f0f8c639eae | |
parent | 31cb3abd3683270edcc18c8e61a9ab851dd99b17 (diff) | |
download | webrtc-1062cfee8daaabbaaa67da7485d49984e245fd78.tar.gz |
Add list of local_addresses for network stats object
local_addresses is a list of IPs that were used to send data, which was
used during stats calculation.
Bug: webrtc:11756
Change-Id: Ie6307eaa69c73ebe9f69e44503752151be9e9ef6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/179841
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Reviewed-by: Andrey Logvin <landrey@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31774}
-rw-r--r-- | api/test/network_emulation/network_emulation_interfaces.h | 5 | ||||
-rw-r--r-- | test/network/network_emulation.cc | 4 | ||||
-rw-r--r-- | test/network/network_emulation_unittest.cc | 6 |
3 files changed, 15 insertions, 0 deletions
diff --git a/api/test/network_emulation/network_emulation_interfaces.h b/api/test/network_emulation/network_emulation_interfaces.h index d27319e1da..260ab0e292 100644 --- a/api/test/network_emulation/network_emulation_interfaces.h +++ b/api/test/network_emulation/network_emulation_interfaces.h @@ -11,6 +11,7 @@ #define API_TEST_NETWORK_EMULATION_NETWORK_EMULATION_INTERFACES_H_ #include <map> +#include <vector> #include "absl/types/optional.h" #include "api/units/data_rate.h" @@ -93,6 +94,10 @@ struct EmulatedNetworkStats { Timestamp first_packet_sent_time = Timestamp::PlusInfinity(); Timestamp last_packet_sent_time = Timestamp::MinusInfinity(); + // List of IP addresses that were used to send data considered in this stats + // object. + std::vector<rtc::IPAddress> local_addresses; + std::map<rtc::IPAddress, EmulatedNetworkIncomingStats> incoming_stats_per_source; diff --git a/test/network/network_emulation.cc b/test/network/network_emulation.cc index 37e307e725..f3e29317ba 100644 --- a/test/network/network_emulation.cc +++ b/test/network/network_emulation.cc @@ -196,6 +196,7 @@ EmulatedEndpointImpl::EmulatedEndpointImpl(uint64_t id, network_->AddIP(ip); enabled_state_checker_.Detach(); + stats_.local_addresses.push_back(peer_local_addr_); } EmulatedEndpointImpl::~EmulatedEndpointImpl() = default; @@ -389,6 +390,9 @@ EmulatedNetworkStats EndpointsContainer::GetStats() const { if (stats.last_packet_sent_time < endpoint_stats.last_packet_sent_time) { stats.last_packet_sent_time = endpoint_stats.last_packet_sent_time; } + for (const rtc::IPAddress& addr : endpoint_stats.local_addresses) { + stats.local_addresses.push_back(addr); + } for (auto& entry : endpoint_stats.incoming_stats_per_source) { const EmulatedNetworkIncomingStats& source = entry.second; EmulatedNetworkIncomingStats& in_stats = diff --git a/test/network/network_emulation_unittest.cc b/test/network/network_emulation_unittest.cc index fa10b1e4d5..ff8539007d 100644 --- a/test/network/network_emulation_unittest.cc +++ b/test/network/network_emulation_unittest.cc @@ -29,6 +29,8 @@ namespace webrtc { namespace test { namespace { +using ::testing::ElementsAreArray; + constexpr TimeDelta kNetworkPacketWaitTimeout = TimeDelta::Millis(100); constexpr TimeDelta kStatsWaitTimeout = TimeDelta::Seconds(1); constexpr int kOverheadIpv4Udp = 20 + 8; @@ -248,6 +250,8 @@ TEST(NetworkEmulationManagerTest, Run) { nt1->GetStats([&](EmulatedNetworkStats st) { EXPECT_EQ(st.packets_sent, 2000l); EXPECT_EQ(st.bytes_sent.bytes(), single_packet_size * 2000l); + EXPECT_THAT(st.local_addresses, + ElementsAreArray({alice_endpoint->GetPeerLocalAddress()})); EXPECT_EQ(st.PacketsReceived(), 2000l); EXPECT_EQ(st.BytesReceived().bytes(), single_packet_size * 2000l); EXPECT_EQ(st.PacketsDropped(), 0l); @@ -270,6 +274,8 @@ TEST(NetworkEmulationManagerTest, Run) { nt2->GetStats([&](EmulatedNetworkStats st) { EXPECT_EQ(st.packets_sent, 2000l); EXPECT_EQ(st.bytes_sent.bytes(), single_packet_size * 2000l); + EXPECT_THAT(st.local_addresses, + ElementsAreArray({bob_endpoint->GetPeerLocalAddress()})); EXPECT_EQ(st.PacketsReceived(), 2000l); EXPECT_EQ(st.BytesReceived().bytes(), single_packet_size * 2000l); EXPECT_EQ(st.PacketsDropped(), 0l); |