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

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

Issue 1777293002: Add a new QUIC Ack Decimation mode that is reordering tolerant. Protected by FLAG_quic_ack_decimati… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@115844136
Patch Set: Created 4 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
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_flags.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/quic_connection.h" 5 #include "net/quic/quic_connection.h"
6 6
7 #include <ostream> 7 #include <ostream>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 4354 matching lines...) Expand 10 before | Expand all | Expand 10 after
4365 // Simulate delayed ack alarm firing. 4365 // Simulate delayed ack alarm firing.
4366 connection_.GetAckAlarm()->Fire(); 4366 connection_.GetAckAlarm()->Fire();
4367 // Check that ack is sent and that delayed ack alarm is reset. 4367 // Check that ack is sent and that delayed ack alarm is reset.
4368 EXPECT_EQ(2u, writer_->frame_count()); 4368 EXPECT_EQ(2u, writer_->frame_count());
4369 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); 4369 EXPECT_FALSE(writer_->stop_waiting_frames().empty());
4370 EXPECT_FALSE(writer_->ack_frames().empty()); 4370 EXPECT_FALSE(writer_->ack_frames().empty());
4371 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); 4371 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
4372 } 4372 }
4373 4373
4374 TEST_P(QuicConnectionTest, SendDelayedAckDecimation) { 4374 TEST_P(QuicConnectionTest, SendDelayedAckDecimation) {
4375 QuicConnectionPeer::EnableAckDecimation(&connection_); 4375 QuicConnectionPeer::SetAckMode(&connection_, QuicConnection::ACK_DECIMATION);
4376 4376
4377 const size_t kMinRttMs = 40; 4377 const size_t kMinRttMs = 40;
4378 RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_); 4378 RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_);
4379 rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs), 4379 rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs),
4380 QuicTime::Delta::Zero(), QuicTime::Zero()); 4380 QuicTime::Delta::Zero(), QuicTime::Zero());
4381 // The ack time should be based on min_rtt/4, since it's less than the 4381 // The ack time should be based on min_rtt/4, since it's less than the
4382 // default delayed ack time. 4382 // default delayed ack time.
4383 QuicTime ack_time = clock_.ApproximateNow().Add( 4383 QuicTime ack_time = clock_.ApproximateNow().Add(
4384 QuicTime::Delta::FromMilliseconds(kMinRttMs / 4)); 4384 QuicTime::Delta::FromMilliseconds(kMinRttMs / 4));
4385 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 4385 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
(...skipping 30 matching lines...) Expand all
4416 !kEntropyFlag, !kHasStopWaiting, 4416 !kEntropyFlag, !kHasStopWaiting,
4417 ENCRYPTION_INITIAL); 4417 ENCRYPTION_INITIAL);
4418 } 4418 }
4419 // Check that ack is sent and that delayed ack alarm is reset. 4419 // Check that ack is sent and that delayed ack alarm is reset.
4420 EXPECT_EQ(2u, writer_->frame_count()); 4420 EXPECT_EQ(2u, writer_->frame_count());
4421 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); 4421 EXPECT_FALSE(writer_->stop_waiting_frames().empty());
4422 EXPECT_FALSE(writer_->ack_frames().empty()); 4422 EXPECT_FALSE(writer_->ack_frames().empty());
4423 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); 4423 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
4424 } 4424 }
4425 4425
4426 TEST_P(QuicConnectionTest, SendDelayedAckDecimationWithReordering) {
4427 FLAGS_quic_ack_decimation2 = true;
4428 QuicConnectionPeer::SetAckMode(
4429 &connection_, QuicConnection::ACK_DECIMATION_WITH_REORDERING);
4430
4431 const size_t kMinRttMs = 40;
4432 RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_);
4433 rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs),
4434 QuicTime::Delta::Zero(), QuicTime::Zero());
4435 // The ack time should be based on min_rtt/4, since it's less than the
4436 // default delayed ack time.
4437 QuicTime ack_time = clock_.ApproximateNow().Add(
4438 QuicTime::Delta::FromMilliseconds(kMinRttMs / 4));
4439 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
4440 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
4441 const uint8_t tag = 0x07;
4442 connection_.SetDecrypter(ENCRYPTION_INITIAL, new StrictTaggingDecrypter(tag));
4443 framer_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag));
4444 // Process a packet from the non-crypto stream.
4445 frame1_.stream_id = 3;
4446
4447 // Process all the initial packets in order so there aren't missing packets.
4448 QuicPacketNumber kFirstDecimatedPacket = 101;
4449 for (unsigned int i = 0; i < kFirstDecimatedPacket - 1; ++i) {
4450 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
4451 ProcessDataPacketAtLevel(kDefaultPathId, 1 + i, 0, !kEntropyFlag,
4452 !kHasStopWaiting, ENCRYPTION_INITIAL);
4453 }
4454 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
4455 // The same as ProcessPacket(1) except that ENCRYPTION_INITIAL is used
4456 // instead of ENCRYPTION_NONE.
4457 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
4458 ProcessDataPacketAtLevel(kDefaultPathId, kFirstDecimatedPacket, 0,
4459 !kEntropyFlag, !kHasStopWaiting, ENCRYPTION_INITIAL);
4460
4461 // Check if delayed ack timer is running for the expected interval.
4462 EXPECT_TRUE(connection_.GetAckAlarm()->IsSet());
4463 EXPECT_EQ(ack_time, connection_.GetAckAlarm()->deadline());
4464
4465 // Process packet 10 first and ensure the alarm is one eighth min_rtt.
4466 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
4467 ProcessDataPacketAtLevel(kDefaultPathId, kFirstDecimatedPacket + 9, 0,
4468 !kEntropyFlag, !kHasStopWaiting, ENCRYPTION_INITIAL);
4469 ack_time = clock_.ApproximateNow().Add(QuicTime::Delta::FromMilliseconds(5));
4470 EXPECT_TRUE(connection_.GetAckAlarm()->IsSet());
4471 EXPECT_EQ(ack_time, connection_.GetAckAlarm()->deadline());
4472
4473 // The 10th received packet causes an ack to be sent.
4474 for (int i = 0; i < 8; ++i) {
4475 EXPECT_TRUE(connection_.GetAckAlarm()->IsSet());
4476 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
4477 ProcessDataPacketAtLevel(kDefaultPathId, kFirstDecimatedPacket + 1 + i, 0,
4478 !kEntropyFlag, !kHasStopWaiting,
4479 ENCRYPTION_INITIAL);
4480 }
4481 // Check that ack is sent and that delayed ack alarm is reset.
4482 EXPECT_EQ(2u, writer_->frame_count());
4483 EXPECT_FALSE(writer_->stop_waiting_frames().empty());
4484 EXPECT_FALSE(writer_->ack_frames().empty());
4485 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
4486 }
4487
4488 TEST_P(QuicConnectionTest, SendDelayedAckDecimationWithLargeReordering) {
4489 FLAGS_quic_ack_decimation2 = true;
4490 QuicConnectionPeer::SetAckMode(
4491 &connection_, QuicConnection::ACK_DECIMATION_WITH_REORDERING);
4492
4493 const size_t kMinRttMs = 40;
4494 RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_);
4495 rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs),
4496 QuicTime::Delta::Zero(), QuicTime::Zero());
4497 // The ack time should be based on min_rtt/4, since it's less than the
4498 // default delayed ack time.
4499 QuicTime ack_time = clock_.ApproximateNow().Add(
4500 QuicTime::Delta::FromMilliseconds(kMinRttMs / 4));
4501 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
4502 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
4503 const uint8_t tag = 0x07;
4504 connection_.SetDecrypter(ENCRYPTION_INITIAL, new StrictTaggingDecrypter(tag));
4505 framer_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag));
4506 // Process a packet from the non-crypto stream.
4507 frame1_.stream_id = 3;
4508
4509 // Process all the initial packets in order so there aren't missing packets.
4510 QuicPacketNumber kFirstDecimatedPacket = 101;
4511 for (unsigned int i = 0; i < kFirstDecimatedPacket - 1; ++i) {
4512 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
4513 ProcessDataPacketAtLevel(kDefaultPathId, 1 + i, 0, !kEntropyFlag,
4514 !kHasStopWaiting, ENCRYPTION_INITIAL);
4515 }
4516 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
4517 // The same as ProcessPacket(1) except that ENCRYPTION_INITIAL is used
4518 // instead of ENCRYPTION_NONE.
4519 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
4520 ProcessDataPacketAtLevel(kDefaultPathId, kFirstDecimatedPacket, 0,
4521 !kEntropyFlag, !kHasStopWaiting, ENCRYPTION_INITIAL);
4522
4523 // Check if delayed ack timer is running for the expected interval.
4524 EXPECT_TRUE(connection_.GetAckAlarm()->IsSet());
4525 EXPECT_EQ(ack_time, connection_.GetAckAlarm()->deadline());
4526
4527 // Process packet 10 first and ensure the alarm is one eighth min_rtt.
4528 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
4529 ProcessDataPacketAtLevel(kDefaultPathId, kFirstDecimatedPacket + 19, 0,
4530 !kEntropyFlag, !kHasStopWaiting, ENCRYPTION_INITIAL);
4531 ack_time = clock_.ApproximateNow().Add(QuicTime::Delta::FromMilliseconds(5));
4532 EXPECT_TRUE(connection_.GetAckAlarm()->IsSet());
4533 EXPECT_EQ(ack_time, connection_.GetAckAlarm()->deadline());
4534
4535 // The 10th received packet causes an ack to be sent.
4536 for (int i = 0; i < 8; ++i) {
4537 EXPECT_TRUE(connection_.GetAckAlarm()->IsSet());
4538 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
4539 ProcessDataPacketAtLevel(kDefaultPathId, kFirstDecimatedPacket + 1 + i, 0,
4540 !kEntropyFlag, !kHasStopWaiting,
4541 ENCRYPTION_INITIAL);
4542 }
4543 // Check that ack is sent and that delayed ack alarm is reset.
4544 EXPECT_EQ(2u, writer_->frame_count());
4545 EXPECT_FALSE(writer_->stop_waiting_frames().empty());
4546 EXPECT_FALSE(writer_->ack_frames().empty());
4547 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
4548
4549 // The next packet received in order will cause an immediate ack,
4550 // because it fills a hole.
4551 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
4552 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
4553 ProcessDataPacketAtLevel(kDefaultPathId, kFirstDecimatedPacket + 10, 0,
4554 !kEntropyFlag, !kHasStopWaiting, ENCRYPTION_INITIAL);
4555 // Check that ack is sent and that delayed ack alarm is reset.
4556 EXPECT_EQ(2u, writer_->frame_count());
4557 EXPECT_FALSE(writer_->stop_waiting_frames().empty());
4558 EXPECT_FALSE(writer_->ack_frames().empty());
4559 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
4560 }
4561
4426 TEST_P(QuicConnectionTest, SendDelayedAckOnHandshakeConfirmed) { 4562 TEST_P(QuicConnectionTest, SendDelayedAckOnHandshakeConfirmed) {
4427 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 4563 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
4428 ProcessPacket(kDefaultPathId, 1); 4564 ProcessPacket(kDefaultPathId, 1);
4429 // Check that ack is sent and that delayed ack alarm is set. 4565 // Check that ack is sent and that delayed ack alarm is set.
4430 EXPECT_TRUE(connection_.GetAckAlarm()->IsSet()); 4566 EXPECT_TRUE(connection_.GetAckAlarm()->IsSet());
4431 QuicTime ack_time = clock_.ApproximateNow().Add(DefaultDelayedAckTime()); 4567 QuicTime ack_time = clock_.ApproximateNow().Add(DefaultDelayedAckTime());
4432 EXPECT_EQ(ack_time, connection_.GetAckAlarm()->deadline()); 4568 EXPECT_EQ(ack_time, connection_.GetAckAlarm()->deadline());
4433 4569
4434 // Completing the handshake as the server does nothing. 4570 // Completing the handshake as the server does nothing.
4435 QuicConnectionPeer::SetPerspective(&connection_, Perspective::IS_SERVER); 4571 QuicConnectionPeer::SetPerspective(&connection_, Perspective::IS_SERVER);
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after
5596 // result in multiple attempts to close the connection - it will be marked as 5732 // result in multiple attempts to close the connection - it will be marked as
5597 // disconnected after the first call. 5733 // disconnected after the first call.
5598 EXPECT_CALL(visitor_, OnConnectionClosed(_, _)).Times(1); 5734 EXPECT_CALL(visitor_, OnConnectionClosed(_, _)).Times(1);
5599 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason"); 5735 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason");
5600 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason"); 5736 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason");
5601 } 5737 }
5602 5738
5603 } // namespace 5739 } // namespace
5604 } // namespace test 5740 } // namespace test
5605 } // namespace net 5741 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_flags.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698