From 57606328f62d5d2876535a6a014e92df223ea8fc Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Mon, 10 Sep 2018 18:27:21 +0200 Subject: [PATCH] Adds initial data window field trial to GoogCC. Bug: webrtc:9718 Change-Id: Ia5a77a09d7ba82b545e9ab12036f717765fdf3b4 Reviewed-on: https://webrtc-review.googlesource.com/97740 Commit-Queue: Sebastian Jansson Reviewed-by: Christoffer Rodbro Cr-Commit-Position: refs/heads/master@{#24659} --- .../congestion_controller/goog_cc/BUILD.gn | 1 + .../goog_cc/goog_cc_network_control.cc | 37 +++++++++++++++++-- .../goog_cc/goog_cc_network_control.h | 18 +++++++++ 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/modules/congestion_controller/goog_cc/BUILD.gn b/modules/congestion_controller/goog_cc/BUILD.gn index 74219f3de4..b27b28c526 100644 --- a/modules/congestion_controller/goog_cc/BUILD.gn +++ b/modules/congestion_controller/goog_cc/BUILD.gn @@ -38,6 +38,7 @@ rtc_static_library("goog_cc") { "../../../rtc_base:checks", "../../../rtc_base:rtc_base_approved", "../../../rtc_base/experiments:alr_experiment", + "../../../rtc_base/experiments:field_trial_parser", "../../../system_wrappers", "../../../system_wrappers:field_trial_api", "../../../system_wrappers:metrics_api", diff --git a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc index be2bdd1ae6..a984f10f32 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc @@ -54,7 +54,6 @@ bool CwndExperimentEnabled() { // The experiment is enabled iff the field trial string begins with "Enabled". return experiment_string.find("Enabled") == 0; } - bool ReadCwndExperimentParameter(int64_t* accepted_queue_ms) { RTC_DCHECK(accepted_queue_ms); std::string experiment_string = @@ -115,6 +114,16 @@ int64_t GetBpsOrDefault(const absl::optional& rate, } // namespace +InitialDataWindowConfig::InitialDataWindowConfig() + : size("size", DataSize::Infinity()), exit_rate_factor("rate", 1.0) { + std::string trial_string = + field_trial::FindFullName("WebRTC-Bwe-InitialDataWindow"); + ParseFieldTrial({&size, &exit_rate_factor}, trial_string); +} +InitialDataWindowConfig::InitialDataWindowConfig( + const InitialDataWindowConfig&) = default; +InitialDataWindowConfig::~InitialDataWindowConfig() = default; + GoogCcNetworkController::GoogCcNetworkController(RtcEventLog* event_log, NetworkControllerConfig config, bool feedback_only) @@ -128,6 +137,7 @@ GoogCcNetworkController::GoogCcNetworkController(RtcEventLog* event_log, acknowledged_bitrate_estimator_( absl::make_unique()), initial_config_(config), + initial_data_window_(InitialDataWindowConfig()), last_bandwidth_(*config.constraints.starting_rate), pacing_factor_(config.stream_based_config.pacing_factor.value_or( kDefaultPaceMultiplier)), @@ -249,7 +259,15 @@ NetworkControlUpdate GoogCcNetworkController::OnSentPacket( SentPacket sent_packet) { alr_detector_->OnBytesSent(sent_packet.size.bytes(), sent_packet.send_time.ms()); - return NetworkControlUpdate(); + if (initial_state_ == InitialState::kWaitingForEstimate && + sent_packet.data_in_flight > initial_data_window_.size) { + initial_state_ = InitialState::kWindowFullWaitingForEstimate; + NetworkControlUpdate update; + MaybeTriggerOnNetworkChanged(&update, sent_packet.send_time); + return update; + } else { + return NetworkControlUpdate(); + } } NetworkControlUpdate GoogCcNetworkController::OnStreamsConfig( @@ -395,10 +413,19 @@ NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback( previously_in_alr = alr_start_time.has_value(); acknowledged_bitrate_estimator_->IncomingPacketFeedbackVector( received_feedback_vector); + auto acknowledged_bitrate = acknowledged_bitrate_estimator_->bitrate_bps(); DelayBasedBwe::Result result; result = delay_based_bwe_->IncomingPacketFeedbackVector( - received_feedback_vector, acknowledged_bitrate_estimator_->bitrate_bps(), + received_feedback_vector, acknowledged_bitrate, report.feedback_time.ms()); + + if (acknowledged_bitrate || result.probe) { + if (initial_state_ == InitialState::kWindowFullWaitingForEstimate) + delay_based_bwe_->SetStartBitrate(result.target_bitrate_bps * + initial_data_window_.exit_rate_factor); + initial_state_ = InitialState::kReceivedEstimate; + } + NetworkControlUpdate update; if (result.updated) { if (result.probe) { @@ -473,6 +500,9 @@ void GoogCcNetworkController::MaybeTriggerOnNetworkChanged( estimated_bitrate_bps = std::max( estimated_bitrate_bps, bandwidth_estimation_->GetMinBitrate()); + if (initial_state_ == InitialState::kWindowFullWaitingForEstimate) + estimated_bitrate_bps = bandwidth_estimation_->GetMinBitrate(); + BWE_TEST_LOGGING_PLOT(1, "fraction_loss_%", at_time.ms(), (fraction_loss * 100) / 256); BWE_TEST_LOGGING_PLOT(1, "rtt_ms", at_time.ms(), rtt_ms); @@ -526,4 +556,5 @@ PacerConfig GoogCcNetworkController::GetPacingRates(Timestamp at_time) const { msg.pad_window = padding_rate * msg.time_window; return msg; } + } // namespace webrtc diff --git a/modules/congestion_controller/goog_cc/goog_cc_network_control.h b/modules/congestion_controller/goog_cc/goog_cc_network_control.h index b1fceebc29..a8c5c83629 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control.h +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control.h @@ -25,9 +25,19 @@ #include "modules/congestion_controller/goog_cc/delay_based_bwe.h" #include "modules/congestion_controller/goog_cc/probe_controller.h" #include "rtc_base/constructormagic.h" +#include "rtc_base/experiments/field_trial_parser.h" +#include "rtc_base/experiments/field_trial_units.h" namespace webrtc { +struct InitialDataWindowConfig { + InitialDataWindowConfig(); + InitialDataWindowConfig(const InitialDataWindowConfig&); + ~InitialDataWindowConfig(); + FieldTrialParameter size; + FieldTrialParameter exit_rate_factor; +}; + class GoogCcNetworkController : public NetworkControllerInterface { public: GoogCcNetworkController(RtcEventLog* event_log, @@ -53,6 +63,11 @@ class GoogCcNetworkController : public NetworkControllerInterface { private: friend class GoogCcStatePrinter; + enum class InitialState { + kWaitingForEstimate, + kWindowFullWaitingForEstimate, + kReceivedEstimate + }; std::vector UpdateBitrateConstraints( TargetRateConstraints constraints, absl::optional starting_rate); @@ -72,6 +87,9 @@ class GoogCcNetworkController : public NetworkControllerInterface { absl::optional initial_config_; + const InitialDataWindowConfig initial_data_window_; + InitialState initial_state_ = InitialState::kWaitingForEstimate; + Timestamp next_loss_update_ = Timestamp::MinusInfinity(); int lost_packets_since_last_loss_update_ = 0; int expected_packets_since_last_loss_update_ = 0;