Revert "Probing integration in loss based bwe 2."

This reverts commit 332810ab5d41862b8f85ef30e84dbec4241f8b21.

Reason for revert: This commit chain seems to cause problems in LossBasedBwe.

Original change's description:
> Probing integration in loss based bwe 2.
>
> - Loss based bwe has 3 states: increasing (increasing when loss limited), decreasing (decreasing when loss limited), or delay based bwe (the same as delay based estimate).
> - When bandwidth is loss limited and decreasing, and probe result is available, GetLossBasedResult = min(estimate, probe result).
> - When bandwidth is loss limited and increasing, and the estimate is bounded by acked bitrate * a factor.
> - When bandwidth is loss limited and probe result is available, use probe bitrate as the current estimate, and reset probe bitrate.
>
> Bug: webrtc:12707
> Change-Id: I53cb82aa16397941c0cfaf1035116f775bdce72b
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/277400
> Commit-Queue: Diep Bui <diepbp@webrtc.org>
> Reviewed-by: Per Kjellander <perkj@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#38382}

Bug: webrtc:12707
Change-Id: Ied86323b0ce94b87ac503a2ee34753cebef5f53d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/279500
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Commit-Queue: Diep Bui <diepbp@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38412}
This commit is contained in:
Diep Bui
2022-10-17 07:36:00 +00:00
committed by WebRTC LUCI CQ
parent 3c5a1bf8f3
commit 70d08c05aa
6 changed files with 185 additions and 445 deletions

View File

