mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
correct ack ranges calculation
This commit is contained in:
parent
b918499f14
commit
b744a0cc38
|
@ -1607,26 +1607,32 @@ namespace transport
|
||||||
}
|
}
|
||||||
// ranges
|
// ranges
|
||||||
uint32_t lastNum = ackThrough - acnt;
|
uint32_t lastNum = ackThrough - acnt;
|
||||||
it++;
|
while (it != m_OutOfSequencePackets.rend () && lastNum > m_ReceivePacketNum && numRanges < SSU2_MAX_NUM_ACK_RANGES)
|
||||||
while (it != m_OutOfSequencePackets.rend () && lastNum > m_ReceivePacketNum && numRanges < 8)
|
|
||||||
{
|
{
|
||||||
if (lastNum - (*it) < 255)
|
if (lastNum - (*it) < 255)
|
||||||
{
|
{
|
||||||
buf[7 + numRanges*2] = lastNum - (*it); // NACKs
|
buf[7 + numRanges*2] = lastNum - (*it) - 1; // NACKs
|
||||||
lastNum = *it;
|
lastNum = *it; it++;
|
||||||
uint8_t numAcks = 0;
|
uint8_t numAcks = 1;
|
||||||
while (it != m_OutOfSequencePackets.rend () && numAcks < 255 && lastNum > m_ReceivePacketNum && *it == lastNum - 1)
|
while (it != m_OutOfSequencePackets.rend () && numAcks < 255 && lastNum > m_ReceivePacketNum && *it == lastNum - 1)
|
||||||
{
|
{
|
||||||
numAcks++; lastNum--;
|
numAcks++; lastNum--;
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
buf[7 + numRanges*2 + 1] = numAcks; // Acks
|
buf[7 + numRanges*2 + 1] = numAcks; // Acks
|
||||||
numRanges++; it++;
|
numRanges++;
|
||||||
if (numAcks == 255) break;
|
if (numAcks == 255) break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (numRanges < SSU2_MAX_NUM_ACK_RANGES && m_ReceivePacketNum)
|
||||||
|
{
|
||||||
|
// add received packets to last range
|
||||||
|
int numAcks = buf[7 + numRanges*2 + 1] + m_ReceivePacketNum;
|
||||||
|
if (numAcks > 255) numAcks = 255;
|
||||||
|
buf[7 + numRanges*2 + 1] = numAcks;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buf[7] = acnt; // acnt
|
buf[7] = acnt; // acnt
|
||||||
|
|
|
@ -34,6 +34,7 @@ namespace transport
|
||||||
const int SSU2_MAX_NUM_RESENDS = 5;
|
const int SSU2_MAX_NUM_RESENDS = 5;
|
||||||
const int SSU2_INCOMPLETE_MESSAGES_CLEANUP_TIMEOUT = 30; // in seconds
|
const int SSU2_INCOMPLETE_MESSAGES_CLEANUP_TIMEOUT = 30; // in seconds
|
||||||
const size_t SSU2_MAX_WINDOW_SIZE = 128; // in packets
|
const size_t SSU2_MAX_WINDOW_SIZE = 128; // in packets
|
||||||
|
const int SSU2_MAX_NUM_ACK_RANGES = 32; // to send
|
||||||
|
|
||||||
enum SSU2MessageType
|
enum SSU2MessageType
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue