From 49167de0be56dc8657e301d17b14c107ba2f6192 Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Thu, 27 Jun 2019 15:59:03 +0200 Subject: [PATCH] Adds interface for remote network estimates to NetworkControllerInterface. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:10742 Change-Id: I593fc17ce5d42c5dc17fd289f0621230319f9752 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144039 Commit-Queue: Sebastian Jansson Reviewed-by: Björn Terelius Cr-Commit-Position: refs/heads/master@{#28405} --- api/transport/network_control.h | 2 ++ .../bbr/bbr_network_controller.cc | 5 +++++ .../bbr/bbr_network_controller.h | 2 ++ .../goog_cc/goog_cc_network_control.cc | 20 +++++++++++-------- .../goog_cc/goog_cc_network_control.h | 4 ++++ .../pcc/pcc_network_controller.cc | 5 +++++ .../pcc/pcc_network_controller.h | 2 ++ test/scenario/call_client.cc | 5 +++++ test/scenario/call_client.h | 2 ++ 9 files changed, 39 insertions(+), 8 deletions(-) diff --git a/api/transport/network_control.h b/api/transport/network_control.h index 9c60ccb29f..11cda46cfc 100644 --- a/api/transport/network_control.h +++ b/api/transport/network_control.h @@ -84,6 +84,8 @@ class NetworkControllerInterface { // Called with per packet feedback regarding receive time. virtual NetworkControlUpdate OnTransportPacketsFeedback( TransportPacketsFeedback) = 0; + // Called with network state estimate updates. + virtual NetworkControlUpdate OnNetworkStateEstimate(NetworkStateEstimate) = 0; }; // NetworkControllerFactoryInterface is an interface for creating a network diff --git a/modules/congestion_controller/bbr/bbr_network_controller.cc b/modules/congestion_controller/bbr/bbr_network_controller.cc index 2e395e9fd0..c64152c943 100644 --- a/modules/congestion_controller/bbr/bbr_network_controller.cc +++ b/modules/congestion_controller/bbr/bbr_network_controller.cc @@ -503,6 +503,11 @@ NetworkControlUpdate BbrNetworkController::OnReceivedPacket( return NetworkControlUpdate(); } +NetworkControlUpdate BbrNetworkController::OnNetworkStateEstimate( + NetworkStateEstimate msg) { + return NetworkControlUpdate(); +} + TimeDelta BbrNetworkController::GetMinRtt() const { return !min_rtt_.IsZero() ? min_rtt_ : TimeDelta::us(rtt_stats_.initial_rtt_us()); diff --git a/modules/congestion_controller/bbr/bbr_network_controller.h b/modules/congestion_controller/bbr/bbr_network_controller.h index 8598cadab1..e99452a4fa 100644 --- a/modules/congestion_controller/bbr/bbr_network_controller.h +++ b/modules/congestion_controller/bbr/bbr_network_controller.h @@ -165,6 +165,8 @@ class BbrNetworkController : public NetworkControllerInterface { NetworkControlUpdate OnRoundTripTimeUpdate(RoundTripTimeUpdate msg) override; NetworkControlUpdate OnTransportLossReport(TransportLossReport msg) override; NetworkControlUpdate OnReceivedPacket(ReceivedPacket msg) override; + NetworkControlUpdate OnNetworkStateEstimate( + NetworkStateEstimate msg) override; NetworkControlUpdate CreateRateUpdate(Timestamp at_time) const; 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 8bd3cfb228..ddc5ca3b11 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc @@ -253,10 +253,9 @@ NetworkControlUpdate GoogCcNetworkController::OnSentPacket( } bandwidth_estimation_->OnSentPacket(sent_packet); bool network_changed = false; - if (network_estimator_ && overuse_predictor_.Enabled()) { + if (overuse_predictor_.Enabled()) { overuse_predictor_.OnSentPacket(sent_packet); - auto estimate = network_estimator_->GetCurrentEstimate(); - if (estimate && overuse_predictor_.PredictOveruse(*estimate)) { + if (estimate_ && overuse_predictor_.PredictOveruse(*estimate_)) { DataRate new_target = delay_based_bwe_->TriggerOveruse( sent_packet.send_time, acknowledged_bitrate_estimator_->bitrate()); bandwidth_estimation_->UpdateDelayBasedEstimate(sent_packet.send_time, @@ -510,19 +509,18 @@ NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback( report.feedback_time); bandwidth_estimation_->IncomingPacketFeedbackVector(report); - if (network_estimator_) + if (network_estimator_) { network_estimator_->OnTransportPacketsFeedback(report); + estimate_ = network_estimator_->GetCurrentEstimate(); + } NetworkControlUpdate update; bool recovered_from_overuse = false; bool backoff_in_alr = false; DelayBasedBwe::Result result; - absl::optional network_estimate = - network_estimator_ ? network_estimator_->GetCurrentEstimate() - : absl::nullopt; result = delay_based_bwe_->IncomingPacketFeedbackVector( - report, acknowledged_bitrate, probe_bitrate, network_estimate, + report, acknowledged_bitrate, probe_bitrate, estimate_, alr_start_time.has_value()); if (result.updated) { @@ -568,6 +566,12 @@ NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback( return update; } +NetworkControlUpdate GoogCcNetworkController::OnNetworkStateEstimate( + NetworkStateEstimate msg) { + estimate_ = msg; + return NetworkControlUpdate(); +} + NetworkControlUpdate GoogCcNetworkController::GetNetworkState( Timestamp at_time) const { DataRate bandwidth = use_stable_bandwidth_estimate_ 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 ef75d7a849..5b24d14492 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control.h +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control.h @@ -64,6 +64,8 @@ class GoogCcNetworkController : public NetworkControllerInterface { NetworkControlUpdate OnTransportLossReport(TransportLossReport msg) override; NetworkControlUpdate OnTransportPacketsFeedback( TransportPacketsFeedback msg) override; + NetworkControlUpdate OnNetworkStateEstimate( + NetworkStateEstimate msg) override; NetworkControlUpdate GetNetworkState(Timestamp at_time) const; @@ -110,6 +112,8 @@ class GoogCcNetworkController : public NetworkControllerInterface { bool first_packet_sent_ = false; + absl::optional estimate_; + Timestamp next_loss_update_ = Timestamp::MinusInfinity(); int lost_packets_since_last_loss_update_ = 0; int expected_packets_since_last_loss_update_ = 0; diff --git a/modules/congestion_controller/pcc/pcc_network_controller.cc b/modules/congestion_controller/pcc/pcc_network_controller.cc index a284710d8f..c6fac49fda 100644 --- a/modules/congestion_controller/pcc/pcc_network_controller.cc +++ b/modules/congestion_controller/pcc/pcc_network_controller.cc @@ -381,5 +381,10 @@ NetworkControlUpdate PccNetworkController::OnReceivedPacket( return NetworkControlUpdate(); } +NetworkControlUpdate PccNetworkController::OnNetworkStateEstimate( + NetworkStateEstimate msg) { + return NetworkControlUpdate(); +} + } // namespace pcc } // namespace webrtc diff --git a/modules/congestion_controller/pcc/pcc_network_controller.h b/modules/congestion_controller/pcc/pcc_network_controller.h index befabbf91e..c70684a8d2 100644 --- a/modules/congestion_controller/pcc/pcc_network_controller.h +++ b/modules/congestion_controller/pcc/pcc_network_controller.h @@ -78,6 +78,8 @@ class PccNetworkController : public NetworkControllerInterface { NetworkControlUpdate OnRoundTripTimeUpdate(RoundTripTimeUpdate msg) override; NetworkControlUpdate OnTransportLossReport(TransportLossReport msg) override; NetworkControlUpdate OnReceivedPacket(ReceivedPacket msg) override; + NetworkControlUpdate OnNetworkStateEstimate( + NetworkStateEstimate msg) override; private: void UpdateSendingRateAndMode(); diff --git a/test/scenario/call_client.cc b/test/scenario/call_client.cc index fe77e7aabc..f36699759d 100644 --- a/test/scenario/call_client.cc +++ b/test/scenario/call_client.cc @@ -132,6 +132,11 @@ NetworkControlUpdate NetworkControleUpdateCache::OnTransportPacketsFeedback( TransportPacketsFeedback msg) { return Update(controller_->OnTransportPacketsFeedback(msg)); } +NetworkControlUpdate NetworkControleUpdateCache::OnNetworkStateEstimate( + NetworkStateEstimate msg) { + return Update(controller_->OnNetworkStateEstimate(msg)); +} + NetworkControlUpdate NetworkControleUpdateCache::update_state() const { return update_state_; } diff --git a/test/scenario/call_client.h b/test/scenario/call_client.h index 37efad620b..e863e602f6 100644 --- a/test/scenario/call_client.h +++ b/test/scenario/call_client.h @@ -52,6 +52,8 @@ class NetworkControleUpdateCache : public NetworkControllerInterface { NetworkControlUpdate OnTransportLossReport(TransportLossReport msg) override; NetworkControlUpdate OnTransportPacketsFeedback( TransportPacketsFeedback msg) override; + NetworkControlUpdate OnNetworkStateEstimate( + NetworkStateEstimate msg) override; NetworkControlUpdate update_state() const;