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

Unified Diff: webrtc/modules/congestion_controller/delay_based_bwe_unittest.cc

Issue 2126793002: Reset InterArrival if arrival time clock makes a jump. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Cleanup Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/congestion_controller/delay_based_bwe_unittest.cc
diff --git a/webrtc/modules/congestion_controller/delay_based_bwe_unittest.cc b/webrtc/modules/congestion_controller/delay_based_bwe_unittest.cc
index a78dd7fb08ed0a7074ec1719095c892ba9837927..7c1644e973bd4668ce7b24859d7b35503114c068 100644
--- a/webrtc/modules/congestion_controller/delay_based_bwe_unittest.cc
+++ b/webrtc/modules/congestion_controller/delay_based_bwe_unittest.cc
@@ -8,10 +8,11 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "webrtc/modules/congestion_controller/delay_based_bwe.h"
-
#include "testing/gtest/include/gtest/gtest.h"
+#include "webrtc/base/constructormagic.h"
#include "webrtc/modules/pacing/paced_sender.h"
+#include "webrtc/modules/congestion_controller/delay_based_bwe.h"
philipel 2016/07/06 13:36:36 Move to top
stefan-webrtc 2016/07/06 14:53:24 I don't think it should be at the top since this i
philipel 2016/07/07 08:11:38 Right, my bad.
+#include "webrtc/modules/congestion_controller/delay_based_bwe_unittest_helper.h"
#include "webrtc/system_wrappers/include/clock.h"
namespace webrtc {
@@ -22,26 +23,25 @@ class TestDelayBasedBwe : public ::testing::Test, public RemoteBitrateObserver {
static constexpr int kNumProbes = 5;
philipel 2016/07/06 13:36:36 Move both constexpr to namespace {...} and drop st
stefan-webrtc 2016/07/06 14:53:24 Done.
TestDelayBasedBwe()
- : bwe_(this), clock_(0), bitrate_updated_(false), latest_bitrate_(0) {}
+ : clock_(0),
+ bwe_(this, &clock_),
+ bitrate_updated_(false),
+ latest_bitrate_(0) {}
uint32_t AbsSendTime(int64_t t, int64_t denom) {
philipel 2016/07/06 13:36:36 Remove, since it's not used anymore.
stefan-webrtc 2016/07/06 14:53:24 Done.
return (((t << 18) + (denom >> 1)) / denom) & 0x00fffffful;
}
- void IncomingPacket(uint32_t ssrc,
+ void IncomingPacket(int64_t arrival_time,
philipel 2016/07/06 13:36:36 Rename to AddPacketInfo or IncomingFeedback or som
stefan-webrtc 2016/07/06 14:53:24 Done.
+ int64_t send_time_ms,
philipel 2016/07/06 13:36:36 |arrival_time| -> |arrival_time_ms| Nit: don't yo
stefan-webrtc 2016/07/06 14:53:24 Done.
+ uint16_t sequence_number,
size_t payload_size,
- int64_t arrival_time,
- uint32_t rtp_timestamp,
- uint32_t absolute_send_time,
int probe_cluster_id) {
- RTPHeader header;
- memset(&header, 0, sizeof(header));
- header.ssrc = ssrc;
- header.timestamp = rtp_timestamp;
- header.extension.hasAbsoluteSendTime = true;
- header.extension.absoluteSendTime = absolute_send_time;
- bwe_.IncomingPacket(arrival_time + kArrivalTimeClockOffsetMs, payload_size,
- header, probe_cluster_id);
+ std::vector<PacketInfo> packets;
+ packets.push_back(PacketInfo(arrival_time + kArrivalTimeClockOffsetMs,
+ send_time_ms, sequence_number, payload_size,
philipel 2016/07/06 13:36:36 Sequence number is not used by delay_based_bwe, se
stefan-webrtc 2016/07/06 14:53:24 I don't know, it seems like a good idea to pass in
philipel 2016/07/07 08:11:38 That makes sense.
+ probe_cluster_id));
+ bwe_.IncomingPacketFeedbackVector(packets);
}
void OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs,
@@ -58,8 +58,9 @@ class TestDelayBasedBwe : public ::testing::Test, public RemoteBitrateObserver {
int latest_bitrate() { return latest_bitrate_; }
- DelayBasedBwe bwe_;
+ protected:
SimulatedClock clock_;
+ DelayBasedBwe bwe_;
private:
bool bitrate_updated_;
@@ -68,12 +69,13 @@ class TestDelayBasedBwe : public ::testing::Test, public RemoteBitrateObserver {
TEST_F(TestDelayBasedBwe, ProbeDetection) {
int64_t now_ms = clock_.TimeInMilliseconds();
+ uint16_t seq_num = 0;
// First burst sent at 8 * 1000 / 10 = 800 kbps.
for (int i = 0; i < kNumProbes; ++i) {
clock_.AdvanceTimeMilliseconds(10);
now_ms = clock_.TimeInMilliseconds();
- IncomingPacket(0, 1000, now_ms, 90 * now_ms, AbsSendTime(now_ms, 1000), 0);
+ IncomingPacket(now_ms, now_ms, seq_num++, 1000, 1);
philipel 2016/07/06 13:36:36 Note: 0 is a valid probe cluster id.
stefan-webrtc 2016/07/06 14:53:24 Yes, I happened to change it because I thought it
}
EXPECT_TRUE(bitrate_updated());
@@ -81,7 +83,7 @@ TEST_F(TestDelayBasedBwe, ProbeDetection) {
for (int i = 0; i < kNumProbes; ++i) {
clock_.AdvanceTimeMilliseconds(5);
now_ms = clock_.TimeInMilliseconds();
- IncomingPacket(0, 1000, now_ms, 90 * now_ms, AbsSendTime(now_ms, 1000), 1);
+ IncomingPacket(now_ms, now_ms, seq_num++, 1000, 2);
}
EXPECT_TRUE(bitrate_updated());
@@ -90,16 +92,18 @@ TEST_F(TestDelayBasedBwe, ProbeDetection) {
TEST_F(TestDelayBasedBwe, ProbeDetectionNonPacedPackets) {
int64_t now_ms = clock_.TimeInMilliseconds();
+ uint16_t seq_num = 0;
// First burst sent at 8 * 1000 / 10 = 800 kbps, but with every other packet
// not being paced which could mess things up.
for (int i = 0; i < kNumProbes; ++i) {
clock_.AdvanceTimeMilliseconds(5);
now_ms = clock_.TimeInMilliseconds();
- IncomingPacket(0, 1000, now_ms, 90 * now_ms, AbsSendTime(now_ms, 1000), 0);
+ IncomingPacket(now_ms, now_ms, seq_num++, 1000, 1);
// Non-paced packet, arriving 5 ms after.
clock_.AdvanceTimeMilliseconds(5);
- IncomingPacket(0, PacedSender::kMinProbePacketSize + 1, now_ms, 90 * now_ms,
- AbsSendTime(now_ms, 1000), PacketInfo::kNotAProbe);
+ IncomingPacket(now_ms, now_ms, seq_num++,
+ PacedSender::kMinProbePacketSize + 1,
+ PacketInfo::kNotAProbe);
}
EXPECT_TRUE(bitrate_updated());
@@ -111,13 +115,13 @@ TEST_F(TestDelayBasedBwe, ProbeDetectionNonPacedPackets) {
TEST_F(TestDelayBasedBwe, ProbeDetectionTooHighBitrate) {
int64_t now_ms = clock_.TimeInMilliseconds();
int64_t send_time_ms = 0;
+ uint16_t seq_num = 0;
// First burst sent at 8 * 1000 / 10 = 800 kbps.
for (int i = 0; i < kNumProbes; ++i) {
clock_.AdvanceTimeMilliseconds(10);
now_ms = clock_.TimeInMilliseconds();
send_time_ms += 10;
- IncomingPacket(0, 1000, now_ms, 90 * send_time_ms,
- AbsSendTime(send_time_ms, 1000), 0);
+ IncomingPacket(now_ms, send_time_ms, seq_num++, 1000, 1);
}
// Second burst sent at 8 * 1000 / 5 = 1600 kbps, arriving at 8 * 1000 / 8 =
@@ -126,8 +130,7 @@ TEST_F(TestDelayBasedBwe, ProbeDetectionTooHighBitrate) {
clock_.AdvanceTimeMilliseconds(8);
now_ms = clock_.TimeInMilliseconds();
send_time_ms += 5;
- IncomingPacket(0, 1000, now_ms, send_time_ms,
- AbsSendTime(send_time_ms, 1000), 1);
+ IncomingPacket(now_ms, send_time_ms, seq_num++, 1000, 2);
}
EXPECT_TRUE(bitrate_updated());
@@ -136,6 +139,7 @@ TEST_F(TestDelayBasedBwe, ProbeDetectionTooHighBitrate) {
TEST_F(TestDelayBasedBwe, ProbeDetectionSlightlyFasterArrival) {
int64_t now_ms = clock_.TimeInMilliseconds();
+ uint16_t seq_num = 0;
// First burst sent at 8 * 1000 / 10 = 800 kbps.
// Arriving at 8 * 1000 / 5 = 1600 kbps.
int64_t send_time_ms = 0;
@@ -143,8 +147,7 @@ TEST_F(TestDelayBasedBwe, ProbeDetectionSlightlyFasterArrival) {
clock_.AdvanceTimeMilliseconds(5);
send_time_ms += 10;
now_ms = clock_.TimeInMilliseconds();
- IncomingPacket(0, 1000, now_ms, 90 * send_time_ms,
- AbsSendTime(send_time_ms, 1000), 23);
+ IncomingPacket(now_ms, send_time_ms, seq_num++, 1000, 23);
}
EXPECT_TRUE(bitrate_updated());
@@ -153,6 +156,7 @@ TEST_F(TestDelayBasedBwe, ProbeDetectionSlightlyFasterArrival) {
TEST_F(TestDelayBasedBwe, ProbeDetectionFasterArrival) {
int64_t now_ms = clock_.TimeInMilliseconds();
+ uint16_t seq_num = 0;
// First burst sent at 8 * 1000 / 10 = 800 kbps.
// Arriving at 8 * 1000 / 5 = 1600 kbps.
int64_t send_time_ms = 0;
@@ -160,8 +164,7 @@ TEST_F(TestDelayBasedBwe, ProbeDetectionFasterArrival) {
clock_.AdvanceTimeMilliseconds(1);
send_time_ms += 10;
now_ms = clock_.TimeInMilliseconds();
- IncomingPacket(0, 1000, now_ms, 90 * send_time_ms,
- AbsSendTime(send_time_ms, 1000), 0);
+ IncomingPacket(now_ms, send_time_ms, seq_num++, 1000, 1);
}
EXPECT_FALSE(bitrate_updated());
@@ -169,6 +172,7 @@ TEST_F(TestDelayBasedBwe, ProbeDetectionFasterArrival) {
TEST_F(TestDelayBasedBwe, ProbeDetectionSlowerArrival) {
int64_t now_ms = clock_.TimeInMilliseconds();
+ uint16_t seq_num = 0;
// First burst sent at 8 * 1000 / 5 = 1600 kbps.
// Arriving at 8 * 1000 / 7 = 1142 kbps.
int64_t send_time_ms = 0;
@@ -176,8 +180,7 @@ TEST_F(TestDelayBasedBwe, ProbeDetectionSlowerArrival) {
clock_.AdvanceTimeMilliseconds(7);
send_time_ms += 5;
now_ms = clock_.TimeInMilliseconds();
- IncomingPacket(0, 1000, now_ms, 90 * send_time_ms,
- AbsSendTime(send_time_ms, 1000), 1);
+ IncomingPacket(now_ms, send_time_ms, seq_num++, 1000, 1);
}
EXPECT_TRUE(bitrate_updated());
@@ -186,6 +189,7 @@ TEST_F(TestDelayBasedBwe, ProbeDetectionSlowerArrival) {
TEST_F(TestDelayBasedBwe, ProbeDetectionSlowerArrivalHighBitrate) {
int64_t now_ms = clock_.TimeInMilliseconds();
+ uint16_t seq_num = 0;
// Burst sent at 8 * 1000 / 1 = 8000 kbps.
// Arriving at 8 * 1000 / 2 = 4000 kbps.
int64_t send_time_ms = 0;
@@ -193,8 +197,7 @@ TEST_F(TestDelayBasedBwe, ProbeDetectionSlowerArrivalHighBitrate) {
clock_.AdvanceTimeMilliseconds(2);
send_time_ms += 1;
now_ms = clock_.TimeInMilliseconds();
- IncomingPacket(0, 1000, now_ms, 90 * send_time_ms,
- AbsSendTime(send_time_ms, 1000), 1);
+ IncomingPacket(now_ms, send_time_ms, seq_num++, 1000, 1);
}
EXPECT_TRUE(bitrate_updated());
@@ -203,13 +206,14 @@ TEST_F(TestDelayBasedBwe, ProbeDetectionSlowerArrivalHighBitrate) {
TEST_F(TestDelayBasedBwe, ProbingIgnoresSmallPackets) {
int64_t now_ms = clock_.TimeInMilliseconds();
+ uint16_t seq_num = 0;
// Probing with 200 bytes every 10 ms, should be ignored by the probe
// detection.
for (int i = 0; i < kNumProbes; ++i) {
clock_.AdvanceTimeMilliseconds(10);
now_ms = clock_.TimeInMilliseconds();
- IncomingPacket(0, PacedSender::kMinProbePacketSize, now_ms, 90 * now_ms,
- AbsSendTime(now_ms, 1000), 1);
+ IncomingPacket(now_ms, now_ms, seq_num++, PacedSender::kMinProbePacketSize,
+ 1);
}
EXPECT_FALSE(bitrate_updated());
@@ -219,7 +223,7 @@ TEST_F(TestDelayBasedBwe, ProbingIgnoresSmallPackets) {
for (int i = 0; i < kNumProbes; ++i) {
clock_.AdvanceTimeMilliseconds(10);
now_ms = clock_.TimeInMilliseconds();
- IncomingPacket(0, 1000, now_ms, 90 * now_ms, AbsSendTime(now_ms, 1000), 1);
+ IncomingPacket(now_ms, now_ms, seq_num++, 1000, 1);
}
// Wait long enough so that we can call Process again.
@@ -228,4 +232,264 @@ TEST_F(TestDelayBasedBwe, ProbingIgnoresSmallPackets) {
EXPECT_TRUE(bitrate_updated());
EXPECT_NEAR(latest_bitrate(), 800000u, 10000);
}
+
+TEST_F(DelayBasedBweTest, InitialBehavior) {
+ InitialBehaviorTestHelper(674840);
+}
+
+TEST_F(DelayBasedBweTest, RateIncreaseReordering) {
+ RateIncreaseReorderingTestHelper(674840);
+}
+
+TEST_F(DelayBasedBweTest, RateIncreaseRtpTimestamps) {
+ RateIncreaseRtpTimestampsTestHelper(1240);
+}
+
+TEST_F(DelayBasedBweTest, CapacityDropOneStream) {
+ CapacityDropTestHelper(1, false, 633, 0);
+}
+
+TEST_F(DelayBasedBweTest, CapacityDropPosOffsetChange) {
+ CapacityDropTestHelper(1, false, 200, 30000);
+}
+
+TEST_F(DelayBasedBweTest, CapacityDropNegOffsetChange) {
+ CapacityDropTestHelper(1, false, 733, -30000);
+}
+
+TEST_F(DelayBasedBweTest, CapacityDropOneStreamWrap) {
+ CapacityDropTestHelper(1, true, 633, 0);
+}
+
+TEST_F(DelayBasedBweTest, CapacityDropTwoStreamsWrap) {
+ CapacityDropTestHelper(2, true, 567, 0);
+}
+
+TEST_F(DelayBasedBweTest, CapacityDropThreeStreamsWrap) {
+ CapacityDropTestHelper(3, true, 633, 0);
+}
+
+TEST_F(DelayBasedBweTest, CapacityDropThirteenStreamsWrap) {
+ CapacityDropTestHelper(13, true, 733, 0);
+}
+
+TEST_F(DelayBasedBweTest, CapacityDropNineteenStreamsWrap) {
+ CapacityDropTestHelper(19, true, 667, 0);
+}
+
+TEST_F(DelayBasedBweTest, CapacityDropThirtyStreamsWrap) {
+ CapacityDropTestHelper(30, true, 667, 0);
+}
+
+TEST_F(DelayBasedBweTest, TestTimestampGrouping) {
+ TestTimestampGroupingTestHelper();
+}
+
+TEST_F(DelayBasedBweTest, TestShortTimeoutAndWrap) {
+ // Simulate a client leaving and rejoining the call after 35 seconds. This
+ // will make abs send time wrap, so if streams aren't timed out properly
+ // the next 30 seconds of packets will be out of order.
+ TestWrappingHelper(35);
+}
+
+TEST_F(DelayBasedBweTest, TestLongTimeoutAndWrap) {
+ // Simulate a client leaving and rejoining the call after some multiple of
+ // 64 seconds later. This will cause a zero difference in abs send times due
+ // to the wrap, but a big difference in arrival time, if streams aren't
+ // properly timed out.
+ TestWrappingHelper(10 * 64);
+}
+
+TEST_F(DelayBasedBweTest, TestProcessAfterTimeout) {
+ // This time constant must be equal to the ones defined for the
+ // RemoteBitrateEstimator.
+ const int64_t kStreamTimeOutMs = 2000;
+ const int64_t kProcessIntervalMs = 1000;
+ IncomingPacket(1000, clock_.TimeInMilliseconds(), 0, 0);
+ clock_.AdvanceTimeMilliseconds(kStreamTimeOutMs + 1);
+ // Trigger timeout.
+ bitrate_estimator_->Process();
+ clock_.AdvanceTimeMilliseconds(kProcessIntervalMs);
+ // This shouldn't crash.
+ bitrate_estimator_->Process();
+}
+
+TEST_F(DelayBasedBweTest, TestProbeDetection) {
+ const int kProbeLength = 5;
+ int64_t now_ms = clock_.TimeInMilliseconds();
+ uint16_t sequence_number = 0;
+ // First burst sent at 8 * 1000 / 10 = 800 kbps.
+ for (int i = 0; i < kProbeLength; ++i) {
+ clock_.AdvanceTimeMilliseconds(10);
+ now_ms = clock_.TimeInMilliseconds();
+ IncomingPacket(1000, now_ms, now_ms, sequence_number++, 1);
+ }
+
+ // Second burst sent at 8 * 1000 / 5 = 1600 kbps.
+ for (int i = 0; i < kProbeLength; ++i) {
+ clock_.AdvanceTimeMilliseconds(5);
+ now_ms = clock_.TimeInMilliseconds();
+ IncomingPacket(1000, now_ms, now_ms, sequence_number++, 2);
+ }
+
+ bitrate_estimator_->Process();
+ EXPECT_TRUE(bitrate_observer_->updated());
+ EXPECT_GT(bitrate_observer_->latest_bitrate(), 1500000u);
+}
+
+TEST_F(DelayBasedBweTest, TestProbeDetectionNonPacedPackets) {
+ const int kProbeLength = 5;
+ int64_t now_ms = clock_.TimeInMilliseconds();
+ uint16_t sequence_number = 0;
+ // First burst sent at 8 * 1000 / 10 = 800 kbps, but with every other packet
+ // not being paced which could mess things up.
+ for (int i = 0; i < kProbeLength; ++i) {
+ clock_.AdvanceTimeMilliseconds(5);
+ now_ms = clock_.TimeInMilliseconds();
+ IncomingPacket(1000, now_ms, now_ms, sequence_number++, 1);
+ // Non-paced packet, arriving 5 ms after.
+ clock_.AdvanceTimeMilliseconds(5);
+ IncomingPacket(100, now_ms, now_ms, sequence_number++,
+ PacketInfo::kNotAProbe);
+ }
+
+ bitrate_estimator_->Process();
+ EXPECT_TRUE(bitrate_observer_->updated());
+ EXPECT_GT(bitrate_observer_->latest_bitrate(), 800000u);
+}
+
+// Packets will require 5 ms to be transmitted to the receiver, causing packets
+// of the second probe to be dispersed.
+TEST_F(DelayBasedBweTest, TestProbeDetectionTooHighBitrate) {
+ const int kProbeLength = 5;
+ int64_t now_ms = clock_.TimeInMilliseconds();
+ int64_t send_time_ms = 0;
+ uint16_t sequence_number = 0;
+ // First burst sent at 8 * 1000 / 10 = 800 kbps.
+ for (int i = 0; i < kProbeLength; ++i) {
+ clock_.AdvanceTimeMilliseconds(10);
+ now_ms = clock_.TimeInMilliseconds();
+ send_time_ms += 10;
+ IncomingPacket(1000, now_ms, send_time_ms, sequence_number++, 1);
+ }
+
+ // Second burst sent at 8 * 1000 / 5 = 1600 kbps, arriving at 8 * 1000 / 8 =
+ // 1000 kbps.
+ for (int i = 0; i < kProbeLength; ++i) {
+ clock_.AdvanceTimeMilliseconds(8);
+ now_ms = clock_.TimeInMilliseconds();
+ send_time_ms += 5;
+ IncomingPacket(1000, now_ms, send_time_ms, sequence_number++, 2);
+ }
+
+ bitrate_estimator_->Process();
+ EXPECT_TRUE(bitrate_observer_->updated());
+ EXPECT_NEAR(bitrate_observer_->latest_bitrate(), 800000u, 10000);
+}
+
+TEST_F(DelayBasedBweTest, TestProbeDetectionSlightlyFasterArrival) {
+ const int kProbeLength = 5;
+ int64_t now_ms = clock_.TimeInMilliseconds();
+ uint16_t sequence_number = 0;
+ // First burst sent at 8 * 1000 / 10 = 800 kbps.
+ // Arriving at 8 * 1000 / 5 = 1600 kbps.
+ int64_t send_time_ms = 0;
+ for (int i = 0; i < kProbeLength; ++i) {
+ clock_.AdvanceTimeMilliseconds(5);
+ send_time_ms += 10;
+ now_ms = clock_.TimeInMilliseconds();
+ IncomingPacket(1000, now_ms, send_time_ms, sequence_number++, 1);
+ }
+
+ bitrate_estimator_->Process();
+ EXPECT_TRUE(bitrate_observer_->updated());
+ EXPECT_GT(bitrate_observer_->latest_bitrate(), 800000u);
+}
+
+TEST_F(DelayBasedBweTest, TestProbeDetectionFasterArrival) {
+ const int kProbeLength = 5;
+ int64_t now_ms = clock_.TimeInMilliseconds();
+ uint16_t sequence_number = 0;
+ // First burst sent at 8 * 1000 / 10 = 800 kbps.
+ // Arriving at 8 * 1000 / 5 = 1600 kbps.
+ int64_t send_time_ms = 0;
+ for (int i = 0; i < kProbeLength; ++i) {
+ clock_.AdvanceTimeMilliseconds(1);
+ send_time_ms += 10;
+ now_ms = clock_.TimeInMilliseconds();
+ IncomingPacket(1000, now_ms, send_time_ms, sequence_number++, 1);
+ }
+
+ bitrate_estimator_->Process();
+ EXPECT_FALSE(bitrate_observer_->updated());
+}
+
+TEST_F(DelayBasedBweTest, TestProbeDetectionSlowerArrival) {
+ const int kProbeLength = 5;
+ int64_t now_ms = clock_.TimeInMilliseconds();
+ uint16_t sequence_number = 0;
+ // First burst sent at 8 * 1000 / 5 = 1600 kbps.
+ // Arriving at 8 * 1000 / 7 = 1142 kbps.
+ int64_t send_time_ms = 0;
+ for (int i = 0; i < kProbeLength; ++i) {
+ clock_.AdvanceTimeMilliseconds(7);
+ send_time_ms += 5;
+ now_ms = clock_.TimeInMilliseconds();
+ IncomingPacket(1000, now_ms, send_time_ms, sequence_number++, 1);
+ }
+
+ bitrate_estimator_->Process();
+ EXPECT_TRUE(bitrate_observer_->updated());
+ EXPECT_NEAR(bitrate_observer_->latest_bitrate(), 1140000, 10000);
+}
+
+TEST_F(DelayBasedBweTest, TestProbeDetectionSlowerArrivalHighBitrate) {
+ const int kProbeLength = 5;
+ int64_t now_ms = clock_.TimeInMilliseconds();
+ uint16_t sequence_number = 0;
+ // Burst sent at 8 * 1000 / 1 = 8000 kbps.
+ // Arriving at 8 * 1000 / 2 = 4000 kbps.
+ int64_t send_time_ms = 0;
+ for (int i = 0; i < kProbeLength; ++i) {
+ clock_.AdvanceTimeMilliseconds(2);
+ send_time_ms += 1;
+ now_ms = clock_.TimeInMilliseconds();
+ IncomingPacket(1000, now_ms, send_time_ms, sequence_number++, 1);
+ }
+
+ bitrate_estimator_->Process();
+ EXPECT_TRUE(bitrate_observer_->updated());
+ EXPECT_NEAR(bitrate_observer_->latest_bitrate(), 4000000u, 10000);
+}
+
+TEST_F(DelayBasedBweTest, ProbingIgnoresSmallPackets) {
+ const int kProbeLength = 5;
+ int64_t now_ms = clock_.TimeInMilliseconds();
+ uint16_t sequence_number = 0;
+ // Probing with 200 bytes every 10 ms, should be ignored by the probe
+ // detection.
+ for (int i = 0; i < kProbeLength; ++i) {
+ clock_.AdvanceTimeMilliseconds(10);
+ now_ms = clock_.TimeInMilliseconds();
+ IncomingPacket(200, now_ms, now_ms, sequence_number++, 1);
+ }
+
+ bitrate_estimator_->Process();
+ EXPECT_FALSE(bitrate_observer_->updated());
+
+ // Followed by a probe with 1000 bytes packets, should be detected as a
+ // probe.
+ for (int i = 0; i < kProbeLength; ++i) {
+ clock_.AdvanceTimeMilliseconds(10);
+ now_ms = clock_.TimeInMilliseconds();
+ IncomingPacket(1000, now_ms, now_ms, sequence_number++, 2);
+ }
+
+ // Wait long enough so that we can call Process again.
+ clock_.AdvanceTimeMilliseconds(1000);
+
+ bitrate_estimator_->Process();
+ EXPECT_TRUE(bitrate_observer_->updated());
+ EXPECT_NEAR(bitrate_observer_->latest_bitrate(), 800000u, 10000);
+}
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698