| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/core/congestion_control/bbr_sender.h" | 5 #include "net/quic/core/congestion_control/bbr_sender.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "net/quic/core/congestion_control/rtt_stats.h" | 11 #include "net/quic/core/congestion_control/rtt_stats.h" |
| 12 #include "net/quic/core/quic_packets.h" | 12 #include "net/quic/core/quic_packets.h" |
| 13 #include "net/quic/core/quic_utils.h" | 13 #include "net/quic/core/quic_utils.h" |
| 14 #include "net/quic/platform/api/quic_logging.h" | 14 #include "net/quic/platform/api/quic_logging.h" |
| 15 #include "net/quic/platform/api/quic_test.h" |
| 15 #include "net/quic/test_tools/mock_clock.h" | 16 #include "net/quic/test_tools/mock_clock.h" |
| 16 #include "net/quic/test_tools/quic_config_peer.h" | 17 #include "net/quic/test_tools/quic_config_peer.h" |
| 17 #include "net/quic/test_tools/quic_connection_peer.h" | 18 #include "net/quic/test_tools/quic_connection_peer.h" |
| 18 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" | 19 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" |
| 19 #include "net/quic/test_tools/quic_test_utils.h" | 20 #include "net/quic/test_tools/quic_test_utils.h" |
| 20 #include "net/quic/test_tools/simulator/quic_endpoint.h" | 21 #include "net/quic/test_tools/simulator/quic_endpoint.h" |
| 21 #include "net/quic/test_tools/simulator/simulator.h" | 22 #include "net/quic/test_tools/simulator/simulator.h" |
| 22 #include "net/quic/test_tools/simulator/switch.h" | 23 #include "net/quic/test_tools/simulator/switch.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | |
| 24 | 24 |
| 25 namespace net { | 25 namespace net { |
| 26 namespace test { | 26 namespace test { |
| 27 | 27 |
| 28 // Use the initial CWND of 10, as 32 is too much for the test network. | 28 // Use the initial CWND of 10, as 32 is too much for the test network. |
| 29 const uint32_t kInitialCongestionWindowPackets = 10; | 29 const uint32_t kInitialCongestionWindowPackets = 10; |
| 30 const uint32_t kDefaultWindowTCP = | 30 const uint32_t kDefaultWindowTCP = |
| 31 kInitialCongestionWindowPackets * kDefaultTCPMSS; | 31 kInitialCongestionWindowPackets * kDefaultTCPMSS; |
| 32 | 32 |
| 33 // Test network parameters. Here, the topology of the network is: | 33 // Test network parameters. Here, the topology of the network is: |
| (...skipping 23 matching lines...) Expand all Loading... |
| 57 QuicTime::Delta::FromMilliseconds(30); | 57 QuicTime::Delta::FromMilliseconds(30); |
| 58 const QuicTime::Delta kLocalPropagationDelay = | 58 const QuicTime::Delta kLocalPropagationDelay = |
| 59 QuicTime::Delta::FromMilliseconds(2); | 59 QuicTime::Delta::FromMilliseconds(2); |
| 60 const QuicTime::Delta kTestTransferTime = | 60 const QuicTime::Delta kTestTransferTime = |
| 61 kTestLinkBandwidth.TransferTime(kMaxPacketSize) + | 61 kTestLinkBandwidth.TransferTime(kMaxPacketSize) + |
| 62 kLocalLinkBandwidth.TransferTime(kMaxPacketSize); | 62 kLocalLinkBandwidth.TransferTime(kMaxPacketSize); |
| 63 const QuicTime::Delta kTestRtt = | 63 const QuicTime::Delta kTestRtt = |
| 64 (kTestPropagationDelay + kLocalPropagationDelay + kTestTransferTime) * 2; | 64 (kTestPropagationDelay + kLocalPropagationDelay + kTestTransferTime) * 2; |
| 65 const QuicByteCount kTestBdp = kTestRtt * kTestLinkBandwidth; | 65 const QuicByteCount kTestBdp = kTestRtt * kTestLinkBandwidth; |
| 66 | 66 |
| 67 class BbrSenderTest : public ::testing::Test { | 67 class BbrSenderTest : public QuicTest { |
| 68 protected: | 68 protected: |
| 69 BbrSenderTest() | 69 BbrSenderTest() |
| 70 : simulator_(), | 70 : simulator_(), |
| 71 bbr_sender_(&simulator_, | 71 bbr_sender_(&simulator_, |
| 72 "BBR sender", | 72 "BBR sender", |
| 73 "Receiver", | 73 "Receiver", |
| 74 Perspective::IS_CLIENT, | 74 Perspective::IS_CLIENT, |
| 75 /*connection_id=*/42), | 75 /*connection_id=*/42), |
| 76 competing_sender_(&simulator_, | 76 competing_sender_(&simulator_, |
| 77 "Competing sender", | 77 "Competing sender", |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 std::unique_ptr<simulator::SymmetricLink> bbr_sender_link_; | 119 std::unique_ptr<simulator::SymmetricLink> bbr_sender_link_; |
| 120 std::unique_ptr<simulator::SymmetricLink> competing_sender_link_; | 120 std::unique_ptr<simulator::SymmetricLink> competing_sender_link_; |
| 121 std::unique_ptr<simulator::SymmetricLink> receiver_link_; | 121 std::unique_ptr<simulator::SymmetricLink> receiver_link_; |
| 122 | 122 |
| 123 SimpleRandom random_; | 123 SimpleRandom random_; |
| 124 | 124 |
| 125 // Owned by different components of the connection. | 125 // Owned by different components of the connection. |
| 126 const QuicClock* clock_; | 126 const QuicClock* clock_; |
| 127 const RttStats* rtt_stats_; | 127 const RttStats* rtt_stats_; |
| 128 BbrSender* sender_; | 128 BbrSender* sender_; |
| 129 QuicFlagSaver flags_; | |
| 130 | 129 |
| 131 // Enables BBR on |endpoint| and returns the associated BBR congestion | 130 // Enables BBR on |endpoint| and returns the associated BBR congestion |
| 132 // controller. | 131 // controller. |
| 133 BbrSender* SetupBbrSender(simulator::QuicEndpoint* endpoint) { | 132 BbrSender* SetupBbrSender(simulator::QuicEndpoint* endpoint) { |
| 134 const RttStats* rtt_stats = | 133 const RttStats* rtt_stats = |
| 135 endpoint->connection()->sent_packet_manager().GetRttStats(); | 134 endpoint->connection()->sent_packet_manager().GetRttStats(); |
| 136 // Ownership of the sender will be overtaken by the endpoint. | 135 // Ownership of the sender will be overtaken by the endpoint. |
| 137 BbrSender* sender = new BbrSender( | 136 BbrSender* sender = new BbrSender( |
| 138 rtt_stats, | 137 rtt_stats, |
| 139 QuicSentPacketManagerPeer::GetUnackedPacketMap( | 138 QuicSentPacketManagerPeer::GetUnackedPacketMap( |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 sender_->ResumeConnectionState(params, false); | 818 sender_->ResumeConnectionState(params, false); |
| 820 EXPECT_EQ(kTestLinkBandwidth, sender_->ExportDebugState().max_bandwidth); | 819 EXPECT_EQ(kTestLinkBandwidth, sender_->ExportDebugState().max_bandwidth); |
| 821 EXPECT_EQ(kTestLinkBandwidth, sender_->BandwidthEstimate()); | 820 EXPECT_EQ(kTestLinkBandwidth, sender_->BandwidthEstimate()); |
| 822 ExpectApproxEq(kTestRtt, sender_->ExportDebugState().min_rtt, 0.01f); | 821 ExpectApproxEq(kTestRtt, sender_->ExportDebugState().min_rtt, 0.01f); |
| 823 | 822 |
| 824 DriveOutOfStartup(); | 823 DriveOutOfStartup(); |
| 825 } | 824 } |
| 826 | 825 |
| 827 } // namespace test | 826 } // namespace test |
| 828 } // namespace net | 827 } // namespace net |
| OLD | NEW |