Chromium Code Reviews

Side by Side Diff: net/quic/congestion_control/time_loss_algorithm_test.cc

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « net/quic/congestion_control/tcp_receiver_test.cc ('k') | net/quic/crypto/aead_base_decrypter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "net/quic/congestion_control/rtt_stats.h" 9 #include "net/quic/congestion_control/rtt_stats.h"
10 #include "net/quic/congestion_control/time_loss_algorithm.h" 10 #include "net/quic/congestion_control/time_loss_algorithm.h"
(...skipping 17 matching lines...)
28 rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(100), 28 rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(100),
29 QuicTime::Delta::Zero(), 29 QuicTime::Delta::Zero(),
30 clock_.Now()); 30 clock_.Now());
31 } 31 }
32 32
33 ~TimeLossAlgorithmTest() override { 33 ~TimeLossAlgorithmTest() override {
34 STLDeleteElements(&packets_); 34 STLDeleteElements(&packets_);
35 } 35 }
36 36
37 void SendDataPacket(QuicPacketSequenceNumber sequence_number) { 37 void SendDataPacket(QuicPacketSequenceNumber sequence_number) {
38 packets_.push_back(QuicPacket::NewDataPacket( 38 packets_.push_back(new QuicEncryptedPacket(nullptr, kDefaultLength));
39 nullptr, kDefaultLength, false, PACKET_8BYTE_CONNECTION_ID, false,
40 PACKET_1BYTE_SEQUENCE_NUMBER));
41 SerializedPacket packet(sequence_number, PACKET_1BYTE_SEQUENCE_NUMBER, 39 SerializedPacket packet(sequence_number, PACKET_1BYTE_SEQUENCE_NUMBER,
42 packets_.back(), 0, new RetransmittableFrames()); 40 packets_.back(), 0, new RetransmittableFrames());
43 unacked_packets_.AddSentPacket(packet, 0, NOT_RETRANSMISSION, clock_.Now(), 41 unacked_packets_.AddSentPacket(packet, 0, NOT_RETRANSMISSION, clock_.Now(),
44 1000, true); 42 1000, true);
45 } 43 }
46 44
47 void VerifyLosses(QuicPacketSequenceNumber largest_observed, 45 void VerifyLosses(QuicPacketSequenceNumber largest_observed,
48 QuicPacketSequenceNumber* losses_expected, 46 QuicPacketSequenceNumber* losses_expected,
49 size_t num_losses) { 47 size_t num_losses) {
50 SequenceNumberSet lost_packets = 48 SequenceNumberSet lost_packets =
51 loss_algorithm_.DetectLostPackets( 49 loss_algorithm_.DetectLostPackets(
52 unacked_packets_, clock_.Now(), largest_observed, rtt_stats_); 50 unacked_packets_, clock_.Now(), largest_observed, rtt_stats_);
53 EXPECT_EQ(num_losses, lost_packets.size()); 51 EXPECT_EQ(num_losses, lost_packets.size());
54 for (size_t i = 0; i < num_losses; ++i) { 52 for (size_t i = 0; i < num_losses; ++i) {
55 EXPECT_TRUE(ContainsKey(lost_packets, losses_expected[i])); 53 EXPECT_TRUE(ContainsKey(lost_packets, losses_expected[i]));
56 } 54 }
57 } 55 }
58 56
59 vector<QuicPacket*> packets_; 57 vector<QuicEncryptedPacket*> packets_;
60 QuicUnackedPacketMap unacked_packets_; 58 QuicUnackedPacketMap unacked_packets_;
61 TimeLossAlgorithm loss_algorithm_; 59 TimeLossAlgorithm loss_algorithm_;
62 RttStats rtt_stats_; 60 RttStats rtt_stats_;
63 MockClock clock_; 61 MockClock clock_;
64 }; 62 };
65 63
66 TEST_F(TimeLossAlgorithmTest, NoLossFor500Nacks) { 64 TEST_F(TimeLossAlgorithmTest, NoLossFor500Nacks) {
67 const size_t kNumSentPackets = 5; 65 const size_t kNumSentPackets = 5;
68 // Transmit 5 packets. 66 // Transmit 5 packets.
69 for (size_t i = 1; i <= kNumSentPackets; ++i) { 67 for (size_t i = 1; i <= kNumSentPackets; ++i) {
(...skipping 74 matching lines...)
144 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now())); 142 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now()));
145 clock_.AdvanceTime(rtt_stats_.smoothed_rtt().Multiply(0.25)); 143 clock_.AdvanceTime(rtt_stats_.smoothed_rtt().Multiply(0.25));
146 QuicPacketSequenceNumber lost[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; 144 QuicPacketSequenceNumber lost[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
147 VerifyLosses(10, lost, arraysize(lost)); 145 VerifyLosses(10, lost, arraysize(lost));
148 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 146 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
149 } 147 }
150 148
151 } // namespace 149 } // namespace
152 } // namespace test 150 } // namespace test
153 } // namespace net 151 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/tcp_receiver_test.cc ('k') | net/quic/crypto/aead_base_decrypter.h » ('j') | no next file with comments »

Powered by Google App Engine