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

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

Issue 2789233005: Move BWE period calculation from ProbingIntervalEstimator to AimdRateControl. (Closed)
Patch Set: Remove unused include. Created 3 years, 8 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
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 "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h" 12 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h"
13 #include "webrtc/system_wrappers/include/clock.h" 13 #include "webrtc/system_wrappers/include/clock.h"
14 #include "webrtc/test/gtest.h" 14 #include "webrtc/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 kMinIntervalMs = 2000;
22 constexpr int kMaxIntervalMs = 50000;
23 constexpr int kDefaultIntervalMs = 3000;
24
21 struct AimdRateControlStates { 25 struct AimdRateControlStates {
22 std::unique_ptr<AimdRateControl> aimd_rate_control; 26 std::unique_ptr<AimdRateControl> aimd_rate_control;
23 std::unique_ptr<SimulatedClock> simulated_clock; 27 std::unique_ptr<SimulatedClock> simulated_clock;
24 }; 28 };
25 29
26 AimdRateControlStates CreateAimdRateControlStates() { 30 AimdRateControlStates CreateAimdRateControlStates() {
27 AimdRateControlStates states; 31 AimdRateControlStates states;
28 states.aimd_rate_control.reset(new AimdRateControl()); 32 states.aimd_rate_control.reset(new AimdRateControl());
29 states.simulated_clock.reset(new SimulatedClock(kClockInitialTime)); 33 states.simulated_clock.reset(new SimulatedClock(kClockInitialTime));
30 return states; 34 return states;
(...skipping 28 matching lines...) Expand all
59 63
60 TEST(AimdRateControlTest, NearMaxIncreaseRateIs5kbpsOn60kbpsAnd100msRtt) { 64 TEST(AimdRateControlTest, NearMaxIncreaseRateIs5kbpsOn60kbpsAnd100msRtt) {
61 auto states = CreateAimdRateControlStates(); 65 auto states = CreateAimdRateControlStates();
62 constexpr int kBitrate = 60000; 66 constexpr int kBitrate = 60000;
63 states.aimd_rate_control->SetEstimate( 67 states.aimd_rate_control->SetEstimate(
64 kBitrate, states.simulated_clock->TimeInMilliseconds()); 68 kBitrate, states.simulated_clock->TimeInMilliseconds());
65 states.aimd_rate_control->SetRtt(100); 69 states.aimd_rate_control->SetRtt(100);
66 EXPECT_EQ(5000, states.aimd_rate_control->GetNearMaxIncreaseRateBps()); 70 EXPECT_EQ(5000, states.aimd_rate_control->GetNearMaxIncreaseRateBps());
67 } 71 }
68 72
69 TEST(AimdRateControlTest, UnknownBitrateDecreaseBeforeFirstOveruse) { 73 TEST(AimdRateControlTest, DefaultPeriodBeforeFirstOveruse) {
70 auto states = CreateAimdRateControlStates(); 74 auto states = CreateAimdRateControlStates();
71 EXPECT_EQ(rtc::Optional<int>(), 75 EXPECT_EQ(3000, states.aimd_rate_control->GetExpectedBandwidthPeriodMs());
72 states.aimd_rate_control->GetLastBitrateDecreaseBps());
73 } 76 }
74 77
75 TEST(AimdRateControlTest, GetLastBitrateDecrease) { 78 TEST(AimdRateControlTest, GetLastBitrateDecrease) {
76 auto states = CreateAimdRateControlStates(); 79 auto states = CreateAimdRateControlStates();
77 constexpr int kBitrate = 300000; 80 constexpr int kBitrate = 300000;
78 states.aimd_rate_control->SetEstimate( 81 states.aimd_rate_control->SetEstimate(
79 kBitrate, states.simulated_clock->TimeInMilliseconds()); 82 kBitrate, states.simulated_clock->TimeInMilliseconds());
80 UpdateRateControl(states, kBwOverusing, kBitrate - 2000, 83 UpdateRateControl(states, kBwOverusing, kBitrate,
81 states.simulated_clock->TimeInMilliseconds()); 84 states.simulated_clock->TimeInMilliseconds());
82 EXPECT_EQ(rtc::Optional<int>(46700), 85 EXPECT_NEAR(14000, states.aimd_rate_control->GetNearMaxIncreaseRateBps(),
83 states.aimd_rate_control->GetLastBitrateDecreaseBps()); 86 1000);
87 ASSERT_TRUE(states.aimd_rate_control->GetExpectedBandwidthPeriodMs());
88 EXPECT_EQ(3000, states.aimd_rate_control->GetExpectedBandwidthPeriodMs());
84 } 89 }
85 90
86 TEST(AimdRateControlTest, BweLimitedByAckedBitrate) { 91 TEST(AimdRateControlTest, BweLimitedByAckedBitrate) {
87 auto states = CreateAimdRateControlStates(); 92 auto states = CreateAimdRateControlStates();
88 constexpr int kAckedBitrate = 10000; 93 constexpr int kAckedBitrate = 10000;
89 states.aimd_rate_control->SetEstimate( 94 states.aimd_rate_control->SetEstimate(
90 kAckedBitrate, states.simulated_clock->TimeInMilliseconds()); 95 kAckedBitrate, states.simulated_clock->TimeInMilliseconds());
91 while (states.simulated_clock->TimeInMilliseconds() - kClockInitialTime < 96 while (states.simulated_clock->TimeInMilliseconds() - kClockInitialTime <
92 20000) { 97 20000) {
93 UpdateRateControl(states, kBwNormal, kAckedBitrate, 98 UpdateRateControl(states, kBwNormal, kAckedBitrate,
(...skipping 20 matching lines...) Expand all
114 // If the acked bitrate decreases the BWE shouldn't be reduced to 1.5x 119 // If the acked bitrate decreases the BWE shouldn't be reduced to 1.5x
115 // what's being acked, but also shouldn't get to increase more. 120 // what's being acked, but also shouldn't get to increase more.
116 uint32_t prev_estimate = states.aimd_rate_control->LatestEstimate(); 121 uint32_t prev_estimate = states.aimd_rate_control->LatestEstimate();
117 UpdateRateControl(states, kBwNormal, kAckedBitrate / 2, 122 UpdateRateControl(states, kBwNormal, kAckedBitrate / 2,
118 states.simulated_clock->TimeInMilliseconds()); 123 states.simulated_clock->TimeInMilliseconds());
119 uint32_t new_estimate = states.aimd_rate_control->LatestEstimate(); 124 uint32_t new_estimate = states.aimd_rate_control->LatestEstimate();
120 EXPECT_NEAR(new_estimate, static_cast<uint32_t>(1.5 * kAckedBitrate + 10000), 125 EXPECT_NEAR(new_estimate, static_cast<uint32_t>(1.5 * kAckedBitrate + 10000),
121 2000); 126 2000);
122 EXPECT_EQ(new_estimate, prev_estimate); 127 EXPECT_EQ(new_estimate, prev_estimate);
123 } 128 }
129
130 TEST(AimdRateControlTest, DefaultIntervalUntilFirstOveruse) {
michaelt 2017/04/05 07:06:02 Seams to be the same test as in DefaultPeriodBefor
terelius 2017/04/05 10:58:03 Done. Removed DefaultPeriodBeforeFirstOveruse.
131 auto states = CreateAimdRateControlStates();
132 states.aimd_rate_control->SetStartBitrate(300000);
133 EXPECT_EQ(kDefaultIntervalMs,
134 states.aimd_rate_control->GetExpectedBandwidthPeriodMs());
135 states.simulated_clock->AdvanceTimeMilliseconds(100);
136 UpdateRateControl(states, kBwOverusing, 100000,
137 states.simulated_clock->TimeInMilliseconds());
138 EXPECT_NE(kDefaultIntervalMs,
139 states.aimd_rate_control->GetExpectedBandwidthPeriodMs());
140 }
141
142 TEST(AimdRateControlTest, CalcInterval) {
michaelt 2017/04/05 07:06:02 Rename the test according to the new Function name
terelius 2017/04/05 10:58:03 Done.
143 auto states = CreateAimdRateControlStates();
144 constexpr int kInitialBitrate = 110000;
145 states.aimd_rate_control->SetEstimate(
146 kInitialBitrate, states.simulated_clock->TimeInMilliseconds());
147 states.simulated_clock->AdvanceTimeMilliseconds(100);
148 // Make the bitrate drop to 20 kbps fo get to 90 kbps.
149 // The rate increase at 90 kbps should be 5 kbps.
150 UpdateRateControl(states, kBwOverusing, (kInitialBitrate - 20000) / 0.85,
151 states.simulated_clock->TimeInMilliseconds());
152 EXPECT_EQ(4000, states.aimd_rate_control->GetExpectedBandwidthPeriodMs());
153 }
154
155 TEST(AimdRateControlTest, IntervalNotBelowMin) {
michaelt 2017/04/05 07:06:02 Same here.
terelius 2017/04/05 10:58:03 Done.
156 auto states = CreateAimdRateControlStates();
157 constexpr int kInitialBitrate = 10000;
158 states.aimd_rate_control->SetEstimate(
159 kInitialBitrate, states.simulated_clock->TimeInMilliseconds());
160 states.simulated_clock->AdvanceTimeMilliseconds(100);
161 // Make a small (1.5 kbps) bitrate drop to 8.5 kbps.
162 UpdateRateControl(states, kBwOverusing, kInitialBitrate - 1,
163 states.simulated_clock->TimeInMilliseconds());
164 EXPECT_EQ(kMinIntervalMs,
165 states.aimd_rate_control->GetExpectedBandwidthPeriodMs());
166 }
167
168 TEST(AimdRateControlTest, IntervalNotAboveMax) {
michaelt 2017/04/05 07:06:02 Same here.
terelius 2017/04/05 10:58:03 Done.
169 auto states = CreateAimdRateControlStates();
170 constexpr int kInitialBitrate = 10010000;
171 states.aimd_rate_control->SetEstimate(
172 kInitialBitrate, states.simulated_clock->TimeInMilliseconds());
173 states.simulated_clock->AdvanceTimeMilliseconds(100);
174 // Make a large (10 Mbps) bitrate drop to 10 kbps.
175 UpdateRateControl(states, kBwOverusing, 10000 / 0.85,
176 states.simulated_clock->TimeInMilliseconds());
177 EXPECT_EQ(kMaxIntervalMs,
178 states.aimd_rate_control->GetExpectedBandwidthPeriodMs());
179 }
180
124 } // namespace webrtc 181 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698