OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/core/congestion_control/prr_sender.h" | 5 #include "net/quic/core/congestion_control/prr_sender.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "net/quic/core/crypto/crypto_protocol.h" | 9 #include "net/quic/core/crypto/crypto_protocol.h" |
10 #include "net/quic/core/quic_constants.h" | 10 #include "net/quic/core/quic_constants.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "net/quic/platform/api/quic_test.h" |
12 | 12 |
13 namespace net { | 13 namespace net { |
14 namespace test { | 14 namespace test { |
15 | 15 |
16 namespace { | 16 namespace { |
17 // Constant based on TCP defaults. | 17 // Constant based on TCP defaults. |
18 const QuicByteCount kMaxSegmentSize = kDefaultTCPMSS; | 18 const QuicByteCount kMaxSegmentSize = kDefaultTCPMSS; |
19 } // namespace | 19 } // namespace |
20 | 20 |
21 class PrrSenderTest : public ::testing::Test {}; | 21 class PrrSenderTest : public QuicTest {}; |
22 | 22 |
23 TEST_F(PrrSenderTest, SingleLossResultsInSendOnEveryOtherAck) { | 23 TEST_F(PrrSenderTest, SingleLossResultsInSendOnEveryOtherAck) { |
24 PrrSender prr; | 24 PrrSender prr; |
25 QuicPacketCount num_packets_in_flight = 50; | 25 QuicPacketCount num_packets_in_flight = 50; |
26 QuicByteCount bytes_in_flight = num_packets_in_flight * kMaxSegmentSize; | 26 QuicByteCount bytes_in_flight = num_packets_in_flight * kMaxSegmentSize; |
27 const QuicPacketCount ssthresh_after_loss = num_packets_in_flight / 2; | 27 const QuicPacketCount ssthresh_after_loss = num_packets_in_flight / 2; |
28 const QuicByteCount congestion_window = ssthresh_after_loss * kMaxSegmentSize; | 28 const QuicByteCount congestion_window = ssthresh_after_loss * kMaxSegmentSize; |
29 | 29 |
30 prr.OnPacketLost(bytes_in_flight); | 30 prr.OnPacketLost(bytes_in_flight); |
31 // Ack a packet. PRR allows one packet to leave immediately. | 31 // Ack a packet. PRR allows one packet to leave immediately. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 prr.TimeUntilSend(congestion_window, bytes_in_flight, | 123 prr.TimeUntilSend(congestion_window, bytes_in_flight, |
124 ssthresh_after_loss * kMaxSegmentSize)); | 124 ssthresh_after_loss * kMaxSegmentSize)); |
125 // Send a packet in response. | 125 // Send a packet in response. |
126 prr.OnPacketSent(kMaxSegmentSize); | 126 prr.OnPacketSent(kMaxSegmentSize); |
127 bytes_in_flight += kMaxSegmentSize; | 127 bytes_in_flight += kMaxSegmentSize; |
128 } | 128 } |
129 } | 129 } |
130 | 130 |
131 } // namespace test | 131 } // namespace test |
132 } // namespace net | 132 } // namespace net |
OLD | NEW |