mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
commit
0c5dee69ba
|
@ -85,7 +85,7 @@ namespace transport
|
|||
m_DestConnID (0), m_SourceConnID (0), m_State (eSSU2SessionStateUnknown),
|
||||
m_SendPacketNum (0), m_ReceivePacketNum (0), m_LastDatetimeSentPacketNum (0),
|
||||
m_IsDataReceived (false), m_WindowSize (SSU2_MIN_WINDOW_SIZE),
|
||||
m_RTT (SSU2_RESEND_INTERVAL), m_RTO (SSU2_RESEND_INTERVAL*SSU2_kAPPA), m_RelayTag (0),
|
||||
m_RTT (SSU2_UNKNOWN_RTT), m_RTO (SSU2_INITIAL_RTO), m_RelayTag (0),
|
||||
m_ConnectTimer (server.GetService ()), m_TerminationReason (eSSU2TerminationReasonNormalClose),
|
||||
m_MaxPayloadSize (SSU2_MIN_PACKET_SIZE - IPV6_HEADER_SIZE - UDP_HEADER_SIZE - 32) // min size
|
||||
{
|
||||
|
@ -1753,7 +1753,10 @@ namespace transport
|
|||
if (ts > it1->second->sendTime)
|
||||
{
|
||||
auto rtt = ts - it1->second->sendTime;
|
||||
m_RTT = std::round ((m_RTT*m_SendPacketNum + rtt)/(m_SendPacketNum + 1.0));
|
||||
if (m_RTT != SSU2_UNKNOWN_RTT)
|
||||
m_RTT = SSU2_RTT_EWMA_ALPHA * rtt + (1.0 - SSU2_RTT_EWMA_ALPHA) * m_RTT;
|
||||
else
|
||||
m_RTT = rtt;
|
||||
m_RTO = m_RTT*SSU2_kAPPA;
|
||||
if (m_RTO < SSU2_MIN_RTO) m_RTO = SSU2_MIN_RTO;
|
||||
if (m_RTO > SSU2_MAX_RTO) m_RTO = SSU2_MAX_RTO;
|
||||
|
|
|
@ -36,7 +36,6 @@ namespace transport
|
|||
const size_t SSU2_MAX_PACKET_SIZE = 1500;
|
||||
const size_t SSU2_MIN_PACKET_SIZE = 1280;
|
||||
const int SSU2_HANDSHAKE_RESEND_INTERVAL = 1000; // in milliseconds
|
||||
const int SSU2_RESEND_INTERVAL = 300; // in milliseconds
|
||||
const int SSU2_MAX_NUM_RESENDS = 5;
|
||||
const int SSU2_INCOMPLETE_MESSAGES_CLEANUP_TIMEOUT = 30; // in seconds
|
||||
const int SSU2_MAX_NUM_RECEIVED_I2NP_MSGIDS = 5000; // how many msgID we store for duplicates check
|
||||
|
@ -45,7 +44,10 @@ namespace transport
|
|||
const size_t SSU2_MIN_WINDOW_SIZE = 16; // in packets
|
||||
const size_t SSU2_MAX_WINDOW_SIZE = 256; // in packets
|
||||
const size_t SSU2_MIN_RTO = 100; // in milliseconds
|
||||
const size_t SSU2_INITIAL_RTO = 540; // in milliseconds
|
||||
const size_t SSU2_MAX_RTO = 2500; // in milliseconds
|
||||
const double SSU2_UNKNOWN_RTT = -1;
|
||||
const double SSU2_RTT_EWMA_ALPHA = 0.125;
|
||||
const float SSU2_kAPPA = 1.8;
|
||||
const int SSU2_MAX_NUM_ACNT = 255; // acnt, acks or nacks
|
||||
const int SSU2_MAX_NUM_ACK_PACKETS = 511; // ackthrough + acnt + 1 range
|
||||
|
@ -356,7 +358,8 @@ namespace transport
|
|||
std::list<std::shared_ptr<I2NPMessage> > m_SendQueue;
|
||||
i2p::I2NPMessagesHandler m_Handler;
|
||||
bool m_IsDataReceived;
|
||||
size_t m_WindowSize, m_RTT, m_RTO;
|
||||
double m_RTT;
|
||||
size_t m_WindowSize, m_RTO;
|
||||
uint32_t m_RelayTag; // between Bob and Charlie
|
||||
OnEstablished m_OnEstablished; // callback from Established
|
||||
boost::asio::deadline_timer m_ConnectTimer;
|
||||
|
|
|
@ -434,7 +434,7 @@ namespace stream
|
|||
rtt = 1;
|
||||
}
|
||||
if (seqn)
|
||||
m_RTT = std::round (RTT_EWMA_ALPHA * m_RTT + (1.0 - RTT_EWMA_ALPHA) * rtt);
|
||||
m_RTT = RTT_EWMA_ALPHA * rtt + (1.0 - RTT_EWMA_ALPHA) * m_RTT;
|
||||
else
|
||||
m_RTT = rtt;
|
||||
m_RTO = m_RTT*1.5; // TODO: implement it better
|
||||
|
@ -457,7 +457,7 @@ namespace stream
|
|||
if (!seqn && m_RoutingSession) // first message confirmed
|
||||
m_RoutingSession->SetSharedRoutingPath (
|
||||
std::make_shared<i2p::garlic::GarlicRoutingPath> (
|
||||
i2p::garlic::GarlicRoutingPath{m_CurrentOutboundTunnel, m_CurrentRemoteLease, m_RTT, 0, 0}));
|
||||
i2p::garlic::GarlicRoutingPath{m_CurrentOutboundTunnel, m_CurrentRemoteLease, (int)m_RTT, 0, 0}));
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace stream
|
|||
const int MIN_WINDOW_SIZE = 1;
|
||||
const int MAX_WINDOW_SIZE = 128;
|
||||
const int WINDOW_SIZE_DROP_FRACTION = 10; // 1/10
|
||||
const double RTT_EWMA_ALPHA = 0.5;
|
||||
const double RTT_EWMA_ALPHA = 0.125;
|
||||
const int INITIAL_RTT = 8000; // in milliseconds
|
||||
const int INITIAL_RTO = 9000; // in milliseconds
|
||||
const int MIN_SEND_ACK_TIMEOUT = 2; // in milliseconds
|
||||
|
@ -254,7 +254,8 @@ namespace stream
|
|||
uint16_t m_Port;
|
||||
|
||||
SendBufferQueue m_SendBuffer;
|
||||
int m_WindowSize, m_RTT, m_RTO, m_AckDelay;
|
||||
double m_RTT;
|
||||
int m_WindowSize, m_RTO, m_AckDelay;
|
||||
uint64_t m_LastWindowSizeIncreaseTime;
|
||||
int m_NumResendAttempts;
|
||||
size_t m_MTU;
|
||||
|
|
Loading…
Reference in a new issue