OLD | NEW |
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 <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 3566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3577 EXPECT_EQ(2u, writer_->frame_count()); | 3577 EXPECT_EQ(2u, writer_->frame_count()); |
3578 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); | 3578 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); |
3579 EXPECT_FALSE(writer_->ack_frames().empty()); | 3579 EXPECT_FALSE(writer_->ack_frames().empty()); |
3580 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3580 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
3581 } | 3581 } |
3582 | 3582 |
3583 TEST_P(QuicConnectionTest, SendDelayedAckDecimation) { | 3583 TEST_P(QuicConnectionTest, SendDelayedAckDecimation) { |
3584 QuicConnectionPeer::SetAckMode(&connection_, QuicConnection::ACK_DECIMATION); | 3584 QuicConnectionPeer::SetAckMode(&connection_, QuicConnection::ACK_DECIMATION); |
3585 | 3585 |
3586 const size_t kMinRttMs = 40; | 3586 const size_t kMinRttMs = 40; |
3587 RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_); | 3587 RttStats* rtt_stats = const_cast<RttStats*>(manager_->GetRttStats()); |
3588 rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs), | 3588 rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs), |
3589 QuicTime::Delta::Zero(), QuicTime::Zero()); | 3589 QuicTime::Delta::Zero(), QuicTime::Zero()); |
3590 // The ack time should be based on min_rtt/4, since it's less than the | 3590 // The ack time should be based on min_rtt/4, since it's less than the |
3591 // default delayed ack time. | 3591 // default delayed ack time. |
3592 QuicTime ack_time = clock_.ApproximateNow().Add( | 3592 QuicTime ack_time = clock_.ApproximateNow().Add( |
3593 QuicTime::Delta::FromMilliseconds(kMinRttMs / 4)); | 3593 QuicTime::Delta::FromMilliseconds(kMinRttMs / 4)); |
3594 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3594 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3595 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3595 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
3596 const uint8_t tag = 0x07; | 3596 const uint8_t tag = 0x07; |
3597 connection_.SetDecrypter(ENCRYPTION_INITIAL, new StrictTaggingDecrypter(tag)); | 3597 connection_.SetDecrypter(ENCRYPTION_INITIAL, new StrictTaggingDecrypter(tag)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3630 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); | 3630 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); |
3631 EXPECT_FALSE(writer_->ack_frames().empty()); | 3631 EXPECT_FALSE(writer_->ack_frames().empty()); |
3632 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3632 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
3633 } | 3633 } |
3634 | 3634 |
3635 TEST_P(QuicConnectionTest, SendDelayedAckDecimationEighthRtt) { | 3635 TEST_P(QuicConnectionTest, SendDelayedAckDecimationEighthRtt) { |
3636 QuicConnectionPeer::SetAckMode(&connection_, QuicConnection::ACK_DECIMATION); | 3636 QuicConnectionPeer::SetAckMode(&connection_, QuicConnection::ACK_DECIMATION); |
3637 QuicConnectionPeer::SetAckDecimationDelay(&connection_, 0.125); | 3637 QuicConnectionPeer::SetAckDecimationDelay(&connection_, 0.125); |
3638 | 3638 |
3639 const size_t kMinRttMs = 40; | 3639 const size_t kMinRttMs = 40; |
3640 RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_); | 3640 RttStats* rtt_stats = const_cast<RttStats*>(manager_->GetRttStats()); |
3641 rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs), | 3641 rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs), |
3642 QuicTime::Delta::Zero(), QuicTime::Zero()); | 3642 QuicTime::Delta::Zero(), QuicTime::Zero()); |
3643 // The ack time should be based on min_rtt/8, since it's less than the | 3643 // The ack time should be based on min_rtt/8, since it's less than the |
3644 // default delayed ack time. | 3644 // default delayed ack time. |
3645 QuicTime ack_time = clock_.ApproximateNow().Add( | 3645 QuicTime ack_time = clock_.ApproximateNow().Add( |
3646 QuicTime::Delta::FromMilliseconds(kMinRttMs / 8)); | 3646 QuicTime::Delta::FromMilliseconds(kMinRttMs / 8)); |
3647 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3647 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3648 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3648 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
3649 const uint8_t tag = 0x07; | 3649 const uint8_t tag = 0x07; |
3650 connection_.SetDecrypter(ENCRYPTION_INITIAL, new StrictTaggingDecrypter(tag)); | 3650 connection_.SetDecrypter(ENCRYPTION_INITIAL, new StrictTaggingDecrypter(tag)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3683 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); | 3683 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); |
3684 EXPECT_FALSE(writer_->ack_frames().empty()); | 3684 EXPECT_FALSE(writer_->ack_frames().empty()); |
3685 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3685 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
3686 } | 3686 } |
3687 | 3687 |
3688 TEST_P(QuicConnectionTest, SendDelayedAckDecimationWithReordering) { | 3688 TEST_P(QuicConnectionTest, SendDelayedAckDecimationWithReordering) { |
3689 QuicConnectionPeer::SetAckMode( | 3689 QuicConnectionPeer::SetAckMode( |
3690 &connection_, QuicConnection::ACK_DECIMATION_WITH_REORDERING); | 3690 &connection_, QuicConnection::ACK_DECIMATION_WITH_REORDERING); |
3691 | 3691 |
3692 const size_t kMinRttMs = 40; | 3692 const size_t kMinRttMs = 40; |
3693 RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_); | 3693 RttStats* rtt_stats = const_cast<RttStats*>(manager_->GetRttStats()); |
3694 rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs), | 3694 rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs), |
3695 QuicTime::Delta::Zero(), QuicTime::Zero()); | 3695 QuicTime::Delta::Zero(), QuicTime::Zero()); |
3696 // The ack time should be based on min_rtt/4, since it's less than the | 3696 // The ack time should be based on min_rtt/4, since it's less than the |
3697 // default delayed ack time. | 3697 // default delayed ack time. |
3698 QuicTime ack_time = clock_.ApproximateNow().Add( | 3698 QuicTime ack_time = clock_.ApproximateNow().Add( |
3699 QuicTime::Delta::FromMilliseconds(kMinRttMs / 4)); | 3699 QuicTime::Delta::FromMilliseconds(kMinRttMs / 4)); |
3700 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3700 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3701 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3701 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
3702 const uint8_t tag = 0x07; | 3702 const uint8_t tag = 0x07; |
3703 connection_.SetDecrypter(ENCRYPTION_INITIAL, new StrictTaggingDecrypter(tag)); | 3703 connection_.SetDecrypter(ENCRYPTION_INITIAL, new StrictTaggingDecrypter(tag)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3744 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); | 3744 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); |
3745 EXPECT_FALSE(writer_->ack_frames().empty()); | 3745 EXPECT_FALSE(writer_->ack_frames().empty()); |
3746 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3746 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
3747 } | 3747 } |
3748 | 3748 |
3749 TEST_P(QuicConnectionTest, SendDelayedAckDecimationWithLargeReordering) { | 3749 TEST_P(QuicConnectionTest, SendDelayedAckDecimationWithLargeReordering) { |
3750 QuicConnectionPeer::SetAckMode( | 3750 QuicConnectionPeer::SetAckMode( |
3751 &connection_, QuicConnection::ACK_DECIMATION_WITH_REORDERING); | 3751 &connection_, QuicConnection::ACK_DECIMATION_WITH_REORDERING); |
3752 | 3752 |
3753 const size_t kMinRttMs = 40; | 3753 const size_t kMinRttMs = 40; |
3754 RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_); | 3754 RttStats* rtt_stats = const_cast<RttStats*>(manager_->GetRttStats()); |
3755 rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs), | 3755 rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs), |
3756 QuicTime::Delta::Zero(), QuicTime::Zero()); | 3756 QuicTime::Delta::Zero(), QuicTime::Zero()); |
3757 // The ack time should be based on min_rtt/4, since it's less than the | 3757 // The ack time should be based on min_rtt/4, since it's less than the |
3758 // default delayed ack time. | 3758 // default delayed ack time. |
3759 QuicTime ack_time = clock_.ApproximateNow().Add( | 3759 QuicTime ack_time = clock_.ApproximateNow().Add( |
3760 QuicTime::Delta::FromMilliseconds(kMinRttMs / 4)); | 3760 QuicTime::Delta::FromMilliseconds(kMinRttMs / 4)); |
3761 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3761 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3762 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3762 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
3763 const uint8_t tag = 0x07; | 3763 const uint8_t tag = 0x07; |
3764 connection_.SetDecrypter(ENCRYPTION_INITIAL, new StrictTaggingDecrypter(tag)); | 3764 connection_.SetDecrypter(ENCRYPTION_INITIAL, new StrictTaggingDecrypter(tag)); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3818 EXPECT_FALSE(writer_->ack_frames().empty()); | 3818 EXPECT_FALSE(writer_->ack_frames().empty()); |
3819 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3819 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
3820 } | 3820 } |
3821 | 3821 |
3822 TEST_P(QuicConnectionTest, SendDelayedAckDecimationWithReorderingEighthRtt) { | 3822 TEST_P(QuicConnectionTest, SendDelayedAckDecimationWithReorderingEighthRtt) { |
3823 QuicConnectionPeer::SetAckMode( | 3823 QuicConnectionPeer::SetAckMode( |
3824 &connection_, QuicConnection::ACK_DECIMATION_WITH_REORDERING); | 3824 &connection_, QuicConnection::ACK_DECIMATION_WITH_REORDERING); |
3825 QuicConnectionPeer::SetAckDecimationDelay(&connection_, 0.125); | 3825 QuicConnectionPeer::SetAckDecimationDelay(&connection_, 0.125); |
3826 | 3826 |
3827 const size_t kMinRttMs = 40; | 3827 const size_t kMinRttMs = 40; |
3828 RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_); | 3828 RttStats* rtt_stats = const_cast<RttStats*>(manager_->GetRttStats()); |
3829 rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs), | 3829 rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs), |
3830 QuicTime::Delta::Zero(), QuicTime::Zero()); | 3830 QuicTime::Delta::Zero(), QuicTime::Zero()); |
3831 // The ack time should be based on min_rtt/8, since it's less than the | 3831 // The ack time should be based on min_rtt/8, since it's less than the |
3832 // default delayed ack time. | 3832 // default delayed ack time. |
3833 QuicTime ack_time = clock_.ApproximateNow().Add( | 3833 QuicTime ack_time = clock_.ApproximateNow().Add( |
3834 QuicTime::Delta::FromMilliseconds(kMinRttMs / 8)); | 3834 QuicTime::Delta::FromMilliseconds(kMinRttMs / 8)); |
3835 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3835 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3836 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3836 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
3837 const uint8_t tag = 0x07; | 3837 const uint8_t tag = 0x07; |
3838 connection_.SetDecrypter(ENCRYPTION_INITIAL, new StrictTaggingDecrypter(tag)); | 3838 connection_.SetDecrypter(ENCRYPTION_INITIAL, new StrictTaggingDecrypter(tag)); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3881 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3881 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
3882 } | 3882 } |
3883 | 3883 |
3884 TEST_P(QuicConnectionTest, | 3884 TEST_P(QuicConnectionTest, |
3885 SendDelayedAckDecimationWithLargeReorderingEighthRtt) { | 3885 SendDelayedAckDecimationWithLargeReorderingEighthRtt) { |
3886 QuicConnectionPeer::SetAckMode( | 3886 QuicConnectionPeer::SetAckMode( |
3887 &connection_, QuicConnection::ACK_DECIMATION_WITH_REORDERING); | 3887 &connection_, QuicConnection::ACK_DECIMATION_WITH_REORDERING); |
3888 QuicConnectionPeer::SetAckDecimationDelay(&connection_, 0.125); | 3888 QuicConnectionPeer::SetAckDecimationDelay(&connection_, 0.125); |
3889 | 3889 |
3890 const size_t kMinRttMs = 40; | 3890 const size_t kMinRttMs = 40; |
3891 RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_); | 3891 RttStats* rtt_stats = const_cast<RttStats*>(manager_->GetRttStats()); |
3892 rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs), | 3892 rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs), |
3893 QuicTime::Delta::Zero(), QuicTime::Zero()); | 3893 QuicTime::Delta::Zero(), QuicTime::Zero()); |
3894 // The ack time should be based on min_rtt/8, since it's less than the | 3894 // The ack time should be based on min_rtt/8, since it's less than the |
3895 // default delayed ack time. | 3895 // default delayed ack time. |
3896 QuicTime ack_time = clock_.ApproximateNow().Add( | 3896 QuicTime ack_time = clock_.ApproximateNow().Add( |
3897 QuicTime::Delta::FromMilliseconds(kMinRttMs / 8)); | 3897 QuicTime::Delta::FromMilliseconds(kMinRttMs / 8)); |
3898 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3898 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3899 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3899 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
3900 const uint8_t tag = 0x07; | 3900 const uint8_t tag = 0x07; |
3901 connection_.SetDecrypter(ENCRYPTION_INITIAL, new StrictTaggingDecrypter(tag)); | 3901 connection_.SetDecrypter(ENCRYPTION_INITIAL, new StrictTaggingDecrypter(tag)); |
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4959 EXPECT_CALL(visitor_, OnConnectionClosed(_, _, _)).Times(1); | 4959 EXPECT_CALL(visitor_, OnConnectionClosed(_, _, _)).Times(1); |
4960 connection_.CloseConnection(QUIC_NO_ERROR, "no reason", | 4960 connection_.CloseConnection(QUIC_NO_ERROR, "no reason", |
4961 ConnectionCloseBehavior::SILENT_CLOSE); | 4961 ConnectionCloseBehavior::SILENT_CLOSE); |
4962 connection_.CloseConnection(QUIC_NO_ERROR, "no reason", | 4962 connection_.CloseConnection(QUIC_NO_ERROR, "no reason", |
4963 ConnectionCloseBehavior::SILENT_CLOSE); | 4963 ConnectionCloseBehavior::SILENT_CLOSE); |
4964 } | 4964 } |
4965 | 4965 |
4966 } // namespace | 4966 } // namespace |
4967 } // namespace test | 4967 } // namespace test |
4968 } // namespace net | 4968 } // namespace net |
OLD | NEW |