Skip to content

Commit

Permalink
don't send ack in case of lost packet and incoming speed limitation
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Sep 18, 2024
1 parent 2fa4237 commit ac1c28c
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions libi2pd/Streaming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,7 @@ namespace stream
// for limit inbound speed
auto ts = i2p::util::GetMillisecondsSinceEpoch ();
int numPackets = 0;
bool lostPackets = false;
int64_t passedTime = m_PacketACKInterval * INITIAL_WINDOW_SIZE; // in microseconds // while m_LastACKSendTime == 0
if (m_LastACKSendTime)
passedTime = (ts - m_LastACKSendTime)*1000; // in microseconds
Expand All @@ -851,8 +852,26 @@ namespace stream
for (auto it: m_SavedPackets)
{
auto seqn = it->GetSeqn ();
if (m_LastConfirmedReceivedSequenceNumber + numPackets < int(seqn)) break; // for limit inbound speed
if ((int)seqn > lastReceivedSeqn) lastReceivedSeqn = seqn;
// for limit inbound speed
if (m_LastConfirmedReceivedSequenceNumber + numPackets < int(seqn))
{
if (!m_IsAckSendScheduled)
{
auto ackTimeout = m_RTT/10;
if (ackTimeout > m_AckDelay) ackTimeout = m_AckDelay;
ScheduleAck (ackTimeout);
}
if (lostPackets)
break;
else
return;
}
// for limit inbound speed
if ((int)seqn > lastReceivedSeqn)
{
lastReceivedSeqn = seqn;
lostPackets = true; // for limit inbound speed
}
}
}
if (lastReceivedSeqn < 0)
Expand Down

0 comments on commit ac1c28c

Please sign in to comment.