diff options
author | Melanie Thielker | 2008-10-05 14:44:26 +0000 |
---|---|---|
committer | Melanie Thielker | 2008-10-05 14:44:26 +0000 |
commit | c84987426bccf4d71094f127de02e95f8a811299 (patch) | |
tree | 0e634426ea989128155b49b498d43e8ce8247b41 /OpenSim | |
parent | Update svn properties, minor formatting cleanup. (diff) | |
download | opensim-SC_OLD-c84987426bccf4d71094f127de02e95f8a811299.zip opensim-SC_OLD-c84987426bccf4d71094f127de02e95f8a811299.tar.gz opensim-SC_OLD-c84987426bccf4d71094f127de02e95f8a811299.tar.bz2 opensim-SC_OLD-c84987426bccf4d71094f127de02e95f8a811299.tar.xz |
Craters, take 2. Remove old discard logic and absolute discard timer.
Introduce a resend counter on the ack queue. The header "Resent" field is
now obsolete. Implement 3 resends on reliable packets, variable.
Increase default resend timeout to 3000ms and default silence threshold
to 350ms.
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs | 74 |
1 files changed, 27 insertions, 47 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs index 8bcf5ea..48a54d7 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs | |||
@@ -55,9 +55,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
55 | int PacketsReceived { get; } | 55 | int PacketsReceived { get; } |
56 | int PacketsReceivedReported { get; } | 56 | int PacketsReceivedReported { get; } |
57 | uint SilenceLimit { get; set; } | 57 | uint SilenceLimit { get; set; } |
58 | uint DiscardTimeout { get; set; } | ||
59 | uint ResendTimeout { get; set; } | 58 | uint ResendTimeout { get; set; } |
60 | bool ReliableIsImportant { get; set; } | 59 | bool ReliableIsImportant { get; set; } |
60 | int MaxReliableResends { get; set; } | ||
61 | 61 | ||
62 | void InPacket(Packet packet); | 62 | void InPacket(Packet packet); |
63 | void ProcessInPacket(LLQueItem item); | 63 | void ProcessInPacket(LLQueItem item); |
@@ -104,16 +104,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
104 | // | 104 | // |
105 | private class AckData | 105 | private class AckData |
106 | { | 106 | { |
107 | public AckData(Packet packet, Object identifier, int tickCount) | 107 | public AckData(Packet packet, Object identifier, int tickCount, int resends) |
108 | { | 108 | { |
109 | Packet = packet; | 109 | Packet = packet; |
110 | Identifier = identifier; | 110 | Identifier = identifier; |
111 | TickCount = tickCount; | 111 | TickCount = tickCount; |
112 | Resends = resends; | ||
112 | } | 113 | } |
113 | 114 | ||
114 | public Packet Packet; | 115 | public Packet Packet; |
115 | public Object Identifier; | 116 | public Object Identifier; |
116 | public int TickCount; | 117 | public int TickCount; |
118 | public int Resends; | ||
117 | } | 119 | } |
118 | 120 | ||
119 | private Dictionary<uint, AckData> m_NeedAck = | 121 | private Dictionary<uint, AckData> m_NeedAck = |
@@ -122,7 +124,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
122 | /// <summary> | 124 | /// <summary> |
123 | /// The number of milliseconds that can pass before a packet that needs an ack is resent. | 125 | /// The number of milliseconds that can pass before a packet that needs an ack is resent. |
124 | /// </param> | 126 | /// </param> |
125 | private uint m_ResendTimeout = 2000; | 127 | private uint m_ResendTimeout = 4000; |
126 | 128 | ||
127 | public uint ResendTimeout | 129 | public uint ResendTimeout |
128 | { | 130 | { |
@@ -130,23 +132,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
130 | set { m_ResendTimeout = value; } | 132 | set { m_ResendTimeout = value; } |
131 | } | 133 | } |
132 | 134 | ||
133 | /// <summary> | 135 | private uint m_SilenceLimit = 350; |
134 | /// The number of milliseconds that can pass before a packet that needs an ack is discarded instead. | ||
135 | /// </summary> | ||
136 | private uint m_DiscardTimeout = 16000; | ||
137 | 136 | ||
138 | public uint DiscardTimeout | 137 | public uint SilenceLimit |
139 | { | 138 | { |
140 | get { return m_DiscardTimeout; } | 139 | get { return m_SilenceLimit; } |
141 | set { m_DiscardTimeout = value; } | 140 | set { m_SilenceLimit = value; } |
142 | } | 141 | } |
143 | 142 | ||
144 | private uint m_SilenceLimit = 250; | 143 | private int m_MaxReliableResends = 3; |
145 | 144 | ||
146 | public uint SilenceLimit | 145 | public int MaxReliableResends |
147 | { | 146 | { |
148 | get { return m_SilenceLimit; } | 147 | get { return m_MaxReliableResends; } |
149 | set { m_SilenceLimit = value; } | 148 | set { m_MaxReliableResends = value; } |
150 | } | 149 | } |
151 | 150 | ||
152 | private int m_LastAck = 0; | 151 | private int m_LastAck = 0; |
@@ -204,7 +203,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
204 | // Packet dropping | 203 | // Packet dropping |
205 | // | 204 | // |
206 | List<PacketType> m_ImportantPackets = new List<PacketType>(); | 205 | List<PacketType> m_ImportantPackets = new List<PacketType>(); |
207 | private bool m_ReliableIsImportant = true; | 206 | private bool m_ReliableIsImportant = false; |
208 | 207 | ||
209 | public bool ReliableIsImportant | 208 | public bool ReliableIsImportant |
210 | { | 209 | { |
@@ -362,41 +361,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
362 | // | 361 | // |
363 | if ((now - data.TickCount) > m_ResendTimeout) | 362 | if ((now - data.TickCount) > m_ResendTimeout) |
364 | { | 363 | { |
365 | // Resend the packet. Set the packet's tick count to | 364 | m_NeedAck[packet.Header.Sequence].Resends++; |
366 | // now, and keep it marked as resent. | ||
367 | //m_log.DebugFormat( | ||
368 | // "[CLIENT]: In {0} resending unacked packet {1} after {2}ms", | ||
369 | // m_Client.Scene.RegionInfo.ExternalEndPoint.Port, packet.Header.Sequence, now - data.TickCount); | ||
370 | //m_log.DebugFormat("[CLIENT]: Resent {0} packets in total", ++m_resentCount); | ||
371 | |||
372 | packet.Header.Resent = true; | ||
373 | QueuePacket(packet, ThrottleOutPacketType.Resend, | ||
374 | data.Identifier); | ||
375 | } | ||
376 | 365 | ||
377 | // The discard logic | 366 | if (m_NeedAck[packet.Header.Sequence].Resends >= |
378 | // If the packet is in the queue for <DiscardTimeout> s | 367 | m_MaxReliableResends && (!m_ReliableIsImportant)) |
379 | // without having been processed, then we have clogged | ||
380 | // pipes. Most likely, the client is gone | ||
381 | // Drop the packets | ||
382 | // | ||
383 | if ((now - data.TickCount) > m_DiscardTimeout) | ||
384 | { | ||
385 | if (!m_ReliableIsImportant || !packet.Header.Reliable) | ||
386 | { | 368 | { |
387 | if (!m_ImportantPackets.Contains(packet.Type)) | 369 | m_NeedAck.Remove(packet.Header.Sequence); |
388 | { | ||
389 | m_NeedAck.Remove(packet.Header.Sequence); | ||
390 | |||
391 | //m_log.DebugFormat( | ||
392 | // "[CLIENT]: In {0} discarding ack requirement for packet {1}", | ||
393 | // m_Client.Scene.RegionInfo.ExternalEndPoint.Port, packet.Header.Sequence); | ||
394 | } | ||
395 | |||
396 | TriggerOnPacketDrop(packet, data.Identifier); | 370 | TriggerOnPacketDrop(packet, data.Identifier); |
397 | |||
398 | continue; | 371 | continue; |
399 | } | 372 | } |
373 | |||
374 | m_NeedAck[packet.Header.Sequence].TickCount = | ||
375 | System.Environment.TickCount; | ||
376 | |||
377 | QueuePacket(packet, ThrottleOutPacketType.Resend, | ||
378 | data.Identifier); | ||
400 | } | 379 | } |
401 | } | 380 | } |
402 | } | 381 | } |
@@ -712,7 +691,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
712 | { | 691 | { |
713 | } | 692 | } |
714 | 693 | ||
715 | m_NeedAck.Add(key, new AckData(packet, null, System.Environment.TickCount)); | 694 | m_NeedAck.Add(key, new AckData(packet, null, System.Environment.TickCount, 0)); |
716 | } | 695 | } |
717 | 696 | ||
718 | m_Sequence = info.sequence; | 697 | m_Sequence = info.sequence; |
@@ -776,7 +755,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
776 | 755 | ||
777 | // Keep track of when this packet was sent out | 756 | // Keep track of when this packet was sent out |
778 | m_NeedAck[packet.Header.Sequence] = new AckData(packet, | 757 | m_NeedAck[packet.Header.Sequence] = new AckData(packet, |
779 | item.Identifier, System.Environment.TickCount); | 758 | item.Identifier, System.Environment.TickCount, |
759 | 0); | ||
780 | } | 760 | } |
781 | } | 761 | } |
782 | } | 762 | } |