Browse Source

Merge pull request #2036 from Vort/stream_ewma2

changes in stream RTT estimation and window size drop percent
pull/2040/head
orignal 9 months ago committed by GitHub
parent
commit
ce97ec1534
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 9
      libi2pd/Streaming.cpp
  2. 2
      libi2pd/Streaming.h

9
libi2pd/Streaming.cpp

@ -433,7 +433,10 @@ namespace stream
LogPrint(eLogError, "Streaming: Packet ", seqn, "sent from the future, sendTime=", sentPacket->sendTime); LogPrint(eLogError, "Streaming: Packet ", seqn, "sent from the future, sendTime=", sentPacket->sendTime);
rtt = 1; rtt = 1;
} }
m_RTT = std::round ((m_RTT*seqn + rtt)/(seqn + 1.0)); if (seqn)
m_RTT = std::round (RTT_EWMA_ALPHA * m_RTT + (1.0 - RTT_EWMA_ALPHA) * rtt);
else
m_RTT = rtt;
m_RTO = m_RTT*1.5; // TODO: implement it better m_RTO = m_RTT*1.5; // TODO: implement it better
LogPrint (eLogDebug, "Streaming: Packet ", seqn, " acknowledged rtt=", rtt, " sentTime=", sentPacket->sendTime); LogPrint (eLogDebug, "Streaming: Packet ", seqn, " acknowledged rtt=", rtt, " sentTime=", sentPacket->sendTime);
m_SentPackets.erase (it++); m_SentPackets.erase (it++);
@ -998,8 +1001,8 @@ namespace stream
m_RTO *= 2; m_RTO *= 2;
switch (m_NumResendAttempts) switch (m_NumResendAttempts)
{ {
case 1: // congesion avoidance case 1: // congestion avoidance
m_WindowSize >>= 1; // /2 m_WindowSize -= (m_WindowSize + WINDOW_SIZE_DROP_FRACTION) / WINDOW_SIZE_DROP_FRACTION; // adjustment >= 1
if (m_WindowSize < MIN_WINDOW_SIZE) m_WindowSize = MIN_WINDOW_SIZE; if (m_WindowSize < MIN_WINDOW_SIZE) m_WindowSize = MIN_WINDOW_SIZE;
break; break;
case 2: case 2:

2
libi2pd/Streaming.h

@ -56,6 +56,8 @@ namespace stream
const int WINDOW_SIZE = 6; // in messages const int WINDOW_SIZE = 6; // in messages
const int MIN_WINDOW_SIZE = 1; const int MIN_WINDOW_SIZE = 1;
const int MAX_WINDOW_SIZE = 128; const int MAX_WINDOW_SIZE = 128;
const int WINDOW_SIZE_DROP_FRACTION = 10; // 1/10
const double RTT_EWMA_ALPHA = 0.5;
const int INITIAL_RTT = 8000; // in milliseconds const int INITIAL_RTT = 8000; // in milliseconds
const int INITIAL_RTO = 9000; // in milliseconds const int INITIAL_RTO = 9000; // in milliseconds
const int MIN_SEND_ACK_TIMEOUT = 2; // in milliseconds const int MIN_SEND_ACK_TIMEOUT = 2; // in milliseconds

Loading…
Cancel
Save