From 9129565879352118b64c4c20bb6b166be56a1a0e Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Tue, 7 Aug 2018 18:18:57 +0200 Subject: [PATCH] Adds functionality to add delay spikes in SimulatedNetwork. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:9467 Change-Id: Ifddafa65a9e18a3131fc0415764599740fab2db4 Reviewed-on: https://webrtc-review.googlesource.com/92089 Commit-Queue: Sebastian Jansson Reviewed-by: Erik Språng Reviewed-by: Björn Terelius Cr-Commit-Position: refs/heads/master@{#24213} --- call/fake_network_pipe.cc | 13 +++++++++++++ call/fake_network_pipe.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/call/fake_network_pipe.cc b/call/fake_network_pipe.cc index 9bbde61377..b9bf4e7398 100644 --- a/call/fake_network_pipe.cc +++ b/call/fake_network_pipe.cc @@ -194,6 +194,11 @@ void SimulatedNetwork::SetConfig(const SimulatedNetwork::Config& config) { } } +void SimulatedNetwork::PauseTransmissionUntil(int64_t until_us) { + rtc::CritScope crit(&config_lock_); + pause_transmission_until_us_ = until_us; +} + bool SimulatedNetwork::EnqueuePacket(PacketInFlightInfo packet) { Config config; { @@ -222,6 +227,14 @@ bool SimulatedNetwork::EnqueuePacket(PacketInFlightInfo packet) { } int64_t network_start_time_us = packet.send_time_us; + { + rtc::CritScope crit(&config_lock_); + if (pause_transmission_until_us_) { + network_start_time_us = + std::max(network_start_time_us, *pause_transmission_until_us_); + pause_transmission_until_us_.reset(); + } + } // Check if there already are packets on the link and change network start // time forward if there is. if (!capacity_link_.empty() && diff --git a/call/fake_network_pipe.h b/call/fake_network_pipe.h index b7d5e2e6a2..ea9c60b047 100644 --- a/call/fake_network_pipe.h +++ b/call/fake_network_pipe.h @@ -109,6 +109,7 @@ class SimulatedNetwork : public NetworkSimulationInterface { // Sets a new configuration. This won't affect packets already in the pipe. void SetConfig(const Config& config); + void PauseTransmissionUntil(int64_t until_us); // NetworkSimulationInterface bool EnqueuePacket(PacketInFlightInfo packet) override; @@ -134,6 +135,8 @@ class SimulatedNetwork : public NetworkSimulationInterface { // Link configuration. Config config_ RTC_GUARDED_BY(config_lock_); + absl::optional pause_transmission_until_us_ + RTC_GUARDED_BY(config_lock_); // Are we currently dropping a burst of packets? bool bursting_;