@ -549,8 +549,8 @@ NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback(
bandwidth_estimation_->UpdateDelayBasedEstimate(report.feedback_time,
result.target_bitrate);
}
bandwidth_estimation_->UpdateLossBasedEstimator(
report, result.delay_detector_state, probe_bitrate);
bandwidth_estimation_->UpdateLossBasedEstimator(report,
result.delay_detector_state);
if (result.updated) {
// Update the estimate in the ProbeController, in case we want to probe.
MaybeTriggerOnNetworkChanged(&update, report.feedback_time);

View File

@ -42,10 +42,6 @@ bool IsValid(DataRate datarate) {
return datarate.IsFinite();
}
bool IsValid(absl::optional<DataRate> datarate) {
return datarate.has_value() && IsValid(datarate.value());
}
bool IsValid(Timestamp timestamp) {
return timestamp.IsFinite();
}
@ -138,10 +134,8 @@ bool LossBasedBweV2::IsReady() const {
num_observations_ > 0;
}
LossBasedBweV2::Result LossBasedBweV2::GetLossBasedResult(
DataRate LossBasedBweV2::GetBandwidthEstimate(
DataRate delay_based_limit) const {
Result result;
result.state = current_state_;
if (!IsReady()) {
if (!IsEnabled()) {
RTC_LOG(LS_WARNING)
@ -156,21 +150,17 @@ LossBasedBweV2::Result LossBasedBweV2::GetLossBasedResult(
"statistics before it can be used.";
}
}
result.bandwidth_estimate = IsValid(delay_based_limit)
? delay_based_limit
: DataRate::PlusInfinity();
return result;
return IsValid(delay_based_limit) ? delay_based_limit
: DataRate::PlusInfinity();
}
if (IsValid(delay_based_limit)) {
result.bandwidth_estimate =
std::min({current_estimate_.loss_limited_bandwidth,
GetInstantUpperBound(), delay_based_limit});
if (delay_based_limit.IsFinite()) {
return std::min({current_estimate_.loss_limited_bandwidth,
GetInstantUpperBound(), delay_based_limit});
} else {
result.bandwidth_estimate = std::min(
current_estimate_.loss_limited_bandwidth, GetInstantUpperBound());
return std::min(current_estimate_.loss_limited_bandwidth,
GetInstantUpperBound());
}
return result;
}
void LossBasedBweV2::SetAcknowledgedBitrate(DataRate acknowledged_bitrate) {
@ -200,25 +190,15 @@ void LossBasedBweV2::SetMinBitrate(DataRate min_bitrate) {
}
}
void LossBasedBweV2::SetProbeBitrate(absl::optional<DataRate> probe_bitrate) {
if (probe_bitrate.has_value() && IsValid(probe_bitrate.value())) {
if (!IsValid(probe_bitrate_) || probe_bitrate_ > probe_bitrate.value()) {
probe_bitrate_ = probe_bitrate.value();
}
}
}
void LossBasedBweV2::UpdateBandwidthEstimate(
rtc::ArrayView<const PacketResult> packet_results,
DataRate delay_based_estimate,
BandwidthUsage delay_detector_state,
absl::optional<DataRate> probe_bitrate) {
BandwidthUsage delay_detector_state) {
if (!IsEnabled()) {
RTC_LOG(LS_WARNING)
<< "The estimator must be enabled before it can be used.";
return;
}
SetProbeBitrate(probe_bitrate);
if (packet_results.empty()) {
RTC_LOG(LS_VERBOSE)
<< "The estimate cannot be updated without any loss statistics.";
@ -261,75 +241,34 @@ void LossBasedBweV2::UpdateBandwidthEstimate(
current_estimate_.loss_limited_bandwidth;
}
if (IsBandwidthLimitedDueToLoss()) {
// Bound the estimate increase if:
// 1. The estimate has been increased for less than
// `delayed_increase_window` ago, and
// 2. The best candidate is greater than bandwidth_limit_in_current_window.
if (recovering_after_loss_timestamp_.IsFinite() &&
recovering_after_loss_timestamp_ + config_->delayed_increase_window >
last_send_time_most_recent_observation_ &&
best_candidate.loss_limited_bandwidth >
bandwidth_limit_in_current_window_) {
best_candidate.loss_limited_bandwidth =
bandwidth_limit_in_current_window_;
}
bool increasing_when_loss_limited =
IsEstimateIncreasingWhenLossLimited(best_candidate);
// Bound the best candidate by the acked bitrate unless there is a recent
// probe result.
if (increasing_when_loss_limited && !IsValid(probe_bitrate_) &&
IsValid(acknowledged_bitrate_)) {
best_candidate.loss_limited_bandwidth =
IsValid(best_candidate.loss_limited_bandwidth)
? std::min(best_candidate.loss_limited_bandwidth,
config_->bandwidth_rampup_upper_bound_factor *
(*acknowledged_bitrate_))
: config_->bandwidth_rampup_upper_bound_factor *
(*acknowledged_bitrate_);
}
// Use probe bitrate as the estimate as probe bitrate is trusted to be
// correct. After being used, the probe bitrate is reset.
if (config_->probe_integration_enabled && IsValid(probe_bitrate_)) {
best_candidate.loss_limited_bandwidth =
std::min(probe_bitrate_, best_candidate.loss_limited_bandwidth);
probe_bitrate_ = DataRate::MinusInfinity();
}
// Bound the estimate increase if:
// 1. The estimate is limited due to loss, and
// 2. The estimate has been increased for less than `delayed_increase_window`
// ago, and
// 3. The best candidate is greater than bandwidth_limit_in_current_window.
if (limited_due_to_loss_candidate_ &&
recovering_after_loss_timestamp_.IsFinite() &&
recovering_after_loss_timestamp_ + config_->delayed_increase_window >
last_send_time_most_recent_observation_ &&
best_candidate.loss_limited_bandwidth >
bandwidth_limit_in_current_window_) {
best_candidate.loss_limited_bandwidth = bandwidth_limit_in_current_window_;
}
limited_due_to_loss_candidate_ =
delay_based_estimate.IsFinite() &&
best_candidate.loss_limited_bandwidth < delay_based_estimate;
if (IsEstimateIncreasingWhenLossLimited(best_candidate)) {
current_state_ = LossBasedState::kIncreasing;
} else if (IsValid(delay_based_estimate) &&
best_candidate.loss_limited_bandwidth < delay_based_estimate) {
current_state_ = LossBasedState::kDecreasing;
} else if (IsValid(delay_based_estimate) &&
best_candidate.loss_limited_bandwidth == delay_based_estimate) {
current_state_ = LossBasedState::kDelayBasedEstimate;
}
current_estimate_ = best_candidate;
if (IsBandwidthLimitedDueToLoss() &&
if (limited_due_to_loss_candidate_ &&
(recovering_after_loss_timestamp_.IsInfinite() ||
recovering_after_loss_timestamp_ + config_->delayed_increase_window <
last_send_time_most_recent_observation_)) {
bandwidth_limit_in_current_window_ =
std::max(kCongestionControllerMinBitrate,
current_estimate_.loss_limited_bandwidth *
config_->max_increase_factor);
bandwidth_limit_in_current_window_ = std::max(
kCongestionControllerMinBitrate,
best_candidate.loss_limited_bandwidth * config_->max_increase_factor);
recovering_after_loss_timestamp_ = last_send_time_most_recent_observation_;
}
}
bool LossBasedBweV2::IsEstimateIncreasingWhenLossLimited(
const ChannelParameters& best_candidate) {
return (current_estimate_.loss_limited_bandwidth <
best_candidate.loss_limited_bandwidth ||
(current_estimate_.loss_limited_bandwidth ==
best_candidate.loss_limited_bandwidth &&
current_state_ == LossBasedState::kIncreasing)) &&
IsBandwidthLimitedDueToLoss();
current_estimate_ = best_candidate;
}
// Returns a `LossBasedBweV2::Config` iff the `key_value_config` specifies a
@ -400,8 +339,6 @@ absl::optional<LossBasedBweV2::Config> LossBasedBweV2::CreateConfig(
"BandwidthCapAtHighLossRate", DataRate::KilobitsPerSec(500.0));
FieldTrialParameter<double> slope_of_bwe_high_loss_func(
"SlopeOfBweHighLossFunc", 1000);
FieldTrialParameter<bool> probe_integration_enabled("ProbeIntegrationEnabled",
false);
if (key_value_config) {
ParseFieldTrial({&enabled,
&bandwidth_rampup_upper_bound_factor,
@ -434,7 +371,6 @@ absl::optional<LossBasedBweV2::Config> LossBasedBweV2::CreateConfig(
&delayed_increase_window,
&use_acked_bitrate_only_when_overusing,
&not_increase_if_inherent_loss_less_than_average_loss,
&probe_integration_enabled,
&high_loss_rate_threshold,
&bandwidth_cap_at_high_loss_rate,
&slope_of_bwe_high_loss_func},
@ -497,8 +433,6 @@ absl::optional<LossBasedBweV2::Config> LossBasedBweV2::CreateConfig(
config->bandwidth_cap_at_high_loss_rate =
bandwidth_cap_at_high_loss_rate.Get();
config->slope_of_bwe_high_loss_func = slope_of_bwe_high_loss_func.Get();
config->probe_integration_enabled = probe_integration_enabled.Get();
return config;
}
@ -711,7 +645,7 @@ double LossBasedBweV2::GetAverageReportedLossRatio() const {
DataRate LossBasedBweV2::GetCandidateBandwidthUpperBound(
DataRate delay_based_estimate) const {
DataRate candidate_bandwidth_upper_bound = DataRate::PlusInfinity();
if (IsBandwidthLimitedDueToLoss()) {
if (limited_due_to_loss_candidate_) {
candidate_bandwidth_upper_bound = bandwidth_limit_in_current_window_;
}
@ -727,6 +661,14 @@ DataRate LossBasedBweV2::GetCandidateBandwidthUpperBound(
if (!acknowledged_bitrate_.has_value())
return candidate_bandwidth_upper_bound;
candidate_bandwidth_upper_bound =
IsValid(candidate_bandwidth_upper_bound)
? std::min(candidate_bandwidth_upper_bound,
config_->bandwidth_rampup_upper_bound_factor *
(*acknowledged_bitrate_))
: config_->bandwidth_rampup_upper_bound_factor *
(*acknowledged_bitrate_);
if (config_->rampup_acceleration_max_factor > 0.0) {
const TimeDelta time_since_bandwidth_reduced = std::min(
config_->rampup_acceleration_maxout_time,
@ -1053,8 +995,4 @@ bool LossBasedBweV2::PushBackObservation(
return true;
}
bool LossBasedBweV2::IsBandwidthLimitedDueToLoss() const {
return current_state_ != LossBasedState::kDelayBasedEstimate;
}
} // namespace webrtc

View File

@ -27,21 +27,8 @@
namespace webrtc {
// State of the loss based estimate, which can be either increasing/decreasing
// when network is loss limited, or equal to the delay based estimate.
enum class LossBasedState {
kIncreasing = 0,
kDecreasing = 1,
kDelayBasedEstimate = 2
};
class LossBasedBweV2 {
public:
struct Result {
~Result() = default;
DataRate bandwidth_estimate = DataRate::Zero();
LossBasedState state = LossBasedState::kDelayBasedEstimate;
};
// Creates a disabled `LossBasedBweV2` if the
// `key_value_config` is not valid.
explicit LossBasedBweV2(const FieldTrialsView* key_value_config);
@ -57,7 +44,7 @@ class LossBasedBweV2 {
bool IsReady() const;
// Returns `DataRate::PlusInfinity` if no BWE can be calculated.
Result GetLossBasedResult(DataRate delay_based_limit) const;
DataRate GetBandwidthEstimate(DataRate delay_based_limit) const;
void SetAcknowledgedBitrate(DataRate acknowledged_bitrate);
void SetBandwidthEstimate(DataRate bandwidth_estimate);
@ -65,8 +52,7 @@ class LossBasedBweV2 {
void UpdateBandwidthEstimate(
rtc::ArrayView<const PacketResult> packet_results,
DataRate delay_based_estimate,
BandwidthUsage delay_detector_state,
absl::optional<DataRate> probe_bitrate);
BandwidthUsage delay_detector_state);
private:
struct ChannelParameters {
@ -109,7 +95,6 @@ class LossBasedBweV2 {
double high_loss_rate_threshold = 1.0;
DataRate bandwidth_cap_at_high_loss_rate = DataRate::MinusInfinity();
double slope_of_bwe_high_loss_func = 1000.0;
bool probe_integration_enabled = false;
};
struct Derivatives {
@ -170,10 +155,6 @@ class LossBasedBweV2 {
const std::vector<PacketResult>& packet_feedbacks,
Timestamp at_time);
void UpdateDelayDetector(BandwidthUsage delay_detector_state);
bool IsEstimateIncreasingWhenLossLimited(
const ChannelParameters& best_candidate);
bool IsBandwidthLimitedDueToLoss() const;
void SetProbeBitrate(absl::optional<DataRate> probe_bitrate);
absl::optional<DataRate> acknowledged_bitrate_;
absl::optional<Config> config_;
@ -189,9 +170,8 @@ class LossBasedBweV2 {
std::deque<BandwidthUsage> delay_detector_states_;
Timestamp recovering_after_loss_timestamp_ = Timestamp::MinusInfinity();
DataRate bandwidth_limit_in_current_window_ = DataRate::PlusInfinity();
bool limited_due_to_loss_candidate_ = false;
DataRate min_bitrate_ = DataRate::KilobitsPerSec(1);
LossBasedState current_state_ = LossBasedState::kDelayBasedEstimate;
DataRate probe_bitrate_ = DataRate::PlusInfinity();
};
} // namespace webrtc

View File

@ -202,10 +202,8 @@ TEST_P(LossBasedBweV2Test, ReturnsDelayBasedEstimateWhenDisabled) {
/*trendline_integration_enabled=*/GetParam()));
LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config);
EXPECT_EQ(loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::KilobitsPerSec(100))
.bandwidth_estimate,
EXPECT_EQ(loss_based_bandwidth_estimator.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::KilobitsPerSec(100)),
DataRate::KilobitsPerSec(100));
}
@ -216,10 +214,8 @@ TEST_P(LossBasedBweV2Test,
/*trendline_integration_enabled=*/GetParam()));
LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config);
EXPECT_EQ(loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::KilobitsPerSec(100))
.bandwidth_estimate,
EXPECT_EQ(loss_based_bandwidth_estimator.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::KilobitsPerSec(100)),
DataRate::KilobitsPerSec(100));
}
@ -237,14 +233,13 @@ TEST_P(LossBasedBweV2Test,
loss_based_bandwidth_estimator.SetBandwidthEstimate(
DataRate::KilobitsPerSec(600));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
enough_feedback, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal);
EXPECT_TRUE(loss_based_bandwidth_estimator.IsReady());
EXPECT_TRUE(
loss_based_bandwidth_estimator
.GetLossBasedResult(/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate.IsFinite());
.GetBandwidthEstimate(/*delay_based_limit=*/DataRate::PlusInfinity())
.IsFinite());
}
TEST_P(LossBasedBweV2Test, NoBandwidthEstimateGivenNoInitialization) {
@ -257,14 +252,13 @@ TEST_P(LossBasedBweV2Test, NoBandwidthEstimateGivenNoInitialization) {
LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config);
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
enough_feedback, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal);
EXPECT_FALSE(loss_based_bandwidth_estimator.IsReady());
EXPECT_TRUE(
loss_based_bandwidth_estimator
.GetLossBasedResult(/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate.IsPlusInfinity());
.GetBandwidthEstimate(/*delay_based_limit=*/DataRate::PlusInfinity())
.IsPlusInfinity());
}
TEST_P(LossBasedBweV2Test, NoBandwidthEstimateGivenNotEnoughFeedback) {
@ -292,18 +286,17 @@ TEST_P(LossBasedBweV2Test, NoBandwidthEstimateGivenNotEnoughFeedback) {
EXPECT_FALSE(loss_based_bandwidth_estimator.IsReady());
EXPECT_TRUE(
loss_based_bandwidth_estimator
.GetLossBasedResult(/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate.IsPlusInfinity());
.GetBandwidthEstimate(/*delay_based_limit=*/DataRate::PlusInfinity())
.IsPlusInfinity());
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
not_enough_feedback, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
not_enough_feedback, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal);
EXPECT_FALSE(loss_based_bandwidth_estimator.IsReady());
EXPECT_TRUE(
loss_based_bandwidth_estimator
.GetLossBasedResult(/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate.IsPlusInfinity());
.GetBandwidthEstimate(/*delay_based_limit=*/DataRate::PlusInfinity())
.IsPlusInfinity());
}
TEST_P(LossBasedBweV2Test,
@ -324,32 +317,24 @@ TEST_P(LossBasedBweV2Test,
loss_based_bandwidth_estimator.SetBandwidthEstimate(
DataRate::KilobitsPerSec(600));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal);
EXPECT_NE(loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate,
EXPECT_NE(loss_based_bandwidth_estimator.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::PlusInfinity()),
DataRate::KilobitsPerSec(600));
loss_based_bandwidth_estimator.SetBandwidthEstimate(
DataRate::KilobitsPerSec(600));
EXPECT_EQ(loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate,
EXPECT_EQ(loss_based_bandwidth_estimator.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::PlusInfinity()),
DataRate::KilobitsPerSec(600));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal);
EXPECT_NE(loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate,
EXPECT_NE(loss_based_bandwidth_estimator.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::PlusInfinity()),
DataRate::KilobitsPerSec(600));
}
@ -374,42 +359,30 @@ TEST_P(LossBasedBweV2Test,
loss_based_bandwidth_estimator_2.SetBandwidthEstimate(
DataRate::KilobitsPerSec(600));
loss_based_bandwidth_estimator_1.UpdateBandwidthEstimate(
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal);
loss_based_bandwidth_estimator_2.UpdateBandwidthEstimate(
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal);
EXPECT_EQ(loss_based_bandwidth_estimator_1
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate,
EXPECT_EQ(loss_based_bandwidth_estimator_1.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::PlusInfinity()),
DataRate::KilobitsPerSec(660));
loss_based_bandwidth_estimator_1.SetAcknowledgedBitrate(
DataRate::KilobitsPerSec(900));
DataRate::KilobitsPerSec(600));
EXPECT_EQ(loss_based_bandwidth_estimator_1
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate,
EXPECT_EQ(loss_based_bandwidth_estimator_1.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::PlusInfinity()),
DataRate::KilobitsPerSec(660));
loss_based_bandwidth_estimator_1.UpdateBandwidthEstimate(
enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal);
loss_based_bandwidth_estimator_2.UpdateBandwidthEstimate(
enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal);
EXPECT_NE(loss_based_bandwidth_estimator_1
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate,
loss_based_bandwidth_estimator_2
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate);
EXPECT_NE(loss_based_bandwidth_estimator_1.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::PlusInfinity()),
loss_based_bandwidth_estimator_2.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::PlusInfinity()));
}
TEST_P(LossBasedBweV2Test,
@ -427,12 +400,10 @@ TEST_P(LossBasedBweV2Test,
DataRate::KilobitsPerSec(600));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_no_received_packets, DataRate::PlusInfinity(),
BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt);
BandwidthUsage::kBwNormal);
EXPECT_EQ(loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate,
EXPECT_EQ(loss_based_bandwidth_estimator.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::PlusInfinity()),
DataRate::KilobitsPerSec(100));
}
@ -458,19 +429,14 @@ TEST_P(LossBasedBweV2Test, BandwidthEstimateNotIncreaseWhenNetworkUnderusing) {
DataRate::KilobitsPerSec(600));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_1, DataRate::PlusInfinity(),
BandwidthUsage::kBwUnderusing, /*probe_estimate=*/absl::nullopt);
EXPECT_LE(loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate,
BandwidthUsage::kBwUnderusing);
EXPECT_LE(loss_based_bandwidth_estimator.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::PlusInfinity()),
DataRate::KilobitsPerSec(600));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
EXPECT_LE(loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate,
enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal);
EXPECT_LE(loss_based_bandwidth_estimator.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::PlusInfinity()),
DataRate::KilobitsPerSec(600));
}
@ -495,24 +461,18 @@ TEST_P(LossBasedBweV2Test,
loss_based_bandwidth_estimator.SetBandwidthEstimate(
DataRate::KilobitsPerSec(600));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal);
// If the delay based estimate is infinity, then loss based estimate increases
// and not bounded by delay based estimate.
EXPECT_GT(loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate,
EXPECT_GT(loss_based_bandwidth_estimator.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::PlusInfinity()),
DataRate::KilobitsPerSec(600));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal);
// If the delay based estimate is not infinity, then loss based estimate is
// bounded by delay based estimate.
EXPECT_EQ(loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::KilobitsPerSec(500))
.bandwidth_estimate,
EXPECT_EQ(loss_based_bandwidth_estimator.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::KilobitsPerSec(500)),
DataRate::KilobitsPerSec(500));
}
@ -540,18 +500,16 @@ TEST_P(LossBasedBweV2Test, UseAckedBitrateForEmegencyBackOff) {
loss_based_bandwidth_estimator.SetAcknowledgedBitrate(acked_bitrate);
// Update estimate when network is overusing, and 50% loss rate.
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwOverusing,
/*probe_estimate=*/absl::nullopt);
enough_feedback_1, DataRate::PlusInfinity(),
BandwidthUsage::kBwOverusing);
// Update estimate again when network is continuously overusing, and 100%
// loss rate.
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwOverusing,
/*probe_estimate=*/absl::nullopt);
enough_feedback_2, DataRate::PlusInfinity(),
BandwidthUsage::kBwOverusing);
// The estimate bitrate now is backed off based on acked bitrate.
EXPECT_LE(loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate,
EXPECT_LE(loss_based_bandwidth_estimator.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::PlusInfinity()),
acked_bitrate);
}
@ -571,21 +529,15 @@ TEST_P(LossBasedBweV2Test, NoBweChangeIfObservationDurationUnchanged) {
DataRate::KilobitsPerSec(300));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
DataRate estimate_1 = loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate;
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal);
DataRate estimate_1 = loss_based_bandwidth_estimator.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::PlusInfinity());
// Use the same feedback and check if the estimate is unchanged.
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
DataRate estimate_2 = loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate;
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal);
DataRate estimate_2 = loss_based_bandwidth_estimator.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::PlusInfinity());
EXPECT_EQ(estimate_2, estimate_1);
}
@ -608,20 +560,14 @@ TEST_P(LossBasedBweV2Test,
loss_based_bandwidth_estimator.SetBandwidthEstimate(
DataRate::KilobitsPerSec(600));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
DataRate estimate_1 = loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate;
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal);
DataRate estimate_1 = loss_based_bandwidth_estimator.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::PlusInfinity());
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
DataRate estimate_2 = loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate;
enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal);
DataRate estimate_2 = loss_based_bandwidth_estimator.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::PlusInfinity());
EXPECT_EQ(estimate_2, estimate_1);
}
@ -644,20 +590,15 @@ TEST_P(LossBasedBweV2Test,
loss_based_bandwidth_estimator.SetBandwidthEstimate(
DataRate::KilobitsPerSec(600));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
DataRate estimate_1 = loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate;
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal);
DataRate estimate_1 = loss_based_bandwidth_estimator.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::PlusInfinity());
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_2, DataRate::PlusInfinity(),
BandwidthUsage::kBwUnderusing, /*probe_estimate=*/absl::nullopt);
DataRate estimate_2 = loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate;
BandwidthUsage::kBwUnderusing);
DataRate estimate_2 = loss_based_bandwidth_estimator.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::PlusInfinity());
EXPECT_LE(estimate_2, estimate_1);
}
@ -687,20 +628,15 @@ TEST_P(LossBasedBweV2Test,
loss_based_bandwidth_estimator.SetAcknowledgedBitrate(
DataRate::KilobitsPerSec(300));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
DataRate estimate_1 = loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate;
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal);
DataRate estimate_1 = loss_based_bandwidth_estimator.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::PlusInfinity());
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwOverusing,
/*probe_estimate=*/absl::nullopt);
DataRate estimate_2 = loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate;
enough_feedback_2, DataRate::PlusInfinity(),
BandwidthUsage::kBwOverusing);
DataRate estimate_2 = loss_based_bandwidth_estimator.GetBandwidthEstimate(
/*delay_based_limit=*/DataRate::PlusInfinity());
EXPECT_LT(estimate_2, estimate_1);
}
@ -722,73 +658,26 @@ TEST_P(LossBasedBweV2Test,
DataRate::KilobitsPerSec(600));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_1, delay_based_estimate, BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
enough_feedback_1, delay_based_estimate, BandwidthUsage::kBwNormal);
EXPECT_EQ(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetBandwidthEstimate(delay_based_estimate),
delay_based_estimate);
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_2, delay_based_estimate, BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
enough_feedback_2, delay_based_estimate, BandwidthUsage::kBwNormal);
EXPECT_EQ(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetBandwidthEstimate(delay_based_estimate),
delay_based_estimate);
}
TEST_P(LossBasedBweV2Test,
IncreaseByMaxIncreaseFactorAfterLossBasedBweBacksOff) {
ExplicitKeyValueConfig key_value_config(
"WebRTC-Bwe-LossBasedBweV2/"
"Enabled:true,CandidateFactors:1.2|1|0.5,AckedRateCandidate:true,"
"ObservationWindowSize:2,ObservationDurationLowerBound:200ms,"
"InstantUpperBoundBwBalance:10000kbps,"
"DelayBasedCandidate:true,MaxIncreaseFactor:1.5,BwRampupUpperBoundFactor:"
"2.0/");
LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config);
DataRate delay_based_estimate = DataRate::KilobitsPerSec(5000);
DataRate acked_rate = DataRate::KilobitsPerSec(300);
loss_based_bandwidth_estimator.SetBandwidthEstimate(
DataRate::KilobitsPerSec(600));
loss_based_bandwidth_estimator.SetAcknowledgedBitrate(acked_rate);
// Create some loss to create the loss limited scenario.
std::vector<PacketResult> enough_feedback_1 =
CreatePacketResultsWith100pLossRate(
/*first_packet_timestamp=*/Timestamp::Zero());
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_1, delay_based_estimate, BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
LossBasedBweV2::Result result_at_loss =
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate);
// Network recovers after loss.
std::vector<PacketResult> enough_feedback_2 =
CreatePacketResultsWithReceivedPackets(
/*first_packet_timestamp=*/Timestamp::Zero() +
kObservationDurationLowerBound);
loss_based_bandwidth_estimator.SetAcknowledgedBitrate(
DataRate::KilobitsPerSec(600));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_2, delay_based_estimate, BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
LossBasedBweV2::Result result_after_recovery =
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate);
EXPECT_EQ(result_after_recovery.bandwidth_estimate,
result_at_loss.bandwidth_estimate * 1.5);
}
// After loss based bwe backs off, the next estimate is capped by
// a factor of acked bitrate.
// MaxIncreaseFactor * current estimate.
TEST_P(LossBasedBweV2Test,
IncreaseByFactorOfAckedBitrateAfterLossBasedBweBacksOff) {
IncreaseByMaxIncreaseFactorAfterLossBasedBweBacksOff) {
std::vector<PacketResult> enough_feedback_1 =
CreatePacketResultsWith100pLossRate(
CreatePacketResultsWithReceivedPackets(
/*first_packet_timestamp=*/Timestamp::Zero());
std::vector<PacketResult> enough_feedback_2 =
CreatePacketResultsWith10pLossRate(
CreatePacketResultsWithReceivedPackets(
/*first_packet_timestamp=*/Timestamp::Zero() +
kObservationDurationLowerBound);
ExplicitKeyValueConfig key_value_config(
@ -802,22 +691,22 @@ TEST_P(LossBasedBweV2Test,
loss_based_bandwidth_estimator.SetAcknowledgedBitrate(
DataRate::KilobitsPerSec(300));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_1, delay_based_estimate, BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
// Change the acked bitrate to make sure that the estimate is bounded by a
// factor of acked bitrate.
DataRate acked_bitrate = DataRate::KilobitsPerSec(50);
loss_based_bandwidth_estimator.SetAcknowledgedBitrate(acked_bitrate);
enough_feedback_1, delay_based_estimate, BandwidthUsage::kBwNormal);
DataRate estimate_1 =
loss_based_bandwidth_estimator.GetBandwidthEstimate(delay_based_estimate);
// Increase the acknowledged bitrate to make sure that the estimate is not
// capped too low.
loss_based_bandwidth_estimator.SetAcknowledgedBitrate(
DataRate::KilobitsPerSec(5000));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_2, delay_based_estimate, BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
enough_feedback_2, delay_based_estimate, BandwidthUsage::kBwNormal);
// The estimate is capped by acked_bitrate * BwRampupUpperBoundFactor.
// The estimate is capped by current_estimate * kMaxIncreaseFactor because it
// recently backed off.
DataRate estimate_2 =
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate;
EXPECT_EQ(estimate_2, acked_bitrate * 1.2);
loss_based_bandwidth_estimator.GetBandwidthEstimate(delay_based_estimate);
EXPECT_EQ(estimate_2, estimate_1 * kMaxIncreaseFactor);
EXPECT_LE(estimate_2, delay_based_estimate);
}
// After loss based bwe backs off, the estimate is bounded during the delayed
@ -846,30 +735,25 @@ TEST_P(LossBasedBweV2Test,
loss_based_bandwidth_estimator.SetAcknowledgedBitrate(
DataRate::KilobitsPerSec(300));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_1, delay_based_estimate, BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
enough_feedback_1, delay_based_estimate, BandwidthUsage::kBwNormal);
// Increase the acknowledged bitrate to make sure that the estimate is not
// capped too low.
loss_based_bandwidth_estimator.SetAcknowledgedBitrate(
DataRate::KilobitsPerSec(5000));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_2, delay_based_estimate, BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
enough_feedback_2, delay_based_estimate, BandwidthUsage::kBwNormal);
// The estimate is capped by current_estimate * kMaxIncreaseFactor because
// it recently backed off.
DataRate estimate_2 =
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate;
loss_based_bandwidth_estimator.GetBandwidthEstimate(delay_based_estimate);
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_3, delay_based_estimate, BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
enough_feedback_3, delay_based_estimate, BandwidthUsage::kBwNormal);
// The latest estimate is the same as the previous estimate since the sent
// packets were sent within the DelayedIncreaseWindow.
EXPECT_EQ(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetBandwidthEstimate(delay_based_estimate),
estimate_2);
}
@ -897,29 +781,24 @@ TEST_P(LossBasedBweV2Test, KeepIncreasingEstimateAfterDelayedIncreaseWindow) {
loss_based_bandwidth_estimator.SetAcknowledgedBitrate(
DataRate::KilobitsPerSec(300));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_1, delay_based_estimate, BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
enough_feedback_1, delay_based_estimate, BandwidthUsage::kBwNormal);
// Increase the acknowledged bitrate to make sure that the estimate is not
// capped too low.
loss_based_bandwidth_estimator.SetAcknowledgedBitrate(
DataRate::KilobitsPerSec(5000));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_2, delay_based_estimate, BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
enough_feedback_2, delay_based_estimate, BandwidthUsage::kBwNormal);
// The estimate is capped by current_estimate * kMaxIncreaseFactor because it
// recently backed off.
DataRate estimate_2 =
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate;
loss_based_bandwidth_estimator.GetBandwidthEstimate(delay_based_estimate);
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_3, delay_based_estimate, BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
enough_feedback_3, delay_based_estimate, BandwidthUsage::kBwNormal);
// The estimate can continue increasing after the DelayedIncreaseWindow.
EXPECT_GE(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetBandwidthEstimate(delay_based_estimate),
estimate_2);
}
@ -942,7 +821,7 @@ TEST_P(LossBasedBweV2Test, NotIncreaseIfInherentLossLessThanAverageLoss) {
/*first_packet_timestamp=*/Timestamp::Zero());
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_10p_loss_1, delay_based_estimate,
BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt);
BandwidthUsage::kBwNormal);
std::vector<PacketResult> enough_feedback_10p_loss_2 =
CreatePacketResultsWith10pLossRate(
@ -950,12 +829,11 @@ TEST_P(LossBasedBweV2Test, NotIncreaseIfInherentLossLessThanAverageLoss) {
kObservationDurationLowerBound);
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_10p_loss_2, delay_based_estimate,
BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt);
BandwidthUsage::kBwNormal);
// Do not increase the bitrate because inherent loss is less than average loss
EXPECT_EQ(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetBandwidthEstimate(delay_based_estimate),
DataRate::KilobitsPerSec(600));
}
@ -980,7 +858,7 @@ TEST_P(LossBasedBweV2Test,
/*first_packet_timestamp=*/Timestamp::Zero());
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_10p_loss_1, delay_based_estimate,
BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt);
BandwidthUsage::kBwNormal);
std::vector<PacketResult> enough_feedback_10p_loss_2 =
CreatePacketResultsWith10pLossRate(
@ -988,13 +866,12 @@ TEST_P(LossBasedBweV2Test,
kObservationDurationLowerBound);
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_10p_loss_2, delay_based_estimate,
BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt);
BandwidthUsage::kBwNormal);
// Because LossThresholdOfHighBandwidthPreference is 20%, the average loss is
// 10%, bandwidth estimate should increase.
EXPECT_GT(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetBandwidthEstimate(delay_based_estimate),
DataRate::KilobitsPerSec(600));
}
@ -1019,7 +896,7 @@ TEST_P(LossBasedBweV2Test,
/*first_packet_timestamp=*/Timestamp::Zero());
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_10p_loss_1, delay_based_estimate,
BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt);
BandwidthUsage::kBwNormal);
std::vector<PacketResult> enough_feedback_10p_loss_2 =
CreatePacketResultsWith10pLossRate(
@ -1027,54 +904,15 @@ TEST_P(LossBasedBweV2Test,
kObservationDurationLowerBound);
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_10p_loss_2, delay_based_estimate,
BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt);
BandwidthUsage::kBwNormal);
// Because LossThresholdOfHighBandwidthPreference is 5%, the average loss is
// 10%, bandwidth estimate should decrease.
EXPECT_LT(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetBandwidthEstimate(delay_based_estimate),
DataRate::KilobitsPerSec(600));
}
TEST_P(LossBasedBweV2Test, UseProbeResultWhenRecoveringFromLoss) {
ExplicitKeyValueConfig key_value_config(
"WebRTC-Bwe-LossBasedBweV2/"
"Enabled:true,CandidateFactors:1.2|1|0.5,AckedRateCandidate:true,"
"ObservationWindowSize:2,ObservationDurationLowerBound:200ms,"
"InstantUpperBoundBwBalance:10000kbps,"
"DelayBasedCandidate:true,MaxIncreaseFactor:1000,"
"BwRampupUpperBoundFactor:2.0,ProbeIntegrationEnabled:true/");
LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config);
DataRate delay_based_estimate = DataRate::KilobitsPerSec(5000);
DataRate acked_rate = DataRate::KilobitsPerSec(300);
loss_based_bandwidth_estimator.SetBandwidthEstimate(
DataRate::KilobitsPerSec(600));
loss_based_bandwidth_estimator.SetAcknowledgedBitrate(acked_rate);
// Create some loss to create the loss limited scenario.
std::vector<PacketResult> enough_feedback_1 =
CreatePacketResultsWith100pLossRate(
/*first_packet_timestamp=*/Timestamp::Zero());
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_1, delay_based_estimate, BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
// Network recovers after loss.
DataRate probe_estimate = DataRate::KilobitsPerSec(300);
std::vector<PacketResult> enough_feedback_2 =
CreatePacketResultsWithReceivedPackets(
/*first_packet_timestamp=*/Timestamp::Zero() +
kObservationDurationLowerBound);
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_2, delay_based_estimate, BandwidthUsage::kBwNormal,
probe_estimate);
LossBasedBweV2::Result result_after_recovery =
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate);
EXPECT_EQ(result_after_recovery.bandwidth_estimate, probe_estimate);
}
TEST_P(LossBasedBweV2Test,
StricterBoundUsingHighLossRateThresholdAt10pLossRate) {
ExplicitKeyValueConfig key_value_config(
@ -1096,7 +934,7 @@ TEST_P(LossBasedBweV2Test,
/*first_packet_timestamp=*/Timestamp::Zero());
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_10p_loss_1, delay_based_estimate,
BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt);
BandwidthUsage::kBwNormal);
std::vector<PacketResult> enough_feedback_10p_loss_2 =
CreatePacketResultsWith10pLossRate(
@ -1104,13 +942,12 @@ TEST_P(LossBasedBweV2Test,
kObservationDurationLowerBound);
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_10p_loss_2, delay_based_estimate,
BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt);
BandwidthUsage::kBwNormal);
// At 10% loss rate and high loss rate threshold to be 10%, cap the estimate
// to be 500 * 1000-0.1 = 400kbps.
EXPECT_EQ(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetBandwidthEstimate(delay_based_estimate),
DataRate::KilobitsPerSec(400));
}
@ -1135,7 +972,7 @@ TEST_P(LossBasedBweV2Test,
/*first_packet_timestamp=*/Timestamp::Zero());
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_50p_loss_1, delay_based_estimate,
BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt);
BandwidthUsage::kBwNormal);
std::vector<PacketResult> enough_feedback_50p_loss_2 =
CreatePacketResultsWith50pLossRate(
@ -1143,13 +980,12 @@ TEST_P(LossBasedBweV2Test,
kObservationDurationLowerBound);
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_50p_loss_2, delay_based_estimate,
BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt);
BandwidthUsage::kBwNormal);
// At 50% loss rate and high loss rate threshold to be 30%, cap the estimate
// to be the min bitrate.
EXPECT_EQ(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetBandwidthEstimate(delay_based_estimate),
DataRate::KilobitsPerSec(10));
}
@ -1174,7 +1010,7 @@ TEST_P(LossBasedBweV2Test,
/*first_packet_timestamp=*/Timestamp::Zero());
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_100p_loss_1, delay_based_estimate,
BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt);
BandwidthUsage::kBwNormal);
std::vector<PacketResult> enough_feedback_100p_loss_2 =
CreatePacketResultsWith100pLossRate(
@ -1182,13 +1018,12 @@ TEST_P(LossBasedBweV2Test,
kObservationDurationLowerBound);
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_100p_loss_2, delay_based_estimate,
BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt);
BandwidthUsage::kBwNormal);
// At 100% loss rate and high loss rate threshold to be 30%, cap the estimate
// to be the min bitrate.
EXPECT_EQ(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetBandwidthEstimate(delay_based_estimate),
DataRate::KilobitsPerSec(10));
}
@ -1212,13 +1047,12 @@ TEST_P(LossBasedBweV2Test, EstimateRecoversAfterHighLoss) {
/*first_packet_timestamp=*/Timestamp::Zero());
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_100p_loss_1, delay_based_estimate,
BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt);
BandwidthUsage::kBwNormal);
// Make sure that the estimate is set to min bitrate because of 100% loss
// rate.
EXPECT_EQ(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetBandwidthEstimate(delay_based_estimate),
DataRate::KilobitsPerSec(10));
// Create some feedbacks with 0 loss rate to simulate network recovering.
@ -1228,7 +1062,7 @@ TEST_P(LossBasedBweV2Test, EstimateRecoversAfterHighLoss) {
kObservationDurationLowerBound);
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_0p_loss_1, delay_based_estimate,
BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt);
BandwidthUsage::kBwNormal);
std::vector<PacketResult> enough_feedback_0p_loss_2 =
CreatePacketResultsWithReceivedPackets(
@ -1236,12 +1070,11 @@ TEST_P(LossBasedBweV2Test, EstimateRecoversAfterHighLoss) {
kObservationDurationLowerBound * 2);
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_0p_loss_2, delay_based_estimate,
BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt);
BandwidthUsage::kBwNormal);
// The estimate increases as network recovers.
EXPECT_GT(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetBandwidthEstimate(delay_based_estimate),
DataRate::KilobitsPerSec(10));
}

