mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
drop window size only when lease changes
This commit is contained in:
parent
d4c1a1c0bb
commit
13b2fc3266
|
@ -835,7 +835,15 @@ namespace stream
|
||||||
numPackets = (passedTime + m_PacketACKIntervalRem) / m_PacketACKInterval;
|
numPackets = (passedTime + m_PacketACKIntervalRem) / m_PacketACKInterval;
|
||||||
m_PacketACKIntervalRem = (passedTime + m_PacketACKIntervalRem) - (numPackets * m_PacketACKInterval);
|
m_PacketACKIntervalRem = (passedTime + m_PacketACKIntervalRem) - (numPackets * m_PacketACKInterval);
|
||||||
if (m_LastConfirmedReceivedSequenceNumber + numPackets < m_LastReceivedSequenceNumber)
|
if (m_LastConfirmedReceivedSequenceNumber + numPackets < m_LastReceivedSequenceNumber)
|
||||||
|
{
|
||||||
lastReceivedSeqn = m_LastConfirmedReceivedSequenceNumber + numPackets;
|
lastReceivedSeqn = m_LastConfirmedReceivedSequenceNumber + numPackets;
|
||||||
|
if (!m_IsAckSendScheduled)
|
||||||
|
{
|
||||||
|
auto ackTimeout = m_RTT/10;
|
||||||
|
if (ackTimeout > m_AckDelay) ackTimeout = m_AckDelay;
|
||||||
|
ScheduleAck (ackTimeout);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (numPackets == 0) return;
|
if (numPackets == 0) return;
|
||||||
// for limit inbound speed
|
// for limit inbound speed
|
||||||
if (!m_SavedPackets.empty ())
|
if (!m_SavedPackets.empty ())
|
||||||
|
@ -1396,6 +1404,7 @@ namespace stream
|
||||||
|
|
||||||
void Stream::UpdateCurrentRemoteLease (bool expired)
|
void Stream::UpdateCurrentRemoteLease (bool expired)
|
||||||
{
|
{
|
||||||
|
bool isLeaseChanged = true;
|
||||||
if (!m_RemoteLeaseSet || m_RemoteLeaseSet->IsExpired ())
|
if (!m_RemoteLeaseSet || m_RemoteLeaseSet->IsExpired ())
|
||||||
{
|
{
|
||||||
auto remoteLeaseSet = m_LocalDestination.GetOwner ()->FindLeaseSet (m_RemoteIdentity->GetIdentHash ());
|
auto remoteLeaseSet = m_LocalDestination.GetOwner ()->FindLeaseSet (m_RemoteIdentity->GetIdentHash ());
|
||||||
|
@ -1451,7 +1460,7 @@ namespace stream
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!updated)
|
if (!updated && leases.size () > 1)
|
||||||
{
|
{
|
||||||
uint32_t i = m_LocalDestination.GetRandom () % leases.size ();
|
uint32_t i = m_LocalDestination.GetRandom () % leases.size ();
|
||||||
if (m_CurrentRemoteLease && leases[i]->tunnelID == m_CurrentRemoteLease->tunnelID)
|
if (m_CurrentRemoteLease && leases[i]->tunnelID == m_CurrentRemoteLease->tunnelID)
|
||||||
|
@ -1459,6 +1468,8 @@ namespace stream
|
||||||
i = (i + 1) % leases.size (); // if so, pick next
|
i = (i + 1) % leases.size (); // if so, pick next
|
||||||
m_CurrentRemoteLease = leases[i];
|
m_CurrentRemoteLease = leases[i];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
isLeaseChanged = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1473,20 +1484,23 @@ namespace stream
|
||||||
LogPrint (eLogWarning, "Streaming: Remote LeaseSet not found");
|
LogPrint (eLogWarning, "Streaming: Remote LeaseSet not found");
|
||||||
m_CurrentRemoteLease = nullptr;
|
m_CurrentRemoteLease = nullptr;
|
||||||
}
|
}
|
||||||
// drop window to initial upon RemoteLease change
|
if (isLeaseChanged)
|
||||||
m_RTO = INITIAL_RTO;
|
|
||||||
if (m_WindowSize > INITIAL_WINDOW_SIZE)
|
|
||||||
{
|
{
|
||||||
m_WindowDropTargetSize = std::max (m_WindowSize/2, (float)INITIAL_WINDOW_SIZE);
|
// drop window to initial upon RemoteLease change
|
||||||
m_IsWinDropped = true;
|
m_RTO = INITIAL_RTO;
|
||||||
|
if (m_WindowSize > INITIAL_WINDOW_SIZE)
|
||||||
|
{
|
||||||
|
m_WindowDropTargetSize = std::max (m_WindowSize/2, (float)INITIAL_WINDOW_SIZE);
|
||||||
|
m_IsWinDropped = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_WindowSize = INITIAL_WINDOW_SIZE;
|
||||||
|
m_LastWindowDropSize = 0;
|
||||||
|
m_WindowIncCounter = 0;
|
||||||
|
m_IsFirstRttSample = true;
|
||||||
|
m_IsFirstACK = true;
|
||||||
|
UpdatePacingTime ();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
m_WindowSize = INITIAL_WINDOW_SIZE;
|
|
||||||
m_LastWindowDropSize = 0;
|
|
||||||
m_WindowIncCounter = 0;
|
|
||||||
m_IsFirstRttSample = true;
|
|
||||||
m_IsFirstACK = true;
|
|
||||||
UpdatePacingTime ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stream::ResetRoutingPath ()
|
void Stream::ResetRoutingPath ()
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace stream
|
||||||
const int INITIAL_WINDOW_SIZE = 10;
|
const int INITIAL_WINDOW_SIZE = 10;
|
||||||
const int MIN_WINDOW_SIZE = 2;
|
const int MIN_WINDOW_SIZE = 2;
|
||||||
const int MAX_WINDOW_SIZE = 512;
|
const int MAX_WINDOW_SIZE = 512;
|
||||||
const double RTT_EWMA_ALPHA = 0.5;
|
const double RTT_EWMA_ALPHA = 0.25;
|
||||||
const double SLOWRTT_EWMA_ALPHA = 0.05;
|
const double SLOWRTT_EWMA_ALPHA = 0.05;
|
||||||
const double PREV_SPEED_KEEP_TIME_COEFF = 0.35; // 0.1 - 1 // how long will the window size stay around the previous drop level, less is longer
|
const double PREV_SPEED_KEEP_TIME_COEFF = 0.35; // 0.1 - 1 // how long will the window size stay around the previous drop level, less is longer
|
||||||
const int MIN_RTO = 20; // in milliseconds
|
const int MIN_RTO = 20; // in milliseconds
|
||||||
|
|
Loading…
Reference in a new issue