/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #include #include #include #include #include #include #include #include #include #include #include namespace quic { std::unique_ptr ServerCongestionControllerFactory::makeCongestionController( QuicConnectionStateBase& conn, CongestionControlType type) { auto setupBBR = [&conn](BbrCongestionController* bbr) { bbr->setRttSampler(std::make_unique( std::chrono::seconds(kDefaultRttSamplerExpiration))); bbr->setBandwidthSampler(std::make_unique(conn)); }; std::unique_ptr congestionController; switch (type) { case CongestionControlType::NewReno: congestionController = std::make_unique(conn); break; case CongestionControlType::Cubic: congestionController = std::make_unique(conn); break; case CongestionControlType::Copa: congestionController = std::make_unique(conn); break; case CongestionControlType::Copa2: congestionController = std::make_unique(conn); break; case CongestionControlType::BBR: { auto bbr = std::make_unique(conn); setupBBR(bbr.get()); congestionController = std::move(bbr); break; } case CongestionControlType::BBRTesting: { auto bbr = std::make_unique(conn); setupBBR(bbr.get()); congestionController = std::move(bbr); break; } case CongestionControlType::BBR2: { auto bbr2 = std::make_unique(conn); congestionController = std::move(bbr2); break; } case CongestionControlType::StaticCwnd: { throw QuicInternalException( "StaticCwnd Congestion Controller cannot be " "constructed via CongestionControllerFactory.", LocalErrorCode::INTERNAL_ERROR); } case CongestionControlType::None: break; case CongestionControlType::MAX: throw QuicInternalException( "MAX is not a valid cc algorithm.", LocalErrorCode::INTERNAL_ERROR); } QUIC_STATS(conn.statsCallback, onNewCongestionController, type); return congestionController; } } // namespace quic