| 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/quic_sent_packet_manager.h" | 5 #include "net/quic/quic_sent_packet_manager.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "net/quic/test_tools/quic_config_peer.h" | 8 #include "net/quic/test_tools/quic_config_peer.h" |
| 9 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" | 9 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" |
| 10 #include "net/quic/test_tools/quic_test_utils.h" | 10 #include "net/quic/test_tools/quic_test_utils.h" |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 RetransmitPacket(1, 2); | 314 RetransmitPacket(1, 2); |
| 315 QuicTime::Delta rtt = QuicTime::Delta::FromMilliseconds(15); | 315 QuicTime::Delta rtt = QuicTime::Delta::FromMilliseconds(15); |
| 316 clock_.AdvanceTime(rtt); | 316 clock_.AdvanceTime(rtt); |
| 317 | 317 |
| 318 // Ack 1 but not 2. | 318 // Ack 1 but not 2. |
| 319 ExpectAck(1); | 319 ExpectAck(1); |
| 320 ReceivedPacketInfo received_info; | 320 ReceivedPacketInfo received_info; |
| 321 received_info.largest_observed = 1; | 321 received_info.largest_observed = 1; |
| 322 manager_.OnIncomingAck(received_info, clock_.ApproximateNow()); | 322 manager_.OnIncomingAck(received_info, clock_.ApproximateNow()); |
| 323 | 323 |
| 324 // No packets should be unacked. | 324 // 2 should be unacked, since it may provide an RTT measurement. |
| 325 VerifyUnackedPackets(NULL, 0); | 325 QuicPacketSequenceNumber unacked[] = { 2 }; |
| 326 VerifyUnackedPackets(unacked, arraysize(unacked)); |
| 326 EXPECT_FALSE(QuicSentPacketManagerPeer::HasPendingPackets(&manager_)); | 327 EXPECT_FALSE(QuicSentPacketManagerPeer::HasPendingPackets(&manager_)); |
| 327 VerifyRetransmittablePackets(NULL, 0); | 328 VerifyRetransmittablePackets(NULL, 0); |
| 328 | 329 |
| 329 // Verify that the retransmission alarm would not fire, | 330 // Verify that the retransmission alarm would not fire, |
| 330 // since there is no retransmittable data outstanding. | 331 // since there is no retransmittable data outstanding. |
| 331 EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime()); | 332 EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime()); |
| 332 EXPECT_EQ(1u, stats_.packets_spuriously_retransmitted); | 333 EXPECT_EQ(1u, stats_.packets_spuriously_retransmitted); |
| 333 } | 334 } |
| 334 | 335 |
| 335 TEST_F(QuicSentPacketManagerTest, RetransmitAndSendThenAckPrevious) { | 336 TEST_F(QuicSentPacketManagerTest, RetransmitAndSendThenAckPrevious) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 EXPECT_TRUE(manager_.HasPendingRetransmissions()); | 409 EXPECT_TRUE(manager_.HasPendingRetransmissions()); |
| 409 | 410 |
| 410 // Ack 1 but not 2, before 2 is able to be sent. | 411 // Ack 1 but not 2, before 2 is able to be sent. |
| 411 // Since 1 has been retransmitted, it has already been lost, and so the | 412 // Since 1 has been retransmitted, it has already been lost, and so the |
| 412 // send algorithm is not informed that it has been ACK'd. | 413 // send algorithm is not informed that it has been ACK'd. |
| 413 ReceivedPacketInfo received_info; | 414 ReceivedPacketInfo received_info; |
| 414 received_info.largest_observed = 1; | 415 received_info.largest_observed = 1; |
| 415 ExpectUpdatedRtt(1); | 416 ExpectUpdatedRtt(1); |
| 416 manager_.OnIncomingAck(received_info, clock_.ApproximateNow()); | 417 manager_.OnIncomingAck(received_info, clock_.ApproximateNow()); |
| 417 | 418 |
| 418 // Since 2 was marked for retransmit, when 1 is acked, 2 is discarded. | 419 // Since 2 was marked for retransmit, when 1 is acked, 2 is kept for RTT. |
| 419 VerifyUnackedPackets(NULL, 0); | 420 QuicPacketSequenceNumber unacked[] = { 2 }; |
| 421 VerifyUnackedPackets(unacked, arraysize(unacked)); |
| 420 EXPECT_FALSE(QuicSentPacketManagerPeer::HasPendingPackets(&manager_)); | 422 EXPECT_FALSE(QuicSentPacketManagerPeer::HasPendingPackets(&manager_)); |
| 421 VerifyRetransmittablePackets(NULL, 0); | 423 VerifyRetransmittablePackets(NULL, 0); |
| 422 | 424 |
| 423 // Verify that the retransmission alarm would not fire, | 425 // Verify that the retransmission alarm would not fire, |
| 424 // since there is no retransmittable data outstanding. | 426 // since there is no retransmittable data outstanding. |
| 425 EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime()); | 427 EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime()); |
| 426 } | 428 } |
| 427 | 429 |
| 428 TEST_F(QuicSentPacketManagerTest, RetransmitTwiceThenAckFirst) { | 430 TEST_F(QuicSentPacketManagerTest, RetransmitTwiceThenAckFirst) { |
| 429 SendDataPacket(1); | 431 SendDataPacket(1); |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 EXPECT_TRUE(QuicSentPacketManagerPeer::HasUnackedCryptoPackets(&manager_)); | 912 EXPECT_TRUE(QuicSentPacketManagerPeer::HasUnackedCryptoPackets(&manager_)); |
| 911 | 913 |
| 912 // Retransmit the crypto packet as 2. | 914 // Retransmit the crypto packet as 2. |
| 913 manager_.OnRetransmissionTimeout(); | 915 manager_.OnRetransmissionTimeout(); |
| 914 RetransmitNextPacket(2); | 916 RetransmitNextPacket(2); |
| 915 | 917 |
| 916 // Retransmit the crypto packet as 3. | 918 // Retransmit the crypto packet as 3. |
| 917 manager_.OnRetransmissionTimeout(); | 919 manager_.OnRetransmissionTimeout(); |
| 918 RetransmitNextPacket(3); | 920 RetransmitNextPacket(3); |
| 919 | 921 |
| 920 // Now ack the first crypto packet, and ensure the second gets abandoned and | 922 // Now ack the second crypto packet, and ensure the first gets removed, but |
| 921 // removed from unacked_packets. | 923 // the third does not. |
| 922 ExpectUpdatedRtt(2); | 924 ExpectUpdatedRtt(2); |
| 923 ReceivedPacketInfo received_info; | 925 ReceivedPacketInfo received_info; |
| 924 received_info.largest_observed = 2; | 926 received_info.largest_observed = 2; |
| 925 received_info.missing_packets.insert(1); | 927 received_info.missing_packets.insert(1); |
| 926 manager_.OnIncomingAck(received_info, clock_.ApproximateNow()); | 928 manager_.OnIncomingAck(received_info, clock_.ApproximateNow()); |
| 927 | 929 |
| 928 EXPECT_FALSE(QuicSentPacketManagerPeer::HasUnackedCryptoPackets(&manager_)); | 930 EXPECT_FALSE(QuicSentPacketManagerPeer::HasUnackedCryptoPackets(&manager_)); |
| 929 VerifyUnackedPackets(NULL, 0); | 931 QuicPacketSequenceNumber unacked[] = { 3 }; |
| 932 VerifyUnackedPackets(unacked, arraysize(unacked)); |
| 930 } | 933 } |
| 931 | 934 |
| 932 TEST_F(QuicSentPacketManagerTest, CryptoHandshakeTimeoutUnsentDataPacket) { | 935 TEST_F(QuicSentPacketManagerTest, CryptoHandshakeTimeoutUnsentDataPacket) { |
| 933 // Send 2 crypto packets and serialize 1 data packet. | 936 // Send 2 crypto packets and serialize 1 data packet. |
| 934 const size_t kNumSentCryptoPackets = 2; | 937 const size_t kNumSentCryptoPackets = 2; |
| 935 for (size_t i = 1; i <= kNumSentCryptoPackets; ++i) { | 938 for (size_t i = 1; i <= kNumSentCryptoPackets; ++i) { |
| 936 SendCryptoPacket(i); | 939 SendCryptoPacket(i); |
| 937 } | 940 } |
| 938 SerializedPacket packet(CreateDataPacket(3)); | 941 SerializedPacket packet(CreateDataPacket(3)); |
| 939 manager_.OnSerializedPacket(packet); | 942 manager_.OnSerializedPacket(packet); |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1252 | 1255 |
| 1253 EXPECT_EQ(kTime, | 1256 EXPECT_EQ(kTime, |
| 1254 QuicSentPacketManagerPeer::GetLossAlgorithm( | 1257 QuicSentPacketManagerPeer::GetLossAlgorithm( |
| 1255 &manager_)->GetLossDetectionType()); | 1258 &manager_)->GetLossDetectionType()); |
| 1256 } | 1259 } |
| 1257 | 1260 |
| 1258 | 1261 |
| 1259 } // namespace | 1262 } // namespace |
| 1260 } // namespace test | 1263 } // namespace test |
| 1261 } // namespace net | 1264 } // namespace net |
| OLD | NEW |