mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00

This would allow network controllers, GoogCcNetworkController in particular to have access to Environment at construction and thus it can rely on propagated field trials and won't need to fallback to the global field trial string Bug: webrtc:42220378 Change-Id: I36099522e3866a89a8c8d6303da03f7d5b1cad8e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/350201 Reviewed-by: Björn Terelius <terelius@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/main@{#42260}
105 lines
3.9 KiB
C++
105 lines
3.9 KiB
C++
/*
|
|
* Copyright (c) 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/pcc/pcc_network_controller.h"
|
|
|
|
#include <memory>
|
|
|
|
#include "api/environment/environment_factory.h"
|
|
#include "modules/congestion_controller/pcc/pcc_factory.h"
|
|
#include "test/gmock.h"
|
|
#include "test/gtest.h"
|
|
#include "test/scenario/scenario.h"
|
|
|
|
using ::testing::AllOf;
|
|
using ::testing::Field;
|
|
using ::testing::Ge;
|
|
using ::testing::Le;
|
|
using ::testing::Matcher;
|
|
using ::testing::Property;
|
|
|
|
namespace webrtc {
|
|
namespace test {
|
|
namespace {
|
|
|
|
const DataRate kInitialBitrate = DataRate::KilobitsPerSec(60);
|
|
const Timestamp kDefaultStartTime = Timestamp::Millis(10000000);
|
|
|
|
constexpr double kDataRateMargin = 0.20;
|
|
constexpr double kMinDataRateFactor = 1 - kDataRateMargin;
|
|
constexpr double kMaxDataRateFactor = 1 + kDataRateMargin;
|
|
inline Matcher<TargetTransferRate> TargetRateCloseTo(DataRate rate) {
|
|
DataRate min_data_rate = rate * kMinDataRateFactor;
|
|
DataRate max_data_rate = rate * kMaxDataRateFactor;
|
|
return Field(&TargetTransferRate::target_rate,
|
|
AllOf(Ge(min_data_rate), Le(max_data_rate)));
|
|
}
|
|
|
|
} // namespace
|
|
|
|
TEST(PccNetworkControllerTest, SendsConfigurationOnFirstProcess) {
|
|
Environment env = CreateEnvironment();
|
|
NetworkControllerConfig config(env);
|
|
config.constraints.at_time = kDefaultStartTime;
|
|
config.constraints.min_data_rate = DataRate::Zero();
|
|
config.constraints.max_data_rate = 5 * kInitialBitrate;
|
|
config.constraints.starting_rate = kInitialBitrate;
|
|
pcc::PccNetworkController controller(config);
|
|
|
|
NetworkControlUpdate update =
|
|
controller.OnProcessInterval({.at_time = kDefaultStartTime});
|
|
EXPECT_THAT(*update.target_rate, TargetRateCloseTo(kInitialBitrate));
|
|
EXPECT_THAT(*update.pacer_config,
|
|
Property(&PacerConfig::data_rate, Ge(kInitialBitrate)));
|
|
}
|
|
|
|
TEST(PccNetworkControllerTest, UpdatesTargetSendRate) {
|
|
PccNetworkControllerFactory factory;
|
|
Scenario s("pcc_unit/updates_rate", false);
|
|
CallClientConfig config;
|
|
config.transport.cc_factory = &factory;
|
|
config.transport.rates.min_rate = DataRate::KilobitsPerSec(10);
|
|
config.transport.rates.max_rate = DataRate::KilobitsPerSec(1500);
|
|
config.transport.rates.start_rate = DataRate::KilobitsPerSec(300);
|
|
auto send_net = s.CreateMutableSimulationNode([](NetworkSimulationConfig* c) {
|
|
c->bandwidth = DataRate::KilobitsPerSec(500);
|
|
c->delay = TimeDelta::Millis(100);
|
|
});
|
|
auto ret_net = s.CreateMutableSimulationNode(
|
|
[](NetworkSimulationConfig* c) { c->delay = TimeDelta::Millis(100); });
|
|
|
|
auto* client = s.CreateClient("send", config);
|
|
auto* route = s.CreateRoutes(client, {send_net->node()},
|
|
s.CreateClient("return", CallClientConfig()),
|
|
{ret_net->node()});
|
|
VideoStreamConfig video;
|
|
video.stream.use_rtx = false;
|
|
s.CreateVideoStream(route->forward(), video);
|
|
s.RunFor(TimeDelta::Seconds(30));
|
|
EXPECT_NEAR(client->target_rate().kbps(), 450, 100);
|
|
send_net->UpdateConfig([](NetworkSimulationConfig* c) {
|
|
c->bandwidth = DataRate::KilobitsPerSec(800);
|
|
c->delay = TimeDelta::Millis(100);
|
|
});
|
|
s.RunFor(TimeDelta::Seconds(40));
|
|
EXPECT_NEAR(client->target_rate().kbps(), 750, 150);
|
|
send_net->UpdateConfig([](NetworkSimulationConfig* c) {
|
|
c->bandwidth = DataRate::KilobitsPerSec(200);
|
|
c->delay = TimeDelta::Millis(200);
|
|
});
|
|
ret_net->UpdateConfig(
|
|
[](NetworkSimulationConfig* c) { c->delay = TimeDelta::Millis(200); });
|
|
s.RunFor(TimeDelta::Seconds(35));
|
|
EXPECT_LE(client->target_rate().kbps(), 200);
|
|
EXPECT_GT(client->target_rate().kbps(), 90);
|
|
}
|
|
|
|
} // namespace test
|
|
} // namespace webrtc
|