| 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" |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 const QuicPacketCount kNumberOfPackets = 123; | 705 const QuicPacketCount kNumberOfPackets = 123; |
| 706 const int kBandwidthEstimateBytesPerSecond = | 706 const int kBandwidthEstimateBytesPerSecond = |
| 707 kNumberOfPackets * kMaxPacketSize; | 707 kNumberOfPackets * kMaxPacketSize; |
| 708 cached_network_params.set_bandwidth_estimate_bytes_per_second( | 708 cached_network_params.set_bandwidth_estimate_bytes_per_second( |
| 709 kBandwidthEstimateBytesPerSecond); | 709 kBandwidthEstimateBytesPerSecond); |
| 710 cached_network_params.set_min_rtt_ms(1000); | 710 cached_network_params.set_min_rtt_ms(1000); |
| 711 | 711 |
| 712 // Ensure that an old estimate is not used for bandwidth resumption. | 712 // Ensure that an old estimate is not used for bandwidth resumption. |
| 713 cached_network_params.set_timestamp(clock_.WallNow().ToUNIXSeconds() - | 713 cached_network_params.set_timestamp(clock_.WallNow().ToUNIXSeconds() - |
| 714 (kNumSecondsPerHour + 1)); | 714 (kNumSecondsPerHour + 1)); |
| 715 EXPECT_FALSE(sender_->ResumeConnectionState(cached_network_params)); | 715 EXPECT_FALSE(sender_->ResumeConnectionState(cached_network_params, false)); |
| 716 EXPECT_EQ(10u, sender_->congestion_window()); | 716 EXPECT_EQ(10u, sender_->congestion_window()); |
| 717 | 717 |
| 718 // If the estimate is new enough, make sure it is used. | 718 // If the estimate is new enough, make sure it is used. |
| 719 cached_network_params.set_timestamp(clock_.WallNow().ToUNIXSeconds() - | 719 cached_network_params.set_timestamp(clock_.WallNow().ToUNIXSeconds() - |
| 720 (kNumSecondsPerHour - 1)); | 720 (kNumSecondsPerHour - 1)); |
| 721 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params)); | 721 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params, false)); |
| 722 EXPECT_EQ(kNumberOfPackets, sender_->congestion_window()); | 722 EXPECT_EQ(kNumberOfPackets, sender_->congestion_window()); |
| 723 | 723 |
| 724 // Resumed CWND is limited to be in a sensible range. | 724 // Resumed CWND is limited to be in a sensible range. |
| 725 cached_network_params.set_bandwidth_estimate_bytes_per_second( | 725 cached_network_params.set_bandwidth_estimate_bytes_per_second( |
| 726 (kMaxTcpCongestionWindow + 1) * kMaxPacketSize); | 726 (kMaxTcpCongestionWindow + 1) * kMaxPacketSize); |
| 727 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params)); | 727 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params, false)); |
| 728 EXPECT_EQ(kMaxTcpCongestionWindow, sender_->congestion_window()); | 728 EXPECT_EQ(kMaxTcpCongestionWindow, sender_->congestion_window()); |
| 729 | 729 |
| 730 cached_network_params.set_bandwidth_estimate_bytes_per_second( | 730 cached_network_params.set_bandwidth_estimate_bytes_per_second( |
| 731 (kMinCongestionWindowForBandwidthResumption - 1) * kMaxPacketSize); | 731 (kMinCongestionWindowForBandwidthResumption - 1) * kMaxPacketSize); |
| 732 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params)); | 732 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params, false)); |
| 733 EXPECT_EQ(kMinCongestionWindowForBandwidthResumption, | 733 EXPECT_EQ(kMinCongestionWindowForBandwidthResumption, |
| 734 sender_->congestion_window()); | 734 sender_->congestion_window()); |
| 735 |
| 736 // Resume to the max value. |
| 737 cached_network_params.set_max_bandwidth_estimate_bytes_per_second( |
| 738 (kMinCongestionWindowForBandwidthResumption + 10) * kDefaultTCPMSS); |
| 739 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params, true)); |
| 740 EXPECT_EQ((kMinCongestionWindowForBandwidthResumption + 10) * kDefaultTCPMSS, |
| 741 sender_->GetCongestionWindow()); |
| 735 } | 742 } |
| 736 | 743 |
| 737 } // namespace test | 744 } // namespace test |
| 738 } // namespace net | 745 } // namespace net |
| OLD | NEW |