Browse Source

NACKs and Acks only Ack ranges

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

38
libi2pd/SSU2Session.cpp

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

Loading…
Cancel
Save