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

Side by Side 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: Included cmath for std::ceil. Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « webrtc/test/fake_network_pipe.cc ('k') | webrtc/video/video_loopback.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 last_seq_num = -1; 372 last_seq_num = -1;
373 for (int seq_num : receiver->delivered_sequence_numbers_) { 373 for (int seq_num : receiver->delivered_sequence_numbers_) {
374 if (last_seq_num > seq_num) { 374 if (last_seq_num > seq_num) {
375 reordering_has_occured = true; 375 reordering_has_occured = true;
376 break; 376 break;
377 } 377 }
378 last_seq_num = seq_num; 378 last_seq_num = seq_num;
379 } 379 }
380 EXPECT_TRUE(reordering_has_occured); 380 EXPECT_TRUE(reordering_has_occured);
381 } 381 }
382
383 TEST_F(FakeNetworkPipeTest, BurstLoss) {
384 const int kLossPercent = 5;
385 const int kAvgBurstLength = 3;
386 const int kNumPackets = 10000;
387 const int kPacketSize = 10;
388
389 FakeNetworkPipe::Config config;
390 config.queue_length_packets = kNumPackets;
391 config.loss_percent = kLossPercent;
392 config.avg_burst_loss_length = kAvgBurstLength;
393 std::unique_ptr<FakeNetworkPipe> pipe(
394 new FakeNetworkPipe(&fake_clock_, config));
395 ReorderTestReceiver* receiver = new ReorderTestReceiver();
396 receiver_.reset(receiver);
397 pipe->SetReceiver(receiver_.get());
398
399 SendPackets(pipe.get(), kNumPackets, kPacketSize);
400 fake_clock_.AdvanceTimeMilliseconds(1000);
401 pipe->Process();
402
403 // Check that the average loss is |kLossPercent| percent.
404 int lost_packets = kNumPackets - receiver->delivered_sequence_numbers_.size();
405 double loss_fraction = lost_packets / static_cast<double>(kNumPackets);
406
407 EXPECT_NEAR(kLossPercent / 100.0, loss_fraction, 0.05);
408
409 // Find the number of bursts that has occurred.
410 size_t received_packets = receiver->delivered_sequence_numbers_.size();
411 int num_bursts = 0;
412 for (size_t i = 0; i < received_packets - 1; ++i) {
413 int diff = receiver->delivered_sequence_numbers_[i + 1] -
414 receiver->delivered_sequence_numbers_[i];
415 if (diff > 1)
416 ++num_bursts;
417 }
418
419 double average_burst_length = static_cast<double>(lost_packets) / num_bursts;
420
421 EXPECT_NEAR(kAvgBurstLength, average_burst_length, 0.3);
422 }
382 } // namespace webrtc 423 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/fake_network_pipe.cc ('k') | webrtc/video/video_loopback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698