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

Side by Side Diff: net/quic/quic_sent_packet_manager_test.cc

Issue 693943003: Update from https://crrev.com/302630 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 | « net/quic/quic_sent_packet_manager.cc ('k') | net/quic/quic_server_session.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/quic_sent_packet_manager.h" 5 #include "net/quic/quic_sent_packet_manager.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "net/quic/quic_flags.h" 8 #include "net/quic/quic_flags.h"
9 #include "net/quic/test_tools/quic_config_peer.h" 9 #include "net/quic/test_tools/quic_config_peer.h"
10 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" 10 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h"
11 #include "net/quic/test_tools/quic_test_utils.h" 11 #include "net/quic/test_tools/quic_test_utils.h"
12 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 using std::vector; 15 using std::vector;
16 using testing::AnyNumber; 16 using testing::AnyNumber;
17 using testing::ElementsAre; 17 using testing::ElementsAre;
18 using testing::IsEmpty;
18 using testing::Pair; 19 using testing::Pair;
19 using testing::Pointwise; 20 using testing::Pointwise;
20 using testing::Return; 21 using testing::Return;
21 using testing::StrictMock; 22 using testing::StrictMock;
22 using testing::_; 23 using testing::_;
23 24
24 namespace net { 25 namespace net {
25 namespace test { 26 namespace test {
26 namespace { 27 namespace {
27 28
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 QuicSentPacketManagerPeer::GetNumRetransmittablePackets( 93 QuicSentPacketManagerPeer::GetNumRetransmittablePackets(
93 &manager_)); 94 &manager_));
94 for (size_t i = 0; i < num_packets; ++i) { 95 for (size_t i = 0; i < num_packets; ++i) {
95 EXPECT_TRUE(manager_.HasRetransmittableFrames(packets[i])) 96 EXPECT_TRUE(manager_.HasRetransmittableFrames(packets[i]))
96 << " packets[" << i << "]:" << packets[i]; 97 << " packets[" << i << "]:" << packets[i];
97 } 98 }
98 } 99 }
99 100
100 void ExpectAck(QuicPacketSequenceNumber largest_observed) { 101 void ExpectAck(QuicPacketSequenceNumber largest_observed) {
101 EXPECT_CALL(*send_algorithm_, OnCongestionEvent( 102 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(
102 true, _, ElementsAre(Pair(largest_observed, _)), _)); 103 true, _, ElementsAre(Pair(largest_observed, _)), IsEmpty()));
103 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) 104 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
104 .WillOnce(Return(100 * kDefaultTCPMSS));
105 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_));
106 } 105 }
107 106
108 void ExpectUpdatedRtt(QuicPacketSequenceNumber largest_observed) { 107 void ExpectUpdatedRtt(QuicPacketSequenceNumber largest_observed) {
109 EXPECT_CALL(*send_algorithm_, 108 EXPECT_CALL(*send_algorithm_,
110 OnCongestionEvent(true, _, _, _)); 109 OnCongestionEvent(true, _, IsEmpty(), IsEmpty()));
111 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) 110 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
112 .WillOnce(Return(100 * kDefaultTCPMSS));
113 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_));
114 } 111 }
115 112
116 void ExpectAckAndLoss(bool rtt_updated, 113 void ExpectAckAndLoss(bool rtt_updated,
117 QuicPacketSequenceNumber largest_observed, 114 QuicPacketSequenceNumber largest_observed,
118 QuicPacketSequenceNumber lost_packet) { 115 QuicPacketSequenceNumber lost_packet) {
119 EXPECT_CALL(*send_algorithm_, OnCongestionEvent( 116 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(
120 rtt_updated, _, ElementsAre(Pair(largest_observed, _)), 117 rtt_updated, _, ElementsAre(Pair(largest_observed, _)),
121 ElementsAre(Pair(lost_packet, _)))); 118 ElementsAre(Pair(lost_packet, _))));
122 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) 119 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
123 .WillOnce(Return(100 * kDefaultTCPMSS));
124 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_));
125 } 120 }
126 121
127 // |packets_acked| and |packets_lost| should be in sequence number order. 122 // |packets_acked| and |packets_lost| should be in sequence number order.
128 void ExpectAcksAndLosses(bool rtt_updated, 123 void ExpectAcksAndLosses(bool rtt_updated,
129 QuicPacketSequenceNumber* packets_acked, 124 QuicPacketSequenceNumber* packets_acked,
130 size_t num_packets_acked, 125 size_t num_packets_acked,
131 QuicPacketSequenceNumber* packets_lost, 126 QuicPacketSequenceNumber* packets_lost,
132 size_t num_packets_lost) { 127 size_t num_packets_lost) {
133 vector<QuicPacketSequenceNumber> ack_vector; 128 vector<QuicPacketSequenceNumber> ack_vector;
134 for (size_t i = 0; i < num_packets_acked; ++i) { 129 for (size_t i = 0; i < num_packets_acked; ++i) {
135 ack_vector.push_back(packets_acked[i]); 130 ack_vector.push_back(packets_acked[i]);
136 } 131 }
137 vector<QuicPacketSequenceNumber> lost_vector; 132 vector<QuicPacketSequenceNumber> lost_vector;
138 for (size_t i = 0; i < num_packets_lost; ++i) { 133 for (size_t i = 0; i < num_packets_lost; ++i) {
139 lost_vector.push_back(packets_lost[i]); 134 lost_vector.push_back(packets_lost[i]);
140 } 135 }
141 EXPECT_CALL(*send_algorithm_, 136 EXPECT_CALL(*send_algorithm_,
142 OnCongestionEvent(rtt_updated, _, 137 OnCongestionEvent(rtt_updated, _,
143 Pointwise(KeyEq(), ack_vector), 138 Pointwise(KeyEq(), ack_vector),
144 Pointwise(KeyEq(), lost_vector))); 139 Pointwise(KeyEq(), lost_vector)));
145 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) 140 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange()).
146 .WillRepeatedly(Return(100 * kDefaultTCPMSS));
147 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)).
148 Times(AnyNumber()); 141 Times(AnyNumber());
149 } 142 }
150 143
151 void RetransmitAndSendPacket(QuicPacketSequenceNumber old_sequence_number, 144 void RetransmitAndSendPacket(QuicPacketSequenceNumber old_sequence_number,
152 QuicPacketSequenceNumber new_sequence_number) { 145 QuicPacketSequenceNumber new_sequence_number) {
153 QuicSentPacketManagerPeer::MarkForRetransmission( 146 QuicSentPacketManagerPeer::MarkForRetransmission(
154 &manager_, old_sequence_number, TLP_RETRANSMISSION); 147 &manager_, old_sequence_number, TLP_RETRANSMISSION);
155 EXPECT_TRUE(manager_.HasPendingRetransmissions()); 148 EXPECT_TRUE(manager_.HasPendingRetransmissions());
156 QuicSentPacketManager::PendingRetransmission next_retransmission = 149 QuicSentPacketManager::PendingRetransmission next_retransmission =
157 manager_.NextPendingRetransmission(); 150 manager_.NextPendingRetransmission();
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 // since there is no retransmittable data outstanding. 381 // since there is no retransmittable data outstanding.
389 EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime()); 382 EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime());
390 } 383 }
391 384
392 TEST_F(QuicSentPacketManagerTest, RetransmitTwiceThenAckPreviousBeforeSend) { 385 TEST_F(QuicSentPacketManagerTest, RetransmitTwiceThenAckPreviousBeforeSend) {
393 SendDataPacket(1); 386 SendDataPacket(1);
394 RetransmitAndSendPacket(1, 2); 387 RetransmitAndSendPacket(1, 2);
395 388
396 // Fire the RTO, which will mark 2 for retransmission (but will not send it). 389 // Fire the RTO, which will mark 2 for retransmission (but will not send it).
397 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); 390 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
398 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); 391 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
399 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
400 .WillOnce(Return(2 * kDefaultTCPMSS));
401 manager_.OnRetransmissionTimeout(); 392 manager_.OnRetransmissionTimeout();
402 EXPECT_TRUE(manager_.HasPendingRetransmissions()); 393 EXPECT_TRUE(manager_.HasPendingRetransmissions());
403 394
404 // Ack 1 but not 2, before 2 is able to be sent. 395 // Ack 1 but not 2, before 2 is able to be sent.
405 // Since 1 has been retransmitted, it has already been lost, and so the 396 // Since 1 has been retransmitted, it has already been lost, and so the
406 // send algorithm is not informed that it has been ACK'd. 397 // send algorithm is not informed that it has been ACK'd.
407 QuicAckFrame ack_frame; 398 QuicAckFrame ack_frame;
408 ack_frame.largest_observed = 1; 399 ack_frame.largest_observed = 1;
409 ExpectUpdatedRtt(1); 400 ExpectUpdatedRtt(1);
410 EXPECT_CALL(*send_algorithm_, RevertRetransmissionTimeout()); 401 EXPECT_CALL(*send_algorithm_, RevertRetransmissionTimeout());
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)).WillOnce(Return( 823 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)).WillOnce(Return(
833 QuicTime::Delta::Infinite())); 824 QuicTime::Delta::Infinite()));
834 EXPECT_EQ(QuicTime::Delta::Infinite(), 825 EXPECT_EQ(QuicTime::Delta::Infinite(),
835 manager_.TimeUntilSend(clock_.Now(), HAS_RETRANSMITTABLE_DATA)); 826 manager_.TimeUntilSend(clock_.Now(), HAS_RETRANSMITTABLE_DATA));
836 827
837 // Advance the time enough to ensure all packets are RTO'd. 828 // Advance the time enough to ensure all packets are RTO'd.
838 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1000)); 829 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1000));
839 830
840 // The final RTO abandons all of them. 831 // The final RTO abandons all of them.
841 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); 832 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
842 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); 833 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
843 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
844 .WillOnce(Return(2 * kDefaultTCPMSS));
845 manager_.OnRetransmissionTimeout(); 834 manager_.OnRetransmissionTimeout();
846 EXPECT_TRUE(manager_.HasPendingRetransmissions()); 835 EXPECT_TRUE(manager_.HasPendingRetransmissions());
847 EXPECT_EQ(2u, stats_.tlp_count); 836 EXPECT_EQ(2u, stats_.tlp_count);
848 EXPECT_EQ(1u, stats_.rto_count); 837 EXPECT_EQ(1u, stats_.rto_count);
849 } 838 }
850 839
851 TEST_F(QuicSentPacketManagerTest, CryptoHandshakeTimeout) { 840 TEST_F(QuicSentPacketManagerTest, CryptoHandshakeTimeout) {
852 // Send 2 crypto packets and 3 data packets. 841 // Send 2 crypto packets and 3 data packets.
853 const size_t kNumSentCryptoPackets = 2; 842 const size_t kNumSentCryptoPackets = 2;
854 for (size_t i = 1; i <= kNumSentCryptoPackets; ++i) { 843 for (size_t i = 1; i <= kNumSentCryptoPackets; ++i) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 } 1059 }
1071 1060
1072 TEST_F(QuicSentPacketManagerTest, RetransmissionTimeout) { 1061 TEST_F(QuicSentPacketManagerTest, RetransmissionTimeout) {
1073 // Send 100 packets and then ensure all are abandoned when the RTO fires. 1062 // Send 100 packets and then ensure all are abandoned when the RTO fires.
1074 const size_t kNumSentPackets = 100; 1063 const size_t kNumSentPackets = 100;
1075 for (size_t i = 1; i <= kNumSentPackets; ++i) { 1064 for (size_t i = 1; i <= kNumSentPackets; ++i) {
1076 SendDataPacket(i); 1065 SendDataPacket(i);
1077 } 1066 }
1078 1067
1079 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); 1068 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
1080 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); 1069 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1081 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
1082 .WillOnce(Return(2 * kDefaultTCPMSS));
1083 EXPECT_FALSE(manager_.MaybeRetransmitTailLossProbe()); 1070 EXPECT_FALSE(manager_.MaybeRetransmitTailLossProbe());
1084 manager_.OnRetransmissionTimeout(); 1071 manager_.OnRetransmissionTimeout();
1085 } 1072 }
1086 1073
1087 TEST_F(QuicSentPacketManagerTest, GetTransmissionTime) { 1074 TEST_F(QuicSentPacketManagerTest, GetTransmissionTime) {
1088 EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime()); 1075 EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime());
1089 } 1076 }
1090 1077
1091 TEST_F(QuicSentPacketManagerTest, GetTransmissionTimeCryptoHandshake) { 1078 TEST_F(QuicSentPacketManagerTest, GetTransmissionTimeCryptoHandshake) {
1092 SendCryptoPacket(1); 1079 SendCryptoPacket(1);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 SendDataPacket(3); 1151 SendDataPacket(3);
1165 SendDataPacket(4); 1152 SendDataPacket(4);
1166 1153
1167 QuicTime::Delta expected_rto_delay = QuicTime::Delta::FromMilliseconds(500); 1154 QuicTime::Delta expected_rto_delay = QuicTime::Delta::FromMilliseconds(500);
1168 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()) 1155 EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
1169 .WillRepeatedly(Return(expected_rto_delay)); 1156 .WillRepeatedly(Return(expected_rto_delay));
1170 QuicTime expected_time = clock_.Now().Add(expected_rto_delay); 1157 QuicTime expected_time = clock_.Now().Add(expected_rto_delay);
1171 EXPECT_EQ(expected_time, manager_.GetRetransmissionTime()); 1158 EXPECT_EQ(expected_time, manager_.GetRetransmissionTime());
1172 1159
1173 // Retransmit the packet by invoking the retransmission timeout. 1160 // Retransmit the packet by invoking the retransmission timeout.
1174 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); 1161 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1175 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
1176 .WillOnce(Return(2 * kDefaultTCPMSS));
1177 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); 1162 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
1178 clock_.AdvanceTime(expected_rto_delay); 1163 clock_.AdvanceTime(expected_rto_delay);
1179 manager_.OnRetransmissionTimeout(); 1164 manager_.OnRetransmissionTimeout();
1180 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(&manager_)); 1165 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(&manager_));
1181 RetransmitNextPacket(5); 1166 RetransmitNextPacket(5);
1182 RetransmitNextPacket(6); 1167 RetransmitNextPacket(6);
1183 EXPECT_EQ(2 * kDefaultLength, 1168 EXPECT_EQ(2 * kDefaultLength,
1184 QuicSentPacketManagerPeer::GetBytesInFlight(&manager_)); 1169 QuicSentPacketManagerPeer::GetBytesInFlight(&manager_));
1185 EXPECT_TRUE(manager_.HasPendingRetransmissions()); 1170 EXPECT_TRUE(manager_.HasPendingRetransmissions());
1186 1171
(...skipping 25 matching lines...) Expand all
1212 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()) 1197 EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
1213 .WillRepeatedly(Return(QuicTime::Delta::FromMilliseconds(1))); 1198 .WillRepeatedly(Return(QuicTime::Delta::FromMilliseconds(1)));
1214 QuicTime::Delta delay = QuicTime::Delta::FromMilliseconds(200); 1199 QuicTime::Delta delay = QuicTime::Delta::FromMilliseconds(200);
1215 1200
1216 // If the delay is smaller than the min, ensure it exponentially backs off 1201 // If the delay is smaller than the min, ensure it exponentially backs off
1217 // from the min. 1202 // from the min.
1218 for (int i = 0; i < 5; ++i) { 1203 for (int i = 0; i < 5; ++i) {
1219 EXPECT_EQ(delay, 1204 EXPECT_EQ(delay,
1220 QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_)); 1205 QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_));
1221 delay = delay.Add(delay); 1206 delay = delay.Add(delay);
1222 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); 1207 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1223 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
1224 .WillOnce(Return(2 * kDefaultTCPMSS));
1225 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); 1208 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
1226 manager_.OnRetransmissionTimeout(); 1209 manager_.OnRetransmissionTimeout();
1227 RetransmitNextPacket(i + 2); 1210 RetransmitNextPacket(i + 2);
1228 } 1211 }
1229 } 1212 }
1230 1213
1231 TEST_F(QuicSentPacketManagerTest, GetTransmissionDelayMax) { 1214 TEST_F(QuicSentPacketManagerTest, GetTransmissionDelayMax) {
1232 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()) 1215 EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
1233 .WillOnce(Return(QuicTime::Delta::FromSeconds(500))); 1216 .WillOnce(Return(QuicTime::Delta::FromSeconds(500)));
1234 1217
1235 EXPECT_EQ(QuicTime::Delta::FromSeconds(60), 1218 EXPECT_EQ(QuicTime::Delta::FromSeconds(60),
1236 QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_)); 1219 QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_));
1237 } 1220 }
1238 1221
1239 TEST_F(QuicSentPacketManagerTest, GetTransmissionDelay) { 1222 TEST_F(QuicSentPacketManagerTest, GetTransmissionDelay) {
1240 SendDataPacket(1); 1223 SendDataPacket(1);
1241 QuicTime::Delta delay = QuicTime::Delta::FromMilliseconds(500); 1224 QuicTime::Delta delay = QuicTime::Delta::FromMilliseconds(500);
1242 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()) 1225 EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
1243 .WillRepeatedly(Return(delay)); 1226 .WillRepeatedly(Return(delay));
1244 1227
1245 // Delay should back off exponentially. 1228 // Delay should back off exponentially.
1246 for (int i = 0; i < 5; ++i) { 1229 for (int i = 0; i < 5; ++i) {
1247 EXPECT_EQ(delay, 1230 EXPECT_EQ(delay,
1248 QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_)); 1231 QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_));
1249 delay = delay.Add(delay); 1232 delay = delay.Add(delay);
1250 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); 1233 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1251 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
1252 .WillOnce(Return(2 * kDefaultTCPMSS));
1253 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); 1234 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
1254 manager_.OnRetransmissionTimeout(); 1235 manager_.OnRetransmissionTimeout();
1255 RetransmitNextPacket(i + 2); 1236 RetransmitNextPacket(i + 2);
1256 } 1237 }
1257 } 1238 }
1258 1239
1259 TEST_F(QuicSentPacketManagerTest, GetLossDelay) { 1240 TEST_F(QuicSentPacketManagerTest, GetLossDelay) {
1260 MockLossAlgorithm* loss_algorithm = new MockLossAlgorithm(); 1241 MockLossAlgorithm* loss_algorithm = new MockLossAlgorithm();
1261 QuicSentPacketManagerPeer::SetLossAlgorithm(&manager_, loss_algorithm); 1242 QuicSentPacketManagerPeer::SetLossAlgorithm(&manager_, loss_algorithm);
1262 1243
(...skipping 27 matching lines...) Expand all
1290 TEST_F(QuicSentPacketManagerTest, NegotiateTimeLossDetectionFromOptions) { 1271 TEST_F(QuicSentPacketManagerTest, NegotiateTimeLossDetectionFromOptions) {
1291 EXPECT_EQ(kNack, 1272 EXPECT_EQ(kNack,
1292 QuicSentPacketManagerPeer::GetLossAlgorithm( 1273 QuicSentPacketManagerPeer::GetLossAlgorithm(
1293 &manager_)->GetLossDetectionType()); 1274 &manager_)->GetLossDetectionType());
1294 1275
1295 QuicConfig config; 1276 QuicConfig config;
1296 QuicTagVector options; 1277 QuicTagVector options;
1297 options.push_back(kTIME); 1278 options.push_back(kTIME);
1298 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); 1279 QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
1299 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); 1280 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
1300 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); 1281 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1301 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
1302 .WillOnce(Return(100 * kDefaultTCPMSS));
1303 manager_.SetFromConfig(config); 1282 manager_.SetFromConfig(config);
1304 1283
1305 EXPECT_EQ(kTime, 1284 EXPECT_EQ(kTime,
1306 QuicSentPacketManagerPeer::GetLossAlgorithm( 1285 QuicSentPacketManagerPeer::GetLossAlgorithm(
1307 &manager_)->GetLossDetectionType()); 1286 &manager_)->GetLossDetectionType());
1308 } 1287 }
1309 1288
1310 TEST_F(QuicSentPacketManagerTest, NegotiateCongestionControlFromOptions) { 1289 TEST_F(QuicSentPacketManagerTest, NegotiateCongestionControlFromOptions) {
1311 ValueRestore<bool> old_flag(&FLAGS_quic_allow_bbr, true); 1290 ValueRestore<bool> old_flag(&FLAGS_quic_allow_bbr, true);
1312 QuicConfig config; 1291 QuicConfig config;
1313 QuicTagVector options; 1292 QuicTagVector options;
1314 1293
1315 options.push_back(kRENO); 1294 options.push_back(kRENO);
1316 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); 1295 QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
1317 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); 1296 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1318 manager_.SetFromConfig(config); 1297 manager_.SetFromConfig(config);
1319 EXPECT_EQ(kReno, QuicSentPacketManagerPeer::GetSendAlgorithm( 1298 EXPECT_EQ(kReno, QuicSentPacketManagerPeer::GetSendAlgorithm(
1320 manager_)->GetCongestionControlType()); 1299 manager_)->GetCongestionControlType());
1321 1300
1322 // TODO(rtenneti): Enable the following code after BBR code is checked in. 1301 // TODO(rtenneti): Enable the following code after BBR code is checked in.
1323 #if 0 1302 #if 0
1324 options.clear(); 1303 options.clear();
1325 options.push_back(kTBBR); 1304 options.push_back(kTBBR);
1326 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); 1305 QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
1327 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); 1306 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1328 manager_.SetFromConfig(config); 1307 manager_.SetFromConfig(config);
1329 EXPECT_EQ(kBBR, QuicSentPacketManagerPeer::GetSendAlgorithm( 1308 EXPECT_EQ(kBBR, QuicSentPacketManagerPeer::GetSendAlgorithm(
1330 manager_)->GetCongestionControlType()); 1309 manager_)->GetCongestionControlType());
1331 #endif 1310 #endif
1332 } 1311 }
1333 1312
1334 TEST_F(QuicSentPacketManagerTest, NegotiateNumConnectionsFromOptions) { 1313 TEST_F(QuicSentPacketManagerTest, NegotiateNumConnectionsFromOptions) {
1335 QuicConfig config; 1314 QuicConfig config;
1336 QuicTagVector options; 1315 QuicTagVector options;
1337 1316
1338 options.push_back(k1CON); 1317 options.push_back(k1CON);
1339 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); 1318 QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
1340 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); 1319 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1341 EXPECT_CALL(*send_algorithm_, SetNumEmulatedConnections(1)); 1320 EXPECT_CALL(*send_algorithm_, SetNumEmulatedConnections(1));
1342 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
1343 .WillOnce(Return(100 * kDefaultTCPMSS));
1344 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); 1321 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
1345 manager_.SetFromConfig(config); 1322 manager_.SetFromConfig(config);
1346 1323
1347 QuicSentPacketManagerPeer::SetIsServer(&manager_, false); 1324 QuicSentPacketManagerPeer::SetIsServer(&manager_, false);
1348 QuicConfig client_config; 1325 QuicConfig client_config;
1349 client_config.SetConnectionOptionsToSend(options); 1326 client_config.SetConnectionOptionsToSend(options);
1350 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); 1327 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1351 EXPECT_CALL(*send_algorithm_, SetNumEmulatedConnections(1)); 1328 EXPECT_CALL(*send_algorithm_, SetNumEmulatedConnections(1));
1352 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
1353 .WillOnce(Return(100 * kDefaultTCPMSS));
1354 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); 1329 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
1355 manager_.SetFromConfig(client_config); 1330 manager_.SetFromConfig(client_config);
1356 } 1331 }
1357 1332
1333 TEST_F(QuicSentPacketManagerTest, NegotiateNConnectionFromOptions) {
1334 // By default, changing the number of open streams does nothing.
1335 manager_.SetNumOpenStreams(5);
1336
1337 QuicConfig config;
1338 QuicTagVector options;
1339
1340 options.push_back(kNCON);
1341 QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
1342 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1343 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
1344 manager_.SetFromConfig(config);
1345
1346 EXPECT_CALL(*send_algorithm_, SetNumEmulatedConnections(5));
1347 manager_.SetNumOpenStreams(5);
1348 }
1349
1358 TEST_F(QuicSentPacketManagerTest, NegotiateNoTLPFromOptionsAtServer) { 1350 TEST_F(QuicSentPacketManagerTest, NegotiateNoTLPFromOptionsAtServer) {
1359 QuicConfig config; 1351 QuicConfig config;
1360 QuicTagVector options; 1352 QuicTagVector options;
1361 1353
1362 options.push_back(kNTLP); 1354 options.push_back(kNTLP);
1363 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); 1355 QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
1364 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); 1356 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1365 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
1366 .WillOnce(Return(100 * kDefaultTCPMSS));
1367 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); 1357 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
1368 manager_.SetFromConfig(config); 1358 manager_.SetFromConfig(config);
1369 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetMaxTailLossProbes(&manager_)); 1359 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetMaxTailLossProbes(&manager_));
1370 } 1360 }
1371 1361
1372 TEST_F(QuicSentPacketManagerTest, NegotiateNoTLPFromOptionsAtClient) { 1362 TEST_F(QuicSentPacketManagerTest, NegotiateNoTLPFromOptionsAtClient) {
1373 QuicConfig client_config; 1363 QuicConfig client_config;
1374 QuicTagVector options; 1364 QuicTagVector options;
1375 1365
1376 options.push_back(kNTLP); 1366 options.push_back(kNTLP);
1377 QuicSentPacketManagerPeer::SetIsServer(&manager_, false); 1367 QuicSentPacketManagerPeer::SetIsServer(&manager_, false);
1378 client_config.SetConnectionOptionsToSend(options); 1368 client_config.SetConnectionOptionsToSend(options);
1379 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); 1369 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1380 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
1381 .WillOnce(Return(100 * kDefaultTCPMSS));
1382 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); 1370 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
1383 manager_.SetFromConfig(client_config); 1371 manager_.SetFromConfig(client_config);
1384 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetMaxTailLossProbes(&manager_)); 1372 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetMaxTailLossProbes(&manager_));
1385 } 1373 }
1386 1374
1387 TEST_F(QuicSentPacketManagerTest, NegotiatePacingFromOptions) { 1375 TEST_F(QuicSentPacketManagerTest, NegotiatePacingFromOptions) {
1388 EXPECT_FALSE(manager_.using_pacing()); 1376 EXPECT_FALSE(manager_.using_pacing());
1389 1377
1390 QuicConfig config; 1378 QuicConfig config;
1391 QuicTagVector options; 1379 QuicTagVector options;
1392 options.push_back(kPACE); 1380 options.push_back(kPACE);
1393 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); 1381 QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
1394 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); 1382 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1395 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
1396 .WillOnce(Return(100 * kDefaultTCPMSS));
1397 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); 1383 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
1398 manager_.SetFromConfig(config); 1384 manager_.SetFromConfig(config);
1399 1385
1400 EXPECT_TRUE(manager_.using_pacing()); 1386 EXPECT_TRUE(manager_.using_pacing());
1401 } 1387 }
1402 1388
1403 TEST_F(QuicSentPacketManagerTest, NegotiateReceiveWindowFromOptions) { 1389 TEST_F(QuicSentPacketManagerTest, NegotiateReceiveWindowFromOptions) {
1404 EXPECT_EQ(kDefaultSocketReceiveBuffer, 1390 EXPECT_EQ(kDefaultSocketReceiveBuffer,
1405 QuicSentPacketManagerPeer::GetReceiveWindow(&manager_)); 1391 QuicSentPacketManagerPeer::GetReceiveWindow(&manager_));
1406 1392
1407 // Try to set a size below the minimum and ensure it gets set to the min. 1393 // Try to set a size below the minimum and ensure it gets set to the min.
1408 QuicConfig client_config; 1394 QuicConfig client_config;
1409 QuicConfigPeer::SetReceivedSocketReceiveBuffer(&client_config, 1024); 1395 QuicConfigPeer::SetReceivedSocketReceiveBuffer(&client_config, 1024);
1410 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); 1396 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
1411 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); 1397 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1412 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
1413 .WillOnce(Return(100 * kDefaultTCPMSS));
1414 manager_.SetFromConfig(client_config); 1398 manager_.SetFromConfig(client_config);
1415 1399
1416 EXPECT_EQ(kMinSocketReceiveBuffer, 1400 EXPECT_EQ(kMinSocketReceiveBuffer,
1417 QuicSentPacketManagerPeer::GetReceiveWindow(&manager_)); 1401 QuicSentPacketManagerPeer::GetReceiveWindow(&manager_));
1418 1402
1419 // Ensure the smaller send window only allows 16 packets to be sent. 1403 // Ensure the smaller send window only allows 16 packets to be sent.
1420 for (QuicPacketSequenceNumber i = 1; i <= 16; ++i) { 1404 for (QuicPacketSequenceNumber i = 1; i <= 16; ++i) {
1421 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)).WillOnce(Return( 1405 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)).WillOnce(Return(
1422 QuicTime::Delta::Zero())); 1406 QuicTime::Delta::Zero()));
1423 EXPECT_EQ(QuicTime::Delta::Zero(), 1407 EXPECT_EQ(QuicTime::Delta::Zero(),
(...skipping 10 matching lines...) Expand all
1434 } 1418 }
1435 1419
1436 TEST_F(QuicSentPacketManagerTest, UseInitialRoundTripTimeToSend) { 1420 TEST_F(QuicSentPacketManagerTest, UseInitialRoundTripTimeToSend) {
1437 uint32 initial_rtt_us = 325000; 1421 uint32 initial_rtt_us = 325000;
1438 EXPECT_NE(initial_rtt_us, 1422 EXPECT_NE(initial_rtt_us,
1439 manager_.GetRttStats()->SmoothedRtt().ToMicroseconds()); 1423 manager_.GetRttStats()->SmoothedRtt().ToMicroseconds());
1440 1424
1441 QuicConfig config; 1425 QuicConfig config;
1442 config.SetInitialRoundTripTimeUsToSend(initial_rtt_us); 1426 config.SetInitialRoundTripTimeUsToSend(initial_rtt_us);
1443 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); 1427 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
1444 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); 1428 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1445 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
1446 .WillOnce(Return(100 * kDefaultTCPMSS));
1447 manager_.SetFromConfig(config); 1429 manager_.SetFromConfig(config);
1448 1430
1449 EXPECT_EQ(initial_rtt_us, 1431 EXPECT_EQ(initial_rtt_us,
1450 manager_.GetRttStats()->SmoothedRtt().ToMicroseconds()); 1432 manager_.GetRttStats()->SmoothedRtt().ToMicroseconds());
1451 } 1433 }
1452 1434
1453 } // namespace 1435 } // namespace
1454 } // namespace test 1436 } // namespace test
1455 } // namespace net 1437 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_sent_packet_manager.cc ('k') | net/quic/quic_server_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698