change to ping based RTO

0.9.1.0-post-fixes
UbitUmarov 2019-04-09 21:30:06 +01:00
parent c09b312b05
commit b051b3a81d
3 changed files with 18 additions and 72 deletions

View File

@ -148,7 +148,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// milliseconds or longer will be resent</summary>
/// <remarks>Calculated from <seealso cref="SRTT"/> and <seealso cref="RTTVAR"/> using the
/// guidelines in RFC 2988</remarks>
public int RTO;
public int m_RTO;
/// <summary>Number of bytes received since the last acknowledgement was sent out. This is used
/// to loosely follow the TCP delayed ACK algorithm in RFC 1122 (4.2.3.2)</summary>
public int BytesSinceLastACK;
@ -190,7 +190,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private byte[] m_packedThrottles;
private int m_defaultRTO = 1000; // 1sec is the recommendation in the RFC
private int m_maxRTO = 60000;
private int m_maxRTO = 10000;
public bool m_deliverPackets = true;
private float m_burstTime;
@ -264,7 +264,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
// Default the retransmission timeout to one second
RTO = m_defaultRTO;
m_RTO = m_defaultRTO;
// Initialize this to a sane value to prevent early disconnects
TickLastPacketReceived = Environment.TickCount & Int32.MaxValue;
@ -719,63 +719,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
/// <summary>
/// Called when an ACK packet is received and a round-trip time for a
/// packet is calculated. This is used to calculate the smoothed
/// round-trip time, round trip time variance, and finally the
/// retransmission timeout
/// Called when we get a ping update
/// </summary>
/// <param name="r">Round-trip time of a single packet and its
/// <param name="r"> ping time in ms
/// acknowledgement</param>
public void UpdateRoundTrip(float r)
public void UpdateRoundTrip(int p)
{
return;
/*
const float ALPHA = 0.125f;
const float BETA = 0.25f;
const float K = 4.0f;
p *= 5;
if( p> m_maxRTO)
p = m_maxRTO;
else if(p < m_defaultRTO)
p = m_defaultRTO;
if (RTTVAR == 0.0f)
{
// First RTT measurement
SRTT = r;
RTTVAR = r * 0.5f;
}
else
{
// Subsequence RTT measurement
RTTVAR = (1.0f - BETA) * RTTVAR + BETA * Math.Abs(SRTT - r);
SRTT = (1.0f - ALPHA) * SRTT + ALPHA * r;
}
int rto = (int)(SRTT + Math.Max(m_udpServer.TickCountResolution, K * RTTVAR));
// Clamp the retransmission timeout to manageable values
rto = Utils.Clamp(rto, m_defaultRTO, m_maxRTO);
RTO = rto;
//if (RTO != rto)
// m_log.Debug("[LLUDPCLIENT]: Setting RTO to " + RTO + "ms from " + rto + "ms with an RTTVAR of " +
//RTTVAR + " based on new RTT of " + r + "ms");
*/
}
/// <summary>
/// Exponential backoff of the retransmission timeout, per section 5.5
/// of RFC 2988
/// </summary>
public void BackoffRTO()
{
return;
// Reset SRTT and RTTVAR, we assume they are bogus since things
// didn't work out and we're backing off the timeout
/*
SRTT = 0.0f;
RTTVAR = 0.0f;
// Double the retransmission timeout
RTO = Math.Min(RTO * 2, m_maxRTO);
*/
m_RTO = p;
}
const double MIN_CALLBACK_MS = 20.0;

View File

@ -1120,13 +1120,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
// Get a list of all of the packets that have been sitting unacked longer than udpClient.RTO
List<OutgoingPacket> expiredPackets = udpClient.NeedAcks.GetExpiredPackets(udpClient.RTO);
List<OutgoingPacket> expiredPackets = udpClient.NeedAcks.GetExpiredPackets(udpClient.m_RTO);
if (expiredPackets != null)
{
//m_log.Debug("[LLUDPSERVER]: Handling " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO);
// Exponential backoff of the retransmission timeout
udpClient.BackoffRTO();
for (int i = 0; i < expiredPackets.Count; ++i)
expiredPackets[i].UnackedMethod(expiredPackets[i]);
}
@ -1515,10 +1512,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
else if (packet.Type == PacketType.CompletePingCheck)
{
double t = Util.GetTimeStampMS() - udpClient.m_lastStartpingTimeMS;
double c = udpClient.m_pingMS;
c = 800 * c + 200 * t;
c /= 1000;
udpClient.m_pingMS = (int)c;
double c = 0.8 * udpClient.m_pingMS;
c += 0.2 * t;
int p = (int)c;
udpClient.m_pingMS = p;
udpClient.UpdateRoundTrip(p);
return;
}

View File

@ -215,14 +215,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// As with other network applications, assume that an acknowledged packet is an
// indication that the network can handle a little more load, speed up the transmission
ackedPacket.Client.FlowThrottle.AcknowledgePackets(1);
if (!pendingAcknowledgement.FromResend)
{
// Calculate the round-trip time for this packet and its ACK
int rtt = pendingAcknowledgement.RemoveTime - ackedPacket.TickCount;
if (rtt > 0)
ackedPacket.Client.UpdateRoundTrip(rtt);
}
}
else
{