* 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
0.6.0-stable
Justin Clarke Casey 2008-10-06 16:48:41 +00:00
parent 68021fa8ff
commit 33d957207c
2 changed files with 42 additions and 37 deletions

View File

@ -109,7 +109,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
TextureOutgoingPacketQueue = new Queue<LLQueItem>(); TextureOutgoingPacketQueue = new Queue<LLQueItem>();
AssetOutgoingPacketQueue = new Queue<LLQueItem>(); AssetOutgoingPacketQueue = new Queue<LLQueItem>();
// 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); ResendThrottle = new LLPacketThrottle(5000, 100000, 16000);
LandThrottle = new LLPacketThrottle(1000, 100000, 2000); LandThrottle = new LLPacketThrottle(1000, 100000, 2000);
WindThrottle = new LLPacketThrottle(0, 100000, 0); WindThrottle = new LLPacketThrottle(0, 100000, 0);
@ -118,8 +118,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
AssetThrottle = new LLPacketThrottle(1000, 800000, 1000); AssetThrottle = new LLPacketThrottle(1000, 800000, 1000);
TextureThrottle = new LLPacketThrottle(1000, 800000, 4000); TextureThrottle = new LLPacketThrottle(1000, 800000, 4000);
// Total Throttle trumps all // Total Throttle trumps all - it is the number of bits in total that are allowed to go out per second.
// Number of bytes allowed to go out per second.
ThrottleSettings totalThrottleSettings = userSettings.TotalThrottleSettings; ThrottleSettings totalThrottleSettings = userSettings.TotalThrottleSettings;
if (null == totalThrottleSettings) if (null == totalThrottleSettings)
{ {
@ -320,32 +319,32 @@ namespace OpenSim.Region.ClientStack.LindenUDP
LLQueItem qpack = ResendOutgoingPacketQueue.Dequeue(); LLQueItem qpack = ResendOutgoingPacketQueue.Dequeue();
SendQueue.Enqueue(qpack); SendQueue.Enqueue(qpack);
TotalThrottle.Add(qpack.Packet.ToBytes().Length); TotalThrottle.AddBytes(qpack.Packet.ToBytes().Length);
ResendThrottle.Add(qpack.Packet.ToBytes().Length); ResendThrottle.AddBytes(qpack.Packet.ToBytes().Length);
} }
if (LandThrottle.UnderLimit() && LandOutgoingPacketQueue.Count > 0) if (LandThrottle.UnderLimit() && LandOutgoingPacketQueue.Count > 0)
{ {
LLQueItem qpack = LandOutgoingPacketQueue.Dequeue(); LLQueItem qpack = LandOutgoingPacketQueue.Dequeue();
SendQueue.Enqueue(qpack); SendQueue.Enqueue(qpack);
TotalThrottle.Add(qpack.Packet.ToBytes().Length); TotalThrottle.AddBytes(qpack.Packet.ToBytes().Length);
LandThrottle.Add(qpack.Packet.ToBytes().Length); LandThrottle.AddBytes(qpack.Packet.ToBytes().Length);
} }
if (WindThrottle.UnderLimit() && WindOutgoingPacketQueue.Count > 0) if (WindThrottle.UnderLimit() && WindOutgoingPacketQueue.Count > 0)
{ {
LLQueItem qpack = WindOutgoingPacketQueue.Dequeue(); LLQueItem qpack = WindOutgoingPacketQueue.Dequeue();
SendQueue.Enqueue(qpack); SendQueue.Enqueue(qpack);
TotalThrottle.Add(qpack.Packet.ToBytes().Length); TotalThrottle.AddBytes(qpack.Packet.ToBytes().Length);
WindThrottle.Add(qpack.Packet.ToBytes().Length); WindThrottle.AddBytes(qpack.Packet.ToBytes().Length);
} }
if (CloudThrottle.UnderLimit() && CloudOutgoingPacketQueue.Count > 0) if (CloudThrottle.UnderLimit() && CloudOutgoingPacketQueue.Count > 0)
{ {
LLQueItem qpack = CloudOutgoingPacketQueue.Dequeue(); LLQueItem qpack = CloudOutgoingPacketQueue.Dequeue();
SendQueue.Enqueue(qpack); SendQueue.Enqueue(qpack);
TotalThrottle.Add(qpack.Packet.ToBytes().Length); TotalThrottle.AddBytes(qpack.Packet.ToBytes().Length);
CloudThrottle.Add(qpack.Packet.ToBytes().Length); CloudThrottle.AddBytes(qpack.Packet.ToBytes().Length);
} }
if (TaskThrottle.UnderLimit() && (TaskOutgoingPacketQueue.Count > 0 || TaskLowpriorityPacketQueue.Count > 0)) if (TaskThrottle.UnderLimit() && (TaskOutgoingPacketQueue.Count > 0 || TaskLowpriorityPacketQueue.Count > 0))
{ {
@ -360,24 +359,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP
qpack = TaskLowpriorityPacketQueue.Dequeue(); qpack = TaskLowpriorityPacketQueue.Dequeue();
SendQueue.Enqueue(qpack); SendQueue.Enqueue(qpack);
} }
TotalThrottle.Add(qpack.Packet.ToBytes().Length); TotalThrottle.AddBytes(qpack.Packet.ToBytes().Length);
TaskThrottle.Add(qpack.Packet.ToBytes().Length); TaskThrottle.AddBytes(qpack.Packet.ToBytes().Length);
} }
if (TextureThrottle.UnderLimit() && TextureOutgoingPacketQueue.Count > 0) if (TextureThrottle.UnderLimit() && TextureOutgoingPacketQueue.Count > 0)
{ {
LLQueItem qpack = TextureOutgoingPacketQueue.Dequeue(); LLQueItem qpack = TextureOutgoingPacketQueue.Dequeue();
SendQueue.Enqueue(qpack); SendQueue.Enqueue(qpack);
TotalThrottle.Add(qpack.Packet.ToBytes().Length); TotalThrottle.AddBytes(qpack.Packet.ToBytes().Length);
TextureThrottle.Add(qpack.Packet.ToBytes().Length); TextureThrottle.AddBytes(qpack.Packet.ToBytes().Length);
} }
if (AssetThrottle.UnderLimit() && AssetOutgoingPacketQueue.Count > 0) if (AssetThrottle.UnderLimit() && AssetOutgoingPacketQueue.Count > 0)
{ {
LLQueItem qpack = AssetOutgoingPacketQueue.Dequeue(); LLQueItem qpack = AssetOutgoingPacketQueue.Dequeue();
SendQueue.Enqueue(qpack); SendQueue.Enqueue(qpack);
TotalThrottle.Add(qpack.Packet.ToBytes().Length); TotalThrottle.AddBytes(qpack.Packet.ToBytes().Length);
AssetThrottle.Add(qpack.Packet.ToBytes().Length); AssetThrottle.AddBytes(qpack.Packet.ToBytes().Length);
} }
} }
// m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets"); // m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets");
@ -404,8 +403,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
try try
{ {
Monitor.Enter(this); Monitor.Enter(this);
throttle.Add(item.Packet.ToBytes().Length); throttle.AddBytes(item.Packet.ToBytes().Length);
TotalThrottle.Add(item.Packet.ToBytes().Length); TotalThrottle.AddBytes(item.Packet.ToBytes().Length);
SendQueue.Enqueue(item); SendQueue.Enqueue(item);
} }
catch (Exception e) catch (Exception e)
@ -508,16 +507,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
tAsset = (int) BitConverter.ToSingle(throttle, j); tAsset = (int) BitConverter.ToSingle(throttle, j);
tall = tResend + tLand + tWind + tCloud + tTask + tTexture + tAsset; tall = tResend + tLand + tWind + tCloud + tTask + tTexture + tAsset;
/*
m_log.Info("[CLIENT]: Client AgentThrottle - Got throttle:resendbytes=" + tResend + m_log.Info("[CLIENT]: Client AgentThrottle - Got throttle:resendbits=" + tResend +
" landbytes=" + tLand + " landbits=" + tLand +
" windbytes=" + tWind + " windbits=" + tWind +
" cloudbytes=" + tCloud + " cloudbits=" + tCloud +
" taskbytes=" + tTask + " taskbits=" + tTask +
" texturebytes=" + tTexture + " texturebits=" + tTexture +
" Assetbytes=" + tAsset + " Assetbits=" + tAsset +
" Allbytes=" + tall); " Allbits=" + tall);
*/
// Total Sanity // Total Sanity
// Make sure that the client sent sane total values. // Make sure that the client sent sane total values.

