diff options
author | UbitUmarov | 2019-04-09 21:30:06 +0100 |
---|---|---|
committer | UbitUmarov | 2019-04-09 21:30:06 +0100 |
commit | b051b3a81dbb3bb0e7358e257b1cf82f5daee4ce (patch) | |
tree | 9395fe1dca5d66d176f36c84c37f702863ff388a /OpenSim/Region/ClientStack/Linden | |
parent | testing ... (diff) | |
download | opensim-SC-b051b3a81dbb3bb0e7358e257b1cf82f5daee4ce.zip opensim-SC-b051b3a81dbb3bb0e7358e257b1cf82f5daee4ce.tar.gz opensim-SC-b051b3a81dbb3bb0e7358e257b1cf82f5daee4ce.tar.bz2 opensim-SC-b051b3a81dbb3bb0e7358e257b1cf82f5daee4ce.tar.xz |
change to ping based RTO
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden')
3 files changed, 18 insertions, 72 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index fc1e846..f812ce1 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs | |||
@@ -148,7 +148,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
148 | /// milliseconds or longer will be resent</summary> | 148 | /// milliseconds or longer will be resent</summary> |
149 | /// <remarks>Calculated from <seealso cref="SRTT"/> and <seealso cref="RTTVAR"/> using the | 149 | /// <remarks>Calculated from <seealso cref="SRTT"/> and <seealso cref="RTTVAR"/> using the |
150 | /// guidelines in RFC 2988</remarks> | 150 | /// guidelines in RFC 2988</remarks> |
151 | public int RTO; | 151 | public int m_RTO; |
152 | /// <summary>Number of bytes received since the last acknowledgement was sent out. This is used | 152 | /// <summary>Number of bytes received since the last acknowledgement was sent out. This is used |
153 | /// to loosely follow the TCP delayed ACK algorithm in RFC 1122 (4.2.3.2)</summary> | 153 | /// to loosely follow the TCP delayed ACK algorithm in RFC 1122 (4.2.3.2)</summary> |
154 | public int BytesSinceLastACK; | 154 | public int BytesSinceLastACK; |
@@ -190,7 +190,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
190 | private byte[] m_packedThrottles; | 190 | private byte[] m_packedThrottles; |
191 | 191 | ||
192 | private int m_defaultRTO = 1000; // 1sec is the recommendation in the RFC | 192 | private int m_defaultRTO = 1000; // 1sec is the recommendation in the RFC |
193 | private int m_maxRTO = 60000; | 193 | private int m_maxRTO = 10000; |
194 | public bool m_deliverPackets = true; | 194 | public bool m_deliverPackets = true; |
195 | 195 | ||
196 | private float m_burstTime; | 196 | private float m_burstTime; |
@@ -264,7 +264,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
264 | } | 264 | } |
265 | 265 | ||
266 | // Default the retransmission timeout to one second | 266 | // Default the retransmission timeout to one second |
267 | RTO = m_defaultRTO; | 267 | m_RTO = m_defaultRTO; |
268 | 268 | ||
269 | // Initialize this to a sane value to prevent early disconnects | 269 | // Initialize this to a sane value to prevent early disconnects |
270 | TickLastPacketReceived = Environment.TickCount & Int32.MaxValue; | 270 | TickLastPacketReceived = Environment.TickCount & Int32.MaxValue; |
@@ -719,63 +719,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
719 | } | 719 | } |
720 | 720 | ||
721 | /// <summary> | 721 | /// <summary> |
722 | /// Called when an ACK packet is received and a round-trip time for a | 722 | /// Called when we get a ping update |
723 | /// packet is calculated. This is used to calculate the smoothed | ||
724 | /// round-trip time, round trip time variance, and finally the | ||
725 | /// retransmission timeout | ||
726 | /// </summary> | 723 | /// </summary> |
727 | /// <param name="r">Round-trip time of a single packet and its | 724 | /// <param name="r"> ping time in ms |
728 | /// acknowledgement</param> | 725 | /// acknowledgement</param> |
729 | public void UpdateRoundTrip(float r) | 726 | public void UpdateRoundTrip(int p) |
730 | { | 727 | { |
731 | return; | 728 | p *= 5; |
732 | /* | 729 | if( p> m_maxRTO) |
733 | const float ALPHA = 0.125f; | 730 | p = m_maxRTO; |
734 | const float BETA = 0.25f; | 731 | else if(p < m_defaultRTO) |
735 | const float K = 4.0f; | 732 | p = m_defaultRTO; |
736 | 733 | ||
737 | if (RTTVAR == 0.0f) | 734 | m_RTO = p; |
738 | { | ||
739 | // First RTT measurement | ||
740 | SRTT = r; | ||
741 | RTTVAR = r * 0.5f; | ||
742 | } | ||
743 | else | ||
744 | { | ||
745 | // Subsequence RTT measurement | ||
746 | RTTVAR = (1.0f - BETA) * RTTVAR + BETA * Math.Abs(SRTT - r); | ||
747 | SRTT = (1.0f - ALPHA) * SRTT + ALPHA * r; | ||
748 | } | ||
749 | |||
750 | int rto = (int)(SRTT + Math.Max(m_udpServer.TickCountResolution, K * RTTVAR)); | ||
751 | |||
752 | // Clamp the retransmission timeout to manageable values | ||
753 | rto = Utils.Clamp(rto, m_defaultRTO, m_maxRTO); | ||
754 | |||
755 | RTO = rto; | ||
756 | |||
757 | //if (RTO != rto) | ||
758 | // m_log.Debug("[LLUDPCLIENT]: Setting RTO to " + RTO + "ms from " + rto + "ms with an RTTVAR of " + | ||
759 | //RTTVAR + " based on new RTT of " + r + "ms"); | ||
760 | */ | ||
761 | } | ||
762 | |||
763 | /// <summary> | ||
764 | /// Exponential backoff of the retransmission timeout, per section 5.5 | ||
765 | /// of RFC 2988 | ||
766 | /// </summary> | ||
767 | public void BackoffRTO() | ||
768 | { | ||
769 | return; | ||
770 | // Reset SRTT and RTTVAR, we assume they are bogus since things | ||
771 | // didn't work out and we're backing off the timeout | ||
772 | /* | ||
773 | SRTT = 0.0f; | ||
774 | RTTVAR = 0.0f; | ||
775 | |||
776 | // Double the retransmission timeout | ||
777 | RTO = Math.Min(RTO * 2, m_maxRTO); | ||
778 | */ | ||
779 | } | 735 | } |
780 | 736 | ||
781 | const double MIN_CALLBACK_MS = 20.0; | 737 | const double MIN_CALLBACK_MS = 20.0; |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 285751d..e313934 100755 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | |||
@@ -1120,13 +1120,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | // Get a list of all of the packets that have been sitting unacked longer than udpClient.RTO | 1122 | // Get a list of all of the packets that have been sitting unacked longer than udpClient.RTO |
1123 | List<OutgoingPacket> expiredPackets = udpClient.NeedAcks.GetExpiredPackets(udpClient.RTO); | 1123 | List<OutgoingPacket> expiredPackets = udpClient.NeedAcks.GetExpiredPackets(udpClient.m_RTO); |
1124 | 1124 | ||
1125 | if (expiredPackets != null) | 1125 | if (expiredPackets != null) |
1126 | { | 1126 | { |
1127 | //m_log.Debug("[LLUDPSERVER]: Handling " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO); | ||
1128 | // Exponential backoff of the retransmission timeout | ||
1129 | udpClient.BackoffRTO(); | ||
1130 | for (int i = 0; i < expiredPackets.Count; ++i) | 1127 | for (int i = 0; i < expiredPackets.Count; ++i) |
1131 | expiredPackets[i].UnackedMethod(expiredPackets[i]); | 1128 | expiredPackets[i].UnackedMethod(expiredPackets[i]); |
1132 | } | 1129 | } |
@@ -1515,10 +1512,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1515 | else if (packet.Type == PacketType.CompletePingCheck) | 1512 | else if (packet.Type == PacketType.CompletePingCheck) |
1516 | { | 1513 | { |
1517 | double t = Util.GetTimeStampMS() - udpClient.m_lastStartpingTimeMS; | 1514 | double t = Util.GetTimeStampMS() - udpClient.m_lastStartpingTimeMS; |
1518 | double c = udpClient.m_pingMS; | 1515 | double c = 0.8 * udpClient.m_pingMS; |
1519 | c = 800 * c + 200 * t; | 1516 | c += 0.2 * t; |
1520 | c /= 1000; | 1517 | int p = (int)c; |
1521 | udpClient.m_pingMS = (int)c; | 1518 | udpClient.m_pingMS = p; |
1519 | udpClient.UpdateRoundTrip(p); | ||
1522 | return; | 1520 | return; |
1523 | } | 1521 | } |
1524 | 1522 | ||
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/UnackedPacketCollection.cs b/OpenSim/Region/ClientStack/Linden/UDP/UnackedPacketCollection.cs index 1f978e1..32a6c40 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/UnackedPacketCollection.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/UnackedPacketCollection.cs | |||
@@ -215,14 +215,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
215 | // As with other network applications, assume that an acknowledged packet is an | 215 | // As with other network applications, assume that an acknowledged packet is an |
216 | // indication that the network can handle a little more load, speed up the transmission | 216 | // indication that the network can handle a little more load, speed up the transmission |
217 | ackedPacket.Client.FlowThrottle.AcknowledgePackets(1); | 217 | ackedPacket.Client.FlowThrottle.AcknowledgePackets(1); |
218 | |||
219 | if (!pendingAcknowledgement.FromResend) | ||
220 | { | ||
221 | // Calculate the round-trip time for this packet and its ACK | ||
222 | int rtt = pendingAcknowledgement.RemoveTime - ackedPacket.TickCount; | ||
223 | if (rtt > 0) | ||
224 | ackedPacket.Client.UpdateRoundTrip(rtt); | ||
225 | } | ||
226 | } | 218 | } |
227 | else | 219 | else |
228 | { | 220 | { |