From 33d957207cc598e1a61edad42b4b734a26c362f9 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 6 Oct 2008 16:48:41 +0000 Subject: * Change interpretation of asset throttle values to bits per second rather than bytes per second * Changing network bandwidth in the preferences will now have a much more noticeable effect - a user may want to increase this if data is being slow to download from opensim --- .../Region/ClientStack/LindenUDP/LLPacketQueue.cs | 57 +++++++++++----------- .../ClientStack/LindenUDP/LLPacketThrottle.cs | 22 ++++++--- 2 files changed, 42 insertions(+), 37 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs index 1e03c88..5e4879b 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs @@ -109,7 +109,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP TextureOutgoingPacketQueue = new Queue(); AssetOutgoingPacketQueue = new Queue(); - // Set up the throttle classes (min, max, current) in bytes + // Set up the throttle classes (min, max, current) in bits per second ResendThrottle = new LLPacketThrottle(5000, 100000, 16000); LandThrottle = new LLPacketThrottle(1000, 100000, 2000); WindThrottle = new LLPacketThrottle(0, 100000, 0); @@ -118,8 +118,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP AssetThrottle = new LLPacketThrottle(1000, 800000, 1000); TextureThrottle = new LLPacketThrottle(1000, 800000, 4000); - // Total Throttle trumps all - // Number of bytes allowed to go out per second. + // Total Throttle trumps all - it is the number of bits in total that are allowed to go out per second. ThrottleSettings totalThrottleSettings = userSettings.TotalThrottleSettings; if (null == totalThrottleSettings) { @@ -320,32 +319,32 @@ namespace OpenSim.Region.ClientStack.LindenUDP LLQueItem qpack = ResendOutgoingPacketQueue.Dequeue(); SendQueue.Enqueue(qpack); - TotalThrottle.Add(qpack.Packet.ToBytes().Length); - ResendThrottle.Add(qpack.Packet.ToBytes().Length); + TotalThrottle.AddBytes(qpack.Packet.ToBytes().Length); + ResendThrottle.AddBytes(qpack.Packet.ToBytes().Length); } if (LandThrottle.UnderLimit() && LandOutgoingPacketQueue.Count > 0) { LLQueItem qpack = LandOutgoingPacketQueue.Dequeue(); SendQueue.Enqueue(qpack); - TotalThrottle.Add(qpack.Packet.ToBytes().Length); - LandThrottle.Add(qpack.Packet.ToBytes().Length); + TotalThrottle.AddBytes(qpack.Packet.ToBytes().Length); + LandThrottle.AddBytes(qpack.Packet.ToBytes().Length); } if (WindThrottle.UnderLimit() && WindOutgoingPacketQueue.Count > 0) { LLQueItem qpack = WindOutgoingPacketQueue.Dequeue(); SendQueue.Enqueue(qpack); - TotalThrottle.Add(qpack.Packet.ToBytes().Length); - WindThrottle.Add(qpack.Packet.ToBytes().Length); + TotalThrottle.AddBytes(qpack.Packet.ToBytes().Length); + WindThrottle.AddBytes(qpack.Packet.ToBytes().Length); } if (CloudThrottle.UnderLimit() && CloudOutgoingPacketQueue.Count > 0) { LLQueItem qpack = CloudOutgoingPacketQueue.Dequeue(); SendQueue.Enqueue(qpack); - TotalThrottle.Add(qpack.Packet.ToBytes().Length); - CloudThrottle.Add(qpack.Packet.ToBytes().Length); + TotalThrottle.AddBytes(qpack.Packet.ToBytes().Length); + CloudThrottle.AddBytes(qpack.Packet.ToBytes().Length); } if (TaskThrottle.UnderLimit() && (TaskOutgoingPacketQueue.Count > 0 || TaskLowpriorityPacketQueue.Count > 0)) { @@ -360,24 +359,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP qpack = TaskLowpriorityPacketQueue.Dequeue(); SendQueue.Enqueue(qpack); } - TotalThrottle.Add(qpack.Packet.ToBytes().Length); - TaskThrottle.Add(qpack.Packet.ToBytes().Length); + TotalThrottle.AddBytes(qpack.Packet.ToBytes().Length); + TaskThrottle.AddBytes(qpack.Packet.ToBytes().Length); } if (TextureThrottle.UnderLimit() && TextureOutgoingPacketQueue.Count > 0) { LLQueItem qpack = TextureOutgoingPacketQueue.Dequeue(); SendQueue.Enqueue(qpack); - TotalThrottle.Add(qpack.Packet.ToBytes().Length); - TextureThrottle.Add(qpack.Packet.ToBytes().Length); + TotalThrottle.AddBytes(qpack.Packet.ToBytes().Length); + TextureThrottle.AddBytes(qpack.Packet.ToBytes().Length); } if (AssetThrottle.UnderLimit() && AssetOutgoingPacketQueue.Count > 0) { LLQueItem qpack = AssetOutgoingPacketQueue.Dequeue(); SendQueue.Enqueue(qpack); - TotalThrottle.Add(qpack.Packet.ToBytes().Length); - AssetThrottle.Add(qpack.Packet.ToBytes().Length); + TotalThrottle.AddBytes(qpack.Packet.ToBytes().Length); + AssetThrottle.AddBytes(qpack.Packet.ToBytes().Length); } } // m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets"); @@ -404,8 +403,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP try { Monitor.Enter(this); - throttle.Add(item.Packet.ToBytes().Length); - TotalThrottle.Add(item.Packet.ToBytes().Length); + throttle.AddBytes(item.Packet.ToBytes().Length); + TotalThrottle.AddBytes(item.Packet.ToBytes().Length); SendQueue.Enqueue(item); } catch (Exception e) @@ -508,16 +507,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP tAsset = (int) BitConverter.ToSingle(throttle, j); tall = tResend + tLand + tWind + tCloud + tTask + tTexture + tAsset; - /* - m_log.Info("[CLIENT]: Client AgentThrottle - Got throttle:resendbytes=" + tResend + - " landbytes=" + tLand + - " windbytes=" + tWind + - " cloudbytes=" + tCloud + - " taskbytes=" + tTask + - " texturebytes=" + tTexture + - " Assetbytes=" + tAsset + - " Allbytes=" + tall); - */ + + m_log.Info("[CLIENT]: Client AgentThrottle - Got throttle:resendbits=" + tResend + + " landbits=" + tLand + + " windbits=" + tWind + + " cloudbits=" + tCloud + + " taskbits=" + tTask + + " texturebits=" + tTexture + + " Assetbits=" + tAsset + + " Allbits=" + tall); + // Total Sanity // Make sure that the client sent sane total values. diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketThrottle.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketThrottle.cs index b9f4594..bfb3f6e 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketThrottle.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketThrottle.cs @@ -26,37 +26,43 @@ */ namespace OpenSim.Region.ClientStack.LindenUDP -{ +{ public class LLPacketThrottle { private readonly int m_maxAllowableThrottle; private readonly int m_minAllowableThrottle; private int m_currentThrottle; private const int m_throttleTimeDivisor = 7; - private int m_currentBytesSent; + private int m_currentBitsSent; public LLPacketThrottle(int Min, int Max, int Throttle) { m_maxAllowableThrottle = Max; m_minAllowableThrottle = Min; m_currentThrottle = Throttle; - m_currentBytesSent = 0; + m_currentBitsSent = 0; } public void Reset() { - m_currentBytesSent = 0; + m_currentBitsSent = 0; } public bool UnderLimit() { - return (m_currentBytesSent < (m_currentThrottle/m_throttleTimeDivisor)); + return (m_currentBitsSent < (m_currentThrottle/m_throttleTimeDivisor)); + } + + public int AddBits(int bits) + { + m_currentBitsSent += bits; + return m_currentBitsSent; } - public int Add(int bytes) + public int AddBytes(int bytes) { - m_currentBytesSent += bytes; - return m_currentBytesSent; + m_currentBitsSent += bytes * 8; + return m_currentBitsSent; } // Properties -- cgit v1.1