Adds debug printing for congestion controllers.
These are useful for plotting creating data files that can be used to visualize and debug congestion controller behavior. Bug: webrtc:9467 Change-Id: I75b03a309b4b7d562fefe82a828ae1e6a9f069c8 Reviewed-on: https://webrtc-review.googlesource.com/86126 Commit-Queue: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Björn Terelius <terelius@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23822}
This commit is contained in:
committed by
Commit Bot
parent
d000b0a32e
commit
13171bdba8
@ -143,6 +143,17 @@ rtc_source_set("delay_based_bwe") {
|
||||
}
|
||||
|
||||
if (rtc_include_tests) {
|
||||
rtc_source_set("test_goog_cc_printer") {
|
||||
testonly = true
|
||||
sources = [
|
||||
"test/goog_cc_printer.cc",
|
||||
"test/goog_cc_printer.h",
|
||||
]
|
||||
deps = [
|
||||
":goog_cc",
|
||||
"..:test_controller_printer",
|
||||
]
|
||||
}
|
||||
rtc_source_set("goog_cc_unittests") {
|
||||
testonly = true
|
||||
|
||||
|
||||
@ -336,6 +336,26 @@ NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback(
|
||||
return update;
|
||||
}
|
||||
|
||||
NetworkControlUpdate GoogCcNetworkController::GetNetworkState(
|
||||
Timestamp at_time) const {
|
||||
DataRate bandwidth = DataRate::bps(last_estimated_bitrate_bps_);
|
||||
TimeDelta rtt = TimeDelta::ms(last_estimated_rtt_ms_);
|
||||
NetworkControlUpdate update;
|
||||
update.target_rate = TargetTransferRate();
|
||||
update.target_rate->network_estimate.at_time = at_time;
|
||||
update.target_rate->network_estimate.bandwidth = bandwidth;
|
||||
update.target_rate->network_estimate.loss_rate_ratio =
|
||||
last_estimated_fraction_loss_ / 255.0;
|
||||
update.target_rate->network_estimate.round_trip_time = rtt;
|
||||
update.target_rate->network_estimate.bwe_period =
|
||||
TimeDelta::ms(delay_based_bwe_->GetExpectedBwePeriodMs());
|
||||
update.target_rate->at_time = at_time;
|
||||
update.target_rate->target_rate = bandwidth;
|
||||
update.pacer_config = UpdatePacingRates(at_time);
|
||||
update.congestion_window = current_data_window_;
|
||||
return update;
|
||||
}
|
||||
|
||||
absl::optional<DataSize>
|
||||
GoogCcNetworkController::MaybeUpdateCongestionWindow() {
|
||||
if (!in_cwnd_experiment_)
|
||||
@ -432,7 +452,8 @@ NetworkControlUpdate GoogCcNetworkController::OnNetworkEstimate(
|
||||
return update;
|
||||
}
|
||||
|
||||
PacerConfig GoogCcNetworkController::UpdatePacingRates(Timestamp at_time) {
|
||||
PacerConfig GoogCcNetworkController::UpdatePacingRates(
|
||||
Timestamp at_time) const {
|
||||
DataRate pacing_rate =
|
||||
std::max(min_pacing_rate_, last_bandwidth_) * pacing_factor_;
|
||||
DataRate padding_rate = std::min(max_padding_rate_, last_bandwidth_);
|
||||
|
||||
@ -49,6 +49,8 @@ class GoogCcNetworkController : public NetworkControllerInterface {
|
||||
NetworkControlUpdate OnTransportPacketsFeedback(
|
||||
TransportPacketsFeedback msg) override;
|
||||
|
||||
NetworkControlUpdate GetNetworkState(Timestamp at_time) const;
|
||||
|
||||
private:
|
||||
void UpdateBitrateConstraints(TargetRateConstraints constraints,
|
||||
absl::optional<DataRate> starting_rate);
|
||||
@ -59,7 +61,7 @@ class GoogCcNetworkController : public NetworkControllerInterface {
|
||||
int64_t* rtt_ms,
|
||||
Timestamp at_time);
|
||||
NetworkControlUpdate OnNetworkEstimate(NetworkEstimate msg);
|
||||
PacerConfig UpdatePacingRates(Timestamp at_time);
|
||||
PacerConfig UpdatePacingRates(Timestamp at_time) const;
|
||||
|
||||
RtcEventLog* const event_log_;
|
||||
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#include "modules/congestion_controller/goog_cc/test/goog_cc_printer.h"
|
||||
namespace webrtc {
|
||||
|
||||
GoogCcStatePrinter::GoogCcStatePrinter() = default;
|
||||
GoogCcStatePrinter::~GoogCcStatePrinter() = default;
|
||||
|
||||
void GoogCcStatePrinter::Attach(
|
||||
webrtc_cc::GoogCcNetworkController* controller) {
|
||||
controller_ = controller;
|
||||
}
|
||||
|
||||
bool GoogCcStatePrinter::Attached() const {
|
||||
return controller_ != nullptr;
|
||||
}
|
||||
|
||||
void GoogCcStatePrinter::PrintHeaders(FILE* out) {}
|
||||
|
||||
void GoogCcStatePrinter::PrintValues(FILE* out) {
|
||||
RTC_CHECK(controller_);
|
||||
}
|
||||
|
||||
NetworkControlUpdate GoogCcStatePrinter::GetState(Timestamp at_time) const {
|
||||
RTC_CHECK(controller_);
|
||||
return controller_->GetNetworkState(at_time);
|
||||
}
|
||||
|
||||
GoogCcDebugFactory::GoogCcDebugFactory(RtcEventLog* event_log,
|
||||
GoogCcStatePrinter* printer)
|
||||
: GoogCcNetworkControllerFactory(event_log), printer_(printer) {}
|
||||
|
||||
std::unique_ptr<NetworkControllerInterface> GoogCcDebugFactory::Create(
|
||||
NetworkControllerConfig config) {
|
||||
RTC_CHECK(controller_ == nullptr);
|
||||
auto controller = GoogCcNetworkControllerFactory::Create(config);
|
||||
controller_ =
|
||||
static_cast<webrtc_cc::GoogCcNetworkController*>(controller.get());
|
||||
printer_->Attach(controller_);
|
||||
return controller;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
48
modules/congestion_controller/goog_cc/test/goog_cc_printer.h
Normal file
48
modules/congestion_controller/goog_cc/test/goog_cc_printer.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#ifndef MODULES_CONGESTION_CONTROLLER_GOOG_CC_TEST_GOOG_CC_PRINTER_H_
|
||||
#define MODULES_CONGESTION_CONTROLLER_GOOG_CC_TEST_GOOG_CC_PRINTER_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "modules/congestion_controller/goog_cc/goog_cc_network_control.h"
|
||||
#include "modules/congestion_controller/goog_cc/include/goog_cc_factory.h"
|
||||
#include "modules/congestion_controller/test/controller_printer.h"
|
||||
|
||||
namespace webrtc {
|
||||
class GoogCcStatePrinter : public DebugStatePrinter {
|
||||
public:
|
||||
GoogCcStatePrinter();
|
||||
~GoogCcStatePrinter() override;
|
||||
void Attach(webrtc_cc::GoogCcNetworkController*);
|
||||
bool Attached() const override;
|
||||
|
||||
void PrintHeaders(FILE* out) override;
|
||||
void PrintValues(FILE* out) override;
|
||||
|
||||
NetworkControlUpdate GetState(Timestamp at_time) const override;
|
||||
|
||||
private:
|
||||
webrtc_cc::GoogCcNetworkController* controller_ = nullptr;
|
||||
};
|
||||
|
||||
class GoogCcDebugFactory : public GoogCcNetworkControllerFactory {
|
||||
public:
|
||||
GoogCcDebugFactory(RtcEventLog* event_log, GoogCcStatePrinter* printer);
|
||||
std::unique_ptr<NetworkControllerInterface> Create(
|
||||
NetworkControllerConfig config) override;
|
||||
|
||||
private:
|
||||
GoogCcStatePrinter* printer_;
|
||||
webrtc_cc::GoogCcNetworkController* controller_ = nullptr;
|
||||
};
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // MODULES_CONGESTION_CONTROLLER_GOOG_CC_TEST_GOOG_CC_PRINTER_H_
|
||||
Reference in New Issue
Block a user