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

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

Issue 188153003: Test only change to QUIC TCPLossAlgorithmTest to ensure the early (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 "net/quic/congestion_control/tcp_loss_algorithm.h" 5 #include "net/quic/congestion_control/tcp_loss_algorithm.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 clock_.AdvanceTime(srtt_.Multiply(1.25)); 122 clock_.AdvanceTime(srtt_.Multiply(1.25));
123 QuicPacketSequenceNumber lost[] = { 1 }; 123 QuicPacketSequenceNumber lost[] = { 1 };
124 VerifyLosses(2, lost, arraysize(lost)); 124 VerifyLosses(2, lost, arraysize(lost));
125 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 125 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
126 } 126 }
127 127
128 TEST_F(TcpLossAlgorithmTest, EarlyRetransmitAllPackets) { 128 TEST_F(TcpLossAlgorithmTest, EarlyRetransmitAllPackets) {
129 const size_t kNumSentPackets = 5; 129 const size_t kNumSentPackets = 5;
130 for (size_t i = 1; i <= kNumSentPackets; ++i) { 130 for (size_t i = 1; i <= kNumSentPackets; ++i) {
131 SendDataPacket(i); 131 SendDataPacket(i);
132 // Advance the time 1/4 RTT between 3 and 4.
133 if (i == 3) {
134 clock_.AdvanceTime(srtt_.Multiply(0.25));
135 }
132 } 136 }
133 // Early retransmit when the final packet gets acked and the first 4 are 137
134 // nacked multiple times via FACK. 138 // Early retransmit when the final packet gets acked and 1.25 RTTs have
139 // elapsed since the packets were sent.
135 unacked_packets_.SetNotPending(kNumSentPackets); 140 unacked_packets_.SetNotPending(kNumSentPackets);
141 // This simulates a single ack following multiple missing packets with FACK.
136 for (size_t i = 1; i < kNumSentPackets; ++i) { 142 for (size_t i = 1; i < kNumSentPackets; ++i) {
137 unacked_packets_.NackPacket(i, kNumSentPackets - i); 143 unacked_packets_.NackPacket(i, kNumSentPackets - i);
138 } 144 }
139 QuicPacketSequenceNumber lost[] = { 1, 2 }; 145 QuicPacketSequenceNumber lost[] = { 1, 2 };
140 VerifyLosses(kNumSentPackets, lost, arraysize(lost)); 146 VerifyLosses(kNumSentPackets, lost, arraysize(lost));
141 EXPECT_EQ(clock_.Now().Add(srtt_.Multiply(1.25)), 147 // The time has already advanced 1/4 an RTT, so ensure the timeout is set
148 // 1.25 RTTs after the earliest pending packet(3), not the last(4).
149 EXPECT_EQ(clock_.Now().Add(srtt_),
142 loss_algorithm_.GetLossTimeout()); 150 loss_algorithm_.GetLossTimeout());
143 151
144 clock_.AdvanceTime(srtt_.Multiply(1.25)); 152 clock_.AdvanceTime(srtt_);
145 QuicPacketSequenceNumber lost2[] = { 1, 2, 3, 4 }; 153 QuicPacketSequenceNumber lost2[] = { 1, 2, 3 };
146 VerifyLosses(kNumSentPackets, lost2, arraysize(lost2)); 154 VerifyLosses(kNumSentPackets, lost2, arraysize(lost2));
155 EXPECT_EQ(clock_.Now().Add(srtt_.Multiply(0.25)),
156 loss_algorithm_.GetLossTimeout());
157 clock_.AdvanceTime(srtt_.Multiply(0.25));
158 QuicPacketSequenceNumber lost3[] = { 1, 2, 3, 4 };
159 VerifyLosses(kNumSentPackets, lost3, arraysize(lost3));
147 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 160 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
148 } 161 }
149 162
150 TEST_F(TcpLossAlgorithmTest, DontEarlyRetransmitNeuteredPacket) { 163 TEST_F(TcpLossAlgorithmTest, DontEarlyRetransmitNeuteredPacket) {
151 const size_t kNumSentPackets = 2; 164 const size_t kNumSentPackets = 2;
152 // Transmit 2 packets. 165 // Transmit 2 packets.
153 for (size_t i = 1; i <= kNumSentPackets; ++i) { 166 for (size_t i = 1; i <= kNumSentPackets; ++i) {
154 SendDataPacket(i); 167 SendDataPacket(i);
155 } 168 }
156 // Early retransmit when the final packet gets acked and the first is nacked. 169 // Early retransmit when the final packet gets acked and the first is nacked.
157 unacked_packets_.SetNotPending(2); 170 unacked_packets_.SetNotPending(2);
158 unacked_packets_.NackPacket(1, 1); 171 unacked_packets_.NackPacket(1, 1);
159 unacked_packets_.NeuterPacket(1); 172 unacked_packets_.NeuterPacket(1);
160 VerifyLosses(2, NULL, 0); 173 VerifyLosses(2, NULL, 0);
161 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 174 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
162 } 175 }
163 176
164 } // namespace 177 } // namespace
165 } // namespace test 178 } // namespace test
166 } // namespace net 179 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698