| 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/tcp_loss_algorithm.h" | 5 #include "net/quic/congestion_control/tcp_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" |
| 11 #include "net/quic/congestion_control/rtt_stats.h" | 11 #include "net/quic/congestion_control/rtt_stats.h" |
| 12 #include "net/quic/quic_unacked_packet_map.h" | 12 #include "net/quic/quic_unacked_packet_map.h" |
| 13 #include "net/quic/test_tools/mock_clock.h" | 13 #include "net/quic/test_tools/mock_clock.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 using std::vector; | 16 using std::vector; |
| 17 | 17 |
| 18 namespace net { | 18 namespace net { |
| 19 namespace test { | 19 namespace test { |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 // Default packet length. | 22 // Default packet length. |
| 23 const uint32 kDefaultLength = 1000; | 23 const uint32_t kDefaultLength = 1000; |
| 24 | 24 |
| 25 class TcpLossAlgorithmTest : public ::testing::Test { | 25 class TcpLossAlgorithmTest : public ::testing::Test { |
| 26 protected: | 26 protected: |
| 27 TcpLossAlgorithmTest() { | 27 TcpLossAlgorithmTest() { |
| 28 rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(100), | 28 rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(100), |
| 29 QuicTime::Delta::Zero(), clock_.Now()); | 29 QuicTime::Delta::Zero(), clock_.Now()); |
| 30 } | 30 } |
| 31 | 31 |
| 32 ~TcpLossAlgorithmTest() override { STLDeleteElements(&packets_); } | 32 ~TcpLossAlgorithmTest() override { STLDeleteElements(&packets_); } |
| 33 | 33 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 if (i == 3) { | 144 if (i == 3) { |
| 145 clock_.AdvanceTime(rtt_stats_.smoothed_rtt().Multiply(0.25)); | 145 clock_.AdvanceTime(rtt_stats_.smoothed_rtt().Multiply(0.25)); |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 | 148 |
| 149 // Early retransmit when the final packet gets acked and 1.25 RTTs have | 149 // Early retransmit when the final packet gets acked and 1.25 RTTs have |
| 150 // elapsed since the packets were sent. | 150 // elapsed since the packets were sent. |
| 151 unacked_packets_.RemoveFromInFlight(kNumSentPackets); | 151 unacked_packets_.RemoveFromInFlight(kNumSentPackets); |
| 152 // This simulates a single ack following multiple missing packets with FACK. | 152 // This simulates a single ack following multiple missing packets with FACK. |
| 153 for (size_t i = 1; i < kNumSentPackets; ++i) { | 153 for (size_t i = 1; i < kNumSentPackets; ++i) { |
| 154 unacked_packets_.NackPacket(i, static_cast<uint16>(kNumSentPackets - i)); | 154 unacked_packets_.NackPacket(i, static_cast<uint16_t>(kNumSentPackets - i)); |
| 155 } | 155 } |
| 156 QuicPacketNumber lost[] = {1, 2}; | 156 QuicPacketNumber lost[] = {1, 2}; |
| 157 VerifyLosses(kNumSentPackets, lost, arraysize(lost)); | 157 VerifyLosses(kNumSentPackets, lost, arraysize(lost)); |
| 158 // The time has already advanced 1/4 an RTT, so ensure the timeout is set | 158 // The time has already advanced 1/4 an RTT, so ensure the timeout is set |
| 159 // 1.25 RTTs after the earliest pending packet(3), not the last(4). | 159 // 1.25 RTTs after the earliest pending packet(3), not the last(4). |
| 160 EXPECT_EQ(clock_.Now().Add(rtt_stats_.smoothed_rtt()), | 160 EXPECT_EQ(clock_.Now().Add(rtt_stats_.smoothed_rtt()), |
| 161 loss_algorithm_.GetLossTimeout()); | 161 loss_algorithm_.GetLossTimeout()); |
| 162 | 162 |
| 163 clock_.AdvanceTime(rtt_stats_.smoothed_rtt()); | 163 clock_.AdvanceTime(rtt_stats_.smoothed_rtt()); |
| 164 QuicPacketNumber lost2[] = {1, 2, 3}; | 164 QuicPacketNumber lost2[] = {1, 2, 3}; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 unacked_packets_.IncreaseLargestObserved(2); | 203 unacked_packets_.IncreaseLargestObserved(2); |
| 204 unacked_packets_.RemoveFromInFlight(2); | 204 unacked_packets_.RemoveFromInFlight(2); |
| 205 unacked_packets_.NackPacket(1, 1); | 205 unacked_packets_.NackPacket(1, 1); |
| 206 QuicPacketNumber lost[] = {1}; | 206 QuicPacketNumber lost[] = {1}; |
| 207 VerifyLosses(2, lost, arraysize(lost)); | 207 VerifyLosses(2, lost, arraysize(lost)); |
| 208 } | 208 } |
| 209 | 209 |
| 210 } // namespace | 210 } // namespace |
| 211 } // namespace test | 211 } // namespace test |
| 212 } // namespace net | 212 } // namespace net |
| OLD | NEW |