| OLD | NEW |
| 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 "net/quic/congestion_control/time_loss_algorithm.h" | 5 #include "net/quic/congestion_control/time_loss_algorithm.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 MockClock clock_; | 61 MockClock clock_; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 TEST_F(TimeLossAlgorithmTest, NoLossFor500Nacks) { | 64 TEST_F(TimeLossAlgorithmTest, NoLossFor500Nacks) { |
| 65 const size_t kNumSentPackets = 5; | 65 const size_t kNumSentPackets = 5; |
| 66 // Transmit 5 packets. | 66 // Transmit 5 packets. |
| 67 for (size_t i = 1; i <= kNumSentPackets; ++i) { | 67 for (size_t i = 1; i <= kNumSentPackets; ++i) { |
| 68 SendDataPacket(i); | 68 SendDataPacket(i); |
| 69 } | 69 } |
| 70 unacked_packets_.RemoveFromInFlight(2); | 70 unacked_packets_.RemoveFromInFlight(2); |
| 71 for (size_t i = 1; i < 500; ++i) { | 71 for (uint16 i = 1; i < 500; ++i) { |
| 72 unacked_packets_.NackPacket(1, i); | 72 unacked_packets_.NackPacket(1, i); |
| 73 VerifyLosses(2, nullptr, 0); | 73 VerifyLosses(2, nullptr, 0); |
| 74 } | 74 } |
| 75 EXPECT_EQ(rtt_stats_.smoothed_rtt().Multiply(1.25), | 75 EXPECT_EQ(rtt_stats_.smoothed_rtt().Multiply(1.25), |
| 76 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now())); | 76 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now())); |
| 77 } | 77 } |
| 78 | 78 |
| 79 TEST_F(TimeLossAlgorithmTest, NoLossUntilTimeout) { | 79 TEST_F(TimeLossAlgorithmTest, NoLossUntilTimeout) { |
| 80 const size_t kNumSentPackets = 10; | 80 const size_t kNumSentPackets = 10; |
| 81 // Transmit 10 packets at 1/10th an RTT interval. | 81 // Transmit 10 packets at 1/10th an RTT interval. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now())); | 142 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now())); |
| 143 clock_.AdvanceTime(rtt_stats_.smoothed_rtt().Multiply(0.25)); | 143 clock_.AdvanceTime(rtt_stats_.smoothed_rtt().Multiply(0.25)); |
| 144 QuicPacketNumber lost[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; | 144 QuicPacketNumber lost[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; |
| 145 VerifyLosses(10, lost, arraysize(lost)); | 145 VerifyLosses(10, lost, arraysize(lost)); |
| 146 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); | 146 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); |
| 147 } | 147 } |
| 148 | 148 |
| 149 } // namespace | 149 } // namespace |
| 150 } // namespace test | 150 } // namespace test |
| 151 } // namespace net | 151 } // namespace net |
| OLD | NEW |