diff --git a/solanaceae/ngc_ft1/cubic.cpp b/solanaceae/ngc_ft1/cubic.cpp index d1c12e3..aa02725 100644 --- a/solanaceae/ngc_ft1/cubic.cpp +++ b/solanaceae/ngc_ft1/cubic.cpp @@ -7,7 +7,9 @@ void CUBIC::updateReductionTimer(float time_delta) { const auto now {getTimeNow()}; // only keep updating while the cca interaction is not too long ago - if (now - _time_point_last_update <= getCurrentDelay()*4.f) { + // or simply when there are packets in flight + // (you need space to resend timedout, which still use up pipe space) + if (!_in_flight.empty() || now - _time_point_last_update <= getCurrentDelay()*4.f) { _time_since_reduction += time_delta; } } @@ -86,12 +88,14 @@ int64_t CUBIC::canSend(float time_delta) { updateReductionTimer(time_delta); if (fspace_pkgs == 0u) { + std::cerr << "CUBIC: flow said 0\n"; return 0u; } const auto window = getCWnD(); int64_t cspace_bytes = window - _in_flight_bytes; 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 7f4a5bf..c7247b8 100644 --- a/solanaceae/ngc_ft1/flow_only.cpp +++ b/solanaceae/ngc_ft1/flow_only.cpp @@ -65,7 +65,8 @@ float FlowOnly::getWindow(void) const { int64_t FlowOnly::canSend(float time_delta) { if (_in_flight.empty()) { assert(_in_flight_bytes == 0); - return MAXIMUM_SEGMENT_DATA_SIZE; + // TODO: should we really exit early here?? + return 2*MAXIMUM_SEGMENT_DATA_SIZE; } updateWindow(); diff --git a/solanaceae/ngc_ft1/ngcft1.cpp b/solanaceae/ngc_ft1/ngcft1.cpp index 0da3c77..f691cfd 100644 --- a/solanaceae/ngc_ft1/ngcft1.cpp +++ b/solanaceae/ngc_ft1/ngcft1.cpp @@ -40,22 +40,24 @@ void NGCFT1::updateSendTransfer(float time_delta, uint32_t group_number, uint32_ } else { // timed out, resend std::cerr << "NGCFT1 warning: ft init timed out, resending\n"; - //sendPKG_FT1_INIT(group_number, peer_number, tf.file_kind, tf.file_size, idx, tf.file_id.data(), tf.file_id.size()); _neep.send_ft1_init(group_number, peer_number, tf.file_kind, tf.file_size, idx, tf.file_id.data(), tf.file_id.size()); tf.inits_sent++; tf.time_since_activity = 0.f; } } - //break; - return; + break; case State::FINISHING: // we still have unacked packets tf.ssb.for_each(time_delta, [&](uint16_t id, const std::vector& data, float& time_since_activity) { - if (can_packet_size >= data.size() && timeouts_set.count({idx, id})) { - _neep.send_ft1_data(group_number, peer_number, idx, id, data.data(), data.size()); - peer.cca->onLoss({idx, id}, false); - time_since_activity = 0.f; - timeouts_set.erase({idx, id}); - can_packet_size -= data.size(); + if (timeouts_set.count({idx, id})) { + if (can_packet_size >= data.size()) { + _neep.send_ft1_data(group_number, peer_number, idx, id, data.data(), data.size()); + peer.cca->onLoss({idx, id}, false); + time_since_activity = 0.f; + timeouts_set.erase({idx, id}); + can_packet_size -= data.size(); + } else { + std::cerr << "NGCFT1 warning: no space to resend timedout\n"; + } } }); if (tf.time_since_activity >= sending_give_up_after) { @@ -198,7 +200,6 @@ void NGCFT1::iteratePeer(float time_delta, uint32_t group_number, uint32_t peer_ } } - //for (auto& transfer_opt : peer.recv_transfers) { for (size_t idx = 0; idx < peer.recv_transfers.size(); idx++) { if (!peer.recv_transfers.at(idx).has_value()) { continue; diff --git a/solanaceae/ngc_ft1/ngcft1.hpp b/solanaceae/ngc_ft1/ngcft1.hpp index f098923..44d9dda 100644 --- a/solanaceae/ngc_ft1/ngcft1.hpp +++ b/solanaceae/ngc_ft1/ngcft1.hpp @@ -143,7 +143,7 @@ class NGCFT1 : public ToxEventI, public NGCEXTEventI, public NGCFT1EventProvider // 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) + float sending_give_up_after {10.f}; // sec (per active transfer) struct Group { struct Peer {