mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-19 05:19:57 +00:00
request choking delay if too many NACKs. Drop window size to 1 if choking delay received
This commit is contained in:
parent
75df8d3c7b
commit
4f1cb74f75
@ -289,6 +289,8 @@ namespace stream
|
|||||||
m_AckSendTimer.async_wait (std::bind (&Stream::HandleAckSendTimer,
|
m_AckSendTimer.async_wait (std::bind (&Stream::HandleAckSendTimer,
|
||||||
shared_from_this (), std::placeholders::_1));
|
shared_from_this (), std::placeholders::_1));
|
||||||
}
|
}
|
||||||
|
if (delayRequested >= DELAY_CHOKING)
|
||||||
|
m_WindowSize = 1;
|
||||||
}
|
}
|
||||||
optionData += 2;
|
optionData += 2;
|
||||||
}
|
}
|
||||||
@ -691,6 +693,7 @@ namespace stream
|
|||||||
htobe32buf (packet + size, lastReceivedSeqn);
|
htobe32buf (packet + size, lastReceivedSeqn);
|
||||||
size += 4; // ack Through
|
size += 4; // ack Through
|
||||||
uint8_t numNacks = 0;
|
uint8_t numNacks = 0;
|
||||||
|
bool choking = false;
|
||||||
if (lastReceivedSeqn > m_LastReceivedSequenceNumber)
|
if (lastReceivedSeqn > m_LastReceivedSequenceNumber)
|
||||||
{
|
{
|
||||||
// fill NACKs
|
// fill NACKs
|
||||||
@ -703,6 +706,7 @@ namespace stream
|
|||||||
{
|
{
|
||||||
LogPrint (eLogError, "Streaming: Number of NACKs exceeds 256. seqn=", seqn, " nextSeqn=", nextSeqn);
|
LogPrint (eLogError, "Streaming: Number of NACKs exceeds 256. seqn=", seqn, " nextSeqn=", nextSeqn);
|
||||||
htobe32buf (packet + 12, nextSeqn - 1); // change ack Through back
|
htobe32buf (packet + 12, nextSeqn - 1); // change ack Through back
|
||||||
|
choking = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (uint32_t i = nextSeqn; i < seqn; i++)
|
for (uint32_t i = nextSeqn; i < seqn; i++)
|
||||||
@ -724,10 +728,17 @@ namespace stream
|
|||||||
size++; // NACK count
|
size++; // NACK count
|
||||||
}
|
}
|
||||||
packet[size] = 0;
|
packet[size] = 0;
|
||||||
size++; // resend delay
|
size++; // resend delay
|
||||||
htobuf16 (packet + size, 0); // no flags set
|
htobuf16 (packet + size, choking ? PACKET_FLAG_DELAY_REQUESTED : 0); // no flags set or delay
|
||||||
size += 2; // flags
|
size += 2; // flags
|
||||||
htobuf16 (packet + size, 0); // no options
|
if (choking)
|
||||||
|
{
|
||||||
|
htobuf16 (packet + size, 2); // 2 bytes delay interval
|
||||||
|
htobuf16 (packet + size + 2, DELAY_CHOKING); // set choking interval
|
||||||
|
size += 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
htobuf16 (packet + size, 0); // no options
|
||||||
size += 2; // options size
|
size += 2; // options size
|
||||||
p.len = size;
|
p.len = size;
|
||||||
|
|
||||||
|
@ -66,6 +66,7 @@ namespace stream
|
|||||||
const size_t MAX_PENDING_INCOMING_BACKLOG = 128;
|
const size_t MAX_PENDING_INCOMING_BACKLOG = 128;
|
||||||
const int PENDING_INCOMING_TIMEOUT = 10; // in seconds
|
const int PENDING_INCOMING_TIMEOUT = 10; // in seconds
|
||||||
const int MAX_RECEIVE_TIMEOUT = 20; // in seconds
|
const int MAX_RECEIVE_TIMEOUT = 20; // in seconds
|
||||||
|
const uint16_t DELAY_CHOKING = 60000; // in milliseconds
|
||||||
|
|
||||||
struct Packet
|
struct Packet
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user