Browse Source

send immediate ack request if no packet being sent

pull/2101/head
orignal 3 months ago
parent
commit
07d108bb6f
  1. 11
      libi2pd/Streaming.cpp
  2. 7
      libi2pd/Streaming.h

11
libi2pd/Streaming.cpp

@ -877,13 +877,18 @@ namespace stream
} }
packet[size] = 0; packet[size] = 0;
size++; // resend delay size++; // resend delay
htobuf16 (packet + size, choking ? PACKET_FLAG_DELAY_REQUESTED : 0); // no flags set or delay bool requestImmediateAck = false;
if (!choking)
requestImmediateAck = m_LastSendTime && ts > m_LastSendTime + REQUEST_IMMEDIATE_ACK_INTERVAL &&
ts > m_LastSendTime + REQUEST_IMMEDIATE_ACK_INTERVAL + m_LocalDestination.GetRandom () % REQUEST_IMMEDIATE_ACK_INTERVAL_VARIANCE;
htobuf16 (packet + size, (choking || requestImmediateAck) ? PACKET_FLAG_DELAY_REQUESTED : 0); // no flags set or delay requested
size += 2; // flags size += 2; // flags
if (choking) if (choking || requestImmediateAck)
{ {
htobuf16 (packet + size, 2); // 2 bytes delay interval htobuf16 (packet + size, 2); // 2 bytes delay interval
htobuf16 (packet + size + 2, DELAY_CHOKING); // set choking interval htobuf16 (packet + size + 2, choking ? DELAY_CHOKING : 0); // set choking or immediated ack interval
size += 2; size += 2;
if (requestImmediateAck) m_LastSendTime = ts; // ack request sent
} }
else else
htobuf16 (packet + size, 0); // no options htobuf16 (packet + size, 0); // no options

7
libi2pd/Streaming.h

@ -70,7 +70,9 @@ namespace stream
const int MAX_RECEIVE_TIMEOUT = 20; // in seconds const int MAX_RECEIVE_TIMEOUT = 20; // in seconds
const uint16_t DELAY_CHOKING = 60000; // in milliseconds const uint16_t DELAY_CHOKING = 60000; // in milliseconds
const uint64_t SEND_INTERVAL = 1000; // in microseconds const uint64_t SEND_INTERVAL = 1000; // in microseconds
const uint64_t REQUEST_IMMEDIATE_ACK_INTERVAL = 7500; // in milliseconds
const uint64_t REQUEST_IMMEDIATE_ACK_INTERVAL_VARIANCE = 3200; // in milliseconds
struct Packet struct Packet
{ {
size_t len, offset; size_t len, offset;
@ -283,7 +285,8 @@ namespace stream
float m_WindowSize, m_LastWindowDropSize, m_WindowDropTargetSize; float m_WindowSize, m_LastWindowDropSize, m_WindowDropTargetSize;
int m_WindowIncCounter, m_RTO, m_AckDelay, m_PrevRTTSample; int m_WindowIncCounter, m_RTO, m_AckDelay, m_PrevRTTSample;
double m_Jitter; double m_Jitter;
uint64_t m_MinPacingTime, m_PacingTime, m_PacingTimeRem, m_LastSendTime; // microseconds uint64_t m_MinPacingTime, m_PacingTime, m_PacingTimeRem, // microseconds
m_LastSendTime; // miliseconds
uint64_t m_LastACKSendTime, m_PacketACKInterval, m_PacketACKIntervalRem; // for limit inbound speed uint64_t m_LastACKSendTime, m_PacketACKInterval, m_PacketACKIntervalRem; // for limit inbound speed
int m_NumResendAttempts, m_NumPacketsToSend; int m_NumResendAttempts, m_NumPacketsToSend;
size_t m_MTU; size_t m_MTU;

Loading…
Cancel
Save