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 1926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1937 // Parse the last packet and ensure it's one stream frame from one stream. | 1937 // Parse the last packet and ensure it's one stream frame from one stream. |
1938 EXPECT_EQ(1u, writer_->frame_count()); | 1938 EXPECT_EQ(1u, writer_->frame_count()); |
1939 EXPECT_EQ(1u, writer_->stream_frames().size()); | 1939 EXPECT_EQ(1u, writer_->stream_frames().size()); |
1940 EXPECT_EQ(1u, writer_->stream_frames()[0]->stream_id); | 1940 EXPECT_EQ(1u, writer_->stream_frames()[0]->stream_id); |
1941 } | 1941 } |
1942 | 1942 |
1943 TEST_P(QuicConnectionTest, SendingZeroBytes) { | 1943 TEST_P(QuicConnectionTest, SendingZeroBytes) { |
1944 // Send a zero byte write with a fin using writev. | 1944 // Send a zero byte write with a fin using writev. |
1945 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 1945 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
1946 QuicIOVector empty_iov(nullptr, 0, 0); | 1946 QuicIOVector empty_iov(nullptr, 0, 0); |
1947 connection_.SendStreamData(1, empty_iov, 0, kFin, nullptr); | 1947 connection_.SendStreamData(kHeadersStreamId, empty_iov, 0, kFin, nullptr); |
1948 | 1948 |
1949 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 1949 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
1950 EXPECT_FALSE(connection_.HasQueuedData()); | 1950 EXPECT_FALSE(connection_.HasQueuedData()); |
1951 | 1951 |
1952 // Parse the last packet and ensure it's one stream frame from one stream. | 1952 // Parse the last packet and ensure it's one stream frame from one stream. |
1953 EXPECT_EQ(1u, writer_->frame_count()); | 1953 EXPECT_EQ(1u, writer_->frame_count()); |
1954 EXPECT_EQ(1u, writer_->stream_frames().size()); | 1954 EXPECT_EQ(1u, writer_->stream_frames().size()); |
1955 EXPECT_EQ(1u, writer_->stream_frames()[0]->stream_id); | 1955 EXPECT_EQ(kHeadersStreamId, writer_->stream_frames()[0]->stream_id); |
1956 EXPECT_TRUE(writer_->stream_frames()[0]->fin); | 1956 EXPECT_TRUE(writer_->stream_frames()[0]->fin); |
1957 } | 1957 } |
1958 | 1958 |
1959 TEST_P(QuicConnectionTest, OnCanWrite) { | 1959 TEST_P(QuicConnectionTest, OnCanWrite) { |
1960 // Visitor's OnCanWrite will send data, but will have more pending writes. | 1960 // Visitor's OnCanWrite will send data, but will have more pending writes. |
1961 EXPECT_CALL(visitor_, OnCanWrite()) | 1961 EXPECT_CALL(visitor_, OnCanWrite()) |
1962 .WillOnce(DoAll(IgnoreResult(InvokeWithoutArgs( | 1962 .WillOnce(DoAll(IgnoreResult(InvokeWithoutArgs( |
1963 &connection_, &TestConnection::SendStreamData3)), | 1963 &connection_, &TestConnection::SendStreamData3)), |
1964 IgnoreResult(InvokeWithoutArgs( | 1964 IgnoreResult(InvokeWithoutArgs( |
1965 &connection_, &TestConnection::SendStreamData5)))); | 1965 &connection_, &TestConnection::SendStreamData5)))); |
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2890 connection_.SetNetworkTimeouts(timeout, timeout); | 2890 connection_.SetNetworkTimeouts(timeout, timeout); |
2891 EXPECT_TRUE(connection_.connected()); | 2891 EXPECT_TRUE(connection_.connected()); |
2892 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AnyNumber()); | 2892 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AnyNumber()); |
2893 | 2893 |
2894 QuicTime handshake_timeout = clock_.ApproximateNow().Add(timeout).Subtract( | 2894 QuicTime handshake_timeout = clock_.ApproximateNow().Add(timeout).Subtract( |
2895 QuicTime::Delta::FromSeconds(1)); | 2895 QuicTime::Delta::FromSeconds(1)); |
2896 EXPECT_EQ(handshake_timeout, connection_.GetTimeoutAlarm()->deadline()); | 2896 EXPECT_EQ(handshake_timeout, connection_.GetTimeoutAlarm()->deadline()); |
2897 EXPECT_TRUE(connection_.connected()); | 2897 EXPECT_TRUE(connection_.connected()); |
2898 | 2898 |
2899 // Send and ack new data 3 seconds later to lengthen the idle timeout. | 2899 // Send and ack new data 3 seconds later to lengthen the idle timeout. |
2900 SendStreamDataToPeer(1, "GET /", 0, kFin, nullptr); | 2900 SendStreamDataToPeer(kHeadersStreamId, "GET /", 0, kFin, nullptr); |
2901 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(3)); | 2901 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(3)); |
2902 QuicAckFrame frame = InitAckFrame(1); | 2902 QuicAckFrame frame = InitAckFrame(1); |
2903 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2903 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
2904 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2904 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
2905 ProcessAckPacket(&frame); | 2905 ProcessAckPacket(&frame); |
2906 | 2906 |
2907 // Fire early to verify it wouldn't timeout yet. | 2907 // Fire early to verify it wouldn't timeout yet. |
2908 connection_.GetTimeoutAlarm()->Fire(); | 2908 connection_.GetTimeoutAlarm()->Fire(); |
2909 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); | 2909 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); |
2910 EXPECT_TRUE(connection_.connected()); | 2910 EXPECT_TRUE(connection_.connected()); |
(...skipping 17 matching lines...) Expand all Loading... |
2928 | 2928 |
2929 TEST_P(QuicConnectionTest, PingAfterSend) { | 2929 TEST_P(QuicConnectionTest, PingAfterSend) { |
2930 EXPECT_TRUE(connection_.connected()); | 2930 EXPECT_TRUE(connection_.connected()); |
2931 EXPECT_CALL(visitor_, HasOpenDynamicStreams()).WillRepeatedly(Return(true)); | 2931 EXPECT_CALL(visitor_, HasOpenDynamicStreams()).WillRepeatedly(Return(true)); |
2932 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); | 2932 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); |
2933 | 2933 |
2934 // Advance to 5ms, and send a packet to the peer, which will set | 2934 // Advance to 5ms, and send a packet to the peer, which will set |
2935 // the ping alarm. | 2935 // the ping alarm. |
2936 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); | 2936 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); |
2937 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); | 2937 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
2938 SendStreamDataToPeer(1, "GET /", 0, kFin, nullptr); | 2938 SendStreamDataToPeer(kHeadersStreamId, "GET /", 0, kFin, nullptr); |
2939 EXPECT_TRUE(connection_.GetPingAlarm()->IsSet()); | 2939 EXPECT_TRUE(connection_.GetPingAlarm()->IsSet()); |
2940 EXPECT_EQ(clock_.ApproximateNow().Add(QuicTime::Delta::FromSeconds(15)), | 2940 EXPECT_EQ(clock_.ApproximateNow().Add(QuicTime::Delta::FromSeconds(15)), |
2941 connection_.GetPingAlarm()->deadline()); | 2941 connection_.GetPingAlarm()->deadline()); |
2942 | 2942 |
2943 // Now recevie and ACK of the previous packet, which will move the | 2943 // Now recevie and ACK of the previous packet, which will move the |
2944 // ping alarm forward. | 2944 // ping alarm forward. |
2945 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); | 2945 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); |
2946 QuicAckFrame frame = InitAckFrame(1); | 2946 QuicAckFrame frame = InitAckFrame(1); |
2947 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2947 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
2948 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2948 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
(...skipping 628 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 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4956 // Verifies that multiple calls to CloseConnection do not | 4956 // Verifies that multiple calls to CloseConnection do not |
4957 // result in multiple attempts to close the connection - it will be marked as | 4957 // result in multiple attempts to close the connection - it will be marked as |
4958 // disconnected after the first call. | 4958 // disconnected after the first call. |
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 TEST_P(QuicConnectionTest, ServerReceivesChloOnNonCryptoStream) { |
| 4967 FLAGS_quic_detect_memory_corrpution = true; |
| 4968 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 4969 |
| 4970 set_perspective(Perspective::IS_SERVER); |
| 4971 QuicPacketCreatorPeer::SetSendVersionInPacket(creator_, false); |
| 4972 |
| 4973 CryptoHandshakeMessage message; |
| 4974 CryptoFramer framer; |
| 4975 message.set_tag(kCHLO); |
| 4976 std::unique_ptr<QuicData> data(framer.ConstructHandshakeMessage(message)); |
| 4977 frame1_.stream_id = 10; |
| 4978 frame1_.data_buffer = data->data(); |
| 4979 frame1_.data_length = data->length(); |
| 4980 |
| 4981 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _, |
| 4982 ConnectionCloseSource::FROM_SELF)); |
| 4983 ProcessFramePacket(QuicFrame(&frame1_)); |
| 4984 } |
| 4985 |
| 4986 TEST_P(QuicConnectionTest, ClientReceivesRejOnNonCryptoStream) { |
| 4987 FLAGS_quic_detect_memory_corrpution = true; |
| 4988 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 4989 |
| 4990 CryptoHandshakeMessage message; |
| 4991 CryptoFramer framer; |
| 4992 message.set_tag(kREJ); |
| 4993 std::unique_ptr<QuicData> data(framer.ConstructHandshakeMessage(message)); |
| 4994 frame1_.stream_id = 10; |
| 4995 frame1_.data_buffer = data->data(); |
| 4996 frame1_.data_length = data->length(); |
| 4997 |
| 4998 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _, |
| 4999 ConnectionCloseSource::FROM_SELF)); |
| 5000 ProcessFramePacket(QuicFrame(&frame1_)); |
| 5001 } |
| 5002 |
4966 } // namespace | 5003 } // namespace |
4967 } // namespace test | 5004 } // namespace test |
4968 } // namespace net | 5005 } // namespace net |
OLD | NEW |