Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 | 22 |
| 23 class AlrDetectorTest : public testing::Test { | 23 class AlrDetectorTest : public testing::Test { |
| 24 public: | 24 public: |
| 25 void SetUp() override { | 25 void SetUp() override { |
| 26 alr_detector_.SetEstimatedBitrate(kEstimatedBitrateBps); | 26 alr_detector_.SetEstimatedBitrate(kEstimatedBitrateBps); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void SimulateOutgoingTraffic(int interval_ms, int usage_percentage) { | 29 void SimulateOutgoingTraffic(int interval_ms, int usage_percentage) { |
| 30 const int kTimeStepMs = 10; | 30 const int kTimeStepMs = 10; |
| 31 for (int t = 0; t < interval_ms; t += kTimeStepMs) { | 31 for (int t = 0; t < interval_ms; t += kTimeStepMs) { |
| 32 now_ms += kTimeStepMs; | |
| 33 alr_detector_.OnBytesSent(kEstimatedBitrateBps * usage_percentage * | 32 alr_detector_.OnBytesSent(kEstimatedBitrateBps * usage_percentage * |
| 34 kTimeStepMs / (8 * 100 * 1000), | 33 kTimeStepMs / (8 * 100 * 1000), |
| 35 now_ms); | 34 kTimeStepMs); |
| 36 } | 35 } |
| 37 | |
| 38 int remainder_ms = interval_ms % kTimeStepMs; | 36 int remainder_ms = interval_ms % kTimeStepMs; |
| 39 now_ms += remainder_ms; | |
| 40 if (remainder_ms > 0) { | 37 if (remainder_ms > 0) { |
| 41 alr_detector_.OnBytesSent(kEstimatedBitrateBps * usage_percentage * | 38 alr_detector_.OnBytesSent(kEstimatedBitrateBps * usage_percentage * |
| 42 remainder_ms / (8 * 100 * 1000), | 39 remainder_ms / (8 * 100 * 1000), |
| 43 remainder_ms); | 40 kTimeStepMs); |
| 44 } | 41 } |
| 45 } | 42 } |
| 46 | 43 |
| 47 protected: | 44 protected: |
| 48 AlrDetector alr_detector_; | 45 AlrDetector alr_detector_; |
| 49 int64_t now_ms = 1; | |
| 50 }; | 46 }; |
| 51 | 47 |
| 52 TEST_F(AlrDetectorTest, AlrDetection) { | 48 TEST_F(AlrDetectorTest, AlrDetection) { |
| 53 // Start in non-ALR state. | 49 // Start in non-ALR state. |
| 54 EXPECT_FALSE(alr_detector_.GetApplicationLimitedRegionStartTime()); | 50 EXPECT_FALSE(alr_detector_.GetApplicationLimitedRegionStartTime()); |
| 55 | 51 |
| 56 // Stay in non-ALR state when usage is close to 100%. | 52 // Stay in non-ALR state when usage is close to 100%. |
| 57 SimulateOutgoingTraffic(500, 90); | 53 SimulateOutgoingTraffic(1000, 90); |
| 58 EXPECT_FALSE(alr_detector_.GetApplicationLimitedRegionStartTime()); | 54 EXPECT_FALSE(alr_detector_.GetApplicationLimitedRegionStartTime()); |
| 59 | 55 |
| 60 // Verify that we ALR starts when bitrate drops below 20%. | 56 // Verify that we ALR starts when bitrate drops below 20%. |
| 61 SimulateOutgoingTraffic(500, 20); | 57 SimulateOutgoingTraffic(1000, 20); |
| 62 EXPECT_TRUE(alr_detector_.GetApplicationLimitedRegionStartTime()); | 58 EXPECT_TRUE(alr_detector_.GetApplicationLimitedRegionStartTime()); |
| 63 | 59 |
| 64 // Verify that we remain in ALR state while usage is still below 70%. | 60 // Verify that ALR ends when usage is above 60%. |
|
stefan-webrtc
2017/07/06 14:55:38
Not clear how for instance 60% relates to 1000, 10
tschumi
2017/07/07 08:47:30
Changed the impl a little so that the test code sh
| |
| 65 SimulateOutgoingTraffic(500, 69); | 61 SimulateOutgoingTraffic(1000, 100); |
| 66 EXPECT_TRUE(alr_detector_.GetApplicationLimitedRegionStartTime()); | |
| 67 | |
| 68 // Verify that ALR ends when usage is above 70%. | |
| 69 SimulateOutgoingTraffic(500, 75); | |
| 70 EXPECT_FALSE(alr_detector_.GetApplicationLimitedRegionStartTime()); | 62 EXPECT_FALSE(alr_detector_.GetApplicationLimitedRegionStartTime()); |
| 71 } | 63 } |
| 72 | 64 |
| 73 TEST_F(AlrDetectorTest, ShortSpike) { | 65 TEST_F(AlrDetectorTest, ShortSpike) { |
| 74 // Start in non-ALR state. | 66 // Start in non-ALR state. |
| 75 EXPECT_FALSE(alr_detector_.GetApplicationLimitedRegionStartTime()); | 67 EXPECT_FALSE(alr_detector_.GetApplicationLimitedRegionStartTime()); |
| 76 | 68 |
| 77 // Verify that we ALR starts when bitrate drops below 20%. | 69 // Verify that we ALR starts when bitrate drops below 20%. |
| 78 SimulateOutgoingTraffic(500, 20); | 70 SimulateOutgoingTraffic(1000, 20); |
| 79 EXPECT_TRUE(alr_detector_.GetApplicationLimitedRegionStartTime()); | 71 EXPECT_TRUE(alr_detector_.GetApplicationLimitedRegionStartTime()); |
| 80 | 72 |
| 81 // Verify that we stay in ALR region even after a short bitrate spike. | 73 // Verify that we stay in ALR region even after a short bitrate spike. |
| 82 SimulateOutgoingTraffic(100, 150); | 74 SimulateOutgoingTraffic(200, 150); |
| 83 EXPECT_TRUE(alr_detector_.GetApplicationLimitedRegionStartTime()); | 75 EXPECT_TRUE(alr_detector_.GetApplicationLimitedRegionStartTime()); |
| 84 | 76 |
| 85 SimulateOutgoingTraffic(200, 20); | 77 // ALR ends when usage is above 100%. |
|
stefan-webrtc
2017/07/06 14:55:38
Do we want to change from 70% to 100%?
tschumi
2017/07/07 08:47:30
Yea my mistake => changed it to 65 % (new default
| |
| 86 EXPECT_TRUE(alr_detector_.GetApplicationLimitedRegionStartTime()); | 78 SimulateOutgoingTraffic(1000, 100); |
| 87 | |
| 88 // ALR ends when usage is above 70%. | |
| 89 SimulateOutgoingTraffic(500, 75); | |
| 90 EXPECT_FALSE(alr_detector_.GetApplicationLimitedRegionStartTime()); | 79 EXPECT_FALSE(alr_detector_.GetApplicationLimitedRegionStartTime()); |
| 91 } | 80 } |
| 92 | 81 |
| 93 TEST_F(AlrDetectorTest, BandwidthEstimateChanges) { | 82 TEST_F(AlrDetectorTest, BandwidthEstimateChanges) { |
| 94 // Start in non-ALR state. | 83 // Start in non-ALR state. |
| 95 EXPECT_FALSE(alr_detector_.GetApplicationLimitedRegionStartTime()); | 84 EXPECT_FALSE(alr_detector_.GetApplicationLimitedRegionStartTime()); |
| 96 | 85 |
| 97 // ALR starts when bitrate drops below 20%. | 86 // ALR starts when bitrate drops below 20%. |
|
stefan-webrtc
2017/07/06 14:55:37
Is this comment still correct? Why did it change f
tschumi
2017/07/07 08:47:30
Because of the new impl. it takes more time to det
| |
| 98 SimulateOutgoingTraffic(500, 20); | 87 SimulateOutgoingTraffic(1000, 20); |
| 99 EXPECT_TRUE(alr_detector_.GetApplicationLimitedRegionStartTime()); | 88 EXPECT_TRUE(alr_detector_.GetApplicationLimitedRegionStartTime()); |
| 100 | 89 |
| 101 // When bandwidth estimate drops the detector should stay in ALR mode and quit | 90 // When bandwidth estimate drops the detector should stay in ALR mode and quit |
| 102 // it shortly afterwards as the sender continues sending the same amount of | 91 // it shortly afterwards as the sender continues sending the same amount of |
| 103 // traffic. This is necessary to ensure that ProbeController can still react | 92 // traffic. This is necessary to ensure that ProbeController can still react |
| 104 // to the BWE drop by initiating a new probe. | 93 // to the BWE drop by initiating a new probe. |
| 105 alr_detector_.SetEstimatedBitrate(kEstimatedBitrateBps / 5); | 94 alr_detector_.SetEstimatedBitrate(kEstimatedBitrateBps / 5); |
| 106 EXPECT_TRUE(alr_detector_.GetApplicationLimitedRegionStartTime()); | 95 EXPECT_TRUE(alr_detector_.GetApplicationLimitedRegionStartTime()); |
| 107 SimulateOutgoingTraffic(10, 20); | 96 SimulateOutgoingTraffic(1000, 50); |
| 108 EXPECT_FALSE(alr_detector_.GetApplicationLimitedRegionStartTime()); | 97 EXPECT_FALSE(alr_detector_.GetApplicationLimitedRegionStartTime()); |
| 109 } | 98 } |
| 110 | 99 |
| 111 } // namespace webrtc | 100 } // namespace webrtc |
| OLD | NEW |