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