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

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

Issue 612323013: QUIC - (no behavior change) s/NULL/nullptr/g in .../quic/... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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/tcp_loss_algorithm.h" 10 #include "net/quic/congestion_control/tcp_loss_algorithm.h"
11 #include "net/quic/quic_unacked_packet_map.h" 11 #include "net/quic/quic_unacked_packet_map.h"
12 #include "net/quic/test_tools/mock_clock.h" 12 #include "net/quic/test_tools/mock_clock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace net { 15 namespace net {
16 namespace test { 16 namespace test {
17 17
18 class TcpLossAlgorithmTest : public ::testing::Test { 18 class TcpLossAlgorithmTest : public ::testing::Test {
19 protected: 19 protected:
20 TcpLossAlgorithmTest() 20 TcpLossAlgorithmTest()
21 : unacked_packets_() { 21 : unacked_packets_() {
22 rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(100), 22 rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(100),
23 QuicTime::Delta::Zero(), 23 QuicTime::Delta::Zero(),
24 clock_.Now()); 24 clock_.Now());
25 } 25 }
26 26
27 void SendDataPacket(QuicPacketSequenceNumber sequence_number) { 27 void SendDataPacket(QuicPacketSequenceNumber sequence_number) {
28 SerializedPacket packet(sequence_number, PACKET_1BYTE_SEQUENCE_NUMBER, 28 SerializedPacket packet(sequence_number, PACKET_1BYTE_SEQUENCE_NUMBER,
29 NULL, 0, new RetransmittableFrames()); 29 nullptr, 0, new RetransmittableFrames());
30 unacked_packets_.AddPacket(packet); 30 unacked_packets_.AddPacket(packet);
31 unacked_packets_.SetSent(sequence_number, clock_.Now(), 1000, true); 31 unacked_packets_.SetSent(sequence_number, clock_.Now(), 1000, true);
32 } 32 }
33 33
34 void VerifyLosses(QuicPacketSequenceNumber largest_observed, 34 void VerifyLosses(QuicPacketSequenceNumber largest_observed,
35 QuicPacketSequenceNumber* losses_expected, 35 QuicPacketSequenceNumber* losses_expected,
36 size_t num_losses) { 36 size_t num_losses) {
37 SequenceNumberSet lost_packets = 37 SequenceNumberSet lost_packets =
38 loss_algorithm_.DetectLostPackets( 38 loss_algorithm_.DetectLostPackets(
39 unacked_packets_, clock_.Now(), largest_observed, rtt_stats_); 39 unacked_packets_, clock_.Now(), largest_observed, rtt_stats_);
(...skipping 11 matching lines...) Expand all
51 51
52 TEST_F(TcpLossAlgorithmTest, NackRetransmit1Packet) { 52 TEST_F(TcpLossAlgorithmTest, NackRetransmit1Packet) {
53 const size_t kNumSentPackets = 5; 53 const size_t kNumSentPackets = 5;
54 // Transmit 5 packets. 54 // Transmit 5 packets.
55 for (size_t i = 1; i <= kNumSentPackets; ++i) { 55 for (size_t i = 1; i <= kNumSentPackets; ++i) {
56 SendDataPacket(i); 56 SendDataPacket(i);
57 } 57 }
58 // No loss on one ack. 58 // No loss on one ack.
59 unacked_packets_.RemoveFromInFlight(2); 59 unacked_packets_.RemoveFromInFlight(2);
60 unacked_packets_.NackPacket(1, 1); 60 unacked_packets_.NackPacket(1, 1);
61 VerifyLosses(2, NULL, 0); 61 VerifyLosses(2, nullptr, 0);
62 // No loss on two acks. 62 // No loss on two acks.
63 unacked_packets_.RemoveFromInFlight(3); 63 unacked_packets_.RemoveFromInFlight(3);
64 unacked_packets_.NackPacket(1, 2); 64 unacked_packets_.NackPacket(1, 2);
65 VerifyLosses(3, NULL, 0); 65 VerifyLosses(3, nullptr, 0);
66 // Loss on three acks. 66 // Loss on three acks.
67 unacked_packets_.RemoveFromInFlight(4); 67 unacked_packets_.RemoveFromInFlight(4);
68 unacked_packets_.NackPacket(1, 3); 68 unacked_packets_.NackPacket(1, 3);
69 QuicPacketSequenceNumber lost[] = { 1 }; 69 QuicPacketSequenceNumber lost[] = { 1 };
70 VerifyLosses(4, lost, arraysize(lost)); 70 VerifyLosses(4, lost, arraysize(lost));
71 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 71 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
72 } 72 }
73 73
74 // A stretch ack is an ack that covers more than 1 packet of previously 74 // A stretch ack is an ack that covers more than 1 packet of previously
75 // unacknowledged data. 75 // unacknowledged data.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 TEST_F(TcpLossAlgorithmTest, EarlyRetransmit1Packet) { 111 TEST_F(TcpLossAlgorithmTest, EarlyRetransmit1Packet) {
112 const size_t kNumSentPackets = 2; 112 const size_t kNumSentPackets = 2;
113 // Transmit 2 packets. 113 // Transmit 2 packets.
114 for (size_t i = 1; i <= kNumSentPackets; ++i) { 114 for (size_t i = 1; i <= kNumSentPackets; ++i) {
115 SendDataPacket(i); 115 SendDataPacket(i);
116 } 116 }
117 // Early retransmit when the final packet gets acked and the first is nacked. 117 // Early retransmit when the final packet gets acked and the first is nacked.
118 unacked_packets_.RemoveFromInFlight(2); 118 unacked_packets_.RemoveFromInFlight(2);
119 unacked_packets_.NackPacket(1, 1); 119 unacked_packets_.NackPacket(1, 1);
120 VerifyLosses(2, NULL, 0); 120 VerifyLosses(2, nullptr, 0);
121 EXPECT_EQ(clock_.Now().Add(rtt_stats_.SmoothedRtt().Multiply(1.25)), 121 EXPECT_EQ(clock_.Now().Add(rtt_stats_.SmoothedRtt().Multiply(1.25)),
122 loss_algorithm_.GetLossTimeout()); 122 loss_algorithm_.GetLossTimeout());
123 123
124 clock_.AdvanceTime(rtt_stats_.latest_rtt().Multiply(1.25)); 124 clock_.AdvanceTime(rtt_stats_.latest_rtt().Multiply(1.25));
125 QuicPacketSequenceNumber lost[] = { 1 }; 125 QuicPacketSequenceNumber lost[] = { 1 };
126 VerifyLosses(2, lost, arraysize(lost)); 126 VerifyLosses(2, lost, arraysize(lost));
127 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 127 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
128 } 128 }
129 129
130 TEST_F(TcpLossAlgorithmTest, EarlyRetransmitAllPackets) { 130 TEST_F(TcpLossAlgorithmTest, EarlyRetransmitAllPackets) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 for (size_t i = 1; i <= kNumSentPackets; ++i) { 168 for (size_t i = 1; i <= kNumSentPackets; ++i) {
169 SendDataPacket(i); 169 SendDataPacket(i);
170 } 170 }
171 // Neuter packet 1. 171 // Neuter packet 1.
172 unacked_packets_.RemoveRetransmittability(1); 172 unacked_packets_.RemoveRetransmittability(1);
173 173
174 // Early retransmit when the final packet gets acked and the first is nacked. 174 // Early retransmit when the final packet gets acked and the first is nacked.
175 unacked_packets_.IncreaseLargestObserved(2); 175 unacked_packets_.IncreaseLargestObserved(2);
176 unacked_packets_.RemoveFromInFlight(2); 176 unacked_packets_.RemoveFromInFlight(2);
177 unacked_packets_.NackPacket(1, 1); 177 unacked_packets_.NackPacket(1, 1);
178 VerifyLosses(2, NULL, 0); 178 VerifyLosses(2, nullptr, 0);
179 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 179 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
180 } 180 }
181 181
182 } // namespace test 182 } // namespace test
183 } // namespace net 183 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/send_algorithm_simulator.cc ('k') | net/quic/congestion_control/time_loss_algorithm_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698