From d88c73c7614011c472a221a496f83fe48fe8a001 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Thu, 31 Oct 2024 12:35:32 +0100 Subject: [PATCH] accounted --- solanaceae/ngc_ft1/cca.hpp | 4 ++++ solanaceae/ngc_ft1/cubic.cpp | 3 ++- solanaceae/ngc_ft1/flow_only.cpp | 27 ++++++++++++++++++++++++++- solanaceae/ngc_ft1/flow_only.hpp | 4 ++++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/solanaceae/ngc_ft1/cca.hpp b/solanaceae/ngc_ft1/cca.hpp index 4d8a9d2..635f1e9 100644 --- a/solanaceae/ngc_ft1/cca.hpp +++ b/solanaceae/ngc_ft1/cca.hpp @@ -61,6 +61,10 @@ struct CCAI { // returns -1 if not implemented, can return 0 virtual int64_t inFlightBytes(void) const { return -1; } + // returns -1 if not implemented, can return 0 + // excluded timed out packets (not those currently resent) + virtual int64_t inFlightBytesAccounted(void) const { return -1; } + public: // callbacks // data size is without overhead virtual void onSent(SeqIDType seq, size_t data_size) = 0; diff --git a/solanaceae/ngc_ft1/cubic.cpp b/solanaceae/ngc_ft1/cubic.cpp index aa02725..0f4bc38 100644 --- a/solanaceae/ngc_ft1/cubic.cpp +++ b/solanaceae/ngc_ft1/cubic.cpp @@ -93,7 +93,8 @@ int64_t CUBIC::canSend(float time_delta) { } const auto window = getCWnD(); - int64_t cspace_bytes = window - _in_flight_bytes; + //int64_t cspace_bytes = window - _in_flight_bytes; + int64_t cspace_bytes = window - _in_flight_bytes_accounted; if (cspace_bytes < MAXIMUM_SEGMENT_DATA_SIZE) { //std::cerr << "CUBIC: cspace < seg size\n"; return 0u; diff --git a/solanaceae/ngc_ft1/flow_only.cpp b/solanaceae/ngc_ft1/flow_only.cpp index c7247b8..32814e4 100644 --- a/solanaceae/ngc_ft1/flow_only.cpp +++ b/solanaceae/ngc_ft1/flow_only.cpp @@ -29,6 +29,25 @@ void FlowOnly::updateWindow(void) { _fwnd = std::max(_fwnd, 2.f * MAXIMUM_SEGMENT_DATA_SIZE); } +void FlowOnly::updateAccounted(void) { + int64_t size_timedout {0}; + + { // can be expensive + // code see getTimeouts() + // after 3 rtt delay, we trigger timeout + const auto now_adjusted = getTimeNow() - getCurrentDelay()*3.f; + + for (const auto& [seq, time_stamp, size, _] : _in_flight) { + if (now_adjusted > time_stamp) { + //list.push_back(seq); + size_timedout += size; + } + } + } + + _in_flight_bytes_accounted = _in_flight_bytes - size_timedout; +} + void FlowOnly::updateCongestion(void) { updateWindow(); const auto tmp_window = getWindow(); @@ -70,8 +89,10 @@ int64_t FlowOnly::canSend(float time_delta) { } updateWindow(); + updateAccounted(); - int64_t fspace = _fwnd - _in_flight_bytes; + //int64_t fspace = _fwnd - _in_flight_bytes; + int64_t fspace = _fwnd - _in_flight_bytes_accounted; if (fspace < MAXIMUM_SEGMENT_DATA_SIZE) { return 0u; } @@ -107,6 +128,10 @@ int64_t FlowOnly::inFlightBytes(void) const { return _in_flight_bytes; } +int64_t FlowOnly::inFlightBytesAccounted(void) const { + return _in_flight_bytes_accounted; +} + void FlowOnly::onSent(SeqIDType seq, size_t data_size) { if constexpr (true) { size_t sum {0u}; diff --git a/solanaceae/ngc_ft1/flow_only.hpp b/solanaceae/ngc_ft1/flow_only.hpp index 3322a30..2739744 100644 --- a/solanaceae/ngc_ft1/flow_only.hpp +++ b/solanaceae/ngc_ft1/flow_only.hpp @@ -32,6 +32,7 @@ struct FlowOnly : public CCAI { }; std::vector _in_flight; int64_t _in_flight_bytes {0}; + int64_t _in_flight_bytes_accounted {0}; int32_t _consecutive_events {0}; @@ -58,6 +59,8 @@ struct FlowOnly : public CCAI { void updateWindow(void); + void updateAccounted(void); + virtual void onCongestion(void) {}; // internal logic, calls the onCongestion() event @@ -77,6 +80,7 @@ struct FlowOnly : public CCAI { int64_t inFlightCount(void) const override; int64_t inFlightBytes(void) const override; + int64_t inFlightBytesAccounted(void) const override; public: // callbacks // data size is without overhead