-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08caac8
commit 13085d5
Showing
6 changed files
with
144 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include "gquiche/quic/core/congestion_control/bbr2_sender.h" | ||
#include "gquiche/quic/core/congestion_control/bbr_sender.h" | ||
#include "gquiche/quic/core/congestion_control/tcp_cubic_sender_bytes.h" | ||
|
||
#include "ns3-quic-congestion-factory.h" | ||
#include "ns3-quic-no-destructor.h" | ||
namespace quic{ | ||
class Ns3QuicCongestionFactory:public AbstractCongestionFactory{ | ||
public: | ||
~Ns3QuicCongestionFactory() override{} | ||
SendAlgorithmInterface* Create( | ||
const QuicClock* clock, | ||
const RttStats* rtt_stats, | ||
const QuicUnackedPacketMap* unacked_packets, | ||
CongestionControlType type, | ||
QuicRandom* random, | ||
QuicConnectionStats* stats, | ||
QuicPacketCount initial_congestion_window, | ||
QuicPacketCount max_congestion_window, | ||
SendAlgorithmInterface* old_send_algorithm) override; | ||
}; | ||
SendAlgorithmInterface* Ns3QuicCongestionFactory::Create( | ||
const QuicClock* clock, | ||
const RttStats* rtt_stats, | ||
const QuicUnackedPacketMap* unacked_packets, | ||
CongestionControlType type, | ||
QuicRandom* random, | ||
QuicConnectionStats* stats, | ||
QuicPacketCount initial_congestion_window, | ||
QuicPacketCount max_congestion_window, | ||
SendAlgorithmInterface* old_send_algorithm){ | ||
int v=type; | ||
SendAlgorithmInterface *algo=nullptr; | ||
if(kBBR==v){ | ||
algo=new BbrSender(clock->ApproximateNow(), rtt_stats, unacked_packets, | ||
initial_congestion_window, max_congestion_window, | ||
random, stats); | ||
}else if(kBBRv2==v){ | ||
algo=new Bbr2Sender(clock->ApproximateNow(), rtt_stats, unacked_packets, | ||
initial_congestion_window, max_congestion_window, random, stats, | ||
old_send_algorithm && | ||
old_send_algorithm->GetCongestionControlType() == kBBR | ||
? static_cast<BbrSender*>(old_send_algorithm) | ||
: nullptr); | ||
}else if(kCubicBytes==v){ | ||
algo=new TcpCubicSenderBytes(clock, rtt_stats, false /* don't use Reno */, | ||
initial_congestion_window, max_congestion_window, stats); | ||
}else{ | ||
algo=new TcpCubicSenderBytes(clock, rtt_stats, true /* use Reno */, | ||
initial_congestion_window, | ||
max_congestion_window, stats); | ||
} | ||
return algo; | ||
} | ||
Ns3QuicCongestionFactory* CreateCongestionFactory() { | ||
static NoDestructor<Ns3QuicCongestionFactory> singleton; | ||
return singleton.get(); | ||
} | ||
void RegisterExternalCongestionFactory(){ | ||
SetCongestionFactory(CreateCongestionFactory()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
#include "gquiche/quic/core/congestion_control/send_algorithm_interface.h" | ||
namespace quic{ | ||
enum CongestionControlType2{ | ||
kCC0=CongestionControlType::kBBRv2, | ||
kSelfDefineCC1, | ||
}; | ||
void RegisterExternalCongestionFactory(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#pragma once | ||
namespace quic{ | ||
//copy from leveldb | ||
// Wraps an instance whose destructor is never called. | ||
// | ||
// This is intended for use with function-level static variables. | ||
template <typename InstanceType> | ||
class NoDestructor { | ||
public: | ||
template <typename... ConstructorArgTypes> | ||
explicit NoDestructor(ConstructorArgTypes&&... constructor_args) { | ||
static_assert(sizeof(instance_storage_) >= sizeof(InstanceType), | ||
"instance_storage_ is not large enough to hold the instance"); | ||
static_assert( | ||
alignof(decltype(instance_storage_)) >= alignof(InstanceType), | ||
"instance_storage_ does not meet the instance's alignment requirement"); | ||
new (&instance_storage_) | ||
InstanceType(std::forward<ConstructorArgTypes>(constructor_args)...); | ||
} | ||
|
||
~NoDestructor() = default; | ||
|
||
NoDestructor(const NoDestructor&) = delete; | ||
NoDestructor& operator=(const NoDestructor&) = delete; | ||
|
||
InstanceType* get() { | ||
return reinterpret_cast<InstanceType*>(&instance_storage_); | ||
} | ||
|
||
private: | ||
typename std::aligned_storage<sizeof(InstanceType), | ||
alignof(InstanceType)>::type instance_storage_; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters