aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs90
1 files changed, 39 insertions, 51 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs
index 439621a..2981337 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs
@@ -120,7 +120,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
120 /// <summary>Circuit code that this client is connected on</summary> 120 /// <summary>Circuit code that this client is connected on</summary>
121 public readonly uint CircuitCode; 121 public readonly uint CircuitCode;
122 /// <summary>Sequence numbers of packets we've received (for duplicate checking)</summary> 122 /// <summary>Sequence numbers of packets we've received (for duplicate checking)</summary>
123 public IncomingPacketHistoryCollection PacketArchive = new IncomingPacketHistoryCollection(200); 123 public IncomingPacketHistoryCollection PacketArchive = new IncomingPacketHistoryCollection(256);
124 124
125 /// <summary>Packets we have sent that need to be ACKed by the client</summary> 125 /// <summary>Packets we have sent that need to be ACKed by the client</summary>
126 public UnackedPacketCollection NeedAcks = new UnackedPacketCollection(); 126 public UnackedPacketCollection NeedAcks = new UnackedPacketCollection();
@@ -210,12 +210,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
210 } 210 }
211 } 211 }
212 212
213 /// <summary>
214 /// This is the percentage of the udp texture queue to add to the task queue since
215 /// textures are now generally handled through http.
216 /// </summary>
217 private double m_cannibalrate = 0.0;
218
219 private ClientInfo m_info = new ClientInfo(); 213 private ClientInfo m_info = new ClientInfo();
220 214
221 /// <summary> 215 /// <summary>
@@ -257,8 +251,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
257 // Create an array of token buckets for this clients different throttle categories 251 // Create an array of token buckets for this clients different throttle categories
258 m_throttleCategories = new TokenBucket[THROTTLE_CATEGORY_COUNT]; 252 m_throttleCategories = new TokenBucket[THROTTLE_CATEGORY_COUNT];
259 253
260 m_cannibalrate = rates.CannibalizeTextureRate;
261
262 m_burst = rates.Total * rates.BrustTime; 254 m_burst = rates.Total * rates.BrustTime;
263 255
264 for (int i = 0; i < THROTTLE_CATEGORY_COUNT; i++) 256 for (int i = 0; i < THROTTLE_CATEGORY_COUNT; i++)
@@ -449,12 +441,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
449 asset = Math.Max(asset, LLUDPServer.MTU); 441 asset = Math.Max(asset, LLUDPServer.MTU);
450*/ 442*/
451 443
452 // Since most textures are now delivered through http, make it possible
453 // to cannibalize some of the bw from the texture throttle to use for
454 // the task queue (e.g. object updates)
455 task = task + (int)(m_cannibalrate * texture);
456 texture = (int)((1 - m_cannibalrate) * texture);
457
458 int total = resend + land + wind + cloud + task + texture + asset; 444 int total = resend + land + wind + cloud + task + texture + asset;
459 445
460 float m_burst = total * m_burstTime; 446 float m_burst = total * m_burstTime;
@@ -575,22 +561,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
575 { 561 {
576 DoubleLocklessQueue<OutgoingPacket> queue = m_packetOutboxes[category]; 562 DoubleLocklessQueue<OutgoingPacket> queue = m_packetOutboxes[category];
577 563
578 if (m_deliverPackets == false) 564 if (forceQueue || m_deliverPackets == false)
579 { 565 {
580 queue.Enqueue(packet, highPriority); 566 queue.Enqueue(packet, highPriority);
581 return true; 567 return true;
582 } 568 }
583 569
584 TokenBucket bucket = m_throttleCategories[category]; 570 // need to enqueue if queue is not empty
585
586 // Don't send this packet if queue is not empty
587 if (queue.Count > 0 || m_nextPackets[category] != null) 571 if (queue.Count > 0 || m_nextPackets[category] != null)
588 { 572 {
589 queue.Enqueue(packet, highPriority); 573 queue.Enqueue(packet, highPriority);
590 return true; 574 return true;
591 } 575 }
592 576
593 if (!forceQueue && bucket.CheckTokens(packet.Buffer.DataLength)) 577 // check bandwidth
578 TokenBucket bucket = m_throttleCategories[category];
579 if (bucket.CheckTokens(packet.Buffer.DataLength))
594 { 580 {
595 // enough tokens so it can be sent imediatly by caller 581 // enough tokens so it can be sent imediatly by caller
596 bucket.RemoveTokens(packet.Buffer.DataLength); 582 bucket.RemoveTokens(packet.Buffer.DataLength);
@@ -608,7 +594,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
608 // We don't have a token bucket for this category, so it will not be queued 594 // We don't have a token bucket for this category, so it will not be queued
609 return false; 595 return false;
610 } 596 }
611
612 } 597 }
613 598
614 /// <summary> 599 /// <summary>
@@ -650,6 +635,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
650 // leaving a dequeued packet still waiting to be sent out. Try to 635 // leaving a dequeued packet still waiting to be sent out. Try to
651 // send it again 636 // send it again
652 OutgoingPacket nextPacket = m_nextPackets[i]; 637 OutgoingPacket nextPacket = m_nextPackets[i];
638 if(nextPacket.Buffer == null)
639 {
640 if (m_packetOutboxes[i].Count < 5)
641 emptyCategories |= CategoryToFlag(i);
642 continue;
643 }
653 if (bucket.RemoveTokens(nextPacket.Buffer.DataLength)) 644 if (bucket.RemoveTokens(nextPacket.Buffer.DataLength))
654 { 645 {
655 // Send the packet 646 // Send the packet
@@ -681,21 +672,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP
681 { 672 {
682 // A packet was pulled off the queue. See if we have 673 // A packet was pulled off the queue. See if we have
683 // enough tokens in the bucket to send it out 674 // enough tokens in the bucket to send it out
684 if (bucket.RemoveTokens(packet.Buffer.DataLength)) 675 if(packet.Buffer == null)
685 { 676 {
686 // Send the packet 677 // packet canceled elsewhere (by a ack for example)
687 m_udpServer.SendPacketFinal(packet);
688 packetSent = true;
689
690 if (queue.Count < 5) 678 if (queue.Count < 5)
691 emptyCategories |= CategoryToFlag(i); 679 emptyCategories |= CategoryToFlag(i);
692 } 680 }
693 else 681 else
694 { 682 {
695 // Save the dequeued packet for the next iteration 683 if (bucket.RemoveTokens(packet.Buffer.DataLength))
696 m_nextPackets[i] = packet; 684 {
685 // Send the packet
686 m_udpServer.SendPacketFinal(packet);
687 packetSent = true;
688
689 if (queue.Count < 5)
690 emptyCategories |= CategoryToFlag(i);
691 }
692 else
693 {
694 // Save the dequeued packet for the next iteration
695 m_nextPackets[i] = packet;
696 }
697 } 697 }
698
699 } 698 }
700 else 699 else
701 { 700 {
@@ -803,8 +802,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
803 } 802 }
804 } 803 }
805 804
806
807
808 /// <summary> 805 /// <summary>
809 /// Fires the OnQueueEmpty callback and sets the minimum time that it 806 /// Fires the OnQueueEmpty callback and sets the minimum time that it
810 /// can be called again 807 /// can be called again
@@ -843,6 +840,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
843 return 0; 840 return 0;
844 } 841 }
845 842
843 public void FreeUDPBuffer(UDPPacketBuffer buf)
844 {
845 m_udpServer.FreeUDPBuffer(buf);
846 }
847
846 /// <summary> 848 /// <summary>
847 /// Converts a <seealso cref="ThrottleOutPacketType"/> integer to a 849 /// Converts a <seealso cref="ThrottleOutPacketType"/> integer to a
848 /// flag value 850 /// flag value
@@ -853,34 +855,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
853 { 855 {
854 ThrottleOutPacketType category = (ThrottleOutPacketType)i; 856 ThrottleOutPacketType category = (ThrottleOutPacketType)i;
855 857
856 /*
857 * Land = 1,
858 /// <summary>Wind data</summary>
859 Wind = 2,
860 /// <summary>Cloud data</summary>
861 Cloud = 3,
862 /// <summary>Any packets that do not fit into the other throttles</summary>
863 Task = 4,
864 /// <summary>Texture assets</summary>
865 Texture = 5,
866 /// <summary>Non-texture assets</summary>
867 Asset = 6,
868 */
869
870 switch (category) 858 switch (category)
871 { 859 {
872 case ThrottleOutPacketType.Land: 860 case ThrottleOutPacketType.Land:
873 return ThrottleOutPacketTypeFlags.Land; 861 return ThrottleOutPacketTypeFlags.Land; // Terrain data
874 case ThrottleOutPacketType.Wind: 862 case ThrottleOutPacketType.Wind:
875 return ThrottleOutPacketTypeFlags.Wind; 863 return ThrottleOutPacketTypeFlags.Wind; // Wind data
876 case ThrottleOutPacketType.Cloud: 864 case ThrottleOutPacketType.Cloud:
877 return ThrottleOutPacketTypeFlags.Cloud; 865 return ThrottleOutPacketTypeFlags.Cloud; // Cloud data
878 case ThrottleOutPacketType.Task: 866 case ThrottleOutPacketType.Task:
879 return ThrottleOutPacketTypeFlags.Task; 867 return ThrottleOutPacketTypeFlags.Task; // Object updates and everything not on the other categories
880 case ThrottleOutPacketType.Texture: 868 case ThrottleOutPacketType.Texture:
881 return ThrottleOutPacketTypeFlags.Texture; 869 return ThrottleOutPacketTypeFlags.Texture; // Textures data (also impacts http texture and mesh by default)
882 case ThrottleOutPacketType.Asset: 870 case ThrottleOutPacketType.Asset:
883 return ThrottleOutPacketTypeFlags.Asset; 871 return ThrottleOutPacketTypeFlags.Asset; // Non-texture Assets data
884 default: 872 default:
885 return 0; 873 return 0;
886 } 874 }