aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/test/network_emulation/network_emulation_interfaces.h5
-rw-r--r--test/network/network_emulation.cc4
-rw-r--r--test/network/network_emulation_unittest.cc6
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);