Use field trial parser for BBR Experiment.

Bug: webrtc:8415
Change-Id: If6336b16fa55c6bd891252fc3b9c0bcce56e2fd1
Reviewed-on: https://webrtc-review.googlesource.com/83620
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23761}
This commit is contained in:
Sebastian Jansson
2018-06-27 14:06:00 +02:00
committed by Commit Bot
parent e275174b1b
commit 968b1dd0d7
6 changed files with 151 additions and 239 deletions

View File

@ -30,34 +30,4 @@ bool CongestionControllerExperiment::InjectedControllerEnabled() {
webrtc::field_trial::FindFullName(kControllerExperiment);
return trial_string.find("Enabled,Injected") == 0;
}
absl::optional<CongestionControllerExperiment::BbrExperimentConfig>
CongestionControllerExperiment::GetBbrExperimentConfig() {
if (!BbrControllerEnabled())
return absl::nullopt;
std::string trial_string =
webrtc::field_trial::FindFullName(kControllerExperiment);
BbrExperimentConfig config;
if (sscanf(
trial_string.c_str(),
"Enabled,BBR,"
"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,"
"%lf,%lf,%lf,%lf,%lf,%lf",
&config.exit_startup_on_loss, &config.exit_startup_rtt_threshold_ms,
&config.fully_drain_queue, &config.initial_conservation_in_startup,
&config.num_startup_rtts, &config.probe_rtt_based_on_bdp,
&config.probe_rtt_disabled_if_app_limited,
&config.probe_rtt_skipped_if_similar_rtt, &config.rate_based_recovery,
&config.rate_based_startup, &config.slower_startup,
&config.encoder_rate_gain, &config.encoder_rate_gain_in_probe_rtt,
&config.max_ack_height_window_multiplier,
&config.max_aggregation_bytes_multiplier,
&config.probe_bw_pacing_gain_offset,
&config.probe_rtt_congestion_window_gain) == 17) {
return config;
} else {
return absl::nullopt;
}
}
} // namespace webrtc

View File

@ -9,32 +9,12 @@
*/
#ifndef RTC_BASE_EXPERIMENTS_CONGESTION_CONTROLLER_EXPERIMENT_H_
#define RTC_BASE_EXPERIMENTS_CONGESTION_CONTROLLER_EXPERIMENT_H_
#include <api/optional.h>
namespace webrtc {
class CongestionControllerExperiment {
public:
struct BbrExperimentConfig {
int exit_startup_on_loss;
int exit_startup_rtt_threshold_ms;
int fully_drain_queue;
int initial_conservation_in_startup;
int num_startup_rtts;
int probe_rtt_based_on_bdp;
int probe_rtt_disabled_if_app_limited;
int probe_rtt_skipped_if_similar_rtt;
int rate_based_recovery;
int rate_based_startup;
int slower_startup;
double encoder_rate_gain;
double encoder_rate_gain_in_probe_rtt;
double max_ack_height_window_multiplier;
double max_aggregation_bytes_multiplier;
double probe_bw_pacing_gain_offset;
double probe_rtt_congestion_window_gain;
};
static bool BbrControllerEnabled();
static bool InjectedControllerEnabled();
static absl::optional<BbrExperimentConfig> GetBbrExperimentConfig();
};
} // namespace webrtc

View File

@ -13,35 +13,6 @@
#include "test/field_trial.h"
namespace webrtc {
namespace {
void ExpectEquals(CongestionControllerExperiment::BbrExperimentConfig a,
CongestionControllerExperiment::BbrExperimentConfig b) {
EXPECT_EQ(a.exit_startup_on_loss, b.exit_startup_on_loss);
EXPECT_EQ(a.exit_startup_rtt_threshold_ms, b.exit_startup_rtt_threshold_ms);
EXPECT_EQ(a.fully_drain_queue, b.fully_drain_queue);
EXPECT_EQ(a.initial_conservation_in_startup,
b.initial_conservation_in_startup);
EXPECT_EQ(a.num_startup_rtts, b.num_startup_rtts);
EXPECT_EQ(a.probe_rtt_based_on_bdp, b.probe_rtt_based_on_bdp);
EXPECT_EQ(a.probe_rtt_disabled_if_app_limited,
b.probe_rtt_disabled_if_app_limited);
EXPECT_EQ(a.probe_rtt_skipped_if_similar_rtt,
b.probe_rtt_skipped_if_similar_rtt);
EXPECT_EQ(a.rate_based_recovery, b.rate_based_recovery);
EXPECT_EQ(a.rate_based_startup, b.rate_based_startup);
EXPECT_EQ(a.slower_startup, b.slower_startup);
EXPECT_EQ(a.encoder_rate_gain, b.encoder_rate_gain);
EXPECT_EQ(a.encoder_rate_gain_in_probe_rtt, b.encoder_rate_gain_in_probe_rtt);
EXPECT_EQ(a.max_ack_height_window_multiplier,
b.max_ack_height_window_multiplier);
EXPECT_EQ(a.max_aggregation_bytes_multiplier,
b.max_aggregation_bytes_multiplier);
EXPECT_EQ(a.probe_bw_pacing_gain_offset, b.probe_bw_pacing_gain_offset);
EXPECT_EQ(a.probe_rtt_congestion_window_gain,
b.probe_rtt_congestion_window_gain);
}
} // namespace
TEST(CongestionControllerExperimentTest, BbrDisabledByDefault) {
webrtc::test::ScopedFieldTrials field_trials("");
EXPECT_FALSE(CongestionControllerExperiment::BbrControllerEnabled());
@ -52,38 +23,4 @@ TEST(CongestionControllerExperimentTest, BbrEnabledByFieldTrial) {
"WebRTC-BweCongestionController/Enabled,BBR/");
EXPECT_TRUE(CongestionControllerExperiment::BbrControllerEnabled());
}
TEST(CongestionControllerExperimentTest, BbrBadParametersFails) {
webrtc::test::ScopedFieldTrials field_trials(
"WebRTC-BweCongestionController/Enabled,BBR,"
"garbage,here/");
EXPECT_FALSE(CongestionControllerExperiment::GetBbrExperimentConfig());
}
TEST(CongestionControllerExperimentTest, BbrZeroParametersParsed) {
CongestionControllerExperiment::BbrExperimentConfig truth = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
webrtc::test::ScopedFieldTrials field_trials(
"WebRTC-BweCongestionController/Enabled,BBR,"
"0,0,0,0,0,0,0,0,0,0,0,"
"0,0,0,0,0,0/");
auto config = CongestionControllerExperiment::GetBbrExperimentConfig();
EXPECT_TRUE(config);
if (config)
ExpectEquals(truth, *config);
}
TEST(CongestionControllerExperimentTest, BbrNonZeroParametersParsed) {
CongestionControllerExperiment::BbrExperimentConfig truth = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25};
webrtc::test::ScopedFieldTrials field_trials(
"WebRTC-BweCongestionController/Enabled,BBR,"
"1,1,1,1,1,1,1,1,1,1,1,"
"0.25,0.25,0.25,0.25,0.25,0.25/");
auto config = CongestionControllerExperiment::GetBbrExperimentConfig();
EXPECT_TRUE(config);
if (config)
ExpectEquals(truth, *config);
}
} // namespace webrtc