Add public API for NetworkEmulationManager

Bug: webrtc:10138
Change-Id: Ib5f8e95761813bd117a5e29adbc6822a5c6c73bd
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/126122
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27146}
This commit is contained in:
Artem Titov 2019-03-15 15:00:37 +01:00 committed by Commit Bot
parent 69008a8718
commit 7bf8c7f8cc
15 changed files with 257 additions and 89 deletions

View File

@ -219,6 +219,20 @@ if (rtc_include_tests) {
"//third_party/abseil-cpp/absl/memory",
]
}
rtc_source_set("create_network_emulation_manager_api") {
visibility = [ "*" ]
testonly = true
sources = [
"test/create_network_emulation_manager.cc",
"test/create_network_emulation_manager.h",
]
deps = [
":network_emulation_manager_api",
"../test/scenario/network:emulated_network",
"//third_party/abseil-cpp/absl/memory:memory",
]
}
}
rtc_source_set("libjingle_logging_api") {
@ -305,6 +319,17 @@ rtc_source_set("simulated_network_api") {
]
}
rtc_source_set("network_emulation_manager_api") {
visibility = [ "*" ]
sources = [
"test/network_emulation_manager.h",
]
deps = [
":simulated_network_api",
"../rtc_base:rtc_base",
]
}
rtc_source_set("fec_controller_api") {
visibility = [ "*" ]
sources = [

View File

@ -14,4 +14,8 @@ specific_include_rules = {
"+rtc_base/thread.h",
"+rtc_base/thread_checker.h",
],
"network_emulation_manager\.h": [
"+rtc_base/thread.h",
"+rtc_base/network.h",
],
}

View File

@ -0,0 +1,23 @@
/*
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "api/test/create_network_emulation_manager.h"
#include "absl/memory/memory.h"
#include "test/scenario/network/network_emulation_manager.h"
namespace webrtc {
std::unique_ptr<NetworkEmulationManager> CreateNetworkEmulationManager() {
return absl::make_unique<test::NetworkEmulationManagerImpl>();
}
} // namespace webrtc

View File

@ -0,0 +1,25 @@
/*
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef API_TEST_CREATE_NETWORK_EMULATION_MANAGER_H_
#define API_TEST_CREATE_NETWORK_EMULATION_MANAGER_H_
#include <memory>
#include "api/test/network_emulation_manager.h"
namespace webrtc {
std::unique_ptr<NetworkEmulationManager> CreateNetworkEmulationManager();
} // namespace webrtc
#endif // API_TEST_CREATE_NETWORK_EMULATION_MANAGER_H_

View File

@ -0,0 +1,106 @@
/*
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef API_TEST_NETWORK_EMULATION_MANAGER_H_
#define API_TEST_NETWORK_EMULATION_MANAGER_H_
#include <memory>
#include <vector>
#include "api/test/simulated_network.h"
#include "rtc_base/network.h"
#include "rtc_base/thread.h"
namespace webrtc {
// This API is still in development and can be changed without prior notice.
// These classes are forward declared here, because they used as handles, to
// make it possible for client code to operate with these abstractions and build
// required network configuration. With forward declaration here implementation
// is more readable, than with interfaces approach and cause user needn't any
// API methods on these abstractions it is acceptable here.
// EmulatedNetworkNode is an abstraction for some network in the real world,
// like 3G network between peers, or Wi-Fi for one peer and LTE for another.
// Multiple networks can be joined into chain emulating a network path from
// one peer to another.
class EmulatedNetworkNode;
// EmulatedEndpoint is and abstraction for network interface on device.
class EmulatedEndpoint;
// EmulatedRoute is handle for single route from one network interface on one
// peer device to another network interface on another peer device.
class EmulatedRoute;
struct EmulatedEndpointConfig {
enum class IpAddressFamily { kIpv4, kIpv6 };
IpAddressFamily generated_ip_family = IpAddressFamily::kIpv4;
// If specified will be used as IP address for endpoint node. Must be unique
// among all created nodes.
absl::optional<rtc::IPAddress> ip;
};
// Provides an API for creating and configuring emulated network layer.
// All objects returned by this API are owned by NetworkEmulationManager itself
// and will be deleted when manager will be deleted.
class NetworkEmulationManager {
public:
virtual ~NetworkEmulationManager() = default;
// Creates an emulated network node, which represents single network in
// the emulated network layer.
virtual EmulatedNetworkNode* CreateEmulatedNode(
std::unique_ptr<NetworkBehaviorInterface> network_behavior) = 0;
// Creates an emulated endpoint, which represents single network interface on
// the peer's device.
virtual EmulatedEndpoint* CreateEndpoint(EmulatedEndpointConfig config) = 0;
// Creates a route between endpoints going through specified network nodes.
// This route is single direction only and describe how traffic that was
// sent by network interface |from| have to be delivered to the network
// interface |to|. Return object can be used to remove created route.
//
// Assume there are endpoints E1, E2 and E3 and network nodes A, B, C and D.
// Also assume, that there is a route constructed via A, B and C like this:
// E1 -> A -> B -> C -> E2. In such case:
// * Caller mustn't use A, B and C in any route, that is leading to E2.
// * If caller will then create a new route E1 -> D -> E3, then first
// route will be corrupted, so if caller want to do this, first route
// should be deleted by ClearRoute(...) and then a new one should be
// created.
// * Caller can use A, B or C for any other routes.
// * Caller can create other routes leading to E2.
virtual EmulatedRoute* CreateRoute(
EmulatedEndpoint* from,
const std::vector<EmulatedNetworkNode*>& via_nodes,
EmulatedEndpoint* to) = 0;
// Removes route previously created by CreateRoute(...).
// Caller mustn't call this function with route, that have been already
// removed earlier.
virtual void ClearRoute(EmulatedRoute* route) = 0;
// Creates rtc::Thread that should be used as network thread for peer
// connection. Created thread contains special rtc::SocketServer inside it
// to enable correct integration between peer connection and emulated network
// layer.
virtual rtc::Thread* CreateNetworkThread(
const std::vector<EmulatedEndpoint*>& endpoints) = 0;
// Creates rtc::NetworkManager that should be used inside
// cricket::PortAllocator for peer connection to provide correct list of
// network interfaces, that exists in emulated network later.
virtual rtc::NetworkManager* CreateNetworkManager(
const std::vector<EmulatedEndpoint*>& endpoints) = 0;
};
} // namespace webrtc
#endif // API_TEST_NETWORK_EMULATION_MANAGER_H_

View File

@ -264,7 +264,9 @@ if (rtc_include_tests) {
":default_audio_quality_analyzer",
":default_video_quality_analyzer",
"../../../api:callfactory_api",
"../../../api:create_network_emulation_manager_api",
"../../../api:libjingle_peerconnection_api",
"../../../api:network_emulation_manager_api",
"../../../api:scoped_refptr",
"../../../api:simulated_network_api",
"../../../api/audio_codecs:builtin_audio_decoder_factory",
@ -284,7 +286,6 @@ if (rtc_include_tests) {
"../../../rtc_base:rtc_event",
"../../../test:fileutils",
"../../../test:test_support",
"../../../test/scenario/network:emulated_network",
"api:create_peerconnection_quality_test_fixture",
"api:peer_connection_quality_test_fixture_api",
"//third_party/abseil-cpp/absl/memory:memory",

View File

@ -12,14 +12,14 @@
#include <memory>
#include "absl/memory/memory.h"
#include "api/test/create_network_emulation_manager.h"
#include "api/test/network_emulation_manager.h"
#include "call/simulated_network.h"
#include "test/gtest.h"
#include "test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.h"
#include "test/pc/e2e/analyzer/video/default_video_quality_analyzer.h"
#include "test/pc/e2e/api/create_peerconnection_quality_test_fixture.h"
#include "test/pc/e2e/api/peerconnection_quality_test_fixture.h"
#include "test/scenario/network/network_emulation.h"
#include "test/scenario/network/network_emulation_manager.h"
#include "test/testsupport/file_utils.h"
namespace webrtc {
@ -61,35 +61,36 @@ TEST(PeerConnectionE2EQualityTestSmokeTest, RunWithEmulatedNetwork) {
bob_params->audio_config = AudioConfig();
// Setup emulated network
NetworkEmulationManager network_emulation_manager;
std::unique_ptr<NetworkEmulationManager> network_emulation_manager =
CreateNetworkEmulationManager();
EmulatedNetworkNode* alice_node =
network_emulation_manager.CreateEmulatedNode(
network_emulation_manager->CreateEmulatedNode(
absl::make_unique<SimulatedNetwork>(BuiltInNetworkBehaviorConfig()));
EmulatedNetworkNode* bob_node = network_emulation_manager.CreateEmulatedNode(
EmulatedNetworkNode* bob_node = network_emulation_manager->CreateEmulatedNode(
absl::make_unique<SimulatedNetwork>(BuiltInNetworkBehaviorConfig()));
EmulatedEndpoint* alice_endpoint =
network_emulation_manager.CreateEndpoint(EmulatedEndpointConfig());
network_emulation_manager->CreateEndpoint(EmulatedEndpointConfig());
EmulatedEndpoint* bob_endpoint =
network_emulation_manager.CreateEndpoint(EmulatedEndpointConfig());
network_emulation_manager.CreateRoute(alice_endpoint, {alice_node},
bob_endpoint);
network_emulation_manager.CreateRoute(bob_endpoint, {bob_node},
alice_endpoint);
network_emulation_manager->CreateEndpoint(EmulatedEndpointConfig());
network_emulation_manager->CreateRoute(alice_endpoint, {alice_node},
bob_endpoint);
network_emulation_manager->CreateRoute(bob_endpoint, {bob_node},
alice_endpoint);
rtc::Thread* alice_network_thread =
network_emulation_manager.CreateNetworkThread({alice_endpoint});
network_emulation_manager->CreateNetworkThread({alice_endpoint});
rtc::Thread* bob_network_thread =
network_emulation_manager.CreateNetworkThread({bob_endpoint});
network_emulation_manager->CreateNetworkThread({bob_endpoint});
// Setup components. We need to provide rtc::NetworkManager compatible with
// emulated network layer.
rtc::NetworkManager* alice_network_manager =
network_emulation_manager.CreateNetworkManager({alice_endpoint});
network_emulation_manager->CreateNetworkManager({alice_endpoint});
auto alice_components = absl::make_unique<InjectableComponents>(
alice_network_thread, alice_network_manager);
rtc::NetworkManager* bob_network_manager =
network_emulation_manager.CreateNetworkManager({bob_endpoint});
network_emulation_manager->CreateNetworkManager({bob_endpoint});
auto bob_components = absl::make_unique<InjectableComponents>(
bob_network_thread, bob_network_manager);

View File

@ -26,6 +26,7 @@ rtc_source_set("emulated_network") {
]
deps = [
"../:column_printer",
"../../../api:network_emulation_manager_api",
"../../../api:simulated_network_api",
"../../../api/units:data_rate",
"../../../api/units:data_size",

View File

@ -63,7 +63,7 @@ class CountingBehavior : public NetworkBehaviorInterface {
} // namespace
TEST(CrossTrafficTest, TriggerPacketBurst) {
NetworkEmulationManager network_manager;
NetworkEmulationManagerImpl network_manager;
std::unique_ptr<CountingBehavior> behavior =
absl::make_unique<CountingBehavior>();
@ -86,7 +86,7 @@ TEST(CrossTrafficTest, TriggerPacketBurst) {
}
TEST(CrossTrafficTest, PulsedPeaksCrossTraffic) {
NetworkEmulationManager network_manager;
NetworkEmulationManagerImpl network_manager;
std::unique_ptr<CountingBehavior> behavior =
absl::make_unique<CountingBehavior>();
@ -119,7 +119,7 @@ TEST(CrossTrafficTest, PulsedPeaksCrossTraffic) {
}
TEST(CrossTrafficTest, RandomWalkCrossTraffic) {
NetworkEmulationManager network_manager;
NetworkEmulationManagerImpl network_manager;
std::unique_ptr<CountingBehavior> behavior =
absl::make_unique<CountingBehavior>();

View File

@ -18,7 +18,6 @@
#include "rtc_base/logging.h"
namespace webrtc {
namespace test {
EmulatedIpPacket::EmulatedIpPacket(const rtc::SocketAddress& from,
const rtc::SocketAddress& to,
@ -235,5 +234,4 @@ void EmulatedEndpoint::SetConnectedEndpointId(uint64_t endpoint_id) {
connected_endpoint_id_ = endpoint_id;
}
} // namespace test
} // namespace webrtc

View File

@ -31,6 +31,12 @@
namespace webrtc {
namespace test {
// Forward declare NetworkEmulationManagerImpl for friend access from
// EmulatedEndpoint.
class NetworkEmulationManagerImpl;
} // namespace test
struct EmulatedIpPacket {
public:
EmulatedIpPacket(const rtc::SocketAddress& from,
@ -150,7 +156,7 @@ class EmulatedEndpoint : public EmulatedNetworkReceiverInterface {
void OnPacketReceived(EmulatedIpPacket packet) override;
protected:
friend class NetworkEmulationManager;
friend class test::NetworkEmulationManagerImpl;
EmulatedNetworkNode* GetSendNode() const;
void SetConnectedEndpointId(uint64_t endpoint_id);
@ -187,7 +193,6 @@ class EmulatedRoute {
bool active;
};
} // namespace test
} // namespace webrtc
#endif // TEST_SCENARIO_NETWORK_NETWORK_EMULATION_H_

View File

@ -30,18 +30,7 @@ constexpr uint32_t kMaxIPv4Address = 0xC0A8FFFF;
} // namespace
EmulatedEndpointConfig::EmulatedEndpointConfig() = default;
EmulatedEndpointConfig::~EmulatedEndpointConfig() = default;
EmulatedEndpointConfig::EmulatedEndpointConfig(EmulatedEndpointConfig&) =
default;
EmulatedEndpointConfig& EmulatedEndpointConfig::operator=(
EmulatedEndpointConfig&) = default;
EmulatedEndpointConfig::EmulatedEndpointConfig(EmulatedEndpointConfig&&) =
default;
EmulatedEndpointConfig& EmulatedEndpointConfig::operator=(
EmulatedEndpointConfig&&) = default;
NetworkEmulationManager::NetworkEmulationManager()
NetworkEmulationManagerImpl::NetworkEmulationManagerImpl()
: clock_(Clock::GetRealTimeClock()),
next_node_id_(1),
next_ip4_address_(kMinIPv4Address),
@ -55,9 +44,9 @@ NetworkEmulationManager::NetworkEmulationManager()
// TODO(srte): Ensure that any pending task that must be run for consistency
// (such as stats collection tasks) are not cancelled when the task queue is
// destroyed.
NetworkEmulationManager::~NetworkEmulationManager() = default;
NetworkEmulationManagerImpl::~NetworkEmulationManagerImpl() = default;
EmulatedNetworkNode* NetworkEmulationManager::CreateEmulatedNode(
EmulatedNetworkNode* NetworkEmulationManagerImpl::CreateEmulatedNode(
std::unique_ptr<NetworkBehaviorInterface> network_behavior) {
auto node =
absl::make_unique<EmulatedNetworkNode>(std::move(network_behavior));
@ -65,14 +54,14 @@ EmulatedNetworkNode* NetworkEmulationManager::CreateEmulatedNode(
struct Closure {
void operator()() { manager->network_nodes_.push_back(std::move(node)); }
NetworkEmulationManager* manager;
NetworkEmulationManagerImpl* manager;
std::unique_ptr<EmulatedNetworkNode> node;
};
task_queue_.PostTask(Closure{this, std::move(node)});
return out;
}
EmulatedEndpoint* NetworkEmulationManager::CreateEndpoint(
EmulatedEndpoint* NetworkEmulationManagerImpl::CreateEndpoint(
EmulatedEndpointConfig config) {
absl::optional<rtc::IPAddress> ip = config.ip;
if (!ip) {
@ -97,9 +86,9 @@ EmulatedEndpoint* NetworkEmulationManager::CreateEndpoint(
return out;
}
EmulatedRoute* NetworkEmulationManager::CreateRoute(
EmulatedRoute* NetworkEmulationManagerImpl::CreateRoute(
EmulatedEndpoint* from,
std::vector<EmulatedNetworkNode*> via_nodes,
const std::vector<EmulatedNetworkNode*>& via_nodes,
EmulatedEndpoint* to) {
// Because endpoint has no send node by default at least one should be
// provided here.
@ -121,7 +110,7 @@ EmulatedRoute* NetworkEmulationManager::CreateRoute(
return out;
}
void NetworkEmulationManager::ClearRoute(EmulatedRoute* route) {
void NetworkEmulationManagerImpl::ClearRoute(EmulatedRoute* route) {
RTC_CHECK(route->active) << "Route already cleared";
// Remove receiver from intermediate nodes.
@ -137,8 +126,8 @@ void NetworkEmulationManager::ClearRoute(EmulatedRoute* route) {
route->active = false;
}
TrafficRoute* NetworkEmulationManager::CreateTrafficRoute(
std::vector<EmulatedNetworkNode*> via_nodes) {
TrafficRoute* NetworkEmulationManagerImpl::CreateTrafficRoute(
const std::vector<EmulatedNetworkNode*>& via_nodes) {
RTC_CHECK(!via_nodes.empty());
EmulatedEndpoint* endpoint = CreateEndpoint(EmulatedEndpointConfig());
@ -157,7 +146,8 @@ TrafficRoute* NetworkEmulationManager::CreateTrafficRoute(
return out;
}
RandomWalkCrossTraffic* NetworkEmulationManager::CreateRandomWalkCrossTraffic(
RandomWalkCrossTraffic*
NetworkEmulationManagerImpl::CreateRandomWalkCrossTraffic(
TrafficRoute* traffic_route,
RandomWalkConfig config) {
auto traffic = absl::make_unique<RandomWalkCrossTraffic>(std::move(config),
@ -167,14 +157,15 @@ RandomWalkCrossTraffic* NetworkEmulationManager::CreateRandomWalkCrossTraffic(
void operator()() {
manager->random_cross_traffics_.push_back(std::move(traffic));
}
NetworkEmulationManager* manager;
NetworkEmulationManagerImpl* manager;
std::unique_ptr<RandomWalkCrossTraffic> traffic;
};
task_queue_.PostTask(Closure{this, std::move(traffic)});
return out;
}
PulsedPeaksCrossTraffic* NetworkEmulationManager::CreatePulsedPeaksCrossTraffic(
PulsedPeaksCrossTraffic*
NetworkEmulationManagerImpl::CreatePulsedPeaksCrossTraffic(
TrafficRoute* traffic_route,
PulsedPeaksConfig config) {
auto traffic = absl::make_unique<PulsedPeaksCrossTraffic>(std::move(config),
@ -184,15 +175,15 @@ PulsedPeaksCrossTraffic* NetworkEmulationManager::CreatePulsedPeaksCrossTraffic(
void operator()() {
manager->pulsed_cross_traffics_.push_back(std::move(traffic));
}
NetworkEmulationManager* manager;
NetworkEmulationManagerImpl* manager;
std::unique_ptr<PulsedPeaksCrossTraffic> traffic;
};
task_queue_.PostTask(Closure{this, std::move(traffic)});
return out;
}
rtc::Thread* NetworkEmulationManager::CreateNetworkThread(
std::vector<EmulatedEndpoint*> endpoints) {
rtc::Thread* NetworkEmulationManagerImpl::CreateNetworkThread(
const std::vector<EmulatedEndpoint*>& endpoints) {
FakeNetworkSocketServer* socket_server = CreateSocketServer(endpoints);
std::unique_ptr<rtc::Thread> network_thread =
absl::make_unique<rtc::Thread>(socket_server);
@ -204,8 +195,8 @@ rtc::Thread* NetworkEmulationManager::CreateNetworkThread(
return out;
}
rtc::NetworkManager* NetworkEmulationManager::CreateNetworkManager(
std::vector<EmulatedEndpoint*> endpoints) {
rtc::NetworkManager* NetworkEmulationManagerImpl::CreateNetworkManager(
const std::vector<EmulatedEndpoint*>& endpoints) {
auto network_manager = absl::make_unique<rtc::FakeNetworkManager>();
for (auto* endpoint : endpoints) {
network_manager->AddInterface(
@ -216,8 +207,8 @@ rtc::NetworkManager* NetworkEmulationManager::CreateNetworkManager(
return out;
}
FakeNetworkSocketServer* NetworkEmulationManager::CreateSocketServer(
std::vector<EmulatedEndpoint*> endpoints) {
FakeNetworkSocketServer* NetworkEmulationManagerImpl::CreateSocketServer(
const std::vector<EmulatedEndpoint*>& endpoints) {
auto socket_server =
absl::make_unique<FakeNetworkSocketServer>(clock_, endpoints);
FakeNetworkSocketServer* out = socket_server.get();
@ -225,7 +216,8 @@ FakeNetworkSocketServer* NetworkEmulationManager::CreateSocketServer(
return out;
}
absl::optional<rtc::IPAddress> NetworkEmulationManager::GetNextIPv4Address() {
absl::optional<rtc::IPAddress>
NetworkEmulationManagerImpl::GetNextIPv4Address() {
uint32_t addresses_count = kMaxIPv4Address - kMinIPv4Address;
for (uint32_t i = 0; i < addresses_count; i++) {
rtc::IPAddress ip(next_ip4_address_);
@ -241,7 +233,7 @@ absl::optional<rtc::IPAddress> NetworkEmulationManager::GetNextIPv4Address() {
return absl::nullopt;
}
void NetworkEmulationManager::ProcessNetworkPackets() {
void NetworkEmulationManagerImpl::ProcessNetworkPackets() {
Timestamp current_time = Now();
for (auto& traffic : random_cross_traffics_) {
traffic->Process(current_time);
@ -254,7 +246,7 @@ void NetworkEmulationManager::ProcessNetworkPackets() {
}
}
Timestamp NetworkEmulationManager::Now() const {
Timestamp NetworkEmulationManagerImpl::Now() const {
return Timestamp::us(clock_->TimeInMicroseconds());
}

View File

@ -15,6 +15,7 @@
#include <utility>
#include <vector>
#include "api/test/network_emulation_manager.h"
#include "api/test/simulated_network.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
@ -32,38 +33,23 @@
namespace webrtc {
namespace test {
struct EmulatedEndpointConfig {
enum class IpAddressFamily { kIpv4, kIpv6 };
EmulatedEndpointConfig();
~EmulatedEndpointConfig();
EmulatedEndpointConfig(EmulatedEndpointConfig&);
EmulatedEndpointConfig& operator=(EmulatedEndpointConfig&);
EmulatedEndpointConfig(EmulatedEndpointConfig&&);
EmulatedEndpointConfig& operator=(EmulatedEndpointConfig&&);
IpAddressFamily generated_ip_family = IpAddressFamily::kIpv4;
// If specified will be used as IP address for endpoint node. Must be unique
// among all created nodes.
absl::optional<rtc::IPAddress> ip;
};
class NetworkEmulationManager {
class NetworkEmulationManagerImpl : public NetworkEmulationManager {
public:
NetworkEmulationManager();
~NetworkEmulationManager();
NetworkEmulationManagerImpl();
~NetworkEmulationManagerImpl();
EmulatedNetworkNode* CreateEmulatedNode(
std::unique_ptr<NetworkBehaviorInterface> network_behavior);
std::unique_ptr<NetworkBehaviorInterface> network_behavior) override;
EmulatedEndpoint* CreateEndpoint(EmulatedEndpointConfig config);
EmulatedEndpoint* CreateEndpoint(EmulatedEndpointConfig config) override;
EmulatedRoute* CreateRoute(EmulatedEndpoint* from,
std::vector<EmulatedNetworkNode*> via_nodes,
EmulatedEndpoint* to);
void ClearRoute(EmulatedRoute* route);
const std::vector<EmulatedNetworkNode*>& via_nodes,
EmulatedEndpoint* to) override;
void ClearRoute(EmulatedRoute* route) override;
TrafficRoute* CreateTrafficRoute(std::vector<EmulatedNetworkNode*> via_nodes);
TrafficRoute* CreateTrafficRoute(
const std::vector<EmulatedNetworkNode*>& via_nodes);
RandomWalkCrossTraffic* CreateRandomWalkCrossTraffic(
TrafficRoute* traffic_route,
RandomWalkConfig config);
@ -71,13 +57,14 @@ class NetworkEmulationManager {
TrafficRoute* traffic_route,
PulsedPeaksConfig config);
rtc::Thread* CreateNetworkThread(std::vector<EmulatedEndpoint*> endpoints);
rtc::Thread* CreateNetworkThread(
const std::vector<EmulatedEndpoint*>& endpoints) override;
rtc::NetworkManager* CreateNetworkManager(
std::vector<EmulatedEndpoint*> endpoints);
const std::vector<EmulatedEndpoint*>& endpoints) override;
private:
FakeNetworkSocketServer* CreateSocketServer(
std::vector<EmulatedEndpoint*> endpoints);
const std::vector<EmulatedEndpoint*>& endpoints);
absl::optional<rtc::IPAddress> GetNextIPv4Address();
void ProcessNetworkPackets();
Timestamp Now() const;

View File

@ -100,7 +100,7 @@ TEST(NetworkEmulationManagerPCTest, Run) {
signaling_thread->Start();
// Setup emulated network
NetworkEmulationManager emulation;
NetworkEmulationManagerImpl emulation;
EmulatedNetworkNode* alice_node = emulation.CreateEmulatedNode(
absl::make_unique<SimulatedNetwork>(BuiltInNetworkBehaviorConfig()));

View File

@ -58,7 +58,7 @@ class SocketReader : public sigslot::has_slots<> {
};
TEST(NetworkEmulationManagerTest, GeneratedIpv4AddressDoesNotCollide) {
NetworkEmulationManager network_manager;
NetworkEmulationManagerImpl network_manager;
std::set<rtc::IPAddress> ips;
EmulatedEndpointConfig config;
config.generated_ip_family = EmulatedEndpointConfig::IpAddressFamily::kIpv4;
@ -71,7 +71,7 @@ TEST(NetworkEmulationManagerTest, GeneratedIpv4AddressDoesNotCollide) {
}
TEST(NetworkEmulationManagerTest, GeneratedIpv6AddressDoesNotCollide) {
NetworkEmulationManager network_manager;
NetworkEmulationManagerImpl network_manager;
std::set<rtc::IPAddress> ips;
EmulatedEndpointConfig config;
config.generated_ip_family = EmulatedEndpointConfig::IpAddressFamily::kIpv6;
@ -84,7 +84,7 @@ TEST(NetworkEmulationManagerTest, GeneratedIpv6AddressDoesNotCollide) {
}
TEST(NetworkEmulationManagerTest, Run) {
NetworkEmulationManager network_manager;
NetworkEmulationManagerImpl network_manager;
EmulatedNetworkNode* alice_node = network_manager.CreateEmulatedNode(
absl::make_unique<SimulatedNetwork>(BuiltInNetworkBehaviorConfig()));