1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-04-18 17:24:03 +03:00
mvfst/quic/congestion_control/ServerCongestionControllerFactory.cpp
Konstantin Tsoy adf16f9a07 Remove libccp from mvfst
Summary: We don't use it, and the OSS lib hasn't been updated in a while.

Reviewed By: mjoras

Differential Revision: D46707559

fbshipit-source-id: ec102a52183a736cfb1c0241600816a837062108
2023-06-15 18:17:53 -07:00

74 lines
2.6 KiB
C++

/*
* 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 <quic/congestion_control/ServerCongestionControllerFactory.h>
#include <quic/congestion_control/Bbr.h>
#include <quic/congestion_control/BbrBandwidthSampler.h>
#include <quic/congestion_control/BbrRttSampler.h>
#include <quic/congestion_control/BbrTesting.h>
#include <quic/congestion_control/Copa.h>
#include <quic/congestion_control/Copa2.h>
#include <quic/congestion_control/NewReno.h>
#include <quic/congestion_control/QuicCubic.h>
#include <quic/congestion_control/StaticCwndCongestionController.h>
#include <memory>
namespace quic {
std::unique_ptr<CongestionController>
ServerCongestionControllerFactory::makeCongestionController(
QuicConnectionStateBase& conn,
CongestionControlType type) {
auto setupBBR = [&conn](BbrCongestionController* bbr) {
bbr->setRttSampler(std::make_unique<BbrRttSampler>(
std::chrono::seconds(kDefaultRttSamplerExpiration)));
bbr->setBandwidthSampler(std::make_unique<BbrBandwidthSampler>(conn));
};
std::unique_ptr<CongestionController> congestionController;
switch (type) {
case CongestionControlType::NewReno:
congestionController = std::make_unique<NewReno>(conn);
break;
case CongestionControlType::Cubic:
congestionController = std::make_unique<Cubic>(conn);
break;
case CongestionControlType::Copa:
congestionController = std::make_unique<Copa>(conn);
break;
case CongestionControlType::Copa2:
congestionController = std::make_unique<Copa2>(conn);
break;
case CongestionControlType::BBR: {
auto bbr = std::make_unique<BbrCongestionController>(conn);
setupBBR(bbr.get());
congestionController = std::move(bbr);
break;
}
case CongestionControlType::BBRTesting: {
auto bbr = std::make_unique<BbrTestingCongestionController>(conn);
setupBBR(bbr.get());
congestionController = std::move(bbr);
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