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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.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/tcp_cubic_sender.h" | 10 #include "net/quic/congestion_control/tcp_cubic_sender.h" |
11 #include "net/quic/congestion_control/tcp_receiver.h" | 11 #include "net/quic/congestion_control/tcp_receiver.h" |
| 12 #include "net/quic/crypto/crypto_protocol.h" |
12 #include "net/quic/quic_utils.h" | 13 #include "net/quic/quic_utils.h" |
13 #include "net/quic/test_tools/mock_clock.h" | 14 #include "net/quic/test_tools/mock_clock.h" |
14 #include "net/quic/test_tools/quic_config_peer.h" | 15 #include "net/quic/test_tools/quic_config_peer.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 | 17 |
17 using std::min; | 18 using std::min; |
18 | 19 |
19 namespace net { | 20 namespace net { |
20 namespace test { | 21 namespace test { |
21 | 22 |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 HAS_RETRANSMITTABLE_DATA)); | 606 HAS_RETRANSMITTABLE_DATA)); |
606 } | 607 } |
607 | 608 |
608 TEST_F(TcpCubicSenderTest, ConfigureMaxInitialWindow) { | 609 TEST_F(TcpCubicSenderTest, ConfigureMaxInitialWindow) { |
609 QuicTcpCongestionWindow congestion_window = sender_->congestion_window(); | 610 QuicTcpCongestionWindow congestion_window = sender_->congestion_window(); |
610 QuicConfig config; | 611 QuicConfig config; |
611 QuicConfigPeer::SetReceivedInitialWindow(&config, 2 * congestion_window); | 612 QuicConfigPeer::SetReceivedInitialWindow(&config, 2 * congestion_window); |
612 | 613 |
613 sender_->SetFromConfig(config, true); | 614 sender_->SetFromConfig(config, true); |
614 EXPECT_EQ(2 * congestion_window, sender_->congestion_window()); | 615 EXPECT_EQ(2 * congestion_window, sender_->congestion_window()); |
| 616 |
| 617 // Verify that kCOPT: kIW10 forces the congestion window to the |
| 618 // default of 10 regardless of ReceivedInitialWindow. |
| 619 QuicTagVector options; |
| 620 options.push_back(kIW10); |
| 621 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); |
| 622 sender_->SetFromConfig(config, true); |
| 623 EXPECT_EQ(congestion_window, sender_->congestion_window()); |
615 } | 624 } |
616 | 625 |
617 TEST_F(TcpCubicSenderTest, CongestionAvoidanceAtEndOfRecovery) { | 626 TEST_F(TcpCubicSenderTest, CongestionAvoidanceAtEndOfRecovery) { |
618 // Make sure that we fall out of slow start when we encounter a packet loss. | 627 // Make sure that we fall out of slow start when we encounter a packet loss. |
619 QuicCongestionFeedbackFrame feedback; | 628 QuicCongestionFeedbackFrame feedback; |
620 // Get default QuicCongestionFeedbackFrame from receiver. | 629 // Get default QuicCongestionFeedbackFrame from receiver. |
621 ASSERT_TRUE(receiver_->GenerateCongestionFeedback(&feedback)); | 630 ASSERT_TRUE(receiver_->GenerateCongestionFeedback(&feedback)); |
622 sender_->OnIncomingQuicCongestionFeedbackFrame(feedback, clock_.Now()); | 631 sender_->OnIncomingQuicCongestionFeedbackFrame(feedback, clock_.Now()); |
623 // Ack 10 packets in 5 acks to raise the CWND to 20. | 632 // Ack 10 packets in 5 acks to raise the CWND to 20. |
624 const int kNumberOfAcks = 5; | 633 const int kNumberOfAcks = 5; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 } | 666 } |
658 | 667 |
659 // Next ack should cause congestion window to grow by 1MSS. | 668 // Next ack should cause congestion window to grow by 1MSS. |
660 AckNPackets(2); | 669 AckNPackets(2); |
661 expected_send_window += kDefaultTCPMSS; | 670 expected_send_window += kDefaultTCPMSS; |
662 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 671 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
663 } | 672 } |
664 | 673 |
665 } // namespace test | 674 } // namespace test |
666 } // namespace net | 675 } // namespace net |
OLD | NEW |