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
|
|
|
|
2023-08-30 03:03:43 +02:00
|
|
|
struct CUBIC : public FlowOnly {
|
2023-08-24 18:04:25 +02:00
|
|
|
public: // config
|
2023-09-02 02:28:22 +02:00
|
|
|
static constexpr float BETA {0.8f};
|
2023-08-24 18:04:25 +02:00
|
|
|
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};
|
2024-05-27 11:59:32 +02:00
|
|
|
|
|
|
|
double _time_since_reduction {12.f}; // warm start
|
2023-08-24 18:04:25 +02:00
|
|
|
|
|
|
|
private:
|
2024-05-27 11:59:32 +02:00
|
|
|
void updateReductionTimer(float time_delta);
|
|
|
|
void resetReductionTimer(void);
|
|
|
|
|
2023-08-24 18:04:25 +02:00
|
|
|
float getCWnD(void) const;
|
|
|
|
|
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) {}
|
2024-03-05 16:48:58 +01:00
|
|
|
virtual ~CUBIC(void) {}
|
2023-08-24 18:04:25 +02:00
|
|
|
|
2024-07-12 13:14:24 +02:00
|
|
|
float getWindow(void) const override;
|
2023-09-08 00:41:25 +02:00
|
|
|
|
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
|
2024-01-07 17:23:06 +01:00
|
|
|
int64_t canSend(float time_delta) override;
|
2023-08-24 18:04:25 +02:00
|
|
|
};
|
|
|
|
|