View File

@ -229,7 +229,6 @@ SendSideBandwidthEstimation::SendSideBandwidthEstimation(
bitrate_threshold_(kDefaultBitrateThreshold),
loss_based_bandwidth_estimator_v1_(key_value_config),
loss_based_bandwidth_estimator_v2_(key_value_config),
loss_based_state_(LossBasedState::kDelayBasedEstimate),
disable_receiver_limit_caps_only_("Disabled") {
RTC_DCHECK(event_log);
if (BweLossExperimentIsEnabled()) {
@ -321,10 +320,6 @@ DataRate SendSideBandwidthEstimation::target_rate() const {
return std::max(min_bitrate_configured_, target);
}
LossBasedState SendSideBandwidthEstimation::loss_based_state() const {
return loss_based_state_;
}
DataRate SendSideBandwidthEstimation::delay_based_limit() const {
return delay_based_limit_;
}
@ -369,16 +364,14 @@ void SendSideBandwidthEstimation::SetAcknowledgedRate(
void SendSideBandwidthEstimation::UpdateLossBasedEstimator(
const TransportPacketsFeedback& report,
BandwidthUsage delay_detector_state,
absl::optional<DataRate> probe_bitrate) {
BandwidthUsage delay_detector_state) {
if (LossBasedBandwidthEstimatorV1Enabled()) {
loss_based_bandwidth_estimator_v1_.UpdateLossStatistics(
report.packet_feedbacks, report.feedback_time);
}
if (LossBasedBandwidthEstimatorV2Enabled()) {
loss_based_bandwidth_estimator_v2_.UpdateBandwidthEstimate(
report.packet_feedbacks, delay_based_limit_, delay_detector_state,
probe_bitrate);
report.packet_feedbacks, delay_based_limit_, delay_detector_state);
UpdateEstimate(report.feedback_time);
}
}
@ -526,11 +519,10 @@ void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) {
}
if (LossBasedBandwidthEstimatorV2ReadyForUse()) {
LossBasedBweV2::Result result =
loss_based_bandwidth_estimator_v2_.GetLossBasedResult(
DataRate new_bitrate =
loss_based_bandwidth_estimator_v2_.GetBandwidthEstimate(
delay_based_limit_);
loss_based_state_ = result.state;
UpdateTargetBitrate(result.bandwidth_estimate, at_time);
UpdateTargetBitrate(new_bitrate, at_time);
return;
}

View File

@ -85,7 +85,6 @@ class SendSideBandwidthEstimation {
void OnRouteChange();
DataRate target_rate() const;
LossBasedState loss_based_state() const;
DataRate delay_based_limit() const;
uint8_t fraction_loss() const { return last_fraction_loss_; }
TimeDelta round_trip_time() const { return last_round_trip_time_; }
@ -120,8 +119,7 @@ class SendSideBandwidthEstimation {
void SetAcknowledgedRate(absl::optional<DataRate> acknowledged_rate,
Timestamp at_time);
void UpdateLossBasedEstimator(const TransportPacketsFeedback& report,
BandwidthUsage delay_detector_state,
absl::optional<DataRate> probe_bitrate);
BandwidthUsage delay_detector_state);
private:
friend class GoogCcStatePrinter;
@ -203,7 +201,6 @@ class SendSideBandwidthEstimation {
DataRate bitrate_threshold_;
LossBasedBandwidthEstimation loss_based_bandwidth_estimator_v1_;
LossBasedBweV2 loss_based_bandwidth_estimator_v2_;
LossBasedState loss_based_state_;
FieldTrialFlag disable_receiver_limit_caps_only_;
};
} // namespace webrtc