| Index: net/quic/quic_connection_test.cc
|
| diff --git a/net/quic/quic_connection_test.cc b/net/quic/quic_connection_test.cc
|
| index c30ac0a628cc61a58180641a965b52ed508f53cc..c10b02d63e2d9d4849e666b2f69192c5aab3295a 100644
|
| --- a/net/quic/quic_connection_test.cc
|
| +++ b/net/quic/quic_connection_test.cc
|
| @@ -4372,7 +4372,7 @@ TEST_P(QuicConnectionTest, SendDelayedAck) {
|
| }
|
|
|
| TEST_P(QuicConnectionTest, SendDelayedAckDecimation) {
|
| - QuicConnectionPeer::EnableAckDecimation(&connection_);
|
| + QuicConnectionPeer::SetAckMode(&connection_, QuicConnection::ACK_DECIMATION);
|
|
|
| const size_t kMinRttMs = 40;
|
| RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_);
|
| @@ -4423,6 +4423,142 @@ TEST_P(QuicConnectionTest, SendDelayedAckDecimation) {
|
| EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
|
| }
|
|
|
| +TEST_P(QuicConnectionTest, SendDelayedAckDecimationWithReordering) {
|
| + FLAGS_quic_ack_decimation2 = true;
|
| + QuicConnectionPeer::SetAckMode(
|
| + &connection_, QuicConnection::ACK_DECIMATION_WITH_REORDERING);
|
| +
|
| + const size_t kMinRttMs = 40;
|
| + RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_);
|
| + rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs),
|
| + QuicTime::Delta::Zero(), QuicTime::Zero());
|
| + // The ack time should be based on min_rtt/4, since it's less than the
|
| + // default delayed ack time.
|
| + QuicTime ack_time = clock_.ApproximateNow().Add(
|
| + QuicTime::Delta::FromMilliseconds(kMinRttMs / 4));
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| + EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
|
| + const uint8_t tag = 0x07;
|
| + connection_.SetDecrypter(ENCRYPTION_INITIAL, new StrictTaggingDecrypter(tag));
|
| + framer_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag));
|
| + // Process a packet from the non-crypto stream.
|
| + frame1_.stream_id = 3;
|
| +
|
| + // Process all the initial packets in order so there aren't missing packets.
|
| + QuicPacketNumber kFirstDecimatedPacket = 101;
|
| + for (unsigned int i = 0; i < kFirstDecimatedPacket - 1; ++i) {
|
| + EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
|
| + ProcessDataPacketAtLevel(kDefaultPathId, 1 + i, 0, !kEntropyFlag,
|
| + !kHasStopWaiting, ENCRYPTION_INITIAL);
|
| + }
|
| + EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
|
| + // The same as ProcessPacket(1) except that ENCRYPTION_INITIAL is used
|
| + // instead of ENCRYPTION_NONE.
|
| + EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
|
| + ProcessDataPacketAtLevel(kDefaultPathId, kFirstDecimatedPacket, 0,
|
| + !kEntropyFlag, !kHasStopWaiting, ENCRYPTION_INITIAL);
|
| +
|
| + // Check if delayed ack timer is running for the expected interval.
|
| + EXPECT_TRUE(connection_.GetAckAlarm()->IsSet());
|
| + EXPECT_EQ(ack_time, connection_.GetAckAlarm()->deadline());
|
| +
|
| + // Process packet 10 first and ensure the alarm is one eighth min_rtt.
|
| + EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
|
| + ProcessDataPacketAtLevel(kDefaultPathId, kFirstDecimatedPacket + 9, 0,
|
| + !kEntropyFlag, !kHasStopWaiting, ENCRYPTION_INITIAL);
|
| + ack_time = clock_.ApproximateNow().Add(QuicTime::Delta::FromMilliseconds(5));
|
| + EXPECT_TRUE(connection_.GetAckAlarm()->IsSet());
|
| + EXPECT_EQ(ack_time, connection_.GetAckAlarm()->deadline());
|
| +
|
| + // The 10th received packet causes an ack to be sent.
|
| + for (int i = 0; i < 8; ++i) {
|
| + EXPECT_TRUE(connection_.GetAckAlarm()->IsSet());
|
| + EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
|
| + ProcessDataPacketAtLevel(kDefaultPathId, kFirstDecimatedPacket + 1 + i, 0,
|
| + !kEntropyFlag, !kHasStopWaiting,
|
| + ENCRYPTION_INITIAL);
|
| + }
|
| + // Check that ack is sent and that delayed ack alarm is reset.
|
| + EXPECT_EQ(2u, writer_->frame_count());
|
| + EXPECT_FALSE(writer_->stop_waiting_frames().empty());
|
| + EXPECT_FALSE(writer_->ack_frames().empty());
|
| + EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
|
| +}
|
| +
|
| +TEST_P(QuicConnectionTest, SendDelayedAckDecimationWithLargeReordering) {
|
| + FLAGS_quic_ack_decimation2 = true;
|
| + QuicConnectionPeer::SetAckMode(
|
| + &connection_, QuicConnection::ACK_DECIMATION_WITH_REORDERING);
|
| +
|
| + const size_t kMinRttMs = 40;
|
| + RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_);
|
| + rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs),
|
| + QuicTime::Delta::Zero(), QuicTime::Zero());
|
| + // The ack time should be based on min_rtt/4, since it's less than the
|
| + // default delayed ack time.
|
| + QuicTime ack_time = clock_.ApproximateNow().Add(
|
| + QuicTime::Delta::FromMilliseconds(kMinRttMs / 4));
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| + EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
|
| + const uint8_t tag = 0x07;
|
| + connection_.SetDecrypter(ENCRYPTION_INITIAL, new StrictTaggingDecrypter(tag));
|
| + framer_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag));
|
| + // Process a packet from the non-crypto stream.
|
| + frame1_.stream_id = 3;
|
| +
|
| + // Process all the initial packets in order so there aren't missing packets.
|
| + QuicPacketNumber kFirstDecimatedPacket = 101;
|
| + for (unsigned int i = 0; i < kFirstDecimatedPacket - 1; ++i) {
|
| + EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
|
| + ProcessDataPacketAtLevel(kDefaultPathId, 1 + i, 0, !kEntropyFlag,
|
| + !kHasStopWaiting, ENCRYPTION_INITIAL);
|
| + }
|
| + EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
|
| + // The same as ProcessPacket(1) except that ENCRYPTION_INITIAL is used
|
| + // instead of ENCRYPTION_NONE.
|
| + EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
|
| + ProcessDataPacketAtLevel(kDefaultPathId, kFirstDecimatedPacket, 0,
|
| + !kEntropyFlag, !kHasStopWaiting, ENCRYPTION_INITIAL);
|
| +
|
| + // Check if delayed ack timer is running for the expected interval.
|
| + EXPECT_TRUE(connection_.GetAckAlarm()->IsSet());
|
| + EXPECT_EQ(ack_time, connection_.GetAckAlarm()->deadline());
|
| +
|
| + // Process packet 10 first and ensure the alarm is one eighth min_rtt.
|
| + EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
|
| + ProcessDataPacketAtLevel(kDefaultPathId, kFirstDecimatedPacket + 19, 0,
|
| + !kEntropyFlag, !kHasStopWaiting, ENCRYPTION_INITIAL);
|
| + ack_time = clock_.ApproximateNow().Add(QuicTime::Delta::FromMilliseconds(5));
|
| + EXPECT_TRUE(connection_.GetAckAlarm()->IsSet());
|
| + EXPECT_EQ(ack_time, connection_.GetAckAlarm()->deadline());
|
| +
|
| + // The 10th received packet causes an ack to be sent.
|
| + for (int i = 0; i < 8; ++i) {
|
| + EXPECT_TRUE(connection_.GetAckAlarm()->IsSet());
|
| + EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
|
| + ProcessDataPacketAtLevel(kDefaultPathId, kFirstDecimatedPacket + 1 + i, 0,
|
| + !kEntropyFlag, !kHasStopWaiting,
|
| + ENCRYPTION_INITIAL);
|
| + }
|
| + // Check that ack is sent and that delayed ack alarm is reset.
|
| + EXPECT_EQ(2u, writer_->frame_count());
|
| + EXPECT_FALSE(writer_->stop_waiting_frames().empty());
|
| + EXPECT_FALSE(writer_->ack_frames().empty());
|
| + EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
|
| +
|
| + // The next packet received in order will cause an immediate ack,
|
| + // because it fills a hole.
|
| + EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
|
| + EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
|
| + ProcessDataPacketAtLevel(kDefaultPathId, kFirstDecimatedPacket + 10, 0,
|
| + !kEntropyFlag, !kHasStopWaiting, ENCRYPTION_INITIAL);
|
| + // Check that ack is sent and that delayed ack alarm is reset.
|
| + EXPECT_EQ(2u, writer_->frame_count());
|
| + EXPECT_FALSE(writer_->stop_waiting_frames().empty());
|
| + EXPECT_FALSE(writer_->ack_frames().empty());
|
| + EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
|
| +}
|
| +
|
| TEST_P(QuicConnectionTest, SendDelayedAckOnHandshakeConfirmed) {
|
| EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| ProcessPacket(kDefaultPathId, 1);
|
|
|