From cf77be0eeb403155a1b3c440f3709add13e6f001 Mon Sep 17 00:00:00 2001 From: Vort Date: Tue, 19 Mar 2024 06:37:21 +0200 Subject: [PATCH] add lower limit for stream RTO --- libi2pd/Streaming.cpp | 4 ++-- libi2pd/Streaming.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libi2pd/Streaming.cpp b/libi2pd/Streaming.cpp index aad39db8..bc165478 100644 --- a/libi2pd/Streaming.cpp +++ b/libi2pd/Streaming.cpp @@ -438,7 +438,7 @@ namespace stream else rttUpdated = false; if (rttUpdated) - m_RTO = m_RTT * 1.5; // TODO: implement it better + m_RTO = std::max (MIN_RTO, (int)(m_RTT * 1.5)); // TODO: implement it better LogPrint (eLogDebug, "Streaming: Packet ", seqn, " acknowledged rtt=", rtt, " sentTime=", sentPacket->sendTime); m_SentPackets.erase (it++); m_LocalDestination.DeletePacket (sentPacket); @@ -882,7 +882,7 @@ namespace stream m_CurrentOutboundTunnel = routingPath->outboundTunnel; m_CurrentRemoteLease = routingPath->remoteLease; m_RTT = routingPath->rtt; - m_RTO = m_RTT*1.5; // TODO: implement it better + m_RTO = std::max (MIN_RTO, (int)(m_RTT * 1.5)); // TODO: implement it better } } diff --git a/libi2pd/Streaming.h b/libi2pd/Streaming.h index 9865ba95..35f642bc 100644 --- a/libi2pd/Streaming.h +++ b/libi2pd/Streaming.h @@ -58,6 +58,7 @@ namespace stream const int MAX_WINDOW_SIZE = 128; const int WINDOW_SIZE_DROP_FRACTION = 10; // 1/10 const double RTT_EWMA_ALPHA = 0.125; + const int MIN_RTO = 20; // in milliseconds const int INITIAL_RTT = 8000; // in milliseconds const int INITIAL_RTO = 9000; // in milliseconds const int MIN_SEND_ACK_TIMEOUT = 2; // in milliseconds