2023-08-24 18:04:25 +02:00
|
|
|
#pragma once
|
|
|
|
|
2023-08-30 03:03:43 +02:00
|
|
|
#include "./flow_only.hpp"
|
2023-08-24 18:04:25 +02:00
|
|
|
|
|
|
|
#include <chrono>
|
|
|
|
|
2023-08-30 03:03:43 +02:00
|
|
|
struct CUBIC : public FlowOnly {
|
|
|
|
//using clock = std::chrono::steady_clock;
|
2023-08-24 18:04:25 +02:00
|
|
|
|
|
|
|
public: // config
|
|
|
|
static constexpr float BETA {0.7f};
|
|
|
|
static constexpr float SCALING_CONSTANT {0.4f};
|
|
|
|
static constexpr float RTT_EMA_ALPHA = 0.1f; // 0.1 is very smooth, might need more
|
|
|
|
|
|
|
|
private:
|
|
|
|
// window size before last reduciton
|
|
|
|
double _window_max {2.f * MAXIMUM_SEGMENT_SIZE}; // start with mss*2
|
2023-08-30 03:03:43 +02:00
|
|
|
//double _window_last_max {2.f * MAXIMUM_SEGMENT_SIZE};
|
|
|
|
double _time_point_reduction {getTimeNow()};
|
2023-08-24 18:04:25 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
float getCWnD(void) const;
|
|
|
|
|
|
|
|
// moving avg over the last few delay samples
|
|
|
|
// VERY sensitive to bundling acks
|
2023-08-30 03:03:43 +02:00
|
|
|
//float getCurrentDelay(void) const;
|
|
|
|
|
|
|
|
//void addRTT(float new_delay);
|
2023-08-24 18:04:25 +02:00
|
|
|
|
2023-08-30 03:03:43 +02:00
|
|
|
void onCongestion(void) override;
|
2023-08-24 18:04:25 +02:00
|
|
|
|
|
|
|
public: // api
|
2023-08-30 03:03:43 +02:00
|
|
|
CUBIC(size_t maximum_segment_data_size) : FlowOnly(maximum_segment_data_size) {}
|
2023-08-24 18:04:25 +02:00
|
|
|
|
|
|
|
// TODO: api for how much data we should send
|
|
|
|
// take time since last sent into account
|
|
|
|
// respect max_byterate_allowed
|
2023-08-29 18:21:12 +02:00
|
|
|
size_t canSend(void) override;
|
2023-08-24 18:04:25 +02:00
|
|
|
|
|
|
|
// get the list of timed out seq_ids
|
2023-08-30 03:03:43 +02:00
|
|
|
//std::vector<SeqIDType> getTimeouts(void) const override;
|
2023-08-24 18:04:25 +02:00
|
|
|
|
|
|
|
public: // callbacks
|
|
|
|
// data size is without overhead
|
2023-08-30 03:03:43 +02:00
|
|
|
//void onSent(SeqIDType seq, size_t data_size) override;
|
2023-08-24 18:04:25 +02:00
|
|
|
|
2023-08-30 03:03:43 +02:00
|
|
|
//void onAck(std::vector<SeqIDType> seqs) override;
|
2023-08-24 18:04:25 +02:00
|
|
|
|
|
|
|
// if discard, not resent, not inflight
|
2023-08-30 03:03:43 +02:00
|
|
|
//void onLoss(SeqIDType seq, bool discard) override;
|
2023-08-24 18:04:25 +02:00
|
|
|
};
|
|
|
|
|