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" |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 | 741 |
742 TEST_F(TcpCubicSenderTest, BandwidthResumption) { | 742 TEST_F(TcpCubicSenderTest, BandwidthResumption) { |
743 // Test that when provided with CachedNetworkParameters and opted in to the | 743 // Test that when provided with CachedNetworkParameters and opted in to the |
744 // bandwidth resumption experiment, that the TcpCubicSender sets initial CWND | 744 // bandwidth resumption experiment, that the TcpCubicSender sets initial CWND |
745 // appropriately. | 745 // appropriately. |
746 | 746 |
747 // Set some common values. | 747 // Set some common values. |
748 CachedNetworkParameters cached_network_params; | 748 CachedNetworkParameters cached_network_params; |
749 const QuicPacketCount kNumberOfPackets = 123; | 749 const QuicPacketCount kNumberOfPackets = 123; |
750 const int kBandwidthEstimateBytesPerSecond = | 750 const int kBandwidthEstimateBytesPerSecond = |
751 kNumberOfPackets * kMaxPacketSize; | 751 kNumberOfPackets * kDefaultTCPMSS; |
752 cached_network_params.set_bandwidth_estimate_bytes_per_second( | 752 cached_network_params.set_bandwidth_estimate_bytes_per_second( |
753 kBandwidthEstimateBytesPerSecond); | 753 kBandwidthEstimateBytesPerSecond); |
754 cached_network_params.set_min_rtt_ms(1000); | 754 cached_network_params.set_min_rtt_ms(1000); |
755 | 755 |
756 // Make sure that a bandwidth estimate results in a changed CWND. | 756 // Make sure that a bandwidth estimate results in a changed CWND. |
757 cached_network_params.set_timestamp(clock_.WallNow().ToUNIXSeconds() - | 757 cached_network_params.set_timestamp(clock_.WallNow().ToUNIXSeconds() - |
758 (kNumSecondsPerHour - 1)); | 758 (kNumSecondsPerHour - 1)); |
759 sender_->ResumeConnectionState(cached_network_params, false); | 759 sender_->ResumeConnectionState(cached_network_params, false); |
760 EXPECT_EQ(kNumberOfPackets, sender_->congestion_window()); | 760 EXPECT_EQ(kNumberOfPackets, sender_->congestion_window()); |
761 | 761 |
762 // Resumed CWND is limited to be in a sensible range. | 762 // Resumed CWND is limited to be in a sensible range. |
763 cached_network_params.set_bandwidth_estimate_bytes_per_second( | 763 cached_network_params.set_bandwidth_estimate_bytes_per_second( |
764 (kMaxCongestionWindow + 1) * kMaxPacketSize); | 764 (kMaxCongestionWindow + 1) * kDefaultTCPMSS); |
765 sender_->ResumeConnectionState(cached_network_params, false); | 765 sender_->ResumeConnectionState(cached_network_params, false); |
766 EXPECT_EQ(kMaxCongestionWindow, sender_->congestion_window()); | 766 EXPECT_EQ(kMaxCongestionWindow, sender_->congestion_window()); |
767 | 767 |
768 cached_network_params.set_bandwidth_estimate_bytes_per_second( | 768 cached_network_params.set_bandwidth_estimate_bytes_per_second( |
769 (kMinCongestionWindowForBandwidthResumption - 1) * kMaxPacketSize); | 769 (kMinCongestionWindowForBandwidthResumption - 1) * kDefaultTCPMSS); |
770 sender_->ResumeConnectionState(cached_network_params, false); | 770 sender_->ResumeConnectionState(cached_network_params, false); |
771 EXPECT_EQ(kMinCongestionWindowForBandwidthResumption, | 771 EXPECT_EQ(kMinCongestionWindowForBandwidthResumption, |
772 sender_->congestion_window()); | 772 sender_->congestion_window()); |
773 | 773 |
774 // Resume to the max value. | 774 // Resume to the max value. |
775 cached_network_params.set_max_bandwidth_estimate_bytes_per_second( | 775 cached_network_params.set_max_bandwidth_estimate_bytes_per_second( |
776 (kMinCongestionWindowForBandwidthResumption + 10) * kDefaultTCPMSS); | 776 (kMinCongestionWindowForBandwidthResumption + 10) * kDefaultTCPMSS); |
777 sender_->ResumeConnectionState(cached_network_params, true); | 777 sender_->ResumeConnectionState(cached_network_params, true); |
778 EXPECT_EQ((kMinCongestionWindowForBandwidthResumption + 10) * kDefaultTCPMSS, | 778 EXPECT_EQ((kMinCongestionWindowForBandwidthResumption + 10) * kDefaultTCPMSS, |
779 sender_->GetCongestionWindow()); | 779 sender_->GetCongestionWindow()); |
(...skipping 15 matching lines...) Expand all Loading... |
795 EXPECT_TRUE(sender_->TimeUntilSend(QuicTime::Zero(), 2 * kDefaultTCPMSS, | 795 EXPECT_TRUE(sender_->TimeUntilSend(QuicTime::Zero(), 2 * kDefaultTCPMSS, |
796 HAS_RETRANSMITTABLE_DATA).IsZero()); | 796 HAS_RETRANSMITTABLE_DATA).IsZero()); |
797 EXPECT_TRUE(sender_->TimeUntilSend(QuicTime::Zero(), 3 * kDefaultTCPMSS, | 797 EXPECT_TRUE(sender_->TimeUntilSend(QuicTime::Zero(), 3 * kDefaultTCPMSS, |
798 HAS_RETRANSMITTABLE_DATA).IsZero()); | 798 HAS_RETRANSMITTABLE_DATA).IsZero()); |
799 EXPECT_FALSE(sender_->TimeUntilSend(QuicTime::Zero(), 4 * kDefaultTCPMSS, | 799 EXPECT_FALSE(sender_->TimeUntilSend(QuicTime::Zero(), 4 * kDefaultTCPMSS, |
800 HAS_RETRANSMITTABLE_DATA).IsZero()); | 800 HAS_RETRANSMITTABLE_DATA).IsZero()); |
801 } | 801 } |
802 | 802 |
803 } // namespace test | 803 } // namespace test |
804 } // namespace net | 804 } // namespace net |
OLD | NEW |