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

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

Issue 125253004: Simplify RTO interaction between the QUIC sent packet manager and the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months 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') | net/quic/test_tools/quic_test_utils.h » ('j') | 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 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 861
862 // The second tail loss probe retransmits 1 packet. 862 // The second tail loss probe retransmits 1 packet.
863 manager_.OnRetransmissionTimeout(); 863 manager_.OnRetransmissionTimeout();
864 RetransmitNextPacket(102); 864 RetransmitNextPacket(102);
865 EXPECT_FALSE(manager_.HasPendingRetransmissions()); 865 EXPECT_FALSE(manager_.HasPendingRetransmissions());
866 866
867 // Advance the time enough to ensure all packets are RTO'd. 867 // Advance the time enough to ensure all packets are RTO'd.
868 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1000)); 868 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1000));
869 869
870 // The final RTO abandons all of them. 870 // The final RTO abandons all of them.
871 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()) 871 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
872 .WillOnce(Return(QuicTime::Delta::FromMilliseconds(100)));
873 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout());
874 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _))
875 .Times(kNumSentPackets + 2);
876 manager_.OnRetransmissionTimeout(); 872 manager_.OnRetransmissionTimeout();
877 EXPECT_TRUE(manager_.HasPendingRetransmissions()); 873 EXPECT_TRUE(manager_.HasPendingRetransmissions());
878 } 874 }
879 875
880 TEST_F(QuicSentPacketManagerTest, CryptoHandshakeTimeout) { 876 TEST_F(QuicSentPacketManagerTest, CryptoHandshakeTimeout) {
881 // Send 2 crypto packets and 3 data packets. 877 // Send 2 crypto packets and 3 data packets.
882 const size_t kNumSentCryptoPackets = 2; 878 const size_t kNumSentCryptoPackets = 2;
883 for (size_t i = 1; i <= kNumSentCryptoPackets; ++i) { 879 for (size_t i = 1; i <= kNumSentCryptoPackets; ++i) {
884 SendCryptoPacket(i); 880 SendCryptoPacket(i);
885 } 881 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 EXPECT_FALSE(QuicSentPacketManagerPeer::HasUnackedCryptoPackets(&manager_)); 915 EXPECT_FALSE(QuicSentPacketManagerPeer::HasUnackedCryptoPackets(&manager_));
920 } 916 }
921 917
922 TEST_F(QuicSentPacketManagerTest, RetransmissionTimeout) { 918 TEST_F(QuicSentPacketManagerTest, RetransmissionTimeout) {
923 // Send 100 packets and then ensure all are abandoned when the RTO fires. 919 // Send 100 packets and then ensure all are abandoned when the RTO fires.
924 const size_t kNumSentPackets = 100; 920 const size_t kNumSentPackets = 100;
925 for (size_t i = 1; i <= kNumSentPackets; ++i) { 921 for (size_t i = 1; i <= kNumSentPackets; ++i) {
926 SendDataPacket(i); 922 SendDataPacket(i);
927 } 923 }
928 924
929 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(kNumSentPackets); 925 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
930
931 EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
932 .WillOnce(Return(QuicTime::Delta::FromMilliseconds(1)));
933 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout());
934 manager_.OnRetransmissionTimeout(); 926 manager_.OnRetransmissionTimeout();
935 } 927 }
936 928
937 TEST_F(QuicSentPacketManagerTest, GetTransmissionTime) { 929 TEST_F(QuicSentPacketManagerTest, GetTransmissionTime) {
938 EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime()); 930 EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime());
939 } 931 }
940 932
941 TEST_F(QuicSentPacketManagerTest, GetTransmissionTimeCryptoHandshake) { 933 TEST_F(QuicSentPacketManagerTest, GetTransmissionTimeCryptoHandshake) {
942 SendCryptoPacket(1); 934 SendCryptoPacket(1);
943 935
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 SendDataPacket(1); 998 SendDataPacket(1);
1007 SendDataPacket(2); 999 SendDataPacket(2);
1008 1000
1009 QuicTime::Delta expected_rto_delay = QuicTime::Delta::FromMilliseconds(500); 1001 QuicTime::Delta expected_rto_delay = QuicTime::Delta::FromMilliseconds(500);
1010 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()) 1002 EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
1011 .WillRepeatedly(Return(expected_rto_delay)); 1003 .WillRepeatedly(Return(expected_rto_delay));
1012 QuicTime expected_time = clock_.Now().Add(expected_rto_delay); 1004 QuicTime expected_time = clock_.Now().Add(expected_rto_delay);
1013 EXPECT_EQ(expected_time, manager_.GetRetransmissionTime()); 1005 EXPECT_EQ(expected_time, manager_.GetRetransmissionTime());
1014 1006
1015 // Retransmit the packet by invoking the retransmission timeout. 1007 // Retransmit the packet by invoking the retransmission timeout.
1016 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(2); 1008 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
1017 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout());
1018 clock_.AdvanceTime(expected_rto_delay); 1009 clock_.AdvanceTime(expected_rto_delay);
1019 manager_.OnRetransmissionTimeout(); 1010 manager_.OnRetransmissionTimeout();
1020 RetransmitNextPacket(3); 1011 RetransmitNextPacket(3);
1021 RetransmitNextPacket(4); 1012 RetransmitNextPacket(4);
1022 EXPECT_FALSE(manager_.HasPendingRetransmissions()); 1013 EXPECT_FALSE(manager_.HasPendingRetransmissions());
1023 1014
1024 // The delay should double the second time. 1015 // The delay should double the second time.
1025 expected_time = clock_.Now().Add(expected_rto_delay).Add(expected_rto_delay); 1016 expected_time = clock_.Now().Add(expected_rto_delay).Add(expected_rto_delay);
1026 EXPECT_EQ(expected_time, manager_.GetRetransmissionTime()); 1017 EXPECT_EQ(expected_time, manager_.GetRetransmissionTime());
1027 } 1018 }
(...skipping 18 matching lines...) Expand all
1046 SendDataPacket(1); 1037 SendDataPacket(1);
1047 QuicTime::Delta delay = QuicTime::Delta::FromMilliseconds(500); 1038 QuicTime::Delta delay = QuicTime::Delta::FromMilliseconds(500);
1048 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()) 1039 EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
1049 .WillRepeatedly(Return(delay)); 1040 .WillRepeatedly(Return(delay));
1050 1041
1051 // Delay should back off exponentially. 1042 // Delay should back off exponentially.
1052 for (int i = 0; i < 5; ++i) { 1043 for (int i = 0; i < 5; ++i) {
1053 EXPECT_EQ(delay, 1044 EXPECT_EQ(delay,
1054 QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_)); 1045 QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_));
1055 delay = delay.Add(delay); 1046 delay = delay.Add(delay);
1056 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(i + 1, _)); 1047 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
1057 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout());
1058 manager_.OnRetransmissionTimeout(); 1048 manager_.OnRetransmissionTimeout();
1059 RetransmitNextPacket(i + 2); 1049 RetransmitNextPacket(i + 2);
1060 } 1050 }
1061 } 1051 }
1062 1052
1063 } // namespace 1053 } // namespace
1064 } // namespace test 1054 } // namespace test
1065 } // namespace net 1055 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_sent_packet_manager.cc ('k') | net/quic/test_tools/quic_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698