OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_sent_packet_manager.h" | 5 #include "net/quic/core/quic_sent_packet_manager.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "net/quic/core/quic_flags.h" | 10 #include "net/quic/core/quic_flags.h" |
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 // Retransmit the packet by invoking the retransmission timeout. | 1158 // Retransmit the packet by invoking the retransmission timeout. |
1159 clock_.AdvanceTime(1.5 * srtt); | 1159 clock_.AdvanceTime(1.5 * srtt); |
1160 manager_.OnRetransmissionTimeout(); | 1160 manager_.OnRetransmissionTimeout(); |
1161 RetransmitNextPacket(2); | 1161 RetransmitNextPacket(2); |
1162 | 1162 |
1163 // The retransmission time should now be twice as far in the future. | 1163 // The retransmission time should now be twice as far in the future. |
1164 expected_time = clock_.Now() + srtt * 2 * 1.5; | 1164 expected_time = clock_.Now() + srtt * 2 * 1.5; |
1165 EXPECT_EQ(expected_time, manager_.GetRetransmissionTime()); | 1165 EXPECT_EQ(expected_time, manager_.GetRetransmissionTime()); |
1166 } | 1166 } |
1167 | 1167 |
| 1168 TEST_P(QuicSentPacketManagerTest, |
| 1169 GetConservativeTransmissionTimeCryptoHandshake) { |
| 1170 FLAGS_quic_conservative_handshake_retransmits = true; |
| 1171 QuicConfig config; |
| 1172 QuicTagVector options; |
| 1173 options.push_back(kCONH); |
| 1174 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); |
| 1175 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); |
| 1176 EXPECT_CALL(*network_change_visitor_, OnCongestionChange()); |
| 1177 manager_.SetFromConfig(config); |
| 1178 // Calling SetFromConfig requires mocking out some send algorithm methods. |
| 1179 EXPECT_CALL(*send_algorithm_, PacingRate(_)) |
| 1180 .WillRepeatedly(Return(QuicBandwidth::Zero())); |
| 1181 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) |
| 1182 .WillRepeatedly(Return(10 * kDefaultTCPMSS)); |
| 1183 |
| 1184 SendCryptoPacket(1); |
| 1185 |
| 1186 // Check the min. |
| 1187 RttStats* rtt_stats = const_cast<RttStats*>(manager_.GetRttStats()); |
| 1188 rtt_stats->set_initial_rtt_us(1 * kNumMicrosPerMilli); |
| 1189 EXPECT_EQ(clock_.Now() + QuicTime::Delta::FromMilliseconds(25), |
| 1190 manager_.GetRetransmissionTime()); |
| 1191 |
| 1192 // Test with a standard smoothed RTT. |
| 1193 rtt_stats->set_initial_rtt_us(100 * kNumMicrosPerMilli); |
| 1194 |
| 1195 QuicTime::Delta srtt = |
| 1196 QuicTime::Delta::FromMicroseconds(rtt_stats->initial_rtt_us()); |
| 1197 QuicTime expected_time = clock_.Now() + 2 * srtt; |
| 1198 EXPECT_EQ(expected_time, manager_.GetRetransmissionTime()); |
| 1199 |
| 1200 // Retransmit the packet by invoking the retransmission timeout. |
| 1201 clock_.AdvanceTime(2 * srtt); |
| 1202 manager_.OnRetransmissionTimeout(); |
| 1203 RetransmitNextPacket(2); |
| 1204 |
| 1205 // The retransmission time should now be twice as far in the future. |
| 1206 expected_time = clock_.Now() + srtt * 2 * 2; |
| 1207 EXPECT_EQ(expected_time, manager_.GetRetransmissionTime()); |
| 1208 } |
| 1209 |
1168 TEST_P(QuicSentPacketManagerTest, GetTransmissionTimeTailLossProbe) { | 1210 TEST_P(QuicSentPacketManagerTest, GetTransmissionTimeTailLossProbe) { |
1169 QuicSentPacketManagerPeer::SetMaxTailLossProbes(&manager_, 2); | 1211 QuicSentPacketManagerPeer::SetMaxTailLossProbes(&manager_, 2); |
1170 SendDataPacket(1); | 1212 SendDataPacket(1); |
1171 SendDataPacket(2); | 1213 SendDataPacket(2); |
1172 | 1214 |
1173 // Check the min. | 1215 // Check the min. |
1174 RttStats* rtt_stats = const_cast<RttStats*>(manager_.GetRttStats()); | 1216 RttStats* rtt_stats = const_cast<RttStats*>(manager_.GetRttStats()); |
1175 rtt_stats->set_initial_rtt_us(1 * kNumMicrosPerMilli); | 1217 rtt_stats->set_initial_rtt_us(1 * kNumMicrosPerMilli); |
1176 EXPECT_EQ(clock_.Now() + QuicTime::Delta::FromMilliseconds(10), | 1218 EXPECT_EQ(clock_.Now() + QuicTime::Delta::FromMilliseconds(10), |
1177 manager_.GetRetransmissionTime()); | 1219 manager_.GetRetransmissionTime()); |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1661 ExpectAck(1); | 1703 ExpectAck(1); |
1662 EXPECT_CALL(*network_change_visitor_, | 1704 EXPECT_CALL(*network_change_visitor_, |
1663 OnPathMtuIncreased(kDefaultLength + 100)); | 1705 OnPathMtuIncreased(kDefaultLength + 100)); |
1664 QuicAckFrame ack_frame = InitAckFrame(1); | 1706 QuicAckFrame ack_frame = InitAckFrame(1); |
1665 manager_.OnIncomingAck(ack_frame, clock_.Now()); | 1707 manager_.OnIncomingAck(ack_frame, clock_.Now()); |
1666 } | 1708 } |
1667 | 1709 |
1668 } // namespace | 1710 } // namespace |
1669 } // namespace test | 1711 } // namespace test |
1670 } // namespace net | 1712 } // namespace net |
OLD | NEW |