minor tweaks and fixes
especially preventing a stall on some packetloss scenarios
This commit is contained in:
parent
ee593536a2
commit
2a0350a564
@ -7,7 +7,9 @@ void CUBIC::updateReductionTimer(float time_delta) {
|
|||||||
const auto now {getTimeNow()};
|
const auto now {getTimeNow()};
|
||||||
|
|
||||||
// only keep updating while the cca interaction is not too long ago
|
// 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;
|
_time_since_reduction += time_delta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,12 +88,14 @@ int64_t CUBIC::canSend(float time_delta) {
|
|||||||
updateReductionTimer(time_delta);
|
updateReductionTimer(time_delta);
|
||||||
|
|
||||||
if (fspace_pkgs == 0u) {
|
if (fspace_pkgs == 0u) {
|
||||||
|
std::cerr << "CUBIC: flow said 0\n";
|
||||||
return 0u;
|
return 0u;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto window = getCWnD();
|
const auto window = getCWnD();
|
||||||
int64_t cspace_bytes = window - _in_flight_bytes;
|
int64_t cspace_bytes = window - _in_flight_bytes;
|
||||||
if (cspace_bytes < MAXIMUM_SEGMENT_DATA_SIZE) {
|
if (cspace_bytes < MAXIMUM_SEGMENT_DATA_SIZE) {
|
||||||
|
//std::cerr << "CUBIC: cspace < seg size\n";
|
||||||
return 0u;
|
return 0u;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,8 @@ float FlowOnly::getWindow(void) const {
|
|||||||
int64_t FlowOnly::canSend(float time_delta) {
|
int64_t FlowOnly::canSend(float time_delta) {
|
||||||
if (_in_flight.empty()) {
|
if (_in_flight.empty()) {
|
||||||
assert(_in_flight_bytes == 0);
|
assert(_in_flight_bytes == 0);
|
||||||
return MAXIMUM_SEGMENT_DATA_SIZE;
|
// TODO: should we really exit early here??
|
||||||
|
return 2*MAXIMUM_SEGMENT_DATA_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateWindow();
|
updateWindow();
|
||||||
|
@ -40,22 +40,24 @@ void NGCFT1::updateSendTransfer(float time_delta, uint32_t group_number, uint32_
|
|||||||
} else {
|
} else {
|
||||||
// timed out, resend
|
// timed out, resend
|
||||||
std::cerr << "NGCFT1 warning: ft init timed out, resending\n";
|
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());
|
_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.inits_sent++;
|
||||||
tf.time_since_activity = 0.f;
|
tf.time_since_activity = 0.f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//break;
|
break;
|
||||||
return;
|
|
||||||
case State::FINISHING: // we still have unacked packets
|
case State::FINISHING: // we still have unacked packets
|
||||||
tf.ssb.for_each(time_delta, [&](uint16_t id, const std::vector<uint8_t>& data, float& time_since_activity) {
|
tf.ssb.for_each(time_delta, [&](uint16_t id, const std::vector<uint8_t>& data, float& time_since_activity) {
|
||||||
if (can_packet_size >= data.size() && timeouts_set.count({idx, id})) {
|
if (timeouts_set.count({idx, id})) {
|
||||||
_neep.send_ft1_data(group_number, peer_number, idx, id, data.data(), data.size());
|
if (can_packet_size >= data.size()) {
|
||||||
peer.cca->onLoss({idx, id}, false);
|
_neep.send_ft1_data(group_number, peer_number, idx, id, data.data(), data.size());
|
||||||
time_since_activity = 0.f;
|
peer.cca->onLoss({idx, id}, false);
|
||||||
timeouts_set.erase({idx, id});
|
time_since_activity = 0.f;
|
||||||
can_packet_size -= data.size();
|
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) {
|
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++) {
|
for (size_t idx = 0; idx < peer.recv_transfers.size(); idx++) {
|
||||||
if (!peer.recv_transfers.at(idx).has_value()) {
|
if (!peer.recv_transfers.at(idx).has_value()) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -143,7 +143,7 @@ class NGCFT1 : public ToxEventI, public NGCEXTEventI, public NGCFT1EventProvider
|
|||||||
// TODO: config
|
// TODO: config
|
||||||
size_t acks_per_packet {3u}; // 3
|
size_t acks_per_packet {3u}; // 3
|
||||||
float init_retry_timeout_after {4.f};
|
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 Group {
|
||||||
struct Peer {
|
struct Peer {
|
||||||
|
Loading…
Reference in New Issue
Block a user