From fab3d42ee97fac87bafa3ffb6068b9ccbe2ee0ce Mon Sep 17 00:00:00 2001 From: Green Sky Date: Sun, 7 Jul 2024 15:27:30 +0200 Subject: [PATCH] transfer time temporality buffer --- solanaceae/ngc_ft1/ngcft1.cpp | 5 +++++ solanaceae/ngc_ft1/ngcft1.hpp | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/solanaceae/ngc_ft1/ngcft1.cpp b/solanaceae/ngc_ft1/ngcft1.cpp index 1c4d386..67dbebf 100644 --- a/solanaceae/ngc_ft1/ngcft1.cpp +++ b/solanaceae/ngc_ft1/ngcft1.cpp @@ -212,6 +212,7 @@ NGCFT1::NGCFT1( } float NGCFT1::iterate(float time_delta) { + _time_since_activity += time_delta; bool transfer_in_progress {false}; for (auto& [group_number, group] : groups) { for (auto& [peer_number, peer] : group.peers) { @@ -238,9 +239,13 @@ float NGCFT1::iterate(float time_delta) { } if (transfer_in_progress) { + _time_since_activity = 0.f; // ~15ms for up to 1mb/s // ~5ms for up to 4mb/s return 0.005f; // 5ms + } else if (_time_since_activity < 0.5f) { + // bc of temporality + return 0.025f; } else { return 1.f; // once a sec might be too little } diff --git a/solanaceae/ngc_ft1/ngcft1.hpp b/solanaceae/ngc_ft1/ngcft1.hpp index c96b59c..c6e5779 100644 --- a/solanaceae/ngc_ft1/ngcft1.hpp +++ b/solanaceae/ngc_ft1/ngcft1.hpp @@ -135,12 +135,13 @@ class NGCFT1 : public ToxEventI, public NGCEXTEventI, public NGCFT1EventProvider std::default_random_engine _rng{std::random_device{}()}; + float _time_since_activity {10.f}; + // TODO: config size_t acks_per_packet {3u}; // 3 float init_retry_timeout_after {4.f}; float sending_give_up_after {15.f}; // 30sec (per active transfer) - struct Group { struct Peer { uint32_t max_packet_data_size {500-4};