mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
Introduce a mode that lets NetworkEmulationManager ignore DTLS handshake sizes.
Bug: b/169531206 Change-Id: I02c19385ff7078944f7509ecc07358b4315f7b08 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/350181 Commit-Queue: Sergey Sukhanov <sergeysu@webrtc.org> Reviewed-by: Victor Boivie <boivie@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Per Kjellander <perkj@webrtc.org> Cr-Commit-Position: refs/heads/main@{#42261}
This commit is contained in:
parent
f20ed3e8ad
commit
26a082ce36
18 changed files with 123 additions and 54 deletions
|
@ -12,18 +12,26 @@
|
|||
#include "api/test/create_network_emulation_manager.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "api/field_trials_view.h"
|
||||
#include "test/network/network_emulation_manager.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
std::unique_ptr<NetworkEmulationManager> CreateNetworkEmulationManager(
|
||||
NetworkEmulationManagerConfig config) {
|
||||
return std::make_unique<test::NetworkEmulationManagerImpl>(std::move(config));
|
||||
}
|
||||
|
||||
std::unique_ptr<NetworkEmulationManager> CreateNetworkEmulationManager(
|
||||
TimeMode time_mode,
|
||||
EmulatedNetworkStatsGatheringMode stats_gathering_mode,
|
||||
const FieldTrialsView* field_trials) {
|
||||
return std::make_unique<test::NetworkEmulationManagerImpl>(
|
||||
time_mode, stats_gathering_mode, field_trials);
|
||||
return CreateNetworkEmulationManager(
|
||||
{.time_mode = time_mode,
|
||||
.stats_gathering_mode = stats_gathering_mode,
|
||||
.field_trials = field_trials});
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
|
|
@ -20,7 +20,12 @@ namespace webrtc {
|
|||
|
||||
// Returns a non-null NetworkEmulationManager instance.
|
||||
std::unique_ptr<NetworkEmulationManager> CreateNetworkEmulationManager(
|
||||
TimeMode time_mode = TimeMode::kRealTime,
|
||||
NetworkEmulationManagerConfig config = NetworkEmulationManagerConfig());
|
||||
|
||||
[[deprecated("Use version with NetworkEmulationManagerConfig)")]]
|
||||
std::unique_ptr<NetworkEmulationManager>
|
||||
CreateNetworkEmulationManager(
|
||||
TimeMode time_mode,
|
||||
EmulatedNetworkStatsGatheringMode stats_gathering_mode =
|
||||
EmulatedNetworkStatsGatheringMode::kDefault,
|
||||
const FieldTrialsView* field_trials = nullptr);
|
||||
|
|
|
@ -160,6 +160,26 @@ bool AbslParseFlag(absl::string_view text, TimeMode* mode, std::string* error);
|
|||
// `mode`.
|
||||
std::string AbslUnparseFlag(TimeMode mode);
|
||||
|
||||
// The construction-time configuration options for NetworkEmulationManager.
|
||||
struct NetworkEmulationManagerConfig {
|
||||
// The mode of the underlying time controller.
|
||||
TimeMode time_mode = TimeMode::kRealTime;
|
||||
// The mode that determines the set of metrics to collect into
|
||||
// `EmulatedNetworkStats` and `EmulatedNetworkNodeStats`.
|
||||
EmulatedNetworkStatsGatheringMode stats_gathering_mode =
|
||||
EmulatedNetworkStatsGatheringMode::kDefault;
|
||||
// Field trials that can alter the behavior of NetworkEmulationManager.
|
||||
const FieldTrialsView* field_trials = nullptr;
|
||||
// If this flag is set, NetworkEmulationManager ignores the sizes of peers'
|
||||
// DTLS handshake packets when determining when to let the packets through
|
||||
// a constrained emulated network. Actual hanshake's packet size is ignored
|
||||
// and a hardcoded fake size is used to compute packet's use of link capacity.
|
||||
// This is useful for tests that require deterministic packets scheduling
|
||||
// timing-wise even when the sizes of DTLS hadshake packets are not
|
||||
// deterministic. This mode make sense only together with the simulated time.
|
||||
bool fake_dtls_handshake_sizes = false;
|
||||
};
|
||||
|
||||
// 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.
|
||||
|
|
|
@ -326,7 +326,7 @@ class DcSctpSocketNetworkTest : public testing::Test {
|
|||
DcSctpSocketNetworkTest()
|
||||
: options_(MakeOptionsForTest()),
|
||||
emulation_(webrtc::CreateNetworkEmulationManager(
|
||||
webrtc::TimeMode::kSimulated)) {}
|
||||
{.time_mode = webrtc::TimeMode::kSimulated})) {}
|
||||
|
||||
void MakeNetwork(const webrtc::BuiltInNetworkBehaviorConfig& config) {
|
||||
webrtc::EmulatedEndpoint* endpoint_a =
|
||||
|
|
|
@ -316,7 +316,7 @@ TEST_P(SvcTest, ScalabilityModeSupported) {
|
|||
}
|
||||
test::ScopedFieldTrials override_trials(AppendFieldTrials(trials));
|
||||
std::unique_ptr<NetworkEmulationManager> network_emulation_manager =
|
||||
CreateNetworkEmulationManager(TimeMode::kSimulated);
|
||||
CreateNetworkEmulationManager({.time_mode = TimeMode::kSimulated});
|
||||
auto analyzer = std::make_unique<SvcVideoQualityAnalyzer>(
|
||||
network_emulation_manager->time_controller()->GetClock());
|
||||
SvcVideoQualityAnalyzer* analyzer_ptr = analyzer.get();
|
||||
|
|
|
@ -125,8 +125,7 @@ TEST(CrossTrafficTest, RandomWalkCrossTraffic) {
|
|||
}
|
||||
|
||||
TEST(TcpMessageRouteTest, DeliveredOnLossyNetwork) {
|
||||
NetworkEmulationManagerImpl net(TimeMode::kSimulated,
|
||||
EmulatedNetworkStatsGatheringMode::kDefault);
|
||||
NetworkEmulationManagerImpl net({.time_mode = TimeMode::kSimulated});
|
||||
BuiltInNetworkBehaviorConfig send;
|
||||
// 800 kbps means that the 100 kB message would be delivered in ca 1 second
|
||||
// under ideal conditions and no overhead.
|
||||
|
|
|
@ -12,13 +12,14 @@
|
|||
#include "absl/memory/memory.h"
|
||||
#include "api/transport/network_types.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "test/network/network_emulation_manager.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
FeedbackGeneratorImpl::FeedbackGeneratorImpl(
|
||||
FeedbackGeneratorImpl::Config config)
|
||||
: conf_(config),
|
||||
net_(TimeMode::kSimulated, EmulatedNetworkStatsGatheringMode::kDefault),
|
||||
net_({.time_mode = TimeMode::kSimulated}),
|
||||
send_link_{new SimulatedNetwork(conf_.send_link)},
|
||||
ret_link_{new SimulatedNetwork(conf_.return_link)},
|
||||
route_(this,
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#include "test/network/network_emulation.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
|
@ -51,6 +53,17 @@ EmulatedNetworkIncomingStats GetOverallIncomingStats(
|
|||
return builder.Build();
|
||||
}
|
||||
|
||||
bool IsDtlsHandshakePacket(const uint8_t* payload, size_t payload_size) {
|
||||
if (payload_size < 14) {
|
||||
return false;
|
||||
}
|
||||
// https://tools.ietf.org/html/rfc6347#section-4.1
|
||||
// https://tools.ietf.org/html/rfc6347#section-4.2.2
|
||||
// https://tools.ietf.org/html/rfc5246#section-7.4
|
||||
return payload[0] == 22 &&
|
||||
(payload[13] == 1 || payload[13] == 2 || payload[13] == 11);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
EmulatedNetworkOutgoingStatsBuilder::EmulatedNetworkOutgoingStatsBuilder(
|
||||
|
@ -311,16 +324,31 @@ EmulatedNetworkNodeStats EmulatedNetworkNodeStatsBuilder::Build() const {
|
|||
return stats_;
|
||||
}
|
||||
|
||||
size_t LinkEmulation::GetPacketSizeForEmulation(
|
||||
const EmulatedIpPacket& packet) const {
|
||||
if (fake_dtls_handshake_sizes_ &&
|
||||
IsDtlsHandshakePacket(packet.data.cdata(), packet.data.size())) {
|
||||
// DTLS handshake packets can not have deterministic size unless
|
||||
// the OpenSSL/BoringSSL is configured to have deterministic random,
|
||||
// which is hard. The workaround is - conditionally ignore the actual
|
||||
// size and hardcode the value order of typical handshake packet size.
|
||||
return 1000;
|
||||
}
|
||||
return packet.ip_packet_size();
|
||||
}
|
||||
|
||||
LinkEmulation::LinkEmulation(
|
||||
Clock* clock,
|
||||
absl::Nonnull<TaskQueueBase*> task_queue,
|
||||
std::unique_ptr<NetworkBehaviorInterface> network_behavior,
|
||||
EmulatedNetworkReceiverInterface* receiver,
|
||||
EmulatedNetworkStatsGatheringMode stats_gathering_mode)
|
||||
EmulatedNetworkStatsGatheringMode stats_gathering_mode,
|
||||
bool fake_dtls_handshake_sizes)
|
||||
: clock_(clock),
|
||||
task_queue_(task_queue),
|
||||
network_behavior_(std::move(network_behavior)),
|
||||
receiver_(receiver),
|
||||
fake_dtls_handshake_sizes_(fake_dtls_handshake_sizes),
|
||||
stats_builder_(stats_gathering_mode) {
|
||||
task_queue_->PostTask([&]() {
|
||||
RTC_DCHECK_RUN_ON(task_queue_);
|
||||
|
@ -336,8 +364,9 @@ void LinkEmulation::OnPacketReceived(EmulatedIpPacket packet) {
|
|||
RTC_DCHECK_RUN_ON(task_queue_);
|
||||
|
||||
uint64_t packet_id = next_packet_id_++;
|
||||
bool sent = network_behavior_->EnqueuePacket(PacketInFlightInfo(
|
||||
packet.ip_packet_size(), packet.arrival_time.us(), packet_id));
|
||||
bool sent = network_behavior_->EnqueuePacket(
|
||||
PacketInFlightInfo(GetPacketSizeForEmulation(packet),
|
||||
packet.arrival_time.us(), packet_id));
|
||||
if (sent) {
|
||||
packets_.emplace_back(StoredPacket{.id = packet_id,
|
||||
.sent_time = clock_->CurrentTime(),
|
||||
|
@ -372,7 +401,7 @@ void LinkEmulation::Process(Timestamp at_time) {
|
|||
packet->removed = true;
|
||||
stats_builder_.AddPacketTransportTime(
|
||||
clock_->CurrentTime() - packet->sent_time,
|
||||
packet->packet.ip_packet_size());
|
||||
GetPacketSizeForEmulation(packet->packet));
|
||||
|
||||
if (delivery_info.receive_time_us != PacketDeliveryInfo::kNotReceived) {
|
||||
packet->packet.arrival_time =
|
||||
|
@ -492,13 +521,15 @@ EmulatedNetworkNode::EmulatedNetworkNode(
|
|||
Clock* clock,
|
||||
absl::Nonnull<TaskQueueBase*> task_queue,
|
||||
std::unique_ptr<NetworkBehaviorInterface> network_behavior,
|
||||
EmulatedNetworkStatsGatheringMode stats_gathering_mode)
|
||||
EmulatedNetworkStatsGatheringMode stats_gathering_mode,
|
||||
bool fake_dtls_handshake_sizes)
|
||||
: router_(task_queue),
|
||||
link_(clock,
|
||||
task_queue,
|
||||
std::move(network_behavior),
|
||||
&router_,
|
||||
stats_gathering_mode) {}
|
||||
stats_gathering_mode,
|
||||
fake_dtls_handshake_sizes) {}
|
||||
|
||||
void EmulatedNetworkNode::OnPacketReceived(EmulatedIpPacket packet) {
|
||||
link_.OnPacketReceived(std::move(packet));
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#define TEST_NETWORK_NETWORK_EMULATION_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <deque>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
@ -150,7 +151,8 @@ class LinkEmulation : public EmulatedNetworkReceiverInterface {
|
|||
absl::Nonnull<TaskQueueBase*> task_queue,
|
||||
std::unique_ptr<NetworkBehaviorInterface> network_behavior,
|
||||
EmulatedNetworkReceiverInterface* receiver,
|
||||
EmulatedNetworkStatsGatheringMode stats_gathering_mode);
|
||||
EmulatedNetworkStatsGatheringMode stats_gathering_mode,
|
||||
bool fake_dtls_handshake_sizes);
|
||||
void OnPacketReceived(EmulatedIpPacket packet) override;
|
||||
|
||||
EmulatedNetworkNodeStats stats() const;
|
||||
|
@ -164,12 +166,14 @@ class LinkEmulation : public EmulatedNetworkReceiverInterface {
|
|||
};
|
||||
void UpdateProcessSchedule() RTC_RUN_ON(task_queue_);
|
||||
void Process(Timestamp at_time) RTC_RUN_ON(task_queue_);
|
||||
size_t GetPacketSizeForEmulation(const EmulatedIpPacket& packet) const;
|
||||
|
||||
Clock* const clock_;
|
||||
const absl::Nonnull<TaskQueueBase*> task_queue_;
|
||||
const std::unique_ptr<NetworkBehaviorInterface> network_behavior_
|
||||
RTC_GUARDED_BY(task_queue_);
|
||||
EmulatedNetworkReceiverInterface* const receiver_;
|
||||
const bool fake_dtls_handshake_sizes_;
|
||||
|
||||
RepeatingTaskHandle process_task_ RTC_GUARDED_BY(task_queue_);
|
||||
std::deque<StoredPacket> packets_ RTC_GUARDED_BY(task_queue_);
|
||||
|
@ -224,7 +228,8 @@ class EmulatedNetworkNode : public EmulatedNetworkReceiverInterface {
|
|||
Clock* clock,
|
||||
absl::Nonnull<TaskQueueBase*> task_queue,
|
||||
std::unique_ptr<NetworkBehaviorInterface> network_behavior,
|
||||
EmulatedNetworkStatsGatheringMode stats_gathering_mode);
|
||||
EmulatedNetworkStatsGatheringMode stats_gathering_mode,
|
||||
bool fake_dtls_handshake_sizes);
|
||||
~EmulatedNetworkNode() override;
|
||||
|
||||
EmulatedNetworkNode(const EmulatedNetworkNode&) = delete;
|
||||
|
@ -408,6 +413,7 @@ class FakePacketRoute : public EmulatedNetworkReceiverInterface {
|
|||
RTC_CHECK_GE(size, sizeof(int));
|
||||
sent_.emplace(next_packet_id_, packet);
|
||||
rtc::CopyOnWriteBuffer buf(size);
|
||||
memset(buf.MutableData(), 0, size);
|
||||
reinterpret_cast<int*>(buf.MutableData())[0] = next_packet_id_++;
|
||||
route_->from->SendPacket(send_addr_, recv_addr_, buf);
|
||||
}
|
||||
|
|
|
@ -48,13 +48,13 @@ std::unique_ptr<TimeController> CreateTimeController(
|
|||
} // namespace
|
||||
|
||||
NetworkEmulationManagerImpl::NetworkEmulationManagerImpl(
|
||||
TimeMode mode,
|
||||
EmulatedNetworkStatsGatheringMode stats_gathering_mode,
|
||||
const FieldTrialsView* field_trials)
|
||||
: time_mode_(mode),
|
||||
stats_gathering_mode_(stats_gathering_mode),
|
||||
time_controller_(CreateTimeController(mode, field_trials)),
|
||||
NetworkEmulationManagerConfig config)
|
||||
: time_mode_(config.time_mode),
|
||||
stats_gathering_mode_(config.stats_gathering_mode),
|
||||
time_controller_(
|
||||
CreateTimeController(config.time_mode, config.field_trials)),
|
||||
clock_(time_controller_->GetClock()),
|
||||
fake_dtls_handshake_sizes_(config.fake_dtls_handshake_sizes),
|
||||
next_node_id_(1),
|
||||
next_ip4_address_(kMinIPv4Address),
|
||||
task_queue_(time_controller_->GetTaskQueueFactory()->CreateTaskQueue(
|
||||
|
@ -79,9 +79,9 @@ EmulatedNetworkNode* NetworkEmulationManagerImpl::CreateEmulatedNode(
|
|||
|
||||
EmulatedNetworkNode* NetworkEmulationManagerImpl::CreateEmulatedNode(
|
||||
std::unique_ptr<NetworkBehaviorInterface> network_behavior) {
|
||||
auto node = std::make_unique<EmulatedNetworkNode>(clock_, task_queue_.Get(),
|
||||
std::move(network_behavior),
|
||||
stats_gathering_mode_);
|
||||
auto node = std::make_unique<EmulatedNetworkNode>(
|
||||
clock_, task_queue_.Get(), std::move(network_behavior),
|
||||
stats_gathering_mode_, fake_dtls_handshake_sizes_);
|
||||
EmulatedNetworkNode* out = node.get();
|
||||
task_queue_.PostTask([this, node = std::move(node)]() mutable {
|
||||
network_nodes_.push_back(std::move(node));
|
||||
|
|
|
@ -37,10 +37,7 @@ namespace test {
|
|||
|
||||
class NetworkEmulationManagerImpl : public NetworkEmulationManager {
|
||||
public:
|
||||
NetworkEmulationManagerImpl(
|
||||
TimeMode mode,
|
||||
EmulatedNetworkStatsGatheringMode stats_gathering_mode,
|
||||
const FieldTrialsView* field_trials = nullptr);
|
||||
explicit NetworkEmulationManagerImpl(NetworkEmulationManagerConfig config);
|
||||
~NetworkEmulationManagerImpl();
|
||||
|
||||
EmulatedNetworkNode* CreateEmulatedNode(BuiltInNetworkBehaviorConfig config,
|
||||
|
@ -108,6 +105,7 @@ class NetworkEmulationManagerImpl : public NetworkEmulationManager {
|
|||
const EmulatedNetworkStatsGatheringMode stats_gathering_mode_;
|
||||
const std::unique_ptr<TimeController> time_controller_;
|
||||
Clock* const clock_;
|
||||
const bool fake_dtls_handshake_sizes_;
|
||||
int next_node_id_;
|
||||
|
||||
RepeatingTaskHandle process_task_handle_;
|
||||
|
|
|
@ -111,8 +111,7 @@ TEST(NetworkEmulationManagerPCTest, Run) {
|
|||
signaling_thread->Start();
|
||||
|
||||
// Setup emulated network
|
||||
NetworkEmulationManagerImpl emulation(
|
||||
TimeMode::kRealTime, EmulatedNetworkStatsGatheringMode::kDefault);
|
||||
NetworkEmulationManagerImpl emulation({.time_mode = TimeMode::kRealTime});
|
||||
|
||||
EmulatedNetworkNode* alice_node = emulation.CreateEmulatedNode(
|
||||
std::make_unique<SimulatedNetwork>(BuiltInNetworkBehaviorConfig()));
|
||||
|
@ -203,8 +202,7 @@ TEST(NetworkEmulationManagerPCTest, RunTURN) {
|
|||
signaling_thread->Start();
|
||||
|
||||
// Setup emulated network
|
||||
NetworkEmulationManagerImpl emulation(
|
||||
TimeMode::kRealTime, EmulatedNetworkStatsGatheringMode::kDefault);
|
||||
NetworkEmulationManagerImpl emulation({.time_mode = TimeMode::kRealTime});
|
||||
|
||||
EmulatedNetworkNode* alice_node = emulation.CreateEmulatedNode(
|
||||
std::make_unique<SimulatedNetwork>(BuiltInNetworkBehaviorConfig()));
|
||||
|
|
|
@ -163,7 +163,7 @@ class NetworkEmulationManagerThreeNodesRoutingTest : public ::testing::Test {
|
|||
MockReceiver r_e3_e1_;
|
||||
|
||||
NetworkEmulationManagerImpl emulation_{
|
||||
TimeMode::kRealTime, EmulatedNetworkStatsGatheringMode::kDefault};
|
||||
NetworkEmulationManagerConfig{.time_mode = TimeMode::kRealTime}};
|
||||
EmulatedEndpoint* e1_;
|
||||
EmulatedEndpoint* e2_;
|
||||
EmulatedEndpoint* e3_;
|
||||
|
@ -181,7 +181,7 @@ using ::testing::_;
|
|||
|
||||
TEST(NetworkEmulationManagerTest, GeneratedIpv4AddressDoesNotCollide) {
|
||||
NetworkEmulationManagerImpl network_manager(
|
||||
TimeMode::kRealTime, EmulatedNetworkStatsGatheringMode::kDefault);
|
||||
{.time_mode = TimeMode::kRealTime});
|
||||
std::set<rtc::IPAddress> ips;
|
||||
EmulatedEndpointConfig config;
|
||||
config.generated_ip_family = EmulatedEndpointConfig::IpAddressFamily::kIpv4;
|
||||
|
@ -195,7 +195,7 @@ TEST(NetworkEmulationManagerTest, GeneratedIpv4AddressDoesNotCollide) {
|
|||
|
||||
TEST(NetworkEmulationManagerTest, GeneratedIpv6AddressDoesNotCollide) {
|
||||
NetworkEmulationManagerImpl network_manager(
|
||||
TimeMode::kRealTime, EmulatedNetworkStatsGatheringMode::kDefault);
|
||||
{.time_mode = TimeMode::kRealTime});
|
||||
std::set<rtc::IPAddress> ips;
|
||||
EmulatedEndpointConfig config;
|
||||
config.generated_ip_family = EmulatedEndpointConfig::IpAddressFamily::kIpv6;
|
||||
|
@ -209,7 +209,7 @@ TEST(NetworkEmulationManagerTest, GeneratedIpv6AddressDoesNotCollide) {
|
|||
|
||||
TEST(NetworkEmulationManagerTest, Run) {
|
||||
NetworkEmulationManagerImpl network_manager(
|
||||
TimeMode::kRealTime, EmulatedNetworkStatsGatheringMode::kDefault);
|
||||
{.time_mode = TimeMode::kRealTime});
|
||||
|
||||
EmulatedNetworkNode* alice_node = network_manager.CreateEmulatedNode(
|
||||
std::make_unique<SimulatedNetwork>(BuiltInNetworkBehaviorConfig()));
|
||||
|
@ -363,7 +363,8 @@ TEST(NetworkEmulationManagerTest, Run) {
|
|||
|
||||
TEST(NetworkEmulationManagerTest, DebugStatsCollectedInDebugMode) {
|
||||
NetworkEmulationManagerImpl network_manager(
|
||||
TimeMode::kSimulated, EmulatedNetworkStatsGatheringMode::kDebug);
|
||||
{.time_mode = TimeMode::kSimulated,
|
||||
.stats_gathering_mode = EmulatedNetworkStatsGatheringMode::kDebug});
|
||||
|
||||
EmulatedNetworkNode* alice_node = network_manager.CreateEmulatedNode(
|
||||
std::make_unique<SimulatedNetwork>(BuiltInNetworkBehaviorConfig()));
|
||||
|
@ -463,7 +464,7 @@ TEST(NetworkEmulationManagerTest, DebugStatsCollectedInDebugMode) {
|
|||
|
||||
TEST(NetworkEmulationManagerTest, ThroughputStats) {
|
||||
NetworkEmulationManagerImpl network_manager(
|
||||
TimeMode::kRealTime, EmulatedNetworkStatsGatheringMode::kDefault);
|
||||
{.time_mode = TimeMode::kRealTime});
|
||||
|
||||
EmulatedNetworkNode* alice_node = network_manager.CreateEmulatedNode(
|
||||
std::make_unique<SimulatedNetwork>(BuiltInNetworkBehaviorConfig()));
|
||||
|
@ -594,7 +595,7 @@ TEST_F(NetworkEmulationManagerThreeNodesRoutingTest,
|
|||
|
||||
TEST(NetworkEmulationManagerTest, EndpointLoopback) {
|
||||
NetworkEmulationManagerImpl network_manager(
|
||||
TimeMode::kSimulated, EmulatedNetworkStatsGatheringMode::kDefault);
|
||||
{.time_mode = TimeMode::kSimulated});
|
||||
auto endpoint = network_manager.CreateEndpoint(EmulatedEndpointConfig());
|
||||
|
||||
MockReceiver receiver;
|
||||
|
@ -611,7 +612,7 @@ TEST(NetworkEmulationManagerTest, EndpointCanSendWithDifferentSourceIp) {
|
|||
constexpr uint32_t kEndpointIp = 0xC0A80011; // 192.168.0.17
|
||||
constexpr uint32_t kSourceIp = 0xC0A80012; // 192.168.0.18
|
||||
NetworkEmulationManagerImpl network_manager(
|
||||
TimeMode::kSimulated, EmulatedNetworkStatsGatheringMode::kDefault);
|
||||
{.time_mode = TimeMode::kSimulated});
|
||||
EmulatedEndpointConfig endpoint_config;
|
||||
endpoint_config.ip = rtc::IPAddress(kEndpointIp);
|
||||
endpoint_config.allow_send_packet_with_different_source_ip = true;
|
||||
|
@ -632,7 +633,7 @@ TEST(NetworkEmulationManagerTest,
|
|||
constexpr uint32_t kDestEndpointIp = 0xC0A80011; // 192.168.0.17
|
||||
constexpr uint32_t kDestIp = 0xC0A80012; // 192.168.0.18
|
||||
NetworkEmulationManagerImpl network_manager(
|
||||
TimeMode::kSimulated, EmulatedNetworkStatsGatheringMode::kDefault);
|
||||
{.time_mode = TimeMode::kSimulated});
|
||||
auto sender_endpoint =
|
||||
network_manager.CreateEndpoint(EmulatedEndpointConfig());
|
||||
EmulatedEndpointConfig endpoint_config;
|
||||
|
@ -656,7 +657,7 @@ TEST(NetworkEmulationManagerTest,
|
|||
|
||||
TEST(NetworkEmulationManagerTURNTest, GetIceServerConfig) {
|
||||
NetworkEmulationManagerImpl network_manager(
|
||||
TimeMode::kRealTime, EmulatedNetworkStatsGatheringMode::kDefault);
|
||||
{.time_mode = TimeMode::kRealTime});
|
||||
auto turn = network_manager.CreateTURNServer(EmulatedTURNServerConfig());
|
||||
|
||||
EXPECT_GT(turn->GetIceServerConfig().username.size(), 0u);
|
||||
|
@ -667,8 +668,7 @@ TEST(NetworkEmulationManagerTURNTest, GetIceServerConfig) {
|
|||
}
|
||||
|
||||
TEST(NetworkEmulationManagerTURNTest, ClientTraffic) {
|
||||
NetworkEmulationManagerImpl emulation(
|
||||
TimeMode::kSimulated, EmulatedNetworkStatsGatheringMode::kDefault);
|
||||
NetworkEmulationManagerImpl emulation({.time_mode = TimeMode::kSimulated});
|
||||
auto* ep = emulation.CreateEndpoint(EmulatedEndpointConfig());
|
||||
auto* turn = emulation.CreateTURNServer(EmulatedTURNServerConfig());
|
||||
auto* node = CreateEmulatedNodeWithDefaultBuiltInConfig(&emulation);
|
||||
|
@ -695,7 +695,7 @@ TEST(NetworkEmulationManagerTURNTest, ClientTraffic) {
|
|||
TEST(LinkEmulationTest, HandlesDeliveryTimeChangedCallback) {
|
||||
constexpr uint32_t kEndpointIp = 0xC0A80011; // 192.168.0.17
|
||||
NetworkEmulationManagerImpl network_manager(
|
||||
TimeMode::kSimulated, EmulatedNetworkStatsGatheringMode::kDefault);
|
||||
{.time_mode = TimeMode::kSimulated});
|
||||
auto mock_behaviour =
|
||||
std::make_unique<::testing::NiceMock<MockNetworkBehaviourInterface>>();
|
||||
MockNetworkBehaviourInterface* mock_behaviour_ptr = mock_behaviour.get();
|
||||
|
|
|
@ -108,7 +108,7 @@ std::vector<MetricValidationInfo> ToValidationInfo(
|
|||
TEST(PeerConnectionE2EQualityTestMetricNamesTest,
|
||||
ExportedMetricsHasCorrectNamesAndAnnotation) {
|
||||
std::unique_ptr<NetworkEmulationManager> network_emulation =
|
||||
CreateNetworkEmulationManager(TimeMode::kSimulated);
|
||||
CreateNetworkEmulationManager({.time_mode = TimeMode::kSimulated});
|
||||
DefaultMetricsLogger metrics_logger(
|
||||
network_emulation->time_controller()->GetClock());
|
||||
PeerConnectionE2EQualityTest fixture(
|
||||
|
@ -1124,7 +1124,7 @@ TEST(PeerConnectionE2EQualityTestMetricNamesTest,
|
|||
TEST(PeerConnectionE2EQualityTestMetricNamesTest,
|
||||
ExportedNetworkMetricsHaveCustomNetworkLabelIfSet) {
|
||||
std::unique_ptr<NetworkEmulationManager> network_emulation =
|
||||
CreateNetworkEmulationManager(TimeMode::kSimulated);
|
||||
CreateNetworkEmulationManager({.time_mode = TimeMode::kSimulated});
|
||||
DefaultMetricsLogger metrics_logger(
|
||||
network_emulation->time_controller()->GetClock());
|
||||
PeerConnectionE2EQualityTest fixture(
|
||||
|
|
|
@ -90,7 +90,7 @@ class PeerConnectionE2EQualityTestTest : public Test {
|
|||
|
||||
TEST_F(PeerConnectionE2EQualityTestTest, OutputVideoIsDumpedWhenRequested) {
|
||||
std::unique_ptr<NetworkEmulationManager> network_emulation =
|
||||
CreateNetworkEmulationManager(TimeMode::kSimulated);
|
||||
CreateNetworkEmulationManager({.time_mode = TimeMode::kSimulated});
|
||||
PeerConnectionE2EQualityTest fixture(
|
||||
"test_case", *network_emulation->time_controller(),
|
||||
/*audio_quality_analyzer=*/nullptr, /*video_quality_analyzer=*/nullptr,
|
||||
|
|
|
@ -77,8 +77,9 @@ absl::optional<Metric> FindMeetricByName(absl::string_view name,
|
|||
|
||||
TEST(StatsBasedNetworkQualityMetricsReporterTest, DebugStatsAreCollected) {
|
||||
std::unique_ptr<NetworkEmulationManager> network_emulation =
|
||||
CreateNetworkEmulationManager(TimeMode::kSimulated,
|
||||
EmulatedNetworkStatsGatheringMode::kDebug);
|
||||
CreateNetworkEmulationManager(
|
||||
{.time_mode = TimeMode::kSimulated,
|
||||
.stats_gathering_mode = EmulatedNetworkStatsGatheringMode::kDebug});
|
||||
DefaultMetricsLogger metrics_logger(
|
||||
network_emulation->time_controller()->GetClock());
|
||||
PeerConnectionE2EQualityTest fixture(
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "rtc_base/string_encode.h"
|
||||
#include "rtc_base/strings/string_builder.h"
|
||||
#include "test/logging/file_log_writer.h"
|
||||
#include "test/network/network_emulation_manager.h"
|
||||
#include "test/testsupport/file_utils.h"
|
||||
#include "test/time_controller/real_time_controller.h"
|
||||
#include "test/time_controller/simulated_time_controller.h"
|
||||
|
@ -55,7 +56,7 @@ PeerScenario::PeerScenario(
|
|||
std::unique_ptr<LogWriterFactoryInterface> log_writer_manager,
|
||||
TimeMode mode)
|
||||
: log_writer_manager_(std::move(log_writer_manager)),
|
||||
net_(mode, EmulatedNetworkStatsGatheringMode::kDefault),
|
||||
net_({.time_mode = mode}),
|
||||
signaling_thread_(net_.time_controller()->GetMainThread()) {}
|
||||
|
||||
PeerScenarioClient* PeerScenario::CreateClient(
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "rtc_base/socket_address.h"
|
||||
#include "test/logging/file_log_writer.h"
|
||||
#include "test/network/network_emulation.h"
|
||||
#include "test/network/network_emulation_manager.h"
|
||||
#include "test/scenario/video_stream.h"
|
||||
#include "test/testsupport/file_utils.h"
|
||||
|
||||
|
@ -66,8 +67,8 @@ Scenario::Scenario(
|
|||
std::unique_ptr<LogWriterFactoryInterface> log_writer_factory,
|
||||
bool real_time)
|
||||
: log_writer_factory_(std::move(log_writer_factory)),
|
||||
network_manager_(real_time ? TimeMode::kRealTime : TimeMode::kSimulated,
|
||||
EmulatedNetworkStatsGatheringMode::kDefault),
|
||||
network_manager_({.time_mode = real_time ? TimeMode::kRealTime
|
||||
: TimeMode::kSimulated}),
|
||||
clock_(network_manager_.time_controller()->GetClock()),
|
||||
audio_decoder_factory_(CreateBuiltinAudioDecoderFactory()),
|
||||
audio_encoder_factory_(CreateBuiltinAudioEncoderFactory()),
|
||||
|
|
Loading…
Reference in a new issue