Browse Source

variable retranmission window

pull/1786/head
orignal 2 years ago
parent
commit
fd41fba069
  1. 16
      libi2pd/SSU2Session.cpp
  2. 1
      libi2pd/SSU2Session.h

16
libi2pd/SSU2Session.cpp

@ -24,7 +24,7 @@ namespace transport @@ -24,7 +24,7 @@ namespace transport
m_Server (server), m_Address (addr), m_RemoteTransports (0),
m_DestConnID (0), m_SourceConnID (0), m_State (eSSU2SessionStateUnknown),
m_SendPacketNum (0), m_ReceivePacketNum (0), m_IsDataReceived (false),
m_WindowSize (SSU2_MAX_WINDOW_SIZE), m_RelayTag (0),
m_WindowSize (SSU2_MIN_WINDOW_SIZE), 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
{
@ -428,6 +428,8 @@ namespace transport @@ -428,6 +428,8 @@ namespace transport
#else
m_SentPackets.insert (resentPackets.begin (), resentPackets.end ());
#endif
m_WindowSize >>= 1; // /2
if (m_WindowSize < SSU2_MIN_WINDOW_SIZE) m_WindowSize = SSU2_MIN_WINDOW_SIZE;
}
SendQueue ();
}
@ -1451,8 +1453,18 @@ namespace transport @@ -1451,8 +1453,18 @@ namespace transport
while (it != m_SentPackets.end () && it->first < firstPacketNum) it++; // find first acked packet
if (it == m_SentPackets.end () || it->first > lastPacketNum) return; // not found
auto it1 = it;
while (it1 != m_SentPackets.end () && it1->first <= lastPacketNum) it1++;
int numPackets = 0;
while (it1 != m_SentPackets.end () && it1->first <= lastPacketNum)
{
it1++;
numPackets++;
}
m_SentPackets.erase (it, it1);
if (numPackets > 0)
{
m_WindowSize += numPackets;
if (m_WindowSize > SSU2_MAX_WINDOW_SIZE) m_WindowSize = SSU2_MAX_WINDOW_SIZE;
}
}
void SSU2Session::HandleFirstFragment (const uint8_t * buf, size_t len)

1
libi2pd/SSU2Session.h

@ -38,6 +38,7 @@ namespace transport @@ -38,6 +38,7 @@ namespace transport
const int SSU2_RESEND_INTERVAL = 3; // in seconds
const int SSU2_MAX_NUM_RESENDS = 5;
const int SSU2_INCOMPLETE_MESSAGES_CLEANUP_TIMEOUT = 30; // in seconds
const size_t SSU2_MIN_WINDOW_SIZE = 8; // in packets
const size_t SSU2_MAX_WINDOW_SIZE = 128; // in packets
const size_t SSU2_MAX_OUTGOING_QUEUE_SIZE = 300; // in messages
const int SSU2_MAX_NUM_ACK_RANGES = 32; // to send

Loading…
Cancel
Save