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

Unified Diff: webrtc/test/fake_network_pipe_unittest.cc

Issue 1995683003: Allow FakeNetworkPipe to drop packets in bursts. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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/test/fake_network_pipe_unittest.cc
diff --git a/webrtc/test/fake_network_pipe_unittest.cc b/webrtc/test/fake_network_pipe_unittest.cc
index 0bd46df7fcfdd71b8fd34793a0b6124027d61c3d..0e6b09f3a4dd46894eca1b13536095d0e09fff35 100644
--- a/webrtc/test/fake_network_pipe_unittest.cc
+++ b/webrtc/test/fake_network_pipe_unittest.cc
@@ -379,4 +379,46 @@ TEST_F(FakeNetworkPipeTest, DisallowReorderingThenAllowReordering) {
}
EXPECT_TRUE(reordering_has_occured);
}
+
+TEST_F(FakeNetworkPipeTest, BurstLoss) {
+ const int kLossPercent = 10;
+ const int kAvgBurstLength = 5;
+ const int kNumPackets = 10000;
+ const int kPacketSize = 10;
+
+ FakeNetworkPipe::Config config;
+ config.queue_length_packets = 10000;
+ config.loss_percent = kLossPercent;
+ config.avg_burst_loss_length = kAvgBurstLength;
+ std::unique_ptr<FakeNetworkPipe> pipe(
+ new FakeNetworkPipe(&fake_clock_, config));
+ ReorderTestReceiver* receiver = new ReorderTestReceiver();
+ receiver_.reset(receiver);
+ pipe->SetReceiver(receiver_.get());
+
+ SendPackets(pipe.get(), kNumPackets, kPacketSize);
+ fake_clock_.AdvanceTimeMilliseconds(1000);
+ pipe->Process();
+
+ // Check that the average loss is |kLossPercent| percent.
+ double loss_percent = receiver->delivered_sequence_numbers_.size() /
+ static_cast<double>(kNumPackets);
+
+ EXPECT_NEAR((100.0 - kLossPercent) / 100.0, loss_percent, 0.1);
terelius 2016/05/30 14:00:30 This tests that the receive percentage is between
philipel 2016/05/30 14:42:42 Done.
+
+ // Find the number of bursts that has occurred.
+ size_t received_packets = receiver->delivered_sequence_numbers_.size();
+ int num_bursts = 0;
+ for (size_t i = 0; i < received_packets - 1; ++i) {
+ int diff = receiver->delivered_sequence_numbers_[i + 1] -
+ receiver->delivered_sequence_numbers_[i];
+ if (diff > 1)
+ ++num_bursts;
+ }
+
+ int lost_packets = kNumPackets - receiver->delivered_sequence_numbers_.size();
+ double average_burst_length = static_cast<double>(lost_packets) / num_bursts;
+
+ EXPECT_NEAR(kAvgBurstLength, average_burst_length, 0.3);
+}
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698