blob: 92d5a55b4d39f5f9ca287926e62377e3e4fa31f6 [file] [log] [blame]
stefan@webrtc.orgc88d3362014-02-05 15:57:14 +00001/*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
kwiberg92931b12016-03-01 05:32:29 -080011#include <memory>
12
stefan@webrtc.orgc88d3362014-02-05 15:57:14 +000013#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
14#include "webrtc/modules/remote_bitrate_estimator/test/bwe_test.h"
stefan@webrtc.org14b02792015-02-16 12:02:20 +000015#include "webrtc/modules/remote_bitrate_estimator/test/packet_receiver.h"
16#include "webrtc/modules/remote_bitrate_estimator/test/packet_sender.h"
Edward Lemurc20978e2017-07-06 19:44:34 +020017#include "webrtc/rtc_base/constructormagic.h"
kwibergac9f8762016-09-30 22:29:43 -070018#include "webrtc/test/gtest.h"
stefan@webrtc.orgc88d3362014-02-05 15:57:14 +000019#include "webrtc/test/testsupport/fileutils.h"
20
21namespace webrtc {
22namespace testing {
23namespace bwe {
terelius3dcfd642016-10-07 00:39:56 -070024
stefan@webrtc.orgc88d3362014-02-05 15:57:14 +000025// This test fixture is used to instantiate tests running with adaptive video
26// senders.
stefan@webrtc.org4f616a02014-04-25 10:59:24 +000027class BweSimulation : public BweTest,
stefan@webrtc.org027e1132015-02-10 09:48:35 +000028 public ::testing::TestWithParam<BandwidthEstimatorType> {
stefan@webrtc.orgc88d3362014-02-05 15:57:14 +000029 public:
Cesar Magalhaes59adf342015-07-23 15:40:38 +020030 BweSimulation()
31 : BweTest(), random_(Clock::GetRealTimeClock()->TimeInMicroseconds()) {}
stefan@webrtc.orgc88d3362014-02-05 15:57:14 +000032 virtual ~BweSimulation() {}
33
stefan@webrtc.org027e1132015-02-10 09:48:35 +000034 protected:
Stefan Holmer53d0dc32015-05-07 15:04:19 +020035 void SetUp() override {
36 BweTest::SetUp();
37 VerboseLogging(true);
38 }
stefan@webrtc.org4f616a02014-04-25 10:59:24 +000039
terelius84e78f92015-12-10 01:50:55 -080040 Random random_;
Cesar Magalhaes59adf342015-07-23 15:40:38 +020041
stefan@webrtc.orgc88d3362014-02-05 15:57:14 +000042 private:
henrikg3c089d72015-09-16 05:37:44 -070043 RTC_DISALLOW_COPY_AND_ASSIGN(BweSimulation);
stefan@webrtc.orgc88d3362014-02-05 15:57:14 +000044};
45
stefan@webrtc.org027e1132015-02-10 09:48:35 +000046INSTANTIATE_TEST_CASE_P(VideoSendersTest,
47 BweSimulation,
48 ::testing::Values(kRembEstimator,
terelius2d81eb32016-10-25 07:04:37 -070049 kSendSideEstimator,
gnish6dcdf102017-06-05 06:01:26 -070050 kNadaEstimator,
51 kBbrEstimator));
stefan@webrtc.orgc88d3362014-02-05 15:57:14 +000052
53TEST_P(BweSimulation, SprintUplinkTest) {
stefan@webrtc.orgf88bee62015-01-30 14:36:37 +000054 AdaptiveVideoSource source(0, 30, 300, 0, 0);
Stefan Holmer37959372015-04-16 19:55:45 +020055 VideoSender sender(&uplink_, &source, GetParam());
Cesar Magalhaesd55ce2d2015-07-26 01:44:52 +020056 RateCounterFilter counter1(&uplink_, 0, "sender_output",
57 bwe_names[GetParam()]);
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +000058 TraceBasedDeliveryFilter filter(&uplink_, 0, "link_capacity");
Cesar Magalhaesd55ce2d2015-07-26 01:44:52 +020059 RateCounterFilter counter2(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +000060 PacketReceiver receiver(&uplink_, 0, GetParam(), true, true);
stefan@webrtc.orgc88d3362014-02-05 15:57:14 +000061 ASSERT_TRUE(filter.Init(test::ResourcePath("sprint-uplink", "rx")));
62 RunFor(60 * 1000);
63}
64
65TEST_P(BweSimulation, Verizon4gDownlinkTest) {
stefan@webrtc.orgf88bee62015-01-30 14:36:37 +000066 AdaptiveVideoSource source(0, 30, 300, 0, 0);
Stefan Holmer37959372015-04-16 19:55:45 +020067 VideoSender sender(&downlink_, &source, GetParam());
Cesar Magalhaesd55ce2d2015-07-26 01:44:52 +020068 RateCounterFilter counter1(&downlink_, 0, "sender_output",
oprypin8e58d652017-03-21 07:52:41 -070069 std::string() + bwe_names[GetParam()] + "_up");
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +000070 TraceBasedDeliveryFilter filter(&downlink_, 0, "link_capacity");
Cesar Magalhaesd55ce2d2015-07-26 01:44:52 +020071 RateCounterFilter counter2(&downlink_, 0, "Receiver",
oprypin8e58d652017-03-21 07:52:41 -070072 std::string() + bwe_names[GetParam()] + "_down");
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +000073 PacketReceiver receiver(&downlink_, 0, GetParam(), true, true);
stefan@webrtc.orgc88d3362014-02-05 15:57:14 +000074 ASSERT_TRUE(filter.Init(test::ResourcePath("verizon4g-downlink", "rx")));
75 RunFor(22 * 60 * 1000);
76}
stefan@webrtc.orgf8f7c8b2014-04-01 14:00:05 +000077
stefan@webrtc.org76636842015-02-17 16:03:45 +000078TEST_P(BweSimulation, Choke1000kbps500kbps1000kbpsBiDirectional) {
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +000079 const int kFlowIds[] = {0, 1};
80 const size_t kNumFlows = sizeof(kFlowIds) / sizeof(kFlowIds[0]);
81
82 AdaptiveVideoSource source(kFlowIds[0], 30, 300, 0, 0);
Stefan Holmer37959372015-04-16 19:55:45 +020083 VideoSender sender(&uplink_, &source, GetParam());
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +000084 ChokeFilter choke(&uplink_, kFlowIds[0]);
Cesar Magalhaesd55ce2d2015-07-26 01:44:52 +020085 RateCounterFilter counter(&uplink_, kFlowIds[0], "Receiver_0",
86 bwe_names[GetParam()]);
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +000087 PacketReceiver receiver(&uplink_, kFlowIds[0], GetParam(), true, false);
88
89 AdaptiveVideoSource source2(kFlowIds[1], 30, 300, 0, 0);
Stefan Holmer37959372015-04-16 19:55:45 +020090 VideoSender sender2(&downlink_, &source2, GetParam());
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +000091 ChokeFilter choke2(&downlink_, kFlowIds[1]);
92 DelayFilter delay(&downlink_, CreateFlowIds(kFlowIds, kNumFlows));
Cesar Magalhaesd55ce2d2015-07-26 01:44:52 +020093 RateCounterFilter counter2(&downlink_, kFlowIds[1], "Receiver_1",
94 bwe_names[GetParam()]);
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +000095 PacketReceiver receiver2(&downlink_, kFlowIds[1], GetParam(), true, false);
96
Cesar Magalhaes9c261f22015-07-15 16:31:18 +020097 choke2.set_capacity_kbps(500);
98 delay.SetOneWayDelayMs(0);
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +000099
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200100 choke.set_capacity_kbps(1000);
101 choke.set_max_delay_ms(500);
stefan@webrtc.orgf8f7c8b2014-04-01 14:00:05 +0000102 RunFor(60 * 1000);
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200103 choke.set_capacity_kbps(500);
stefan@webrtc.orgf8f7c8b2014-04-01 14:00:05 +0000104 RunFor(60 * 1000);
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200105 choke.set_capacity_kbps(1000);
stefan@webrtc.orgf8f7c8b2014-04-01 14:00:05 +0000106 RunFor(60 * 1000);
107}
108
stefan@webrtc.org76636842015-02-17 16:03:45 +0000109TEST_P(BweSimulation, Choke1000kbps500kbps1000kbps) {
stefan@webrtc.org76636842015-02-17 16:03:45 +0000110 AdaptiveVideoSource source(0, 30, 300, 0, 0);
Stefan Holmer37959372015-04-16 19:55:45 +0200111 VideoSender sender(&uplink_, &source, GetParam());
stefan@webrtc.org76636842015-02-17 16:03:45 +0000112 ChokeFilter choke(&uplink_, 0);
Cesar Magalhaesd55ce2d2015-07-26 01:44:52 +0200113 RateCounterFilter counter(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
stefan@webrtc.org76636842015-02-17 16:03:45 +0000114 PacketReceiver receiver(&uplink_, 0, GetParam(), true, false);
115
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200116 choke.set_capacity_kbps(1000);
117 choke.set_max_delay_ms(500);
stefan@webrtc.org76636842015-02-17 16:03:45 +0000118 RunFor(60 * 1000);
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200119 choke.set_capacity_kbps(500);
stefan@webrtc.org76636842015-02-17 16:03:45 +0000120 RunFor(60 * 1000);
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200121 choke.set_capacity_kbps(1000);
stefan@webrtc.org76636842015-02-17 16:03:45 +0000122 RunFor(60 * 1000);
123}
124
gnisha36165c2017-08-20 09:19:58 -0700125TEST_P(BweSimulation, SimulationsCompiled) {
126 AdaptiveVideoSource source(0, 30, 300, 0, 0);
127 PacedVideoSender sender(&uplink_, &source, GetParam());
128 int zero = 0;
129 // CreateFlowIds() doesn't support passing int as a flow id, so we pass
130 // pointer instead.
131 DelayFilter delay(&uplink_, CreateFlowIds(&zero, 1));
132 delay.SetOneWayDelayMs(100);
133 ChokeFilter filter(&uplink_, 0);
134 RateCounterFilter counter(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
135 PacketReceiver receiver(&uplink_, 0, GetParam(), true, true);
136 filter.set_max_delay_ms(500);
137 filter.set_capacity_kbps(1000);
138 RunFor(60 * 1000);
139 filter.set_capacity_kbps(500);
140 RunFor(50 * 1000);
141 filter.set_capacity_kbps(1000);
142 RunFor(60 * 1000);
143 filter.set_capacity_kbps(200);
144 RunFor(60 * 1000);
145 filter.set_capacity_kbps(50);
146 RunFor(60 * 1000);
147 filter.set_capacity_kbps(200);
148 RunFor(60 * 1000);
149 filter.set_capacity_kbps(500);
150 RunFor(60 * 1000);
151 filter.set_capacity_kbps(300);
152 RunFor(60 * 1000);
153 filter.set_capacity_kbps(1000);
154 RunFor(60 * 1000);
155 const int kStartingCapacityKbps = 150;
156 const int kEndingCapacityKbps = 1500;
157 const int kStepKbps = 5;
158 const int kStepTimeMs = 1000;
159 for (int i = kStartingCapacityKbps; i <= kEndingCapacityKbps;
160 i += kStepKbps) {
161 filter.set_capacity_kbps(i);
162 RunFor(kStepTimeMs);
163 }
164 for (int i = kEndingCapacityKbps; i >= kStartingCapacityKbps;
165 i -= kStepKbps) {
166 filter.set_capacity_kbps(i);
167 RunFor(kStepTimeMs);
168 }
169 filter.set_capacity_kbps(150);
170 RunFor(120 * 1000);
171 filter.set_capacity_kbps(500);
172 RunFor(60 * 1000);
173}
174
stefan@webrtc.org88e0dda2014-07-04 09:20:42 +0000175TEST_P(BweSimulation, PacerChoke1000kbps500kbps1000kbps) {
stefanc62642c2015-07-07 04:20:34 -0700176 AdaptiveVideoSource source(0, 30, 300, 0, 0);
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +0000177 PacedVideoSender sender(&uplink_, &source, GetParam());
gnisha36165c2017-08-20 09:19:58 -0700178 const int kFlowId = 0;
179 // CreateFlowIds() doesn't support passing int as a flow id, so we pass
180 // pointer instead.
181 DelayFilter delay(&uplink_, CreateFlowIds(&kFlowId, 1));
182 delay.SetOneWayDelayMs(100);
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +0000183 ChokeFilter filter(&uplink_, 0);
Cesar Magalhaesd55ce2d2015-07-26 01:44:52 +0200184 RateCounterFilter counter(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +0000185 PacketReceiver receiver(&uplink_, 0, GetParam(), true, true);
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200186 filter.set_capacity_kbps(1000);
187 filter.set_max_delay_ms(500);
stefan@webrtc.org88e0dda2014-07-04 09:20:42 +0000188 RunFor(60 * 1000);
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200189 filter.set_capacity_kbps(500);
stefan@webrtc.org88e0dda2014-07-04 09:20:42 +0000190 RunFor(60 * 1000);
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200191 filter.set_capacity_kbps(1000);
stefan@webrtc.org88e0dda2014-07-04 09:20:42 +0000192 RunFor(60 * 1000);
193}
194
stefan@webrtc.org82462aa2014-10-23 11:57:05 +0000195TEST_P(BweSimulation, PacerChoke10000kbps) {
stefan@webrtc.orgf88bee62015-01-30 14:36:37 +0000196 PeriodicKeyFrameSource source(0, 30, 300, 0, 0, 1000);
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +0000197 PacedVideoSender sender(&uplink_, &source, GetParam());
198 ChokeFilter filter(&uplink_, 0);
Cesar Magalhaesd55ce2d2015-07-26 01:44:52 +0200199 RateCounterFilter counter(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +0000200 PacketReceiver receiver(&uplink_, 0, GetParam(), true, true);
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200201 filter.set_capacity_kbps(10000);
202 filter.set_max_delay_ms(500);
stefan@webrtc.org82462aa2014-10-23 11:57:05 +0000203 RunFor(60 * 1000);
204}
205
stefan@webrtc.org88e0dda2014-07-04 09:20:42 +0000206TEST_P(BweSimulation, PacerChoke200kbps30kbps200kbps) {
stefanc62642c2015-07-07 04:20:34 -0700207 AdaptiveVideoSource source(0, 30, 300, 0, 0);
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +0000208 PacedVideoSender sender(&uplink_, &source, GetParam());
209 ChokeFilter filter(&uplink_, 0);
Cesar Magalhaesd55ce2d2015-07-26 01:44:52 +0200210 RateCounterFilter counter(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +0000211 PacketReceiver receiver(&uplink_, 0, GetParam(), true, true);
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200212 filter.set_capacity_kbps(200);
213 filter.set_max_delay_ms(500);
stefan@webrtc.org88e0dda2014-07-04 09:20:42 +0000214 RunFor(60 * 1000);
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200215 filter.set_capacity_kbps(30);
stefan@webrtc.org88e0dda2014-07-04 09:20:42 +0000216 RunFor(60 * 1000);
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200217 filter.set_capacity_kbps(200);
stefan@webrtc.org88e0dda2014-07-04 09:20:42 +0000218 RunFor(60 * 1000);
219}
220
stefan@webrtc.orgf8f7c8b2014-04-01 14:00:05 +0000221TEST_P(BweSimulation, Choke200kbps30kbps200kbps) {
stefan@webrtc.orgf88bee62015-01-30 14:36:37 +0000222 AdaptiveVideoSource source(0, 30, 300, 0, 0);
Stefan Holmer37959372015-04-16 19:55:45 +0200223 VideoSender sender(&uplink_, &source, GetParam());
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +0000224 ChokeFilter filter(&uplink_, 0);
Cesar Magalhaesd55ce2d2015-07-26 01:44:52 +0200225 RateCounterFilter counter(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +0000226 PacketReceiver receiver(&uplink_, 0, GetParam(), true, true);
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200227 filter.set_capacity_kbps(200);
228 filter.set_max_delay_ms(500);
stefan@webrtc.orgf8f7c8b2014-04-01 14:00:05 +0000229 RunFor(60 * 1000);
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200230 filter.set_capacity_kbps(30);
stefan@webrtc.orgf8f7c8b2014-04-01 14:00:05 +0000231 RunFor(60 * 1000);
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200232 filter.set_capacity_kbps(200);
stefan@webrtc.orgf8f7c8b2014-04-01 14:00:05 +0000233 RunFor(60 * 1000);
234}
235
terelius568c9e72017-01-24 02:03:31 -0800236TEST_P(BweSimulation, PacerChoke50kbps15kbps50kbps) {
237 AdaptiveVideoSource source(0, 30, 300, 0, 0);
238 PacedVideoSender sender(&uplink_, &source, GetParam());
239 ChokeFilter filter(&uplink_, 0);
240 RateCounterFilter counter(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
241 PacketReceiver receiver(&uplink_, 0, GetParam(), true, true);
242 filter.set_capacity_kbps(50);
243 filter.set_max_delay_ms(500);
244 RunFor(60 * 1000);
245 filter.set_capacity_kbps(15);
246 RunFor(60 * 1000);
247 filter.set_capacity_kbps(50);
248 RunFor(60 * 1000);
249}
250
251TEST_P(BweSimulation, Choke50kbps15kbps50kbps) {
252 AdaptiveVideoSource source(0, 30, 300, 0, 0);
253 VideoSender sender(&uplink_, &source, GetParam());
254 ChokeFilter filter(&uplink_, 0);
255 RateCounterFilter counter(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
256 PacketReceiver receiver(&uplink_, 0, GetParam(), true, true);
257 filter.set_capacity_kbps(50);
258 filter.set_max_delay_ms(500);
259 RunFor(60 * 1000);
260 filter.set_capacity_kbps(15);
261 RunFor(60 * 1000);
262 filter.set_capacity_kbps(50);
263 RunFor(60 * 1000);
264}
265
pbos@webrtc.org03009392014-04-29 15:25:59 +0000266TEST_P(BweSimulation, GoogleWifiTrace3Mbps) {
stefan@webrtc.orgf88bee62015-01-30 14:36:37 +0000267 AdaptiveVideoSource source(0, 30, 300, 0, 0);
Stefan Holmer37959372015-04-16 19:55:45 +0200268 VideoSender sender(&uplink_, &source, GetParam());
Cesar Magalhaesd55ce2d2015-07-26 01:44:52 +0200269 RateCounterFilter counter1(&uplink_, 0, "sender_output",
270 bwe_names[GetParam()]);
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +0000271 TraceBasedDeliveryFilter filter(&uplink_, 0, "link_capacity");
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200272 filter.set_max_delay_ms(500);
Cesar Magalhaesd55ce2d2015-07-26 01:44:52 +0200273 RateCounterFilter counter2(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +0000274 PacketReceiver receiver(&uplink_, 0, GetParam(), true, true);
stefan@webrtc.orgf8f7c8b2014-04-01 14:00:05 +0000275 ASSERT_TRUE(filter.Init(test::ResourcePath("google-wifi-3mbps", "rx")));
276 RunFor(300 * 1000);
277}
stefan@webrtc.org4f616a02014-04-25 10:59:24 +0000278
Cesar Magalhaesf69f1fb2015-05-30 17:49:18 +0200279TEST_P(BweSimulation, LinearIncreasingCapacity) {
280 PeriodicKeyFrameSource source(0, 30, 300, 0, 0, 1000000);
281 PacedVideoSender sender(&uplink_, &source, GetParam());
282 ChokeFilter filter(&uplink_, 0);
Cesar Magalhaesd55ce2d2015-07-26 01:44:52 +0200283 RateCounterFilter counter(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
Cesar Magalhaesf69f1fb2015-05-30 17:49:18 +0200284 PacketReceiver receiver(&uplink_, 0, GetParam(), true, true);
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200285 filter.set_max_delay_ms(500);
Cesar Magalhaesf69f1fb2015-05-30 17:49:18 +0200286 const int kStartingCapacityKbps = 150;
287 const int kEndingCapacityKbps = 1500;
288 const int kStepKbps = 5;
289 const int kStepTimeMs = 1000;
290
291 for (int i = kStartingCapacityKbps; i <= kEndingCapacityKbps;
292 i += kStepKbps) {
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200293 filter.set_capacity_kbps(i);
Cesar Magalhaesf69f1fb2015-05-30 17:49:18 +0200294 RunFor(kStepTimeMs);
295 }
296}
297
298TEST_P(BweSimulation, LinearDecreasingCapacity) {
299 PeriodicKeyFrameSource source(0, 30, 300, 0, 0, 1000000);
300 PacedVideoSender sender(&uplink_, &source, GetParam());
301 ChokeFilter filter(&uplink_, 0);
Cesar Magalhaesd55ce2d2015-07-26 01:44:52 +0200302 RateCounterFilter counter(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
Cesar Magalhaesf69f1fb2015-05-30 17:49:18 +0200303 PacketReceiver receiver(&uplink_, 0, GetParam(), true, true);
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200304 filter.set_max_delay_ms(500);
Cesar Magalhaesf69f1fb2015-05-30 17:49:18 +0200305 const int kStartingCapacityKbps = 1500;
306 const int kEndingCapacityKbps = 150;
307 const int kStepKbps = -5;
308 const int kStepTimeMs = 1000;
309
310 for (int i = kStartingCapacityKbps; i >= kEndingCapacityKbps;
311 i += kStepKbps) {
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200312 filter.set_capacity_kbps(i);
Cesar Magalhaesf69f1fb2015-05-30 17:49:18 +0200313 RunFor(kStepTimeMs);
314 }
315}
316
stefan@webrtc.org82462aa2014-10-23 11:57:05 +0000317TEST_P(BweSimulation, PacerGoogleWifiTrace3Mbps) {
stefan@webrtc.orgf88bee62015-01-30 14:36:37 +0000318 PeriodicKeyFrameSource source(0, 30, 300, 0, 0, 1000);
Stefan Holmer37959372015-04-16 19:55:45 +0200319 PacedVideoSender sender(&uplink_, &source, GetParam());
gnisha36165c2017-08-20 09:19:58 -0700320 int kFlowId = 0;
321 // CreateFlowIds() doesn't support passing int as a flow id, so we pass
322 // pointer instead.
323 DelayFilter delay(&uplink_, CreateFlowIds(&kFlowId, 1));
324 delay.SetOneWayDelayMs(100);
Cesar Magalhaesd55ce2d2015-07-26 01:44:52 +0200325 RateCounterFilter counter1(&uplink_, 0, "sender_output",
326 bwe_names[GetParam()]);
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +0000327 TraceBasedDeliveryFilter filter(&uplink_, 0, "link_capacity");
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200328 filter.set_max_delay_ms(500);
Cesar Magalhaesd55ce2d2015-07-26 01:44:52 +0200329 RateCounterFilter counter2(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +0000330 PacketReceiver receiver(&uplink_, 0, GetParam(), true, true);
stefan@webrtc.org82462aa2014-10-23 11:57:05 +0000331 ASSERT_TRUE(filter.Init(test::ResourcePath("google-wifi-3mbps", "rx")));
332 RunFor(300 * 1000);
333}
334
tereliusafaef8b2016-11-17 03:48:18 -0800335TEST_P(BweSimulation, PacerGoogleWifiTrace3MbpsLowFramerate) {
336 PeriodicKeyFrameSource source(0, 5, 300, 0, 0, 1000);
337 PacedVideoSender sender(&uplink_, &source, GetParam());
338 RateCounterFilter counter1(&uplink_, 0, "sender_output",
339 bwe_names[GetParam()]);
340 TraceBasedDeliveryFilter filter(&uplink_, 0, "link_capacity");
341 filter.set_max_delay_ms(500);
342 RateCounterFilter counter2(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
343 PacketReceiver receiver(&uplink_, 0, GetParam(), true, true);
344 ASSERT_TRUE(filter.Init(test::ResourcePath("google-wifi-3mbps", "rx")));
345 RunFor(300 * 1000);
346}
347
stefan@webrtc.org027e1132015-02-10 09:48:35 +0000348TEST_P(BweSimulation, SelfFairnessTest) {
terelius8f09f172015-12-15 00:51:54 -0800349 Random prng(Clock::GetRealTimeClock()->TimeInMicroseconds());
stefanc62642c2015-07-07 04:20:34 -0700350 const int kAllFlowIds[] = {0, 1, 2, 3};
stefan@webrtc.org4f616a02014-04-25 10:59:24 +0000351 const size_t kNumFlows = sizeof(kAllFlowIds) / sizeof(kAllFlowIds[0]);
kwiberg92931b12016-03-01 05:32:29 -0800352 std::unique_ptr<VideoSource> sources[kNumFlows];
353 std::unique_ptr<VideoSender> senders[kNumFlows];
stefan@webrtc.org4f616a02014-04-25 10:59:24 +0000354 for (size_t i = 0; i < kNumFlows; ++i) {
stefan@webrtc.org387841a2015-01-14 16:45:29 +0000355 // Streams started 20 seconds apart to give them different advantage when
356 // competing for the bandwidth.
stefanc62642c2015-07-07 04:20:34 -0700357 sources[i].reset(new AdaptiveVideoSource(kAllFlowIds[i], 30, 300, 0,
terelius8f09f172015-12-15 00:51:54 -0800358 i * prng.Rand(39999)));
Stefan Holmer37959372015-04-16 19:55:45 +0200359 senders[i].reset(new VideoSender(&uplink_, sources[i].get(), GetParam()));
stefan@webrtc.org4f616a02014-04-25 10:59:24 +0000360 }
stefan@webrtc.org387841a2015-01-14 16:45:29 +0000361
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +0000362 ChokeFilter choke(&uplink_, CreateFlowIds(kAllFlowIds, kNumFlows));
Cesar Magalhaes9c261f22015-07-15 16:31:18 +0200363 choke.set_capacity_kbps(1000);
stefan@webrtc.org4f616a02014-04-25 10:59:24 +0000364
kwiberg92931b12016-03-01 05:32:29 -0800365 std::unique_ptr<RateCounterFilter> rate_counters[kNumFlows];
stefan@webrtc.org4f616a02014-04-25 10:59:24 +0000366 for (size_t i = 0; i < kNumFlows; ++i) {
Cesar Magalhaesd55ce2d2015-07-26 01:44:52 +0200367 rate_counters[i].reset(
368 new RateCounterFilter(&uplink_, CreateFlowIds(&kAllFlowIds[i], 1),
369 "Receiver", bwe_names[GetParam()]));
stefan@webrtc.org4f616a02014-04-25 10:59:24 +0000370 }
stefan@webrtc.org387841a2015-01-14 16:45:29 +0000371
372 RateCounterFilter total_utilization(
Cesar Magalhaesd55ce2d2015-07-26 01:44:52 +0200373 &uplink_, CreateFlowIds(kAllFlowIds, kNumFlows), "total_utilization",
374 "Total_link_utilization");
stefan@webrtc.org387841a2015-01-14 16:45:29 +0000375
kwiberg92931b12016-03-01 05:32:29 -0800376 std::unique_ptr<PacketReceiver> receivers[kNumFlows];
stefan@webrtc.org027e1132015-02-10 09:48:35 +0000377 for (size_t i = 0; i < kNumFlows; ++i) {
stefan@webrtc.org56cb0ea2015-02-13 15:46:23 +0000378 receivers[i].reset(new PacketReceiver(&uplink_, kAllFlowIds[i], GetParam(),
379 i == 0, false));
stefan@webrtc.org027e1132015-02-10 09:48:35 +0000380 }
381
stefan@webrtc.org4f616a02014-04-25 10:59:24 +0000382 RunFor(30 * 60 * 1000);
383}
stefan@webrtc.org387841a2015-01-14 16:45:29 +0000384
stefanc62642c2015-07-07 04:20:34 -0700385TEST_P(BweSimulation, PacedSelfFairness50msTest) {
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200386 const int64_t kAverageOffsetMs = 20 * 1000;
387 const int kNumRmcatFlows = 4;
388 int64_t offsets_ms[kNumRmcatFlows];
terelius56b11282015-11-06 05:13:55 -0800389 offsets_ms[0] = random_.Rand(2 * kAverageOffsetMs);
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200390 for (int i = 1; i < kNumRmcatFlows; ++i) {
terelius56b11282015-11-06 05:13:55 -0800391 offsets_ms[i] = offsets_ms[i - 1] + random_.Rand(2 * kAverageOffsetMs);
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200392 }
393 RunFairnessTest(GetParam(), kNumRmcatFlows, 0, 1000, 3000, 50, 50, 0,
394 offsets_ms);
stefan@webrtc.org387841a2015-01-14 16:45:29 +0000395}
Stefan Holmer37959372015-04-16 19:55:45 +0200396
stefanc62642c2015-07-07 04:20:34 -0700397TEST_P(BweSimulation, PacedSelfFairness500msTest) {
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200398 const int64_t kAverageOffsetMs = 20 * 1000;
399 const int kNumRmcatFlows = 4;
400 int64_t offsets_ms[kNumRmcatFlows];
terelius56b11282015-11-06 05:13:55 -0800401 offsets_ms[0] = random_.Rand(2 * kAverageOffsetMs);
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200402 for (int i = 1; i < kNumRmcatFlows; ++i) {
terelius56b11282015-11-06 05:13:55 -0800403 offsets_ms[i] = offsets_ms[i - 1] + random_.Rand(2 * kAverageOffsetMs);
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200404 }
405 RunFairnessTest(GetParam(), kNumRmcatFlows, 0, 1000, 3000, 500, 50, 0,
406 offsets_ms);
stefanc62642c2015-07-07 04:20:34 -0700407}
408
Stefan Holmerbcbcd842015-04-28 14:39:00 +0200409TEST_P(BweSimulation, PacedSelfFairness1000msTest) {
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200410 const int64_t kAverageOffsetMs = 20 * 1000;
411 const int kNumRmcatFlows = 4;
412 int64_t offsets_ms[kNumRmcatFlows];
terelius56b11282015-11-06 05:13:55 -0800413 offsets_ms[0] = random_.Rand(2 * kAverageOffsetMs);
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200414 for (int i = 1; i < kNumRmcatFlows; ++i) {
terelius56b11282015-11-06 05:13:55 -0800415 offsets_ms[i] = offsets_ms[i - 1] + random_.Rand(2 * kAverageOffsetMs);
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200416 }
417 RunFairnessTest(GetParam(), 4, 0, 1000, 3000, 1000, 50, 0, offsets_ms);
Stefan Holmerbcbcd842015-04-28 14:39:00 +0200418}
419
420TEST_P(BweSimulation, TcpFairness50msTest) {
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200421 const int64_t kAverageOffsetMs = 20 * 1000;
terelius56b11282015-11-06 05:13:55 -0800422 int64_t offset_ms[] = {random_.Rand(2 * kAverageOffsetMs), 0};
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200423 RunFairnessTest(GetParam(), 1, 1, 1000, 2000, 50, 50, 0, offset_ms);
Stefan Holmerbcbcd842015-04-28 14:39:00 +0200424}
425
426TEST_P(BweSimulation, TcpFairness500msTest) {
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200427 const int64_t kAverageOffsetMs = 20 * 1000;
terelius56b11282015-11-06 05:13:55 -0800428 int64_t offset_ms[] = {random_.Rand(2 * kAverageOffsetMs), 0};
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200429 RunFairnessTest(GetParam(), 1, 1, 1000, 2000, 500, 50, 0, offset_ms);
Stefan Holmerbcbcd842015-04-28 14:39:00 +0200430}
431
432TEST_P(BweSimulation, TcpFairness1000msTest) {
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200433 const int kAverageOffsetMs = 20 * 1000;
terelius56b11282015-11-06 05:13:55 -0800434 int64_t offset_ms[] = {random_.Rand(2 * kAverageOffsetMs), 0};
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200435 RunFairnessTest(GetParam(), 1, 1, 1000, 2000, 1000, 50, 0, offset_ms);
436}
437
terelius2d81eb32016-10-25 07:04:37 -0700438// The following test cases begin with "Evaluation" as a reference to the
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200439// Internet draft https://tools.ietf.org/html/draft-ietf-rmcat-eval-test-01.
440
441TEST_P(BweSimulation, Evaluation1) {
442 RunVariableCapacity1SingleFlow(GetParam());
443}
444
445TEST_P(BweSimulation, Evaluation2) {
446 const size_t kNumFlows = 2;
447 RunVariableCapacity2MultipleFlows(GetParam(), kNumFlows);
448}
449
450TEST_P(BweSimulation, Evaluation3) {
451 RunBidirectionalFlow(GetParam());
452}
453
454TEST_P(BweSimulation, Evaluation4) {
455 RunSelfFairness(GetParam());
456}
457
458TEST_P(BweSimulation, Evaluation5) {
459 RunRoundTripTimeFairness(GetParam());
460}
461
462TEST_P(BweSimulation, Evaluation6) {
463 RunLongTcpFairness(GetParam());
464}
465
466// Different calls to the Evaluation7 will create the same FileSizes
467// and StartingTimes as long as the seeds remain unchanged. This is essential
468// when calling it with multiple estimators for comparison purposes.
469TEST_P(BweSimulation, Evaluation7) {
470 const int kNumTcpFiles = 10;
471 RunMultipleShortTcpFairness(GetParam(),
472 BweTest::GetFileSizesBytes(kNumTcpFiles),
473 BweTest::GetStartingTimesMs(kNumTcpFiles));
474}
475
476TEST_P(BweSimulation, Evaluation8) {
477 RunPauseResumeFlows(GetParam());
478}
479
480// Following test cases begin with "GccComparison" run the
481// evaluation test cases for both GCC and other calling RMCAT.
482
483TEST_P(BweSimulation, GccComparison1) {
484 RunVariableCapacity1SingleFlow(GetParam());
485 BweTest gcc_test(false);
terelius2d81eb32016-10-25 07:04:37 -0700486 gcc_test.RunVariableCapacity1SingleFlow(kSendSideEstimator);
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200487}
488
489TEST_P(BweSimulation, GccComparison2) {
490 const size_t kNumFlows = 2;
491 RunVariableCapacity2MultipleFlows(GetParam(), kNumFlows);
492 BweTest gcc_test(false);
terelius2d81eb32016-10-25 07:04:37 -0700493 gcc_test.RunVariableCapacity2MultipleFlows(kSendSideEstimator, kNumFlows);
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200494}
495
496TEST_P(BweSimulation, GccComparison3) {
497 RunBidirectionalFlow(GetParam());
498 BweTest gcc_test(false);
terelius2d81eb32016-10-25 07:04:37 -0700499 gcc_test.RunBidirectionalFlow(kSendSideEstimator);
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200500}
501
502TEST_P(BweSimulation, GccComparison4) {
503 RunSelfFairness(GetParam());
504 BweTest gcc_test(false);
505 gcc_test.RunSelfFairness(GetParam());
506}
507
508TEST_P(BweSimulation, GccComparison5) {
509 RunRoundTripTimeFairness(GetParam());
510 BweTest gcc_test(false);
terelius2d81eb32016-10-25 07:04:37 -0700511 gcc_test.RunRoundTripTimeFairness(kSendSideEstimator);
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200512}
513
514TEST_P(BweSimulation, GccComparison6) {
515 RunLongTcpFairness(GetParam());
516 BweTest gcc_test(false);
terelius2d81eb32016-10-25 07:04:37 -0700517 gcc_test.RunLongTcpFairness(kSendSideEstimator);
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200518}
519
520TEST_P(BweSimulation, GccComparison7) {
521 const int kNumTcpFiles = 10;
522
523 std::vector<int> tcp_file_sizes_bytes =
524 BweTest::GetFileSizesBytes(kNumTcpFiles);
525 std::vector<int64_t> tcp_starting_times_ms =
526 BweTest::GetStartingTimesMs(kNumTcpFiles);
527
528 RunMultipleShortTcpFairness(GetParam(), tcp_file_sizes_bytes,
529 tcp_starting_times_ms);
530
531 BweTest gcc_test(false);
terelius2d81eb32016-10-25 07:04:37 -0700532 gcc_test.RunMultipleShortTcpFairness(kSendSideEstimator, tcp_file_sizes_bytes,
533 tcp_starting_times_ms);
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200534}
535
536TEST_P(BweSimulation, GccComparison8) {
537 RunPauseResumeFlows(GetParam());
538 BweTest gcc_test(false);
terelius2d81eb32016-10-25 07:04:37 -0700539 gcc_test.RunPauseResumeFlows(kSendSideEstimator);
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200540}
541
542TEST_P(BweSimulation, GccComparisonChoke) {
543 int array[] = {1000, 500, 1000};
544 std::vector<int> capacities_kbps(array, array + 3);
545 RunChoke(GetParam(), capacities_kbps);
546
547 BweTest gcc_test(false);
terelius2d81eb32016-10-25 07:04:37 -0700548 gcc_test.RunChoke(kSendSideEstimator, capacities_kbps);
Stefan Holmer37959372015-04-16 19:55:45 +0200549}
Cesar Magalhaesf69f1fb2015-05-30 17:49:18 +0200550
stefan@webrtc.orgc88d3362014-02-05 15:57:14 +0000551} // namespace bwe
552} // namespace testing
553} // namespace webrtc
Cesar Magalhaes59adf342015-07-23 15:40:38 +0200554