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/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 2895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2906 | 2906 |
2907 // Now recevie and ACK of the previous packet, which will move the | 2907 // Now recevie and ACK of the previous packet, which will move the |
2908 // ping alarm forward. | 2908 // ping alarm forward. |
2909 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); | 2909 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); |
2910 QuicAckFrame frame = InitAckFrame(1); | 2910 QuicAckFrame frame = InitAckFrame(1); |
2911 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2911 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
2912 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2912 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
2913 ProcessAckPacket(&frame); | 2913 ProcessAckPacket(&frame); |
2914 EXPECT_TRUE(connection_.GetPingAlarm()->IsSet()); | 2914 EXPECT_TRUE(connection_.GetPingAlarm()->IsSet()); |
2915 // The ping timer is set slightly less than 15 seconds in the future, because | 2915 // The ping timer is set slightly less than 15 seconds in the future, because |
2916 // of the 1s ping timer alarm granularity. | 2916 // of the 1st ping timer alarm granularity. |
Ryan Hamilton
2016/09/02 21:26:52
this really mean 1 second, not first.
Zhongyi Shi
2016/09/02 21:44:45
Sorry for misread the code.
| |
2917 EXPECT_EQ(clock_.ApproximateNow() + QuicTime::Delta::FromSeconds(15) - | 2917 EXPECT_EQ(clock_.ApproximateNow() + QuicTime::Delta::FromSeconds(15) - |
2918 QuicTime::Delta::FromMilliseconds(5), | 2918 QuicTime::Delta::FromMilliseconds(5), |
2919 connection_.GetPingAlarm()->deadline()); | 2919 connection_.GetPingAlarm()->deadline()); |
2920 | 2920 |
2921 writer_->Reset(); | 2921 writer_->Reset(); |
2922 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(15)); | 2922 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(15)); |
2923 connection_.GetPingAlarm()->Fire(); | 2923 connection_.GetPingAlarm()->Fire(); |
2924 EXPECT_EQ(1u, writer_->frame_count()); | 2924 EXPECT_EQ(1u, writer_->frame_count()); |
2925 ASSERT_EQ(1u, writer_->ping_frames().size()); | 2925 ASSERT_EQ(1u, writer_->ping_frames().size()); |
2926 writer_->Reset(); | 2926 writer_->Reset(); |
2927 | 2927 |
2928 EXPECT_CALL(visitor_, HasOpenDynamicStreams()).WillRepeatedly(Return(false)); | 2928 EXPECT_CALL(visitor_, HasOpenDynamicStreams()).WillRepeatedly(Return(false)); |
2929 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); | 2929 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); |
2930 SendAckPacketToPeer(); | 2930 SendAckPacketToPeer(); |
2931 | 2931 |
2932 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); | 2932 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); |
2933 } | 2933 } |
2934 | 2934 |
2935 TEST_P(QuicConnectionTest, ReducedPingTimeout) { | |
2936 EXPECT_TRUE(connection_.connected()); | |
2937 EXPECT_CALL(visitor_, HasOpenDynamicStreams()).WillRepeatedly(Return(true)); | |
2938 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); | |
2939 | |
2940 // Use a reduced ping timeout for this connection. | |
2941 connection_.set_ping_timeout(QuicTime::Delta::FromSeconds(10)); | |
Ryan Hamilton
2016/09/02 21:26:52
To confirm, this test fails if you comment out thi
Zhongyi Shi
2016/09/02 21:44:45
Yes! I just ran the test with this setter commente
| |
2942 | |
2943 // Advance to 5ms, and send a packet to the peer, which will set | |
2944 // the ping alarm. | |
2945 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); | |
2946 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); | |
2947 SendStreamDataToPeer(kHeadersStreamId, "GET /", 0, kFin, nullptr); | |
2948 EXPECT_TRUE(connection_.GetPingAlarm()->IsSet()); | |
2949 EXPECT_EQ(clock_.ApproximateNow() + QuicTime::Delta::FromSeconds(10), | |
2950 connection_.GetPingAlarm()->deadline()); | |
2951 | |
2952 // Now recevie and ACK of the previous packet, which will move the | |
2953 // ping alarm forward. | |
2954 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); | |
2955 QuicAckFrame frame = InitAckFrame(1); | |
2956 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | |
2957 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | |
2958 ProcessAckPacket(&frame); | |
2959 EXPECT_TRUE(connection_.GetPingAlarm()->IsSet()); | |
2960 // The ping timer is set slightly less than 10 seconds in the future, because | |
2961 // of the 1st ping timer alarm granularity. | |
2962 EXPECT_EQ(clock_.ApproximateNow() + QuicTime::Delta::FromSeconds(10) - | |
2963 QuicTime::Delta::FromMilliseconds(5), | |
2964 connection_.GetPingAlarm()->deadline()); | |
2965 | |
2966 writer_->Reset(); | |
2967 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10)); | |
2968 connection_.GetPingAlarm()->Fire(); | |
2969 EXPECT_EQ(1u, writer_->frame_count()); | |
2970 ASSERT_EQ(1u, writer_->ping_frames().size()); | |
2971 writer_->Reset(); | |
2972 | |
2973 EXPECT_CALL(visitor_, HasOpenDynamicStreams()).WillRepeatedly(Return(false)); | |
2974 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); | |
2975 SendAckPacketToPeer(); | |
2976 | |
2977 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); | |
2978 } | |
2979 | |
2935 // Tests whether sending an MTU discovery packet to peer successfully causes the | 2980 // Tests whether sending an MTU discovery packet to peer successfully causes the |
2936 // maximum packet size to increase. | 2981 // maximum packet size to increase. |
2937 TEST_P(QuicConnectionTest, SendMtuDiscoveryPacket) { | 2982 TEST_P(QuicConnectionTest, SendMtuDiscoveryPacket) { |
2938 EXPECT_TRUE(connection_.connected()); | 2983 EXPECT_TRUE(connection_.connected()); |
2939 | 2984 |
2940 // Send an MTU probe. | 2985 // Send an MTU probe. |
2941 const size_t new_mtu = kDefaultMaxPacketSize + 100; | 2986 const size_t new_mtu = kDefaultMaxPacketSize + 100; |
2942 QuicByteCount mtu_probe_size; | 2987 QuicByteCount mtu_probe_size; |
2943 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 2988 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
2944 .WillOnce(DoAll(SaveArg<3>(&mtu_probe_size), Return(true))); | 2989 .WillOnce(DoAll(SaveArg<3>(&mtu_probe_size), Return(true))); |
(...skipping 2260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5205 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); | 5250 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
5206 EXPECT_EQ(1u, writer_->frame_count()); | 5251 EXPECT_EQ(1u, writer_->frame_count()); |
5207 EXPECT_FALSE(writer_->connection_close_frames().empty()); | 5252 EXPECT_FALSE(writer_->connection_close_frames().empty()); |
5208 // Ack frame is not bundled in connection close packet. | 5253 // Ack frame is not bundled in connection close packet. |
5209 EXPECT_TRUE(writer_->ack_frames().empty()); | 5254 EXPECT_TRUE(writer_->ack_frames().empty()); |
5210 } | 5255 } |
5211 | 5256 |
5212 } // namespace | 5257 } // namespace |
5213 } // namespace test | 5258 } // namespace test |
5214 } // namespace net | 5259 } // namespace net |
OLD | NEW |