Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc

Issue 3011323002: Rollback of "Use small BWE period when there is a true network degradation" (Closed)
Patch Set: Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « modules/remote_bitrate_estimator/aimd_rate_control.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 #include <memory> 10 #include <memory>
11 11
12 #include "modules/remote_bitrate_estimator/aimd_rate_control.h" 12 #include "modules/remote_bitrate_estimator/aimd_rate_control.h"
13 #include "system_wrappers/include/clock.h" 13 #include "system_wrappers/include/clock.h"
14 #include "test/gtest.h" 14 #include "test/gtest.h"
15 15
16 namespace webrtc { 16 namespace webrtc {
17 namespace { 17 namespace {
18 18
19 constexpr int64_t kClockInitialTime = 123456; 19 constexpr int64_t kClockInitialTime = 123456;
20 20
21 constexpr int kMinBwePeriodMs = 500; 21 constexpr int kMinBwePeriodMs = 2000;
22 constexpr int kMaxBwePeriodMs = 50000; 22 constexpr int kMaxBwePeriodMs = 50000;
23 constexpr int kDefaultPeriodMs = 3000;
23 24
24 // After an overuse, we back off to 85% to the received bitrate. 25 // After an overuse, we back off to 85% to the received bitrate.
25 constexpr double kFractionAfterOveruse = 0.85; 26 constexpr double kFractionAfterOveruse = 0.85;
26 27
27 struct AimdRateControlStates { 28 struct AimdRateControlStates {
28 std::unique_ptr<AimdRateControl> aimd_rate_control; 29 std::unique_ptr<AimdRateControl> aimd_rate_control;
29 std::unique_ptr<SimulatedClock> simulated_clock; 30 std::unique_ptr<SimulatedClock> simulated_clock;
30 }; 31 };
31 32
32 AimdRateControlStates CreateAimdRateControlStates() { 33 AimdRateControlStates CreateAimdRateControlStates() {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 75
75 TEST(AimdRateControlTest, GetIncreaseRateAndBandwidthPeriod) { 76 TEST(AimdRateControlTest, GetIncreaseRateAndBandwidthPeriod) {
76 auto states = CreateAimdRateControlStates(); 77 auto states = CreateAimdRateControlStates();
77 constexpr int kBitrate = 300000; 78 constexpr int kBitrate = 300000;
78 states.aimd_rate_control->SetEstimate( 79 states.aimd_rate_control->SetEstimate(
79 kBitrate, states.simulated_clock->TimeInMilliseconds()); 80 kBitrate, states.simulated_clock->TimeInMilliseconds());
80 UpdateRateControl(states, BandwidthUsage::kBwOverusing, kBitrate, 81 UpdateRateControl(states, BandwidthUsage::kBwOverusing, kBitrate,
81 states.simulated_clock->TimeInMilliseconds()); 82 states.simulated_clock->TimeInMilliseconds());
82 EXPECT_NEAR(14000, states.aimd_rate_control->GetNearMaxIncreaseRateBps(), 83 EXPECT_NEAR(14000, states.aimd_rate_control->GetNearMaxIncreaseRateBps(),
83 1000); 84 1000);
84 EXPECT_EQ(kMinBwePeriodMs, 85 EXPECT_EQ(3000, states.aimd_rate_control->GetExpectedBandwidthPeriodMs());
85 states.aimd_rate_control->GetExpectedBandwidthPeriodMs());
86 } 86 }
87 87
88 TEST(AimdRateControlTest, BweLimitedByAckedBitrate) { 88 TEST(AimdRateControlTest, BweLimitedByAckedBitrate) {
89 auto states = CreateAimdRateControlStates(); 89 auto states = CreateAimdRateControlStates();
90 constexpr int kAckedBitrate = 10000; 90 constexpr int kAckedBitrate = 10000;
91 states.aimd_rate_control->SetEstimate( 91 states.aimd_rate_control->SetEstimate(
92 kAckedBitrate, states.simulated_clock->TimeInMilliseconds()); 92 kAckedBitrate, states.simulated_clock->TimeInMilliseconds());
93 while (states.simulated_clock->TimeInMilliseconds() - kClockInitialTime < 93 while (states.simulated_clock->TimeInMilliseconds() - kClockInitialTime <
94 20000) { 94 20000) {
95 UpdateRateControl(states, BandwidthUsage::kBwNormal, kAckedBitrate, 95 UpdateRateControl(states, BandwidthUsage::kBwNormal, kAckedBitrate,
(...skipping 21 matching lines...) Expand all
117 // what's being acked, but also shouldn't get to increase more. 117 // what's being acked, but also shouldn't get to increase more.
118 uint32_t prev_estimate = states.aimd_rate_control->LatestEstimate(); 118 uint32_t prev_estimate = states.aimd_rate_control->LatestEstimate();
119 UpdateRateControl(states, BandwidthUsage::kBwNormal, kAckedBitrate / 2, 119 UpdateRateControl(states, BandwidthUsage::kBwNormal, kAckedBitrate / 2,
120 states.simulated_clock->TimeInMilliseconds()); 120 states.simulated_clock->TimeInMilliseconds());
121 uint32_t new_estimate = states.aimd_rate_control->LatestEstimate(); 121 uint32_t new_estimate = states.aimd_rate_control->LatestEstimate();
122 EXPECT_NEAR(new_estimate, static_cast<uint32_t>(1.5 * kAckedBitrate + 10000), 122 EXPECT_NEAR(new_estimate, static_cast<uint32_t>(1.5 * kAckedBitrate + 10000),
123 2000); 123 2000);
124 EXPECT_EQ(new_estimate, prev_estimate); 124 EXPECT_EQ(new_estimate, prev_estimate);
125 } 125 }
126 126
127 TEST(AimdRateControlTest, MinPeriodUntilFirstOveruse) { 127 TEST(AimdRateControlTest, DefaultPeriodUntilFirstOveruse) {
128 auto states = CreateAimdRateControlStates(); 128 auto states = CreateAimdRateControlStates();
129 states.aimd_rate_control->SetStartBitrate(300000); 129 states.aimd_rate_control->SetStartBitrate(300000);
130 EXPECT_EQ(kMinBwePeriodMs, 130 EXPECT_EQ(kDefaultPeriodMs,
131 states.aimd_rate_control->GetExpectedBandwidthPeriodMs()); 131 states.aimd_rate_control->GetExpectedBandwidthPeriodMs());
132 states.simulated_clock->AdvanceTimeMilliseconds(100); 132 states.simulated_clock->AdvanceTimeMilliseconds(100);
133 UpdateRateControl(states, BandwidthUsage::kBwOverusing, 280000, 133 UpdateRateControl(states, BandwidthUsage::kBwOverusing, 100000,
134 states.simulated_clock->TimeInMilliseconds()); 134 states.simulated_clock->TimeInMilliseconds());
135 EXPECT_NE(kMinBwePeriodMs, 135 EXPECT_NE(kDefaultPeriodMs,
136 states.aimd_rate_control->GetExpectedBandwidthPeriodMs()); 136 states.aimd_rate_control->GetExpectedBandwidthPeriodMs());
137 } 137 }
138 138
139 TEST(AimdRateControlTest, ExpectedPeriodAfter20kbpsDropAnd5kbpsIncrease) { 139 TEST(AimdRateControlTest, ExpectedPeriodAfter20kbpsDropAnd5kbpsIncrease) {
140 auto states = CreateAimdRateControlStates(); 140 auto states = CreateAimdRateControlStates();
141 constexpr int kInitialBitrate = 110000; 141 constexpr int kInitialBitrate = 110000;
142 states.aimd_rate_control->SetEstimate( 142 states.aimd_rate_control->SetEstimate(
143 kInitialBitrate, states.simulated_clock->TimeInMilliseconds()); 143 kInitialBitrate, states.simulated_clock->TimeInMilliseconds());
144 states.simulated_clock->AdvanceTimeMilliseconds(100); 144 states.simulated_clock->AdvanceTimeMilliseconds(100);
145 // Make the bitrate drop by 20 kbps to get to 90 kbps. 145 // Make the bitrate drop by 20 kbps to get to 90 kbps.
146 // The rate increase at 90 kbps should be 5 kbps, so the period should be 4 s. 146 // The rate increase at 90 kbps should be 5 kbps, so the period should be 4 s.
147 constexpr int kAckedBitrate = 147 constexpr int kAckedBitrate =
148 (kInitialBitrate - 20000) / kFractionAfterOveruse; 148 (kInitialBitrate - 20000) / kFractionAfterOveruse;
149 UpdateRateControl(states, BandwidthUsage::kBwOverusing, kAckedBitrate, 149 UpdateRateControl(states, BandwidthUsage::kBwOverusing, kAckedBitrate,
150 states.simulated_clock->TimeInMilliseconds()); 150 states.simulated_clock->TimeInMilliseconds());
151 EXPECT_EQ(5000, states.aimd_rate_control->GetNearMaxIncreaseRateBps()); 151 EXPECT_EQ(5000, states.aimd_rate_control->GetNearMaxIncreaseRateBps());
152 EXPECT_EQ(4000, states.aimd_rate_control->GetExpectedBandwidthPeriodMs()); 152 EXPECT_EQ(4000, states.aimd_rate_control->GetExpectedBandwidthPeriodMs());
153 } 153 }
154 154
155 TEST(AimdRateControlTest, MinPeriodAfterLargeBitrateDecrease) {
156 auto states = CreateAimdRateControlStates();
157 constexpr int kInitialBitrate = 110000;
158 states.aimd_rate_control->SetEstimate(
159 kInitialBitrate, states.simulated_clock->TimeInMilliseconds());
160 states.simulated_clock->AdvanceTimeMilliseconds(100);
161 // Make such a large drop in bitrate that should be treated as network
162 // degradation.
163 constexpr int kAckedBitrate = kInitialBitrate * 3 / 4 / kFractionAfterOveruse;
164 UpdateRateControl(states, BandwidthUsage::kBwOverusing, kAckedBitrate,
165 states.simulated_clock->TimeInMilliseconds());
166 EXPECT_EQ(kMinBwePeriodMs,
167 states.aimd_rate_control->GetExpectedBandwidthPeriodMs());
168 }
169
170 TEST(AimdRateControlTest, BandwidthPeriodIsNotBelowMin) { 155 TEST(AimdRateControlTest, BandwidthPeriodIsNotBelowMin) {
171 auto states = CreateAimdRateControlStates(); 156 auto states = CreateAimdRateControlStates();
172 constexpr int kInitialBitrate = 10000; 157 constexpr int kInitialBitrate = 10000;
173 states.aimd_rate_control->SetEstimate( 158 states.aimd_rate_control->SetEstimate(
174 kInitialBitrate, states.simulated_clock->TimeInMilliseconds()); 159 kInitialBitrate, states.simulated_clock->TimeInMilliseconds());
175 states.simulated_clock->AdvanceTimeMilliseconds(100); 160 states.simulated_clock->AdvanceTimeMilliseconds(100);
176 // Make a small (1.5 kbps) bitrate drop to 8.5 kbps. 161 // Make a small (1.5 kbps) bitrate drop to 8.5 kbps.
177 UpdateRateControl(states, BandwidthUsage::kBwOverusing, kInitialBitrate - 1, 162 UpdateRateControl(states, BandwidthUsage::kBwOverusing, kInitialBitrate - 1,
178 states.simulated_clock->TimeInMilliseconds()); 163 states.simulated_clock->TimeInMilliseconds());
179 EXPECT_EQ(kMinBwePeriodMs, 164 EXPECT_EQ(kMinBwePeriodMs,
180 states.aimd_rate_control->GetExpectedBandwidthPeriodMs()); 165 states.aimd_rate_control->GetExpectedBandwidthPeriodMs());
181 } 166 }
182 167
183 TEST(AimdRateControlTest, BandwidthPeriodIsNotAboveMax) { 168 TEST(AimdRateControlTest, BandwidthPeriodIsNotAboveMax) {
184 auto states = CreateAimdRateControlStates(); 169 auto states = CreateAimdRateControlStates();
185 constexpr int kInitialBitrate = 50000000; 170 constexpr int kInitialBitrate = 10010000;
186 states.aimd_rate_control->SetEstimate( 171 states.aimd_rate_control->SetEstimate(
187 kInitialBitrate, states.simulated_clock->TimeInMilliseconds()); 172 kInitialBitrate, states.simulated_clock->TimeInMilliseconds());
188 states.simulated_clock->AdvanceTimeMilliseconds(100); 173 states.simulated_clock->AdvanceTimeMilliseconds(100);
189 // Make a large (10 Mbps) bitrate drop to 10 kbps. 174 // Make a large (10 Mbps) bitrate drop to 10 kbps.
190 constexpr int kAckedBitrate = 40000000 / kFractionAfterOveruse; 175 constexpr int kAckedBitrate = 10000 / kFractionAfterOveruse;
191 UpdateRateControl(states, BandwidthUsage::kBwOverusing, kAckedBitrate, 176 UpdateRateControl(states, BandwidthUsage::kBwOverusing, kAckedBitrate,
192 states.simulated_clock->TimeInMilliseconds()); 177 states.simulated_clock->TimeInMilliseconds());
193 EXPECT_EQ(kMaxBwePeriodMs, 178 EXPECT_EQ(kMaxBwePeriodMs,
194 states.aimd_rate_control->GetExpectedBandwidthPeriodMs()); 179 states.aimd_rate_control->GetExpectedBandwidthPeriodMs());
195 } 180 }
196 181
197 } // namespace webrtc 182 } // namespace webrtc
OLDNEW
« no previous file with comments | « modules/remote_bitrate_estimator/aimd_rate_control.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698