mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
ranges in ack block
This commit is contained in:
parent
05946125b5
commit
8c3e716c3f
|
@ -1038,9 +1038,9 @@ namespace transport
|
||||||
if (len < 8) return 0;
|
if (len < 8) return 0;
|
||||||
buf[0] = eSSU2BlkAck;
|
buf[0] = eSSU2BlkAck;
|
||||||
uint32_t ackThrough = m_OutOfSequencePackets.empty () ? m_ReceivePacketNum : *m_OutOfSequencePackets.rbegin ();
|
uint32_t ackThrough = m_OutOfSequencePackets.empty () ? m_ReceivePacketNum : *m_OutOfSequencePackets.rbegin ();
|
||||||
htobe16buf (buf + 1, 5);
|
|
||||||
htobe32buf (buf + 3, ackThrough); // Ack Through
|
htobe32buf (buf + 3, ackThrough); // Ack Through
|
||||||
uint8_t acnt = 0;
|
uint8_t acnt = 0;
|
||||||
|
int numRanges = 0;
|
||||||
if (ackThrough)
|
if (ackThrough)
|
||||||
{
|
{
|
||||||
if (m_OutOfSequencePackets.empty ())
|
if (m_OutOfSequencePackets.empty ())
|
||||||
|
@ -1053,10 +1053,32 @@ namespace transport
|
||||||
acnt++;
|
acnt++;
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
|
// ranges
|
||||||
|
uint32_t lastNum = ackThrough - acnt;
|
||||||
|
it++;
|
||||||
|
while (it != m_OutOfSequencePackets.rend () && lastNum > m_ReceivePacketNum && numRanges < 8)
|
||||||
|
{
|
||||||
|
if (lastNum - (*it) < 255)
|
||||||
|
{
|
||||||
|
buf[7 + numRanges*2] = lastNum - (*it); // NACKs
|
||||||
|
lastNum = *it;
|
||||||
|
uint8_t numAcks = 0;
|
||||||
|
while (it != m_OutOfSequencePackets.rend () && numAcks < 255 && lastNum > m_ReceivePacketNum && *it == lastNum - 1)
|
||||||
|
{
|
||||||
|
numAcks++; lastNum--;
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
buf[7 + numRanges*2 + 1] = numAcks; // Acks
|
||||||
|
numRanges++; it++;
|
||||||
|
if (numAcks == 255) break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buf[7] = acnt; // acnt
|
buf[7] = acnt; // acnt
|
||||||
// TODO: ranges
|
htobe16buf (buf + 1, 5 + numRanges*2);
|
||||||
return 8;
|
return 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue