From a1a9bf886ab74d2e8152f974ea290850f7ffdfda Mon Sep 17 00:00:00 2001 From: Green Sky Date: Fri, 1 Sep 2023 15:51:28 +0200 Subject: [PATCH] make cubic and flow more resilient --- solanaceae/ngc_ft1/cubic.cpp | 8 +++++--- solanaceae/ngc_ft1/flow_only.cpp | 16 +++++++++------- solanaceae/ngc_ft1/flow_only.hpp | 3 ++- solanaceae/ngc_ft1/ngcft1.cpp | 3 ++- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/solanaceae/ngc_ft1/cubic.cpp b/solanaceae/ngc_ft1/cubic.cpp index b538802..b9548dd 100644 --- a/solanaceae/ngc_ft1/cubic.cpp +++ b/solanaceae/ngc_ft1/cubic.cpp @@ -33,12 +33,14 @@ float CUBIC::getCWnD(void) const { } void CUBIC::onCongestion(void) { - if (getTimeNow() - _time_point_reduction >= getCurrentDelay()) { + if (getTimeNow() - _time_point_reduction >= getCurrentDelay()*4.f) { const auto current_cwnd = getCWnD(); _time_point_reduction = getTimeNow(); - _window_max = current_cwnd; + _window_max = current_cwnd * BETA; + _window_max = std::max(_window_max, 2.*MAXIMUM_SEGMENT_SIZE); - std::cout << "CONGESTION! cwnd:" << current_cwnd << "\n"; + //std::cout << "CONGESTION! cwnd:" << current_cwnd << "\n"; + std::cout << "CONGESTION! cwnd_max:" << _window_max << "\n"; } } diff --git a/solanaceae/ngc_ft1/flow_only.cpp b/solanaceae/ngc_ft1/flow_only.cpp index 5bbfe43..a33e40a 100644 --- a/solanaceae/ngc_ft1/flow_only.cpp +++ b/solanaceae/ngc_ft1/flow_only.cpp @@ -10,6 +10,11 @@ float FlowOnly::getCurrentDelay(void) const { } void FlowOnly::addRTT(float new_delay) { + if (new_delay > _rtt_ema * RTT_UP_MAX) { + // too large a jump up, to be taken into account + return; + } + // lerp(new_delay, rtt_ema, 0.1) _rtt_ema = RTT_EMA_ALPHA * new_delay + (1.f - RTT_EMA_ALPHA) * _rtt_ema; } @@ -88,13 +93,10 @@ void FlowOnly::onAck(std::vector seqs) { if (it != _in_flight.begin()) { // not next expected seq -> skip detected - std::cout << "CONGESTION out of order\n"; + // TODO: change expectations of next seq in order, so we dont trigger a flood of ce + + //std::cout << "CONGESTION out of order\n"; onCongestion(); - //if (getTimeNow() >= _last_congestion_event + _last_congestion_rtt) { - //_recently_lost_data = true; - //_last_congestion_event = getTimeNow(); - //_last_congestion_rtt = getCurrentDelay(); - //} } else { // only mesure delay, if not a congestion addRTT(now - std::get<1>(*it)); @@ -137,7 +139,7 @@ void FlowOnly::onLoss(SeqIDType seq, bool discard) { return; // not found, ignore ?? } - std::cerr << "FLOW loss\n"; + //std::cerr << "FLOW loss\n"; // "if data lost is not to be retransmitted" if (discard) { diff --git a/solanaceae/ngc_ft1/flow_only.hpp b/solanaceae/ngc_ft1/flow_only.hpp index ce2a036..4ef7c83 100644 --- a/solanaceae/ngc_ft1/flow_only.hpp +++ b/solanaceae/ngc_ft1/flow_only.hpp @@ -11,7 +11,8 @@ struct FlowOnly : public CCAI { using clock = std::chrono::steady_clock; public: // config - static constexpr float RTT_EMA_ALPHA = 0.1f; // might need over time + static constexpr float RTT_EMA_ALPHA = 0.001f; // might need change over time + static constexpr float RTT_UP_MAX = 3.0f; // how much larger a delay can be to be taken into account static constexpr float RTT_MAX = 2.f; // 2 sec is probably too much //float max_byterate_allowed {100.f*1024*1024}; // 100MiB/s diff --git a/solanaceae/ngc_ft1/ngcft1.cpp b/solanaceae/ngc_ft1/ngcft1.cpp index 2e33308..5bff1b3 100644 --- a/solanaceae/ngc_ft1/ngcft1.cpp +++ b/solanaceae/ngc_ft1/ngcft1.cpp @@ -599,7 +599,8 @@ bool NGCFT1::onEvent(const Events::NGCEXT_ft1_data_ack& e) { Group::Peer& peer = groups[e.group_number].peers[e.peer_number]; if (!peer.send_transfers[e.transfer_id].has_value()) { - std::cerr << "NGCFT1 warning: data_ack for unknown transfer\n"; + // we delete directly, packets might still be in flight (in practice they are when ce) + //std::cerr << "NGCFT1 warning: data_ack for unknown transfer\n"; return true; }