From ea3dddf1d0880e89d84a7e502f65c65993d4169d Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Tue, 16 Jul 2019 16:31:50 +0200 Subject: [PATCH] Use capacity bounds in AimdRateControl if available. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:10742 Change-Id: I139f7053d33092efe6430d82596b05c730855383 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/145725 Commit-Queue: Sebastian Jansson Reviewed-by: Björn Terelius Cr-Commit-Position: refs/heads/master@{#28584} --- api/transport/network_types.h | 7 ++-- .../aimd_rate_control.cc | 40 ++++++++++++------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/api/transport/network_types.h b/api/transport/network_types.h index 45b651ea73..9e79bce844 100644 --- a/api/transport/network_types.h +++ b/api/transport/network_types.h @@ -236,11 +236,10 @@ struct NetworkStateEstimate { // Total estimated link capacity. DataRate link_capacity = DataRate::MinusInfinity(); - // Lower bound of link capacity estimate. + // Used as a safe measure of available capacity. DataRate link_capacity_lower = DataRate::MinusInfinity(); - // Expected available capacity for sending data after cross traffic is taken - // into consideration. - DataRate available_capacity = DataRate::MinusInfinity(); + // Used as limit for increasing bitrate. + DataRate link_capacity_upper = DataRate::MinusInfinity(); TimeDelta pre_link_buffer_delay = TimeDelta::MinusInfinity(); TimeDelta post_link_buffer_delay = TimeDelta::MinusInfinity(); diff --git a/modules/remote_bitrate_estimator/aimd_rate_control.cc b/modules/remote_bitrate_estimator/aimd_rate_control.cc index 1e5d292cf5..0b523819f3 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control.cc +++ b/modules/remote_bitrate_estimator/aimd_rate_control.cc @@ -305,18 +305,24 @@ DataRate AimdRateControl::ChangeBitrate(DataRate new_bitrate, case kRcDecrease: if (network_estimate_ && capacity_deviation_ratio_threshold_) { - // If we have a low variance network estimate, we use it over the - // acknowledged rate to avoid dropping the bitrate too far. This avoids - // overcompensating when the send rate is lower than the capacity. - double deviation_ratio = network_estimate_->link_capacity_std_dev / - network_estimate_->link_capacity; - if (deviation_ratio < *capacity_deviation_ratio_threshold_) { - double available_ratio = - std::max(0.0, 1.0 - network_estimate_->cross_traffic_ratio * - cross_traffic_factor_); - DataRate available_rate = - network_estimate_->link_capacity * available_ratio; - estimated_throughput = std::max(available_rate, estimated_throughput); + DataRate lower_bound = network_estimate_->link_capacity_lower; + // TODO(srte): Remove this when link_capacity_lower is available. + if (lower_bound.IsInfinite()) { + // If we have a low variance network estimate, we use it over the + // acknowledged rate to avoid dropping the bitrate too far. This + // avoids overcompensating when the send rate is lower than the + // capacity. + double deviation_ratio = network_estimate_->link_capacity_std_dev / + network_estimate_->link_capacity; + if (deviation_ratio < *capacity_deviation_ratio_threshold_) { + double available_ratio = + std::max(0.0, 1.0 - network_estimate_->cross_traffic_ratio * + cross_traffic_factor_); + lower_bound = network_estimate_->link_capacity * available_ratio; + } + } + if (lower_bound > DataRate::Zero()) { + estimated_throughput = std::max(lower_bound, estimated_throughput); } } if (estimated_throughput > low_throughput_threshold_) { @@ -388,9 +394,13 @@ DataRate AimdRateControl::ClampBitrate(DataRate new_bitrate, } if (network_estimate_ && capacity_limit_deviation_factor_) { - DataRate upper_bound = network_estimate_->link_capacity + - network_estimate_->link_capacity_std_dev * - capacity_limit_deviation_factor_.Value(); + DataRate upper_bound = network_estimate_->link_capacity_upper; + // TODO(srte): Remove this when link_capacity_lower is available. + if (upper_bound.IsMinusInfinity()) { + upper_bound = network_estimate_->link_capacity + + network_estimate_->link_capacity_std_dev * + capacity_limit_deviation_factor_.Value(); + } new_bitrate = std::min(new_bitrate, upper_bound); } new_bitrate = std::max(new_bitrate, min_configured_bitrate_);