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

Side by Side Diff: net/quic/core/quic_connection_test.cc

Issue 2359503003: Landing Recent QUIC changes until 9:58 AM, Sep 17, 2016 UTC (Closed)
Patch Set: Reverted flag flip. Created 4 years, 3 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 | « net/quic/core/quic_connection.cc ('k') | net/quic/core/quic_crypto_server_stream.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/core/quic_connection.h" 5 #include "net/quic/core/quic_connection.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <memory> 8 #include <memory>
9 #include <ostream> 9 #include <ostream>
10 #include <utility> 10 #include <utility>
(...skipping 3536 matching lines...) Expand 10 before | Expand all | Expand 10 after
3547 VLOG(1) << "sending data packet"; 3547 VLOG(1) << "sending data packet";
3548 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, !kFin, 3548 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, !kFin,
3549 nullptr); 3549 nullptr);
3550 connection_.GetTimeoutAlarm()->Fire(); 3550 connection_.GetTimeoutAlarm()->Fire();
3551 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); 3551 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1));
3552 } 3552 }
3553 EXPECT_FALSE(connection_.connected()); 3553 EXPECT_FALSE(connection_.connected());
3554 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); 3554 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet());
3555 } 3555 }
3556 3556
3557 TEST_P(QuicConnectionTest, TimeoutAfter5RTOs) { 3557 TEST_P(QuicConnectionTest, TimeoutAfter5ClientRTOs) {
3558 connection_.SetMaxTailLossProbes(kDefaultPathId, 2); 3558 connection_.SetMaxTailLossProbes(kDefaultPathId, 2);
3559 EXPECT_TRUE(connection_.connected()); 3559 EXPECT_TRUE(connection_.connected());
3560 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); 3560 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
3561 QuicConfig config; 3561 QuicConfig config;
3562 QuicTagVector connection_options; 3562 QuicTagVector connection_options;
3563 connection_options.push_back(k5RTO); 3563 connection_options.push_back(k5RTO);
3564 config.SetConnectionOptionsToSend(connection_options); 3564 config.SetConnectionOptionsToSend(connection_options);
3565 connection_.SetFromConfig(config); 3565 connection_.SetFromConfig(config);
3566 3566
3567 // Send stream data. 3567 // Send stream data.
(...skipping 12 matching lines...) Expand all
3580 EXPECT_EQ(4u, connection_.sent_packet_manager().GetConsecutiveRtoCount()); 3580 EXPECT_EQ(4u, connection_.sent_packet_manager().GetConsecutiveRtoCount());
3581 // This time, we should time out. 3581 // This time, we should time out.
3582 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_TOO_MANY_RTOS, _, 3582 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_TOO_MANY_RTOS, _,
3583 ConnectionCloseSource::FROM_SELF)); 3583 ConnectionCloseSource::FROM_SELF));
3584 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); 3584 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
3585 connection_.GetRetransmissionAlarm()->Fire(); 3585 connection_.GetRetransmissionAlarm()->Fire();
3586 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); 3586 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet());
3587 EXPECT_FALSE(connection_.connected()); 3587 EXPECT_FALSE(connection_.connected());
3588 } 3588 }
3589 3589
3590 TEST_P(QuicConnectionTest, TimeoutAfter5ServerRTOs) {
3591 FLAGS_quic_only_5rto_client_side = true;
3592 connection_.SetMaxTailLossProbes(kDefaultPathId, 2);
3593 QuicConnectionPeer::SetPerspective(&connection_, Perspective::IS_SERVER);
3594 QuicFramerPeer::SetPerspective(QuicConnectionPeer::GetFramer(&connection_),
3595 Perspective::IS_SERVER);
3596 creator_->StopSendingVersion();
3597 EXPECT_TRUE(connection_.connected());
3598 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
3599 QuicConfig config;
3600 QuicTagVector connection_options;
3601 connection_options.push_back(k5RTO);
3602 config.SetConnectionOptionsToSend(connection_options);
3603 connection_.SetFromConfig(config);
3604
3605 // Send stream data.
3606 SendStreamDataToPeer(kClientDataStreamId1, "foo", 0, kFin, nullptr);
3607
3608 EXPECT_CALL(visitor_, OnPathDegrading());
3609 // Fire the retransmission alarm 6 times, twice for TLP and 4 times for RTO.
3610 for (int i = 0; i < 6; ++i) {
3611 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
3612 connection_.GetRetransmissionAlarm()->Fire();
3613 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet());
3614 EXPECT_TRUE(connection_.connected());
3615 }
3616
3617 EXPECT_EQ(2u, connection_.sent_packet_manager().GetConsecutiveTlpCount());
3618 EXPECT_EQ(4u, connection_.sent_packet_manager().GetConsecutiveRtoCount());
3619 // The 5th RTO should not time out server side.
3620 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
3621 connection_.GetRetransmissionAlarm()->Fire();
3622 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet());
3623 EXPECT_TRUE(connection_.connected());
3624 }
3625
3590 TEST_P(QuicConnectionTest, SendScheduler) { 3626 TEST_P(QuicConnectionTest, SendScheduler) {
3591 // Test that if we send a packet without delay, it is not queued. 3627 // Test that if we send a packet without delay, it is not queued.
3592 QuicPacket* packet = 3628 QuicPacket* packet =
3593 ConstructDataPacket(kDefaultPathId, 1, !kEntropyFlag, !kHasStopWaiting); 3629 ConstructDataPacket(kDefaultPathId, 1, !kEntropyFlag, !kHasStopWaiting);
3594 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); 3630 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
3595 connection_.SendPacket(ENCRYPTION_NONE, kDefaultPathId, 1, packet, 3631 connection_.SendPacket(ENCRYPTION_NONE, kDefaultPathId, 1, packet,
3596 kTestEntropyHash, HAS_RETRANSMITTABLE_DATA, false, 3632 kTestEntropyHash, HAS_RETRANSMITTABLE_DATA, false,
3597 false); 3633 false);
3598 EXPECT_EQ(0u, connection_.NumQueuedPackets()); 3634 EXPECT_EQ(0u, connection_.NumQueuedPackets());
3599 } 3635 }
(...skipping 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after
5141 frame1_.stream_id = 10; 5177 frame1_.stream_id = 10;
5142 frame1_.data_buffer = data->data(); 5178 frame1_.data_buffer = data->data();
5143 frame1_.data_length = data->length(); 5179 frame1_.data_length = data->length();
5144 5180
5145 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _, 5181 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _,
5146 ConnectionCloseSource::FROM_SELF)); 5182 ConnectionCloseSource::FROM_SELF));
5147 ForceProcessFramePacket(QuicFrame(&frame1_)); 5183 ForceProcessFramePacket(QuicFrame(&frame1_));
5148 } 5184 }
5149 5185
5150 TEST_P(QuicConnectionTest, CloseConnectionOnPacketTooLarge) { 5186 TEST_P(QuicConnectionTest, CloseConnectionOnPacketTooLarge) {
5151 FLAGS_quic_close_connection_on_packet_too_large = true;
5152 SimulateNextPacketTooLarge(); 5187 SimulateNextPacketTooLarge();
5153 // Although the data packet cannot be written, the send packet manager is 5188 if (!FLAGS_quic_only_track_sent_packets) {
5154 // informed. Also a connection close packet is sent. 5189 // Although the data packet cannot be written, the send packet manager is
5155 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); 5190 // informed.
5191 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2);
5192 }
5193 // A connection close packet is sent
5156 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PACKET_WRITE_ERROR, _, 5194 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PACKET_WRITE_ERROR, _,
5157 ConnectionCloseSource::FROM_SELF)) 5195 ConnectionCloseSource::FROM_SELF))
5158 .Times(1); 5196 .Times(1);
5159 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); 5197 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr);
5160 } 5198 }
5161 5199
5162 TEST_P(QuicConnectionTest, AlwaysGetPacketTooLarge) { 5200 TEST_P(QuicConnectionTest, AlwaysGetPacketTooLarge) {
5163 // Test even we always get packet too large, we do not infinitely try to send 5201 // Test even we always get packet too large, we do not infinitely try to send
5164 // close packet. 5202 // close packet.
5165 FLAGS_quic_close_connection_on_packet_too_large = true;
5166 AlwaysGetPacketTooLarge(); 5203 AlwaysGetPacketTooLarge();
5167 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); 5204 if (!FLAGS_quic_only_track_sent_packets) {
5205 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2);
5206 }
5168 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PACKET_WRITE_ERROR, _, 5207 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PACKET_WRITE_ERROR, _,
5169 ConnectionCloseSource::FROM_SELF)) 5208 ConnectionCloseSource::FROM_SELF))
5170 .Times(1); 5209 .Times(1);
5171 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); 5210 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr);
5172 } 5211 }
5173 5212
5174 // Verify that if connection has no outstanding data, it notifies the send 5213 // Verify that if connection has no outstanding data, it notifies the send
5175 // algorithm after the write. 5214 // algorithm after the write.
5176 TEST_P(QuicConnectionTest, SendDataAndBecomeApplicationLimited) { 5215 TEST_P(QuicConnectionTest, SendDataAndBecomeApplicationLimited) {
5177 EXPECT_CALL(*send_algorithm_, OnApplicationLimited(_)).Times(1); 5216 EXPECT_CALL(*send_algorithm_, OnApplicationLimited(_)).Times(1);
(...skipping 26 matching lines...) Expand all
5204 // Verify that the connection does not become app-limited after blocked write 5243 // Verify that the connection does not become app-limited after blocked write
5205 // even if there is outstanding data to send after the write. 5244 // even if there is outstanding data to send after the write.
5206 TEST_P(QuicConnectionTest, NotBecomeApplicationLimitedDueToWriteBlock) { 5245 TEST_P(QuicConnectionTest, NotBecomeApplicationLimitedDueToWriteBlock) {
5207 EXPECT_CALL(*send_algorithm_, OnApplicationLimited(_)).Times(0); 5246 EXPECT_CALL(*send_algorithm_, OnApplicationLimited(_)).Times(0);
5208 EXPECT_CALL(visitor_, WillingAndAbleToWrite()).WillRepeatedly(Return(true)); 5247 EXPECT_CALL(visitor_, WillingAndAbleToWrite()).WillRepeatedly(Return(true));
5209 BlockOnNextWrite(); 5248 BlockOnNextWrite();
5210 5249
5211 connection_.SendStreamData3(); 5250 connection_.SendStreamData3();
5212 } 5251 }
5213 5252
5214 TEST_P(QuicConnectionTest, ForceSendingAckOnPacketTooLarge) { 5253 TEST_P(QuicConnectionTest, DonotForceSendingAckOnPacketTooLarge) {
5215 FLAGS_quic_do_not_send_ack_on_emsgsize = false;
5216 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 5254 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
5217 // Send an ack by simulating delayed ack alarm firing. 5255 // Send an ack by simulating delayed ack alarm firing.
5218 ProcessPacket(kDefaultPathId, 1); 5256 ProcessPacket(kDefaultPathId, 1);
5219 QuicAlarm* ack_alarm = QuicConnectionPeer::GetAckAlarm(&connection_);
5220 EXPECT_TRUE(ack_alarm->IsSet());
5221 connection_.GetAckAlarm()->Fire();
5222 // Simulate data packet causes write error.
5223 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PACKET_WRITE_ERROR, _, _));
5224 SimulateNextPacketTooLarge();
5225 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr);
5226 EXPECT_EQ(3u, writer_->frame_count());
5227 EXPECT_FALSE(writer_->connection_close_frames().empty());
5228 // Ack frame is bundled.
5229 EXPECT_FALSE(writer_->ack_frames().empty());
5230 }
5231
5232 TEST_P(QuicConnectionTest, DonotForceSendingAckOnPacketTooLarge) {
5233 FLAGS_quic_do_not_send_ack_on_emsgsize = true;
5234 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
5235 // Send an ack by simulating delayed ack alarm firing.
5236 ProcessPacket(kDefaultPathId, 1);
5237 QuicAlarm* ack_alarm = QuicConnectionPeer::GetAckAlarm(&connection_); 5257 QuicAlarm* ack_alarm = QuicConnectionPeer::GetAckAlarm(&connection_);
5238 EXPECT_TRUE(ack_alarm->IsSet()); 5258 EXPECT_TRUE(ack_alarm->IsSet());
5239 connection_.GetAckAlarm()->Fire(); 5259 connection_.GetAckAlarm()->Fire();
5240 // Simulate data packet causes write error. 5260 // Simulate data packet causes write error.
5241 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PACKET_WRITE_ERROR, _, _)); 5261 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PACKET_WRITE_ERROR, _, _));
5242 SimulateNextPacketTooLarge(); 5262 SimulateNextPacketTooLarge();
5243 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); 5263 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr);
5244 EXPECT_EQ(1u, writer_->frame_count()); 5264 EXPECT_EQ(1u, writer_->frame_count());
5245 EXPECT_FALSE(writer_->connection_close_frames().empty()); 5265 EXPECT_FALSE(writer_->connection_close_frames().empty());
5246 // Ack frame is not bundled in connection close packet. 5266 // Ack frame is not bundled in connection close packet.
5247 EXPECT_TRUE(writer_->ack_frames().empty()); 5267 EXPECT_TRUE(writer_->ack_frames().empty());
5248 } 5268 }
5249 5269
5250 } // namespace 5270 } // namespace
5251 } // namespace test 5271 } // namespace test
5252 } // namespace net 5272 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_connection.cc ('k') | net/quic/core/quic_crypto_server_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698