From 524a06bc5423ef2289bc6102ee5a2b9e747137cc Mon Sep 17 00:00:00 2001 From: Florent Castelli Date: Tue, 27 Feb 2024 11:19:30 +0000 Subject: [PATCH] Change BuiltInNetworkBehaviorConfig.loss_percent to double This should allow greater precision in the lower ranges of packet loss. Bug: chromium:41175925 Change-Id: Ia35059ad673a3782443b23772511b0b952b07ce7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/341263 Commit-Queue: Florent Castelli Auto-Submit: Florent Castelli Reviewed-by: Artem Titov Cr-Commit-Position: refs/heads/main@{#41822} --- api/test/network_emulation_manager.cc | 2 +- api/test/simulated_network.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/test/network_emulation_manager.cc b/api/test/network_emulation_manager.cc index 756fe4e757..07676eaca9 100644 --- a/api/test/network_emulation_manager.cc +++ b/api/test/network_emulation_manager.cc @@ -71,7 +71,7 @@ NetworkEmulationManager::SimulatedNetworkNode::Builder::capacity_Mbps( NetworkEmulationManager::SimulatedNetworkNode::Builder& NetworkEmulationManager::SimulatedNetworkNode::Builder::loss(double loss_rate) { - config_.loss_percent = std::round(loss_rate * 100); + config_.loss_percent = loss_rate * 100; return *this; } diff --git a/api/test/simulated_network.h b/api/test/simulated_network.h index 04c5517c8d..79f5fada7b 100644 --- a/api/test/simulated_network.h +++ b/api/test/simulated_network.h @@ -60,8 +60,8 @@ struct BuiltInNetworkBehaviorConfig { int delay_standard_deviation_ms = 0; // Link capacity in kbps. int link_capacity_kbps = 0; - // Random packet loss. - int loss_percent = 0; + // Random packet loss, range 0 to 100. + double loss_percent = 0.; // If packets are allowed to be reordered. bool allow_reordering = false; // The average length of a burst of lost packets.