Minor refactor in GoogCcNetworkController.

In-lining GetNetworkParameters and MaybeUpdateCongestionWindow which
was left over from previous refactoring. This prepares for upcoming CLs
changing the behavior.

Bug: webrtc:9586
Change-Id: I6f038acdf97c3db2c85254a36592c617a5754a96
Reviewed-on: https://webrtc-review.googlesource.com/97605
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24570}
This commit is contained in:
Sebastian Jansson
2018-09-04 17:17:16 +02:00
committed by Commit Bot
parent e2924d555d
commit 8f03216bbd
2 changed files with 40 additions and 64 deletions

View File

@ -335,12 +335,13 @@ NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback(
feedback_max_rtt = std::max(feedback_max_rtt, rtt);
max_recv_time = std::max(max_recv_time, packet_feedback.receive_time);
}
absl::optional<int64_t> min_feedback_max_rtt_ms;
if (feedback_max_rtt.IsFinite()) {
feedback_max_rtts_.push_back(feedback_max_rtt.ms());
const size_t kMaxFeedbackRttWindow = 32;
if (feedback_max_rtts_.size() > kMaxFeedbackRttWindow)
feedback_max_rtts_.pop_front();
min_feedback_max_rtt_ms_.emplace(*std::min_element(
min_feedback_max_rtt_ms.emplace(*std::min_element(
feedback_max_rtts_.begin(), feedback_max_rtts_.end()));
}
if (packet_feedback_only_) {
@ -416,7 +417,26 @@ NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback(
update.probe_cluster_configs.insert(update.probe_cluster_configs.end(),
probes.begin(), probes.end());
}
update.congestion_window = MaybeUpdateCongestionWindow();
// No valid RTT could be because send-side BWE isn't used, in which case
// we don't try to limit the outstanding packets.
if (in_cwnd_experiment_ && min_feedback_max_rtt_ms) {
const DataSize kMinCwnd = DataSize::bytes(2 * 1500);
TimeDelta time_window =
TimeDelta::ms(*min_feedback_max_rtt_ms + accepted_queue_ms_);
DataSize data_window = last_bandwidth_ * time_window;
if (current_data_window_) {
data_window =
std::max(kMinCwnd, (data_window + current_data_window_.value()) / 2);
} else {
data_window = std::max(kMinCwnd, data_window);
}
current_data_window_ = data_window;
RTC_LOG(LS_INFO) << "Feedback rtt: " << *min_feedback_max_rtt_ms
<< " Bitrate: " << last_bandwidth_.bps();
}
update.congestion_window = current_data_window_;
return update;
}
@ -440,30 +460,6 @@ NetworkControlUpdate GoogCcNetworkController::GetNetworkState(
return update;
}
absl::optional<DataSize>
GoogCcNetworkController::MaybeUpdateCongestionWindow() {
if (!in_cwnd_experiment_)
return absl::nullopt;
// No valid RTT. Could be because send-side BWE isn't used, in which case
// we don't try to limit the outstanding packets.
if (!min_feedback_max_rtt_ms_)
return absl::nullopt;
const DataSize kMinCwnd = DataSize::bytes(2 * 1500);
TimeDelta time_window =
TimeDelta::ms(*min_feedback_max_rtt_ms_ + accepted_queue_ms_);
DataSize data_window = last_bandwidth_ * time_window;
if (current_data_window_) {
data_window =
std::max(kMinCwnd, (data_window + current_data_window_.value()) / 2);
} else {
data_window = std::max(kMinCwnd, data_window);
}
current_data_window_ = data_window;
RTC_LOG(LS_INFO) << "Feedback rtt: " << *min_feedback_max_rtt_ms_
<< " Bitrate: " << last_bandwidth_.bps();
return data_window;
}
void GoogCcNetworkController::MaybeTriggerOnNetworkChanged(
NetworkControlUpdate* update,
@ -471,10 +467,25 @@ void GoogCcNetworkController::MaybeTriggerOnNetworkChanged(
int32_t estimated_bitrate_bps;
uint8_t fraction_loss;
int64_t rtt_ms;
bandwidth_estimation_->CurrentEstimate(&estimated_bitrate_bps, &fraction_loss,
&rtt_ms);
estimated_bitrate_bps = std::max<int32_t>(
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);
BWE_TEST_LOGGING_PLOT(1, "Target_bitrate_kbps", at_time.ms(),
estimated_bitrate_bps / 1000);
if ((estimated_bitrate_bps != last_estimated_bitrate_bps_) ||
(fraction_loss != last_estimated_fraction_loss_) ||
(rtt_ms != last_estimated_rtt_ms_)) {
last_estimated_bitrate_bps_ = estimated_bitrate_bps;
last_estimated_fraction_loss_ = fraction_loss;
last_estimated_rtt_ms_ = rtt_ms;
bool estimate_changed = GetNetworkParameters(
&estimated_bitrate_bps, &fraction_loss, &rtt_ms, at_time);
if (estimate_changed) {
alr_detector_->SetEstimatedBitrate(estimated_bitrate_bps);
DataRate bandwidth = DataRate::bps(estimated_bitrate_bps);
@ -504,35 +515,6 @@ void GoogCcNetworkController::MaybeTriggerOnNetworkChanged(
}
}
bool GoogCcNetworkController::GetNetworkParameters(
int32_t* estimated_bitrate_bps,
uint8_t* fraction_loss,
int64_t* rtt_ms,
Timestamp at_time) {
bandwidth_estimation_->CurrentEstimate(estimated_bitrate_bps, fraction_loss,
rtt_ms);
*estimated_bitrate_bps = std::max<int32_t>(
*estimated_bitrate_bps, bandwidth_estimation_->GetMinBitrate());
bool estimate_changed = false;
if ((*estimated_bitrate_bps != last_estimated_bitrate_bps_) ||
(*fraction_loss != last_estimated_fraction_loss_) ||
(*rtt_ms != last_estimated_rtt_ms_)) {
last_estimated_bitrate_bps_ = *estimated_bitrate_bps;
last_estimated_fraction_loss_ = *fraction_loss;
last_estimated_rtt_ms_ = *rtt_ms;
estimate_changed = true;
}
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);
BWE_TEST_LOGGING_PLOT(1, "Target_bitrate_kbps", at_time.ms(),
*estimated_bitrate_bps / 1000);
return estimate_changed;
}
PacerConfig GoogCcNetworkController::GetPacingRates(Timestamp at_time) const {
DataRate pacing_rate =
std::max(min_pacing_rate_, last_bandwidth_) * pacing_factor_;

View File

@ -56,13 +56,8 @@ class GoogCcNetworkController : public NetworkControllerInterface {
std::vector<ProbeClusterConfig> UpdateBitrateConstraints(
TargetRateConstraints constraints,
absl::optional<DataRate> starting_rate);
absl::optional<DataSize> MaybeUpdateCongestionWindow();
void MaybeTriggerOnNetworkChanged(NetworkControlUpdate* update,
Timestamp at_time);
bool GetNetworkParameters(int32_t* estimated_bitrate_bps,
uint8_t* fraction_loss,
int64_t* rtt_ms,
Timestamp at_time);
PacerConfig GetPacingRates(Timestamp at_time) const;
RtcEventLog* const event_log_;
@ -82,7 +77,6 @@ class GoogCcNetworkController : public NetworkControllerInterface {
int expected_packets_since_last_loss_update_ = 0;
std::deque<int64_t> feedback_max_rtts_;
absl::optional<int64_t> min_feedback_max_rtt_ms_;
DataRate last_bandwidth_;
absl::optional<TargetTransferRate> last_target_rate_;