Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: net/quic/quic_sent_packet_manager_test.cc

Issue 109993008: Fix QUIC's TCP style retransmission logic to only send a maximum of 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_sent_packet_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_sent_packet_manager_peer.h" 8 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h"
9 #include "net/quic/test_tools/quic_test_utils.h" 9 #include "net/quic/test_tools/quic_test_utils.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 received_info.largest_observed = kNumSentPackets; 624 received_info.largest_observed = kNumSentPackets;
625 EXPECT_CALL(*send_algorithm_, OnPacketAcked(kNumSentPackets, _, _)).Times(1); 625 EXPECT_CALL(*send_algorithm_, OnPacketAcked(kNumSentPackets, _, _)).Times(1);
626 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)).Times(1); 626 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)).Times(1);
627 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1); 627 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1);
628 SequenceNumberSet retransmissions = 628 SequenceNumberSet retransmissions =
629 manager_.OnIncomingAckFrame(received_info, clock_.Now()); 629 manager_.OnIncomingAckFrame(received_info, clock_.Now());
630 EXPECT_EQ(1u, retransmissions.size()); 630 EXPECT_EQ(1u, retransmissions.size());
631 EXPECT_EQ(3u, QuicSentPacketManagerPeer::GetNackCount(&manager_, 1)); 631 EXPECT_EQ(3u, QuicSentPacketManagerPeer::GetNackCount(&manager_, 1));
632 } 632 }
633 633
634 TEST_F(QuicSentPacketManagerTest, NackRetransmit10Packets) { 634 TEST_F(QuicSentPacketManagerTest, NackRetransmit2Packets) {
635 const size_t kNumSentPackets = 20; 635 const size_t kNumSentPackets = 20;
636 // Transmit 20 packets. 636 // Transmit 20 packets.
637 for (QuicPacketSequenceNumber i = 1; i <= kNumSentPackets; ++i) { 637 for (QuicPacketSequenceNumber i = 1; i <= kNumSentPackets; ++i) {
638 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 638 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
639 .Times(1).WillOnce(Return(true)); 639 .Times(1).WillOnce(Return(true));
640 manager_.OnPacketSent(i, clock_.Now(), 1000, 640 manager_.OnPacketSent(i, clock_.Now(), 1000,
641 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA); 641 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA);
642 } 642 }
643 643
644 // Nack the first 19 packets 3 times. 644 // Nack the first 19 packets 3 times.
645 ReceivedPacketInfo received_info; 645 ReceivedPacketInfo received_info;
646 received_info.largest_observed = kNumSentPackets; 646 received_info.largest_observed = kNumSentPackets;
647 received_info.delta_time_largest_observed = 647 received_info.delta_time_largest_observed =
648 QuicTime::Delta::FromMilliseconds(5); 648 QuicTime::Delta::FromMilliseconds(5);
649 for (size_t i = 1; i < kNumSentPackets; ++i) { 649 for (size_t i = 1; i < kNumSentPackets; ++i) {
650 received_info.missing_packets.insert(i); 650 received_info.missing_packets.insert(i);
651 } 651 }
652 EXPECT_CALL(*send_algorithm_, 652 EXPECT_CALL(*send_algorithm_,
653 OnPacketAcked(kNumSentPackets, _, _)).Times(1); 653 OnPacketAcked(kNumSentPackets, _, _)).Times(1);
654 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(10); 654 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(2);
655 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(10); 655 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(2);
656 SequenceNumberSet retransmissions = 656 SequenceNumberSet retransmissions =
657 manager_.OnIncomingAckFrame(received_info, clock_.Now()); 657 manager_.OnIncomingAckFrame(received_info, clock_.Now());
658 EXPECT_EQ(10u, retransmissions.size()); 658 EXPECT_EQ(2u, retransmissions.size());
659 for (size_t i = 1; i < kNumSentPackets; ++i) { 659 for (size_t i = 1; i < kNumSentPackets; ++i) {
660 EXPECT_EQ(kNumSentPackets - i, 660 EXPECT_EQ(kNumSentPackets - i,
661 QuicSentPacketManagerPeer::GetNackCount(&manager_, i)); 661 QuicSentPacketManagerPeer::GetNackCount(&manager_, i));
662 } 662 }
663 } 663 }
664 664
665 TEST_F(QuicSentPacketManagerTest, NackRetransmit10PacketsAlternateAcks) { 665 TEST_F(QuicSentPacketManagerTest, NackRetransmit2PacketsAlternateAcks) {
666 const size_t kNumSentPackets = 30; 666 const size_t kNumSentPackets = 30;
667 // Transmit 15 packets of data and 15 ack packets. The send algorithm will 667 // Transmit 15 packets of data and 15 ack packets. The send algorithm will
668 // inform the congestion manager not to save the acks by returning false. 668 // inform the congestion manager not to save the acks by returning false.
669 for (QuicPacketSequenceNumber i = 1; i <= kNumSentPackets; ++i) { 669 for (QuicPacketSequenceNumber i = 1; i <= kNumSentPackets; ++i) {
670 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 670 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
671 .Times(1).WillOnce(Return(i % 2 == 0 ? false : true)); 671 .Times(1).WillOnce(Return(i % 2 == 0 ? false : true));
672 manager_.OnPacketSent( 672 manager_.OnPacketSent(
673 i, clock_.Now(), 1000, NOT_RETRANSMISSION, 673 i, clock_.Now(), 1000, NOT_RETRANSMISSION,
674 i % 2 == 0 ? NO_RETRANSMITTABLE_DATA : HAS_RETRANSMITTABLE_DATA); 674 i % 2 == 0 ? NO_RETRANSMITTABLE_DATA : HAS_RETRANSMITTABLE_DATA);
675 } 675 }
676 676
677 // Nack the first 29 packets 3 times. 677 // Nack the first 29 packets 3 times.
678 ReceivedPacketInfo received_info; 678 ReceivedPacketInfo received_info;
679 received_info.largest_observed = kNumSentPackets; 679 received_info.largest_observed = kNumSentPackets;
680 received_info.delta_time_largest_observed = 680 received_info.delta_time_largest_observed =
681 QuicTime::Delta::FromMilliseconds(5); 681 QuicTime::Delta::FromMilliseconds(5);
682 for (size_t i = 1; i < kNumSentPackets; ++i) { 682 for (size_t i = 1; i < kNumSentPackets; ++i) {
683 received_info.missing_packets.insert(i); 683 received_info.missing_packets.insert(i);
684 } 684 }
685 // We never actually get an ack call, since the kNumSentPackets packet was 685 // We never actually get an ack call, since the kNumSentPackets packet was
686 // not saved. 686 // not saved.
687 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(10); 687 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(2);
688 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(10); 688 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(2);
689 SequenceNumberSet retransmissions = 689 SequenceNumberSet retransmissions =
690 manager_.OnIncomingAckFrame(received_info, clock_.Now()); 690 manager_.OnIncomingAckFrame(received_info, clock_.Now());
691 EXPECT_EQ(10u, retransmissions.size()); 691 EXPECT_EQ(2u, retransmissions.size());
692 // Only non-ack packets have a nack count. 692 // Only non-ack packets have a nack count.
693 for (size_t i = 1; i < kNumSentPackets; i += 2) { 693 for (size_t i = 1; i < kNumSentPackets; i += 2) {
694 EXPECT_EQ(kNumSentPackets - i, 694 EXPECT_EQ(kNumSentPackets - i,
695 QuicSentPacketManagerPeer::GetNackCount(&manager_, i)); 695 QuicSentPacketManagerPeer::GetNackCount(&manager_, i));
696 } 696 }
697 697
698 // Ensure only the odd packets were retransmitted, since the others were not 698 // Ensure only the odd packets were retransmitted, since the others were not
699 // retransmittable(ie: acks). 699 // retransmittable(ie: acks).
700 for (SequenceNumberSet::const_iterator it = retransmissions.begin(); 700 for (SequenceNumberSet::const_iterator it = retransmissions.begin();
701 it != retransmissions.end(); ++it) { 701 it != retransmissions.end(); ++it) {
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 RetransmitNextPacket(i + 2); 887 RetransmitNextPacket(i + 2);
888 } 888 }
889 889
890 // Then backoff starts 890 // Then backoff starts
891 EXPECT_EQ(delay.Add(delay), manager_.GetRetransmissionDelay()); 891 EXPECT_EQ(delay.Add(delay), manager_.GetRetransmissionDelay());
892 } 892 }
893 893
894 } // namespace 894 } // namespace
895 } // namespace test 895 } // namespace test
896 } // namespace net 896 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_sent_packet_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698