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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } | 42 } |
43 | 43 |
44 QuicPacketCount slowstart_threshold() { | 44 QuicPacketCount slowstart_threshold() { |
45 return slowstart_threshold_; | 45 return slowstart_threshold_; |
46 } | 46 } |
47 | 47 |
48 const HybridSlowStart& hybrid_slow_start() const { | 48 const HybridSlowStart& hybrid_slow_start() const { |
49 return hybrid_slow_start_; | 49 return hybrid_slow_start_; |
50 } | 50 } |
51 | 51 |
| 52 float GetRenoBeta() const { |
| 53 return RenoBeta(); |
| 54 } |
| 55 |
52 RttStats rtt_stats_; | 56 RttStats rtt_stats_; |
53 QuicConnectionStats stats_; | 57 QuicConnectionStats stats_; |
54 }; | 58 }; |
55 | 59 |
56 class TcpCubicSenderTest : public ::testing::Test { | 60 class TcpCubicSenderTest : public ::testing::Test { |
57 protected: | 61 protected: |
58 TcpCubicSenderTest() | 62 TcpCubicSenderTest() |
59 : one_ms_(QuicTime::Delta::FromMilliseconds(1)), | 63 : one_ms_(QuicTime::Delta::FromMilliseconds(1)), |
60 sender_(new TcpCubicSenderPeer(&clock_, true, | 64 sender_(new TcpCubicSenderPeer(&clock_, true, |
61 kDefaultMaxCongestionWindowTCP)), | 65 kDefaultMaxCongestionWindowTCP)), |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 AckNPackets(2); | 596 AckNPackets(2); |
593 } | 597 } |
594 SendAvailableSendWindow(); | 598 SendAvailableSendWindow(); |
595 QuicByteCount expected_send_window = kDefaultWindowTCP + | 599 QuicByteCount expected_send_window = kDefaultWindowTCP + |
596 (kDefaultTCPMSS * 2 * kNumberOfAcks); | 600 (kDefaultTCPMSS * 2 * kNumberOfAcks); |
597 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 601 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
598 | 602 |
599 LoseNPackets(1); | 603 LoseNPackets(1); |
600 | 604 |
601 // We should now have fallen out of slow start with a reduced window. | 605 // We should now have fallen out of slow start with a reduced window. |
602 expected_send_window *= kRenoBeta; | 606 expected_send_window = expected_send_window * sender_->GetRenoBeta(); |
603 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 607 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
604 | 608 |
605 // No congestion window growth should occur in recovery phase, i.e., until the | 609 // No congestion window growth should occur in recovery phase, i.e., until the |
606 // currently outstanding 20 packets are acked. | 610 // currently outstanding 20 packets are acked. |
607 for (int i = 0; i < 10; ++i) { | 611 for (int i = 0; i < 10; ++i) { |
608 // Send our full send window. | 612 // Send our full send window. |
609 SendAvailableSendWindow(); | 613 SendAvailableSendWindow(); |
610 EXPECT_TRUE(sender_->InRecovery()); | 614 EXPECT_TRUE(sender_->InRecovery()); |
611 AckNPackets(2); | 615 AckNPackets(2); |
612 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 616 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 | 683 |
680 // Next ack should cause congestion window to grow by 1MSS. | 684 // Next ack should cause congestion window to grow by 1MSS. |
681 SendAvailableSendWindow(); | 685 SendAvailableSendWindow(); |
682 AckNPackets(2); | 686 AckNPackets(2); |
683 expected_send_window += kDefaultTCPMSS; | 687 expected_send_window += kDefaultTCPMSS; |
684 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 688 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
685 } | 689 } |
686 | 690 |
687 } // namespace test | 691 } // namespace test |
688 } // namespace net | 692 } // namespace net |
OLD | NEW |