OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_cubic_sender.h" | 5 #include "net/quic/congestion_control/tcp_cubic_sender.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "net/quic/congestion_control/rtt_stats.h" | 11 #include "net/quic/congestion_control/rtt_stats.h" |
12 #include "net/quic/crypto/crypto_protocol.h" | 12 #include "net/quic/crypto/crypto_protocol.h" |
13 #include "net/quic/proto/cached_network_parameters.pb.h" | 13 #include "net/quic/proto/cached_network_parameters.pb.h" |
| 14 #include "net/quic/quic_flags.h" |
14 #include "net/quic/quic_protocol.h" | 15 #include "net/quic/quic_protocol.h" |
15 #include "net/quic/quic_utils.h" | 16 #include "net/quic/quic_utils.h" |
16 #include "net/quic/test_tools/mock_clock.h" | 17 #include "net/quic/test_tools/mock_clock.h" |
17 #include "net/quic/test_tools/quic_config_peer.h" | 18 #include "net/quic/test_tools/quic_config_peer.h" |
| 19 #include "net/quic/test_tools/quic_test_utils.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
19 | 21 |
20 using std::min; | 22 using std::min; |
21 | 23 |
22 namespace net { | 24 namespace net { |
23 namespace test { | 25 namespace test { |
24 | 26 |
25 // TODO(ianswett): A number of theses tests were written with the assumption of | 27 // TODO(ianswett): A number of theses tests were written with the assumption of |
26 // an initial CWND of 10. They have carefully calculated values which should be | 28 // an initial CWND of 10. They have carefully calculated values which should be |
27 // updated to be based on kInitialCongestionWindowInsecure. | 29 // updated to be based on kInitialCongestionWindowInsecure. |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 // Send our full send window. | 481 // Send our full send window. |
480 SendAvailableSendWindow(); | 482 SendAvailableSendWindow(); |
481 AckNPackets(2); | 483 AckNPackets(2); |
482 } | 484 } |
483 | 485 |
484 QuicByteCount expected_send_window = kMaxCongestionWindowTCP * kDefaultTCPMSS; | 486 QuicByteCount expected_send_window = kMaxCongestionWindowTCP * kDefaultTCPMSS; |
485 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 487 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
486 } | 488 } |
487 | 489 |
488 TEST_F(TcpCubicSenderTest, TcpCubicResetEpochOnQuiescence) { | 490 TEST_F(TcpCubicSenderTest, TcpCubicResetEpochOnQuiescence) { |
| 491 ValueRestore<bool> old_flag(&FLAGS_reset_cubic_epoch_when_app_limited, true); |
489 const int kMaxCongestionWindow = 50; | 492 const int kMaxCongestionWindow = 50; |
490 const QuicByteCount kMaxCongestionWindowBytes = | 493 const QuicByteCount kMaxCongestionWindowBytes = |
491 kMaxCongestionWindow * kDefaultTCPMSS; | 494 kMaxCongestionWindow * kDefaultTCPMSS; |
492 sender_.reset(new TcpCubicSenderPeer(&clock_, false, kMaxCongestionWindow)); | 495 sender_.reset(new TcpCubicSenderPeer(&clock_, false, kMaxCongestionWindow)); |
493 | 496 |
494 int num_sent = SendAvailableSendWindow(); | 497 int num_sent = SendAvailableSendWindow(); |
495 | 498 |
496 // Make sure we fall out of slow start. | 499 // Make sure we fall out of slow start. |
497 QuicByteCount saved_cwnd = sender_->GetCongestionWindow(); | 500 QuicByteCount saved_cwnd = sender_->GetCongestionWindow(); |
498 LoseNPackets(1); | 501 LoseNPackets(1); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 EXPECT_TRUE(sender_->TimeUntilSend(QuicTime::Zero(), 2 * kDefaultTCPMSS, | 755 EXPECT_TRUE(sender_->TimeUntilSend(QuicTime::Zero(), 2 * kDefaultTCPMSS, |
753 HAS_RETRANSMITTABLE_DATA).IsZero()); | 756 HAS_RETRANSMITTABLE_DATA).IsZero()); |
754 EXPECT_TRUE(sender_->TimeUntilSend(QuicTime::Zero(), 3 * kDefaultTCPMSS, | 757 EXPECT_TRUE(sender_->TimeUntilSend(QuicTime::Zero(), 3 * kDefaultTCPMSS, |
755 HAS_RETRANSMITTABLE_DATA).IsZero()); | 758 HAS_RETRANSMITTABLE_DATA).IsZero()); |
756 EXPECT_FALSE(sender_->TimeUntilSend(QuicTime::Zero(), 4 * kDefaultTCPMSS, | 759 EXPECT_FALSE(sender_->TimeUntilSend(QuicTime::Zero(), 4 * kDefaultTCPMSS, |
757 HAS_RETRANSMITTABLE_DATA).IsZero()); | 760 HAS_RETRANSMITTABLE_DATA).IsZero()); |
758 } | 761 } |
759 | 762 |
760 } // namespace test | 763 } // namespace test |
761 } // namespace net | 764 } // namespace net |
OLD | NEW |