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

Side by Side Diff: net/quic/congestion_control/time_loss_algorithm_test.cc

Issue 302783003: Rename QUIC's TransmissionInfo pending to in_flight and the associated (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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/congestion_control/time_loss_algorithm.cc ('k') | net/quic/quic_protocol.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "net/quic/congestion_control/rtt_stats.h" 9 #include "net/quic/congestion_control/rtt_stats.h"
10 #include "net/quic/congestion_control/time_loss_algorithm.h" 10 #include "net/quic/congestion_control/time_loss_algorithm.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 RttStats rtt_stats_; 48 RttStats rtt_stats_;
49 MockClock clock_; 49 MockClock clock_;
50 }; 50 };
51 51
52 TEST_F(TimeLossAlgorithmTest, NoLossFor500Nacks) { 52 TEST_F(TimeLossAlgorithmTest, NoLossFor500Nacks) {
53 const size_t kNumSentPackets = 5; 53 const size_t kNumSentPackets = 5;
54 // Transmit 5 packets. 54 // Transmit 5 packets.
55 for (size_t i = 1; i <= kNumSentPackets; ++i) { 55 for (size_t i = 1; i <= kNumSentPackets; ++i) {
56 SendDataPacket(i); 56 SendDataPacket(i);
57 } 57 }
58 unacked_packets_.SetNotPending(2); 58 unacked_packets_.RemoveFromInFlight(2);
59 for (size_t i = 1; i < 500; ++i) { 59 for (size_t i = 1; i < 500; ++i) {
60 unacked_packets_.NackPacket(1, i); 60 unacked_packets_.NackPacket(1, i);
61 VerifyLosses(2, NULL, 0); 61 VerifyLosses(2, NULL, 0);
62 } 62 }
63 EXPECT_EQ(rtt_stats_.SmoothedRtt().Multiply(1.25), 63 EXPECT_EQ(rtt_stats_.SmoothedRtt().Multiply(1.25),
64 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now())); 64 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now()));
65 } 65 }
66 66
67 TEST_F(TimeLossAlgorithmTest, NoLossUntilTimeout) { 67 TEST_F(TimeLossAlgorithmTest, NoLossUntilTimeout) {
68 const size_t kNumSentPackets = 10; 68 const size_t kNumSentPackets = 10;
69 // Transmit 10 packets at 1/10th an RTT interval. 69 // Transmit 10 packets at 1/10th an RTT interval.
70 for (size_t i = 1; i <= kNumSentPackets; ++i) { 70 for (size_t i = 1; i <= kNumSentPackets; ++i) {
71 SendDataPacket(i); 71 SendDataPacket(i);
72 clock_.AdvanceTime(rtt_stats_.SmoothedRtt().Multiply(0.1)); 72 clock_.AdvanceTime(rtt_stats_.SmoothedRtt().Multiply(0.1));
73 } 73 }
74 // Expect the timer to not be set. 74 // Expect the timer to not be set.
75 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 75 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
76 // The packet should not be lost until 1.25 RTTs pass. 76 // The packet should not be lost until 1.25 RTTs pass.
77 unacked_packets_.NackPacket(1, 1); 77 unacked_packets_.NackPacket(1, 1);
78 unacked_packets_.SetNotPending(2); 78 unacked_packets_.RemoveFromInFlight(2);
79 VerifyLosses(2, NULL, 0); 79 VerifyLosses(2, NULL, 0);
80 // Expect the timer to be set to 0.25 RTT's in the future. 80 // Expect the timer to be set to 0.25 RTT's in the future.
81 EXPECT_EQ(rtt_stats_.SmoothedRtt().Multiply(0.25), 81 EXPECT_EQ(rtt_stats_.SmoothedRtt().Multiply(0.25),
82 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now())); 82 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now()));
83 unacked_packets_.NackPacket(1, 5); 83 unacked_packets_.NackPacket(1, 5);
84 VerifyLosses(2, NULL, 0); 84 VerifyLosses(2, NULL, 0);
85 clock_.AdvanceTime(rtt_stats_.SmoothedRtt().Multiply(0.25)); 85 clock_.AdvanceTime(rtt_stats_.SmoothedRtt().Multiply(0.25));
86 QuicPacketSequenceNumber lost[] = { 1 }; 86 QuicPacketSequenceNumber lost[] = { 1 };
87 VerifyLosses(2, lost, arraysize(lost)); 87 VerifyLosses(2, lost, arraysize(lost));
88 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 88 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
89 } 89 }
90 90
91 TEST_F(TimeLossAlgorithmTest, NoLossWithoutNack) { 91 TEST_F(TimeLossAlgorithmTest, NoLossWithoutNack) {
92 const size_t kNumSentPackets = 10; 92 const size_t kNumSentPackets = 10;
93 // Transmit 10 packets at 1/10th an RTT interval. 93 // Transmit 10 packets at 1/10th an RTT interval.
94 for (size_t i = 1; i <= kNumSentPackets; ++i) { 94 for (size_t i = 1; i <= kNumSentPackets; ++i) {
95 SendDataPacket(i); 95 SendDataPacket(i);
96 clock_.AdvanceTime(rtt_stats_.SmoothedRtt().Multiply(0.1)); 96 clock_.AdvanceTime(rtt_stats_.SmoothedRtt().Multiply(0.1));
97 } 97 }
98 // Expect the timer to not be set. 98 // Expect the timer to not be set.
99 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 99 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
100 // The packet should not be lost without a nack. 100 // The packet should not be lost without a nack.
101 unacked_packets_.SetNotPending(1); 101 unacked_packets_.RemoveFromInFlight(1);
102 VerifyLosses(1, NULL, 0); 102 VerifyLosses(1, NULL, 0);
103 // The timer should still not be set. 103 // The timer should still not be set.
104 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 104 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
105 clock_.AdvanceTime(rtt_stats_.SmoothedRtt().Multiply(0.25)); 105 clock_.AdvanceTime(rtt_stats_.SmoothedRtt().Multiply(0.25));
106 VerifyLosses(1, NULL, 0); 106 VerifyLosses(1, NULL, 0);
107 clock_.AdvanceTime(rtt_stats_.SmoothedRtt()); 107 clock_.AdvanceTime(rtt_stats_.SmoothedRtt());
108 VerifyLosses(1, NULL, 0); 108 VerifyLosses(1, NULL, 0);
109 109
110 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 110 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
111 } 111 }
112 112
113 TEST_F(TimeLossAlgorithmTest, MultipleLossesAtOnce) { 113 TEST_F(TimeLossAlgorithmTest, MultipleLossesAtOnce) {
114 const size_t kNumSentPackets = 10; 114 const size_t kNumSentPackets = 10;
115 // Transmit 10 packets at once and then go forward an RTT. 115 // Transmit 10 packets at once and then go forward an RTT.
116 for (size_t i = 1; i <= kNumSentPackets; ++i) { 116 for (size_t i = 1; i <= kNumSentPackets; ++i) {
117 SendDataPacket(i); 117 SendDataPacket(i);
118 } 118 }
119 clock_.AdvanceTime(rtt_stats_.SmoothedRtt()); 119 clock_.AdvanceTime(rtt_stats_.SmoothedRtt());
120 // Expect the timer to not be set. 120 // Expect the timer to not be set.
121 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 121 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
122 // The packet should not be lost until 1.25 RTTs pass. 122 // The packet should not be lost until 1.25 RTTs pass.
123 for (size_t i = 1; i < kNumSentPackets; ++i) { 123 for (size_t i = 1; i < kNumSentPackets; ++i) {
124 unacked_packets_.NackPacket(i, 1); 124 unacked_packets_.NackPacket(i, 1);
125 } 125 }
126 unacked_packets_.SetNotPending(10); 126 unacked_packets_.RemoveFromInFlight(10);
127 VerifyLosses(10, NULL, 0); 127 VerifyLosses(10, NULL, 0);
128 // Expect the timer to be set to 0.25 RTT's in the future. 128 // Expect the timer to be set to 0.25 RTT's in the future.
129 EXPECT_EQ(rtt_stats_.SmoothedRtt().Multiply(0.25), 129 EXPECT_EQ(rtt_stats_.SmoothedRtt().Multiply(0.25),
130 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now())); 130 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now()));
131 clock_.AdvanceTime(rtt_stats_.SmoothedRtt().Multiply(0.25)); 131 clock_.AdvanceTime(rtt_stats_.SmoothedRtt().Multiply(0.25));
132 QuicPacketSequenceNumber lost[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; 132 QuicPacketSequenceNumber lost[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
133 VerifyLosses(10, lost, arraysize(lost)); 133 VerifyLosses(10, lost, arraysize(lost));
134 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 134 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
135 } 135 }
136 136
137 } // namespace test 137 } // namespace test
138 } // namespace net 138 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/time_loss_algorithm.cc ('k') | net/quic/quic_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698