View File

@ -26,37 +26,43 @@
*/ */
namespace OpenSim.Region.ClientStack.LindenUDP namespace OpenSim.Region.ClientStack.LindenUDP
{ {
public class LLPacketThrottle public class LLPacketThrottle
{ {
private readonly int m_maxAllowableThrottle; private readonly int m_maxAllowableThrottle;
private readonly int m_minAllowableThrottle; private readonly int m_minAllowableThrottle;
private int m_currentThrottle; private int m_currentThrottle;
private const int m_throttleTimeDivisor = 7; private const int m_throttleTimeDivisor = 7;
private int m_currentBytesSent; private int m_currentBitsSent;
public LLPacketThrottle(int Min, int Max, int Throttle) public LLPacketThrottle(int Min, int Max, int Throttle)
{ {
m_maxAllowableThrottle = Max; m_maxAllowableThrottle = Max;
m_minAllowableThrottle = Min; m_minAllowableThrottle = Min;
m_currentThrottle = Throttle; m_currentThrottle = Throttle;
m_currentBytesSent = 0; m_currentBitsSent = 0;
} }
public void Reset() public void Reset()
{ {
m_currentBytesSent = 0; m_currentBitsSent = 0;
} }
public bool UnderLimit() 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; m_currentBitsSent += bytes * 8;
return m_currentBytesSent; return m_currentBitsSent;
} }
// Properties // Properties