better filter and cubic fixes

This commit is contained in:
Green Sky 2023-09-08 00:41:25 +02:00
parent f91780c602
commit 7af5fda0a6
No known key found for this signature in database
5 changed files with 43 additions and 4 deletions

View File

@ -49,6 +49,8 @@ struct CCAI {
// returns current rtt/delay // returns current rtt/delay
virtual float getCurrentDelay(void) const = 0; virtual float getCurrentDelay(void) const = 0;
virtual float getWindow(void) = 0;
// TODO: api for how much data we should send // TODO: api for how much data we should send
// take time since last sent into account // take time since last sent into account
// respect max_byterate_allowed // respect max_byterate_allowed

View File

@ -37,12 +37,17 @@ void CUBIC::onCongestion(void) {
const auto tmp_old_tp = getTimeNow() - _time_point_reduction; const auto tmp_old_tp = getTimeNow() - _time_point_reduction;
const auto current_cwnd = getCWnD(); const auto current_cwnd = getCWnD();
const auto current_wnd = getWindow(); // respects cwnd and fwnd
_time_point_reduction = getTimeNow(); _time_point_reduction = getTimeNow();
_window_max = current_cwnd * BETA; //_window_max = current_cwnd * BETA;
_window_max = current_wnd * BETA;
_window_max = std::max(_window_max, 2.*MAXIMUM_SEGMENT_SIZE); _window_max = std::max(_window_max, 2.*MAXIMUM_SEGMENT_SIZE);
#if 1 #if 1
std::cout << "----CONGESTION!" std::cout << "----CONGESTION!"
<< " cwnd:" << current_cwnd
<< " wnd:" << current_wnd
<< " cwnd_max:" << _window_max << " cwnd_max:" << _window_max
<< " pts:" << tmp_old_tp << " pts:" << tmp_old_tp
<< " rtt:" << getCurrentDelay() << " rtt:" << getCurrentDelay()
@ -52,6 +57,10 @@ void CUBIC::onCongestion(void) {
} }
} }
float CUBIC::getWindow(void) {
return std::min<float>(getCWnD(), FlowOnly::getWindow());
}
int64_t CUBIC::canSend(void) { int64_t CUBIC::canSend(void) {
const auto fspace_pkgs = FlowOnly::canSend(); const auto fspace_pkgs = FlowOnly::canSend();

View File

@ -33,6 +33,8 @@ struct CUBIC : public FlowOnly {
public: // api public: // api
CUBIC(size_t maximum_segment_data_size) : FlowOnly(maximum_segment_data_size) {} CUBIC(size_t maximum_segment_data_size) : FlowOnly(maximum_segment_data_size) {}
float getWindow(void) override;
// TODO: api for how much data we should send // TODO: api for how much data we should send
// take time since last sent into account // take time since last sent into account
// respect max_byterate_allowed // respect max_byterate_allowed

View File

@ -28,6 +28,11 @@ void FlowOnly::updateWindow(void) {
_fwnd = std::max(_fwnd, 2.f * MAXIMUM_SEGMENT_DATA_SIZE); _fwnd = std::max(_fwnd, 2.f * MAXIMUM_SEGMENT_DATA_SIZE);
} }
float FlowOnly::getWindow(void) {
updateWindow();
return _fwnd;
}
int64_t FlowOnly::canSend(void) { int64_t FlowOnly::canSend(void) {
if (_in_flight.empty()) { if (_in_flight.empty()) {
assert(_in_flight_bytes == 0); assert(_in_flight_bytes == 0);
@ -99,11 +104,30 @@ void FlowOnly::onAck(std::vector<SeqIDType> seqs) {
if (first_it != _in_flight.cend() && it != first_it) { if (first_it != _in_flight.cend() && it != first_it) {
// not next expected seq -> skip detected // not next expected seq -> skip detected
std::cout << "NGC_FT1 Flow: pkg out of order\n";
_consecutive_events++; _consecutive_events++;
it->ignore = true; // only handle once it->ignore = true; // only handle once
if (_consecutive_events > 4) { // TODO: magic number
std::cout << "CONGESTION! NGC_FT1 flow: pkg out of order\n"; const auto tmp_window = getWindow();
// packet window * 0.3
// but atleast 4
int32_t max_consecutive_events = std::clamp<int32_t>(
(tmp_window/MAXIMUM_SEGMENT_DATA_SIZE) * 0.3f,
4,
50 // limit TODO: fix idle/time starved algo
);
// TODO: magic number
#if 0
std::cout << "NGC_FT1 Flow: pkg out of order"
<< " w:" << tmp_window
<< " pw:" << tmp_window/MAXIMUM_SEGMENT_DATA_SIZE
<< " coe:" << _consecutive_events
<< " mcoe:" << max_consecutive_events
<< "\n";
#endif
if (_consecutive_events > max_consecutive_events) {
//std::cout << "CONGESTION! NGC_FT1 flow: pkg out of order\n";
onCongestion(); onCongestion();
} }
} else { } else {

View File

@ -57,6 +57,8 @@ struct FlowOnly : public CCAI {
// VERY sensitive to bundling acks // VERY sensitive to bundling acks
float getCurrentDelay(void) const override; float getCurrentDelay(void) const override;
float getWindow(void) override;
void addRTT(float new_delay); void addRTT(float new_delay);
void updateWindow(void); void updateWindow(void);