Browse Source

NACKs and Acks only Ack ranges

pull/1774/head
orignal 2 years ago
parent
commit
8b649aaaf8
  1. 42
      libi2pd/SSU2Session.cpp

42
libi2pd/SSU2Session.cpp

@ -1917,22 +1917,38 @@ namespace transport
uint32_t lastNum = ackThrough - acnt; uint32_t lastNum = ackThrough - acnt;
while (it != m_OutOfSequencePackets.rend () && numRanges < SSU2_MAX_NUM_ACK_RANGES) while (it != m_OutOfSequencePackets.rend () && numRanges < SSU2_MAX_NUM_ACK_RANGES)
{ {
if (lastNum - (*it) < 255) if (lastNum - (*it) > 255)
{ {
buf[8 + numRanges*2] = lastNum - (*it) - 1; // NACKs // NACKs only ranges
lastNum = *it; it++; if (lastNum > (*it) + 255*(SSU2_MAX_NUM_ACK_RANGES - numRanges)) break; // too many NACKs
uint8_t numAcks = 1; while (lastNum - (*it) > 255)
while (it != m_OutOfSequencePackets.rend () && numAcks < 255 && lastNum > 0 && *it == lastNum - 1)
{ {
numAcks++; lastNum--; buf[8 + numRanges*2] = 255; buf[8 + numRanges*2 + 1] = 0; // NACKs 255, Acks 0
it++; lastNum -= 255;
numRanges++;
} }
buf[8 + numRanges*2 + 1] = numAcks; // Acks }
numRanges++; // NACKs and Acks ranges
if (numAcks == 255) break; buf[8 + numRanges*2] = lastNum - (*it) - 1; // NACKs
lastNum = *it; it++;
int numAcks = 1;
while (it != m_OutOfSequencePackets.rend () && lastNum > 0 && *it == lastNum - 1)
{
numAcks++; lastNum--;
it++;
} }
else while (numAcks > 255)
break; {
// Acks only ranges
buf[8 + numRanges*2 + 1] = 255; // Acks 255
numAcks -= 255;
numRanges++;
buf[8 + numRanges*2] = 0; // NACKs 0
if (numRanges >= SSU2_MAX_NUM_ACK_RANGES) break;
}
if (numAcks > 255) numAcks = 255;
buf[8 + numRanges*2 + 1] = (uint8_t)numAcks; // Acks
numRanges++;
} }
if (numRanges < SSU2_MAX_NUM_ACK_RANGES && it == m_OutOfSequencePackets.rend ()) if (numRanges < SSU2_MAX_NUM_ACK_RANGES && it == m_OutOfSequencePackets.rend ())
{ {

Loading…
Cancel
Save