| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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_bytes_sender.h" | 5 #include "net/quic/congestion_control/tcp_cubic_bytes_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 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 const QuicPacketCount kNumberOfPackets = 123; | 606 const QuicPacketCount kNumberOfPackets = 123; |
| 607 const int kBandwidthEstimateBytesPerSecond = | 607 const int kBandwidthEstimateBytesPerSecond = |
| 608 kNumberOfPackets * kDefaultTCPMSS; | 608 kNumberOfPackets * kDefaultTCPMSS; |
| 609 cached_network_params.set_bandwidth_estimate_bytes_per_second( | 609 cached_network_params.set_bandwidth_estimate_bytes_per_second( |
| 610 kBandwidthEstimateBytesPerSecond); | 610 kBandwidthEstimateBytesPerSecond); |
| 611 cached_network_params.set_min_rtt_ms(1000); | 611 cached_network_params.set_min_rtt_ms(1000); |
| 612 | 612 |
| 613 // Ensure that an old estimate is not used for bandwidth resumption. | 613 // Ensure that an old estimate is not used for bandwidth resumption. |
| 614 cached_network_params.set_timestamp(clock_.WallNow().ToUNIXSeconds() - | 614 cached_network_params.set_timestamp(clock_.WallNow().ToUNIXSeconds() - |
| 615 (kNumSecondsPerHour + 1)); | 615 (kNumSecondsPerHour + 1)); |
| 616 EXPECT_FALSE(sender_->ResumeConnectionState(cached_network_params)); | 616 EXPECT_FALSE(sender_->ResumeConnectionState(cached_network_params, false)); |
| 617 EXPECT_EQ(10u * kDefaultTCPMSS, sender_->GetCongestionWindow()); | 617 EXPECT_EQ(10u * kDefaultTCPMSS, sender_->GetCongestionWindow()); |
| 618 | 618 |
| 619 // If the estimate is new enough, make sure it is used. | 619 // If the estimate is new enough, make sure it is used. |
| 620 cached_network_params.set_timestamp(clock_.WallNow().ToUNIXSeconds() - | 620 cached_network_params.set_timestamp(clock_.WallNow().ToUNIXSeconds() - |
| 621 (kNumSecondsPerHour - 1)); | 621 (kNumSecondsPerHour - 1)); |
| 622 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params)); | 622 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params, false)); |
| 623 EXPECT_EQ(kNumberOfPackets * kDefaultTCPMSS, sender_->GetCongestionWindow()); | 623 EXPECT_EQ(kNumberOfPackets * kDefaultTCPMSS, sender_->GetCongestionWindow()); |
| 624 | 624 |
| 625 // Resumed CWND is limited to be in a sensible range. | 625 // Resumed CWND is limited to be in a sensible range. |
| 626 cached_network_params.set_bandwidth_estimate_bytes_per_second( | 626 cached_network_params.set_bandwidth_estimate_bytes_per_second( |
| 627 (kMaxTcpCongestionWindow + 1) * kDefaultTCPMSS); | 627 (kMaxTcpCongestionWindow + 1) * kDefaultTCPMSS); |
| 628 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params)); | 628 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params, false)); |
| 629 EXPECT_EQ(kMaxTcpCongestionWindow * kDefaultTCPMSS, | 629 EXPECT_EQ(kMaxTcpCongestionWindow * kDefaultTCPMSS, |
| 630 sender_->GetCongestionWindow()); | 630 sender_->GetCongestionWindow()); |
| 631 | 631 |
| 632 cached_network_params.set_bandwidth_estimate_bytes_per_second( | 632 cached_network_params.set_bandwidth_estimate_bytes_per_second( |
| 633 (kMinCongestionWindowForBandwidthResumption - 1) * kDefaultTCPMSS); | 633 (kMinCongestionWindowForBandwidthResumption - 1) * kDefaultTCPMSS); |
| 634 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params)); | 634 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params, false)); |
| 635 EXPECT_EQ(kMinCongestionWindowForBandwidthResumption * kDefaultTCPMSS, | 635 EXPECT_EQ(kMinCongestionWindowForBandwidthResumption * kDefaultTCPMSS, |
| 636 sender_->GetCongestionWindow()); | 636 sender_->GetCongestionWindow()); |
| 637 |
| 638 // Resume to the max value. |
| 639 cached_network_params.set_max_bandwidth_estimate_bytes_per_second( |
| 640 (kMinCongestionWindowForBandwidthResumption + 10) * kDefaultTCPMSS); |
| 641 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params, true)); |
| 642 EXPECT_EQ((kMinCongestionWindowForBandwidthResumption + 10) * kDefaultTCPMSS, |
| 643 sender_->GetCongestionWindow()); |
| 637 } | 644 } |
| 638 | 645 |
| 639 } // namespace test | 646 } // namespace test |
| 640 } // namespace net | 647 } // namespace net |
| OLD | NEW |