mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 08:00:38 +03:00
handle NACKs
This commit is contained in:
parent
921ba9a9d6
commit
053d1d22ac
@ -183,13 +183,29 @@ namespace stream
|
|||||||
void Stream::ProcessAck (Packet * packet)
|
void Stream::ProcessAck (Packet * packet)
|
||||||
{
|
{
|
||||||
uint32_t ackThrough = packet->GetAckThrough ();
|
uint32_t ackThrough = packet->GetAckThrough ();
|
||||||
// TODO: handle NACKs
|
int nackCount = packet->GetNACKCount ();
|
||||||
for (auto it = m_SentPackets.begin (); it != m_SentPackets.end ();)
|
for (auto it = m_SentPackets.begin (); it != m_SentPackets.end ();)
|
||||||
{
|
{
|
||||||
if ((*it)->GetSeqn () <= ackThrough)
|
auto seqn = (*it)->GetSeqn ();
|
||||||
|
if (seqn <= ackThrough)
|
||||||
{
|
{
|
||||||
|
if (nackCount > 0)
|
||||||
|
{
|
||||||
|
bool nacked = false;
|
||||||
|
for (int i = 0; i < nackCount; i++)
|
||||||
|
if (seqn == packet->GetNACK (i))
|
||||||
|
{
|
||||||
|
nacked = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (nacked)
|
||||||
|
{
|
||||||
|
LogPrint ("Packet ", seqn, " NACK");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
auto sentPacket = *it;
|
auto sentPacket = *it;
|
||||||
LogPrint ("Packet ", sentPacket->GetSeqn (), " acknowledged");
|
LogPrint ("Packet ", seqn, " acknowledged");
|
||||||
m_SentPackets.erase (it++);
|
m_SentPackets.erase (it++);
|
||||||
delete sentPacket;
|
delete sentPacket;
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ namespace stream
|
|||||||
uint32_t GetSeqn () const { return be32toh (*(uint32_t *)(buf + 8)); };
|
uint32_t GetSeqn () const { return be32toh (*(uint32_t *)(buf + 8)); };
|
||||||
uint32_t GetAckThrough () const { return be32toh (*(uint32_t *)(buf + 12)); };
|
uint32_t GetAckThrough () const { return be32toh (*(uint32_t *)(buf + 12)); };
|
||||||
uint8_t GetNACKCount () const { return buf[16]; };
|
uint8_t GetNACKCount () const { return buf[16]; };
|
||||||
|
uint32_t GetNACK (int i) const { return be32toh (((uint32_t *)(buf + 17))[i]); };
|
||||||
const uint8_t * GetOption () const { return buf + 17 + GetNACKCount ()*4 + 3; }; // 3 = resendDelay + flags
|
const uint8_t * GetOption () const { return buf + 17 + GetNACKCount ()*4 + 3; }; // 3 = resendDelay + flags
|
||||||
uint16_t GetFlags () const { return be16toh (*(uint16_t *)(GetOption () - 2)); };
|
uint16_t GetFlags () const { return be16toh (*(uint16_t *)(GetOption () - 2)); };
|
||||||
uint16_t GetOptionSize () const { return be16toh (*(uint16_t *)GetOption ()); };
|
uint16_t GetOptionSize () const { return be16toh (*(uint16_t *)GetOption ()); };
|
||||||
|
Loading…
Reference in New Issue
Block a user