DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (c68fe15a81fc)

VCS Links

Line Code
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 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
/*
 *  Copyright (c) 2013 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.
 */

#ifndef WEBRTC_WIN
#include <sys/types.h>
#include <unistd.h>
#endif

#include <algorithm>
#include <sstream>

#include "modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
#include "modules/remote_bitrate_estimator/test/bwe_test.h"
#include "modules/remote_bitrate_estimator/test/packet_receiver.h"
#include "modules/remote_bitrate_estimator/test/packet_sender.h"
#include "rtc_base/constructormagic.h"
#include "rtc_base/random.h"
#include "test/field_trial.h"
#include "test/testsupport/fileutils.h"

namespace webrtc {
namespace testing {
namespace bwe {

// This test fixture is used to instantiate tests running with adaptive video
// senders.
class BweFeedbackTest
    : public BweTest,
      public ::testing::TestWithParam<BandwidthEstimatorType> {
 public:
#ifdef WEBRTC_WIN
  BweFeedbackTest()
      : BweTest(), random_(Clock::GetRealTimeClock()->TimeInMicroseconds()) {}
#else
  BweFeedbackTest()
      : BweTest(),
        // Multiply the time by a random-ish odd number derived from the PID.
        random_((getpid() | 1) *
                Clock::GetRealTimeClock()->TimeInMicroseconds()) {}
#endif
  virtual ~BweFeedbackTest() {}

 protected:
  Random random_;

 private:
  RTC_DISALLOW_COPY_AND_ASSIGN(BweFeedbackTest);
};

INSTANTIATE_TEST_CASE_P(VideoSendersTest,
                        BweFeedbackTest,
                        ::testing::Values(kRembEstimator, kSendSideEstimator));

TEST_P(BweFeedbackTest, ConstantCapacity) {
  AdaptiveVideoSource source(0, 30, 300, 0, 0);
  PacedVideoSender sender(&uplink_, &source, GetParam());
  ChokeFilter filter(&uplink_, 0);
  RateCounterFilter counter(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
  PacketReceiver receiver(&uplink_, 0, GetParam(), false, false);
  const int kCapacityKbps = 1000;
  filter.set_capacity_kbps(kCapacityKbps);
  filter.set_max_delay_ms(500);
  RunFor(180 * 1000);
  PrintResults(kCapacityKbps, counter.GetBitrateStats(), 0,
               receiver.GetDelayStats(), counter.GetBitrateStats());
}

TEST_P(BweFeedbackTest, Choke1000kbps500kbps1000kbps) {
  AdaptiveVideoSource source(0, 30, 300, 0, 0);
  PacedVideoSender sender(&uplink_, &source, GetParam());
  ChokeFilter filter(&uplink_, 0);
  RateCounterFilter counter(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
  PacketReceiver receiver(&uplink_, 0, GetParam(), false, false);
  const int kHighCapacityKbps = 1000;
  const int kLowCapacityKbps = 500;
  filter.set_capacity_kbps(kHighCapacityKbps);
  filter.set_max_delay_ms(500);
  RunFor(60 * 1000);
  filter.set_capacity_kbps(kLowCapacityKbps);
  RunFor(60 * 1000);
  filter.set_capacity_kbps(kHighCapacityKbps);
  RunFor(60 * 1000);
  PrintResults((2 * kHighCapacityKbps + kLowCapacityKbps) / 3.0,
               counter.GetBitrateStats(), 0, receiver.GetDelayStats(),
               counter.GetBitrateStats());
}

TEST_P(BweFeedbackTest, Choke200kbps30kbps200kbps) {
  AdaptiveVideoSource source(0, 30, 300, 0, 0);
  PacedVideoSender sender(&uplink_, &source, GetParam());
  ChokeFilter filter(&uplink_, 0);
  RateCounterFilter counter(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
  PacketReceiver receiver(&uplink_, 0, GetParam(), false, false);
  const int kHighCapacityKbps = 200;
  const int kLowCapacityKbps = 30;
  filter.set_capacity_kbps(kHighCapacityKbps);
  filter.set_max_delay_ms(500);
  RunFor(60 * 1000);
  filter.set_capacity_kbps(kLowCapacityKbps);
  RunFor(60 * 1000);
  filter.set_capacity_kbps(kHighCapacityKbps);
  RunFor(60 * 1000);

  PrintResults((2 * kHighCapacityKbps + kLowCapacityKbps) / 3.0,
               counter.GetBitrateStats(), 0, receiver.GetDelayStats(),
               counter.GetBitrateStats());
}

TEST_P(BweFeedbackTest, Verizon4gDownlinkTest) {
  AdaptiveVideoSource source(0, 30, 300, 0, 0);
  VideoSender sender(&uplink_, &source, GetParam());
  RateCounterFilter counter1(&uplink_, 0, "sender_output",
                             bwe_names[GetParam()]);
  TraceBasedDeliveryFilter filter(&uplink_, 0, "link_capacity");
  RateCounterFilter counter2(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
  PacketReceiver receiver(&uplink_, 0, GetParam(), false, false);
  ASSERT_TRUE(filter.Init(test::ResourcePath("verizon4g-downlink", "rx")));
  RunFor(22 * 60 * 1000);
  PrintResults(filter.GetBitrateStats().GetMean(), counter2.GetBitrateStats(),
               0, receiver.GetDelayStats(), counter2.GetBitrateStats());
}

// webrtc:3277
TEST_P(BweFeedbackTest, GoogleWifiTrace3Mbps) {
  AdaptiveVideoSource source(0, 30, 300, 0, 0);
  VideoSender sender(&uplink_, &source, GetParam());
  RateCounterFilter counter1(&uplink_, 0, "sender_output",
                             bwe_names[GetParam()]);
  TraceBasedDeliveryFilter filter(&uplink_, 0, "link_capacity");
  filter.set_max_delay_ms(500);
  RateCounterFilter counter2(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
  PacketReceiver receiver(&uplink_, 0, GetParam(), false, false);
  ASSERT_TRUE(filter.Init(test::ResourcePath("google-wifi-3mbps", "rx")));
  RunFor(300 * 1000);
  PrintResults(filter.GetBitrateStats().GetMean(), counter2.GetBitrateStats(),
               0, receiver.GetDelayStats(), counter2.GetBitrateStats());
}

TEST_P(BweFeedbackTest, GoogleWifiTrace3MbpsStreaming) {
  test::ScopedFieldTrials override_field_trials(
      "WebRTC-BweWindowSizeInPackets/Enabled-100/"
      "WebRTC-BweBackOffFactor/Enabled-0.95/");
  AdaptiveVideoSource source(0, 30, 300, 0, 0);
  VideoSender sender(&uplink_, &source, GetParam());
  RateCounterFilter counter1(&uplink_, 0, "sender_output",
                             bwe_names[GetParam()]);
  TraceBasedDeliveryFilter filter(&uplink_, 0, "link_capacity");
  filter.set_max_delay_ms(500);
  RateCounterFilter counter2(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
  PacketReceiver receiver(&uplink_, 0, GetParam(), false, false);
  ASSERT_TRUE(filter.Init(test::ResourcePath("google-wifi-3mbps", "rx")));
  RunFor(300 * 1000);
  PrintResults(filter.GetBitrateStats().GetMean(), counter2.GetBitrateStats(),
               0, receiver.GetDelayStats(), counter2.GetBitrateStats());
}

TEST_P(BweFeedbackTest, PacedSelfFairness50msTest) {
  int64_t kRttMs = 100;
  int64_t kMaxJitterMs = 15;

  const int kNumRmcatFlows = 4;
  int64_t offset_ms[kNumRmcatFlows];
  for (int i = 0; i < kNumRmcatFlows; ++i) {
    offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000));
  }

  RunFairnessTest(GetParam(), kNumRmcatFlows, 0, 300, 3000, 50, kRttMs,
                  kMaxJitterMs, offset_ms);
}

TEST_P(BweFeedbackTest, PacedSelfFairness500msTest) {
  int64_t kRttMs = 100;
  int64_t kMaxJitterMs = 15;

  const int kNumRmcatFlows = 4;
  int64_t offset_ms[kNumRmcatFlows];
  for (int i = 0; i < kNumRmcatFlows; ++i) {
    offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000));
  }

  RunFairnessTest(GetParam(), kNumRmcatFlows, 0, 300, 3000, 500, kRttMs,
                  kMaxJitterMs, offset_ms);
}

TEST_P(BweFeedbackTest, PacedSelfFairness1000msTest) {
  int64_t kRttMs = 100;
  int64_t kMaxJitterMs = 15;

  const int kNumRmcatFlows = 4;
  int64_t offset_ms[kNumRmcatFlows];
  for (int i = 0; i < kNumRmcatFlows; ++i) {
    offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000));
  }

  RunFairnessTest(GetParam(), kNumRmcatFlows, 0, 300, 3000, 1000, kRttMs,
                  kMaxJitterMs, offset_ms);
}

TEST_P(BweFeedbackTest, TcpFairness50msTest) {
  int64_t kRttMs = 100;
  int64_t kMaxJitterMs = 15;

  int64_t offset_ms[2];  // One TCP, one RMCAT flow.
  for (int i = 0; i < 2; ++i) {
    offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000));
  }

  RunFairnessTest(GetParam(), 1, 1, 300, 2000, 50, kRttMs, kMaxJitterMs,
                  offset_ms);
}

TEST_P(BweFeedbackTest, TcpFairness500msTest) {
  int64_t kRttMs = 100;
  int64_t kMaxJitterMs = 15;

  int64_t offset_ms[2];  // One TCP, one RMCAT flow.
  for (int i = 0; i < 2; ++i) {
    offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000));
  }

  RunFairnessTest(GetParam(), 1, 1, 300, 2000, 500, kRttMs, kMaxJitterMs,
                  offset_ms);
}

TEST_P(BweFeedbackTest, TcpFairness1000msTest) {
  int64_t kRttMs = 100;
  int64_t kMaxJitterMs = 15;

  int64_t offset_ms[2];  // One TCP, one RMCAT flow.
  for (int i = 0; i < 2; ++i) {
    offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000));
  }

  RunFairnessTest(GetParam(), 1, 1, 300, 2000, 1000, kRttMs, kMaxJitterMs,
                  offset_ms);
}
}  // namespace bwe
}  // namespace testing
}  // namespace webrtc