File: bwe_simulations.cc

package info (click to toggle)
chromium-browser 41.0.2272.118-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 2,189,132 kB
  • sloc: cpp: 9,691,462; ansic: 3,341,451; python: 712,689; asm: 518,779; xml: 208,926; java: 169,820; sh: 119,353; perl: 68,907; makefile: 28,311; yacc: 13,305; objc: 11,385; tcl: 3,186; cs: 2,225; sql: 2,217; lex: 2,215; lisp: 1,349; pascal: 1,256; awk: 407; ruby: 155; sed: 53; php: 14; exp: 11
file content (215 lines) | stat: -rw-r--r-- 7,126 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/*
 *  Copyright (c) 2014 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 "testing/gtest/include/gtest/gtest.h"
#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
#include "webrtc/modules/remote_bitrate_estimator/test/bwe_test.h"
#include "webrtc/test/testsupport/fileutils.h"

using std::string;

namespace webrtc {
namespace testing {
namespace bwe {
#if BWE_TEST_LOGGING_COMPILE_TIME_ENABLE
BweTestConfig::EstimatorConfig CreateEstimatorConfig(
    int flow_id, bool plot_delay, bool plot_estimate) {
  static const AbsoluteSendTimeRemoteBitrateEstimatorFactory factory =
      AbsoluteSendTimeRemoteBitrateEstimatorFactory();

  return BweTestConfig::EstimatorConfig("AST", flow_id, &factory, kAimdControl,
                                        plot_delay, plot_estimate);
}

BweTestConfig MakeAdaptiveBweTestConfig() {
  BweTestConfig result;
  result.estimator_configs.push_back(CreateEstimatorConfig(0, true, true));
  return result;
}

BweTestConfig MakeMultiFlowBweTestConfig(int flow_count) {
  BweTestConfig result;
  for (int i = 0; i < flow_count; ++i) {
    result.estimator_configs.push_back(CreateEstimatorConfig(i, false, true));
  }
  return result;
}

// This test fixture is used to instantiate tests running with adaptive video
// senders.
class BweSimulation : public BweTest,
                      public ::testing::TestWithParam<BweTestConfig> {
 public:
  BweSimulation() : BweTest() {}
  virtual ~BweSimulation() {}

  virtual void SetUp() {
    const BweTestConfig& config = GetParam();
    SetupTestFromConfig(config);
  }

 private:
  DISALLOW_COPY_AND_ASSIGN(BweSimulation);
};

INSTANTIATE_TEST_CASE_P(VideoSendersTest, BweSimulation,
    ::testing::Values(MakeAdaptiveBweTestConfig()));

TEST_P(BweSimulation, SprintUplinkTest) {
  VerboseLogging(true);
  AdaptiveVideoSender sender(0, this, 30, 300, 0, 0);
  RateCounterFilter counter1(this, "sender_output");
  TraceBasedDeliveryFilter filter(this, "link_capacity");
  RateCounterFilter counter2(this, "receiver_input");
  ASSERT_TRUE(filter.Init(test::ResourcePath("sprint-uplink", "rx")));
  RunFor(60 * 1000);
}

TEST_P(BweSimulation, Verizon4gDownlinkTest) {
  VerboseLogging(true);
  AdaptiveVideoSender sender(0, this, 30, 300, 0, 0);
  RateCounterFilter counter1(this, "sender_output");
  TraceBasedDeliveryFilter filter(this, "link_capacity");
  RateCounterFilter counter2(this, "receiver_input");
  ASSERT_TRUE(filter.Init(test::ResourcePath("verizon4g-downlink", "rx")));
  RunFor(22 * 60 * 1000);
}

TEST_P(BweSimulation, Choke1000kbps500kbps1000kbps) {
  VerboseLogging(true);
  AdaptiveVideoSender sender(0, this, 30, 300, 0, 0);
  ChokeFilter filter(this);
  RateCounterFilter counter(this, "receiver_input");
  filter.SetCapacity(1000);
  filter.SetMaxDelay(500);
  RunFor(60 * 1000);
  filter.SetCapacity(500);
  RunFor(60 * 1000);
  filter.SetCapacity(1000);
  RunFor(60 * 1000);
}

TEST_P(BweSimulation, PacerChoke1000kbps500kbps1000kbps) {
  VerboseLogging(true);
  PeriodicKeyFrameSender source(0, NULL, 30, 300, 0, 0, 1000);
  PacedVideoSender sender(this, 300, &source);
  ChokeFilter filter(this);
  RateCounterFilter counter(this, "receiver_input");
  filter.SetCapacity(1000);
  filter.SetMaxDelay(500);
  RunFor(60 * 1000);
  filter.SetCapacity(500);
  RunFor(60 * 1000);
  filter.SetCapacity(1000);
  RunFor(60 * 1000);
}

TEST_P(BweSimulation, PacerChoke10000kbps) {
  VerboseLogging(true);
  PeriodicKeyFrameSender source(0, NULL, 30, 300, 0, 0, 0);
  PacedVideoSender sender(this, 300, &source);
  ChokeFilter filter(this);
  RateCounterFilter counter(this, "receiver_input");
  filter.SetCapacity(10000);
  filter.SetMaxDelay(500);
  RunFor(60 * 1000);
}

TEST_P(BweSimulation, PacerChoke200kbps30kbps200kbps) {
  VerboseLogging(true);
  PeriodicKeyFrameSender source(0, NULL, 30, 300, 0, 0, 1000);
  PacedVideoSender sender(this, 300, &source);
  ChokeFilter filter(this);
  RateCounterFilter counter(this, "receiver_input");
  filter.SetCapacity(200);
  filter.SetMaxDelay(500);
  RunFor(60 * 1000);
  filter.SetCapacity(30);
  RunFor(60 * 1000);
  filter.SetCapacity(200);
  RunFor(60 * 1000);
}

TEST_P(BweSimulation, Choke200kbps30kbps200kbps) {
  VerboseLogging(true);
  AdaptiveVideoSender sender(0, this, 30, 300, 0, 0);
  ChokeFilter filter(this);
  RateCounterFilter counter(this, "receiver_input");
  filter.SetCapacity(200);
  filter.SetMaxDelay(500);
  RunFor(60 * 1000);
  filter.SetCapacity(30);
  RunFor(60 * 1000);
  filter.SetCapacity(200);
  RunFor(60 * 1000);
}

TEST_P(BweSimulation, GoogleWifiTrace3Mbps) {
  VerboseLogging(true);
  AdaptiveVideoSender sender(0, this, 30, 300, 0, 0);
  RateCounterFilter counter1(this, "sender_output");
  TraceBasedDeliveryFilter filter(this, "link_capacity");
  filter.SetMaxDelay(500);
  RateCounterFilter counter2(this, "receiver_input");
  ASSERT_TRUE(filter.Init(test::ResourcePath("google-wifi-3mbps", "rx")));
  RunFor(300 * 1000);
}

TEST_P(BweSimulation, PacerGoogleWifiTrace3Mbps) {
  VerboseLogging(true);
  PeriodicKeyFrameSender source(0, NULL, 30, 300, 0, 0, 1000);
  PacedVideoSender sender(this, 300, &source);
  RateCounterFilter counter1(this, "sender_output");
  TraceBasedDeliveryFilter filter(this, "link_capacity");
  filter.SetMaxDelay(500);
  RateCounterFilter counter2(this, "receiver_input");
  ASSERT_TRUE(filter.Init(test::ResourcePath("google-wifi-3mbps", "rx")));
  RunFor(300 * 1000);
}

class MultiFlowBweSimulation : public BweSimulation {
 public:
  MultiFlowBweSimulation() : BweSimulation() {}
  virtual ~MultiFlowBweSimulation() {}

 private:
  DISALLOW_COPY_AND_ASSIGN(MultiFlowBweSimulation);
};

INSTANTIATE_TEST_CASE_P(VideoSendersTest, MultiFlowBweSimulation,
    ::testing::Values(MakeMultiFlowBweTestConfig(3)));

TEST_P(MultiFlowBweSimulation, SelfFairnessTest) {
  VerboseLogging(true);
  const int kAllFlowIds[] = {0, 1, 2};
  const size_t kNumFlows = sizeof(kAllFlowIds) / sizeof(kAllFlowIds[0]);
  scoped_ptr<AdaptiveVideoSender> senders[kNumFlows];
  for (size_t i = 0; i < kNumFlows; ++i) {
    senders[i].reset(new AdaptiveVideoSender(kAllFlowIds[i], this, 30, 300, 0,
                                             0));
  }
  // Second and third flow.
  ChokeFilter choke(this, CreateFlowIds(&kAllFlowIds[1], 2));
  choke.SetCapacity(1500);
  // First flow.
  ChokeFilter choke2(this, CreateFlowIds(&kAllFlowIds[0], 1));
  choke2.SetCapacity(1000);

  scoped_ptr<RateCounterFilter> rate_counters[kNumFlows];
  for (size_t i = 0; i < kNumFlows; ++i) {
    rate_counters[i].reset(new RateCounterFilter(
        this, CreateFlowIds(&kAllFlowIds[i], 1), "receiver_input"));
  }
  RunFor(30 * 60 * 1000);
}
#endif  // BWE_TEST_LOGGING_COMPILE_TIME_ENABLE
}  // namespace bwe
}  // namespace testing
}  // namespace webrtc