diff --git a/modules/congestion_controller/BUILD.gn b/modules/congestion_controller/BUILD.gn index abb2584bf6..ac720ff8e5 100644 --- a/modules/congestion_controller/BUILD.gn +++ b/modules/congestion_controller/BUILD.gn @@ -101,6 +101,7 @@ if (rtc_include_tests) { "../../system_wrappers", "../../test:field_trial", "../../test:test_support", + "../../test/scenario", "../bitrate_controller", "../pacing", "../pacing:mock_paced_sender", diff --git a/modules/congestion_controller/receive_side_congestion_controller_unittest.cc b/modules/congestion_controller/receive_side_congestion_controller_unittest.cc index 632b762403..d6d739051c 100644 --- a/modules/congestion_controller/receive_side_congestion_controller_unittest.cc +++ b/modules/congestion_controller/receive_side_congestion_controller_unittest.cc @@ -13,6 +13,7 @@ #include "system_wrappers/include/clock.h" #include "test/gmock.h" #include "test/gtest.h" +#include "test/scenario/scenario.h" using ::testing::_; using ::testing::AtLeast; @@ -71,5 +72,47 @@ TEST(ReceiveSideCongestionControllerTest, OnReceivedPacketWithAbsSendTime) { EXPECT_EQ(header.ssrc, ssrcs[0]); } +TEST(ReceiveSideCongestionControllerTest, ConvergesToCapacity) { + Scenario s("recieve_cc_unit/converge"); + NetworkSimulationConfig net_conf; + net_conf.bandwidth = DataRate::kbps(1000); + net_conf.delay = TimeDelta::ms(50); + auto* client = s.CreateClient("send", [&](CallClientConfig* c) { + c->transport.rates.start_rate = DataRate::kbps(300); + }); + + auto* route = s.CreateRoutes(client, {s.CreateSimulationNode(net_conf)}, + s.CreateClient("return", CallClientConfig()), + {s.CreateSimulationNode(net_conf)}); + VideoStreamConfig video; + video.stream.packet_feedback = false; + s.CreateVideoStream(route->forward(), video); + s.RunFor(TimeDelta::seconds(30)); + EXPECT_NEAR(client->send_bandwidth().kbps(), 900, 150); +} + +TEST(ReceiveSideCongestionControllerTest, IsFairToTCP) { + Scenario s("recieve_cc_unit/tcp_fairness"); + NetworkSimulationConfig net_conf; + net_conf.bandwidth = DataRate::kbps(1000); + net_conf.delay = TimeDelta::ms(50); + auto* client = s.CreateClient("send", [&](CallClientConfig* c) { + c->transport.rates.start_rate = DataRate::kbps(1000); + }); + auto send_net = {s.CreateSimulationNode(net_conf)}; + auto ret_net = {s.CreateSimulationNode(net_conf)}; + auto* route = s.CreateRoutes( + client, send_net, s.CreateClient("return", CallClientConfig()), ret_net); + VideoStreamConfig video; + video.stream.packet_feedback = false; + s.CreateVideoStream(route->forward(), video); + s.net()->StartFakeTcpCrossTraffic(s.net()->CreateRoute(send_net), + s.net()->CreateRoute(ret_net), + FakeTcpConfig()); + s.RunFor(TimeDelta::seconds(30)); + // For some reason we get outcompeted by TCP here, this should probably be + // fixed and a lower bound should be added to the test. + EXPECT_LT(client->send_bandwidth().kbps(), 750); +} } // namespace test } // namespace webrtc diff --git a/test/scenario/video_stream.cc b/test/scenario/video_stream.cc index 46852d8c99..00521ea0c5 100644 --- a/test/scenario/video_stream.cc +++ b/test/scenario/video_stream.cc @@ -88,12 +88,16 @@ InterLayerPredMode ToInterLayerPredMode( } std::vector GetVideoRtpExtensions( const VideoStreamConfig config) { - return {RtpExtension(RtpExtension::kTransportSequenceNumberUri, - kTransportSequenceNumberExtensionId), - RtpExtension(RtpExtension::kVideoContentTypeUri, - kVideoContentTypeExtensionId), - RtpExtension(RtpExtension::kVideoRotationUri, - kVideoRotationRtpExtensionId)}; + std::vector res = { + RtpExtension(RtpExtension::kVideoContentTypeUri, + kVideoContentTypeExtensionId), + RtpExtension(RtpExtension::kVideoRotationUri, + kVideoRotationRtpExtensionId)}; + if (config.stream.packet_feedback) { + res.push_back(RtpExtension(RtpExtension::kTransportSequenceNumberUri, + kTransportSequenceNumberExtensionId)); + } + return res; } std::string TransformFilePath(std::string path) { @@ -311,6 +315,7 @@ VideoReceiveStream::Config CreateVideoReceiveStreamConfig( recv.rtp.transport_cc = config.stream.packet_feedback; recv.rtp.local_ssrc = local_ssrc; recv.rtp.extensions = GetVideoRtpExtensions(config); + RTC_DCHECK(!config.stream.use_rtx || config.stream.nack_history_time > TimeDelta::Zero()); recv.rtp.nack.rtp_history_ms = config.stream.nack_history_time.ms();