From 61f918cbda3d928356a15e2b98767279d5b4262b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 16 Nov 2019 22:19:46 +0000 Subject: remove some llUDP options --- .../Region/ClientStack/Linden/UDP/LLUDPClient.cs | 79 ++++++---------------- .../Region/ClientStack/Linden/UDP/ThrottleRates.cs | 54 ++++++--------- .../Region/ClientStack/Linden/UDP/TokenBucket.cs | 41 ++++------- OpenSim/Region/Framework/Scenes/Scene.cs | 6 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 35 +++++----- 5 files changed, 74 insertions(+), 141 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index 4e9cf1c..69e53f6 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs @@ -65,11 +65,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// public sealed class LLUDPClient { - // TODO: Make this a config setting - /// Percentage of the task throttle category that is allocated to avatar and prim - /// state updates - const float STATE_TASK_PERCENTAGE = 0.8f; - private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); /// The number of packet categories to throttle on. If a throttle category is added @@ -194,6 +189,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public bool m_deliverPackets = true; private float m_burstTime; + private int m_maxRate; public double m_lastStartpingTimeMS; public int m_pingMS; @@ -243,16 +239,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_maxRTO = maxRTO; m_burstTime = rates.BurstTime; - float m_burst = rates.ClientMaxRate * m_burstTime; + m_maxRate = rates.ClientMaxRate; // Create a token bucket throttle for this client that has the scene token bucket as a parent - m_throttleClient = new AdaptiveTokenBucket(parentThrottle, rates.ClientMaxRate, m_burst, rates.AdaptiveThrottlesEnabled); + m_throttleClient = new AdaptiveTokenBucket(parentThrottle, m_maxRate, m_maxRate * m_burstTime, rates.AdaptiveThrottlesEnabled); // Create an array of token buckets for this clients different throttle categories m_throttleCategories = new TokenBucket[THROTTLE_CATEGORY_COUNT]; - m_burst = rates.Total * rates.BurstTime; - for (int i = 0; i < THROTTLE_CATEGORY_COUNT; i++) { ThrottleOutPacketType type = (ThrottleOutPacketType)i; @@ -260,18 +254,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Initialize the packet outboxes, where packets sit while they are waiting for tokens m_packetOutboxes[i] = new DoubleLocklessQueue(); // Initialize the token buckets that control the throttling for each category - //m_throttleCategories[i] = new TokenBucket(m_throttleClient, rates.GetRate(type), m_burst); float rate = rates.GetRate(type); - float burst = rate * rates.BurstTime; + float burst = rate * m_burstTime; m_throttleCategories[i] = new TokenBucket(m_throttleClient, rate , burst); } - // Default the retransmission timeout to one second m_RTO = m_defaultRTO; // Initialize this to a sane value to prevent early disconnects TickLastPacketReceived = Environment.TickCount & Int32.MaxValue; - m_pingMS = (int)(3.0 * server.TickCountResolution); // so filter doesnt start at 0; + m_pingMS = 20; // so filter doesnt start at 0; } /// @@ -429,24 +421,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP int texture = (int)(BitConverter.ToSingle(adjData, pos) * scale); pos += 4; int asset = (int)(BitConverter.ToSingle(adjData, pos) * scale); - - - // Make sure none of the throttles are set below our packet MTU, - // otherwise a throttle could become permanently clogged - -/* now using floats - resend = Math.Max(resend, LLUDPServer.MTU); - land = Math.Max(land, LLUDPServer.MTU); - wind = Math.Max(wind, LLUDPServer.MTU); - cloud = Math.Max(cloud, LLUDPServer.MTU); - task = Math.Max(task, LLUDPServer.MTU); - texture = Math.Max(texture, LLUDPServer.MTU); - asset = Math.Max(asset, LLUDPServer.MTU); -*/ - int total = resend + land + wind + cloud + task + texture + asset; - - //float m_burst = total * m_burstTime; + if(total > m_maxRate) + { + scale = (float)total / m_maxRate; + resend = (int)(resend * scale); + land = (int)(land * scale); + wind = (int)(wind * scale); + cloud = (int)(cloud * scale); + task = (int)(task * scale); + texture = (int)(texture * scale); + asset = (int)(texture * scale); + int ntotal = resend + land + wind + cloud + task + texture + asset; + m_log.DebugFormat("[LLUDPCLIENT]: limiting {0} bandwith from {1} to {2}",AgentID, ntotal, total); + total = ntotal; + } if (ThrottleDebugLevel > 0) { @@ -456,35 +445,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP } TokenBucket bucket; - /* - bucket = m_throttleCategories[(int)ThrottleOutPacketType.Resend]; - bucket.RequestedDripRate = resend; - bucket.RequestedBurst = m_burst; - - bucket = m_throttleCategories[(int)ThrottleOutPacketType.Land]; - bucket.RequestedDripRate = land; - bucket.RequestedBurst = m_burst; - - bucket = m_throttleCategories[(int)ThrottleOutPacketType.Wind]; - bucket.RequestedDripRate = wind; - bucket.RequestedBurst = m_burst; - - bucket = m_throttleCategories[(int)ThrottleOutPacketType.Cloud]; - bucket.RequestedDripRate = cloud; - bucket.RequestedBurst = m_burst; - - bucket = m_throttleCategories[(int)ThrottleOutPacketType.Asset]; - bucket.RequestedDripRate = asset; - bucket.RequestedBurst = m_burst; - - bucket = m_throttleCategories[(int)ThrottleOutPacketType.Task]; - bucket.RequestedDripRate = task; - bucket.RequestedBurst = m_burst; - - bucket = m_throttleCategories[(int)ThrottleOutPacketType.Texture]; - bucket.RequestedDripRate = texture; - bucket.RequestedBurst = m_burst; - */ bucket = m_throttleCategories[(int)ThrottleOutPacketType.Resend]; bucket.RequestedDripRate = resend; bucket.RequestedBurst = resend * m_burstTime; @@ -513,7 +473,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP bucket.RequestedDripRate = texture; bucket.RequestedBurst = texture * m_burstTime; - // Reset the packed throttles cached data m_packedThrottles = null; } diff --git a/OpenSim/Region/ClientStack/Linden/UDP/ThrottleRates.cs b/OpenSim/Region/ClientStack/Linden/UDP/ThrottleRates.cs index 707acdd..8c60865 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/ThrottleRates.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/ThrottleRates.cs @@ -39,22 +39,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP public sealed class ThrottleRates { /// Drip rate for resent packets - public int Resend; + public int Resend = 6625; /// Drip rate for terrain packets - public int Land; + public int Land = 9125; /// Drip rate for wind packets - public int Wind; + public int Wind = 1750; /// Drip rate for cloud packets - public int Cloud; + public int Cloud = 1750; /// Drip rate for task packets - public int Task; + public int Task = 18500; /// Drip rate for texture packets - public int Texture; + public int Texture = 18500; /// Drip rate for asset packets - public int Asset; + public int Asset = 10500; /// Drip rate for the parent token bucket - public int Total; + public int Total = 66750; /// Flag used to enable adaptive throttles public bool AdaptiveThrottlesEnabled; @@ -66,8 +66,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// public Int64 MinimumAdaptiveThrottleRate; - public int ClientMaxRate; - public float BurstTime; + public int ClientMaxRate = 640000; // 5,120,000 bps + public float BurstTime = 10e-3f; /// /// Default constructor @@ -78,29 +78,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP try { IConfig throttleConfig = config.Configs["ClientStack.LindenUDP"]; + if(throttleConfig != null) + { + ClientMaxRate = throttleConfig.GetInt("client_throttle_max_bps", ClientMaxRate); + if (ClientMaxRate > 1000000) + ClientMaxRate = 1000000; // no more than 8Mbps + else if (ClientMaxRate < 6250) + ClientMaxRate = 6250; // no less than 50kbps - // Current default total is 66750 - Resend = throttleConfig.GetInt("resend_default", 6625); - Land = throttleConfig.GetInt("land_default", 9125); - Wind = throttleConfig.GetInt("wind_default", 1750); - Cloud = throttleConfig.GetInt("cloud_default", 1750); - Task = throttleConfig.GetInt("task_default", 18500); - Texture = throttleConfig.GetInt("texture_default", 18500); - Asset = throttleConfig.GetInt("asset_default", 10500); - - Total = Resend + Land + Wind + Cloud + Task + Texture + Asset; - // 5120000 bps default max - ClientMaxRate = throttleConfig.GetInt("client_throttle_max_bps", 640000); - if (ClientMaxRate > 1000000) - ClientMaxRate = 1000000; // no more than 8Mbps - - BurstTime = (float)throttleConfig.GetInt("client_throttle_burtsTimeMS", 10); - BurstTime *= 1e-3f; - - // Adaptive is broken -// AdaptiveThrottlesEnabled = throttleConfig.GetBoolean("enable_adaptive_throttles", false); - AdaptiveThrottlesEnabled = false; - MinimumAdaptiveThrottleRate = throttleConfig.GetInt("adaptive_throttle_min_bps", 32000); + // Adaptive is broken + // AdaptiveThrottlesEnabled = throttleConfig.GetBoolean("enable_adaptive_throttles", false); + AdaptiveThrottlesEnabled = false; + MinimumAdaptiveThrottleRate = throttleConfig.GetInt("adaptive_throttle_min_bps", 32000); + } } catch (Exception) { } } diff --git a/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs b/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs index 1bf05a3..06864c0 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs @@ -45,15 +45,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP private static Int32 m_counter = 0; - protected const float m_timeScale = 1e-3f; - - /// + /// /// minimum recovery rate, ie bandwith /// protected const float MINDRIPRATE = 500; - // minimum and maximim burst size, ie max number of bytes token can have - protected const float MINBURST = 1500; // can't be less than one MTU or it will block + // maximim burst size, ie max number of bytes token can have protected const float MAXBURST = 7500; /// Time of the last drip @@ -103,9 +100,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP get { return m_burst; } set { float rate = (value < 0 ? 0 : value); - if (rate < MINBURST) - rate = MINBURST; - else if (rate > MAXBURST) + if (rate > MAXBURST) rate = MAXBURST; m_burst = rate; @@ -114,11 +109,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP public float Burst { - get { - float rate = RequestedBurst * BurstModifier(); - if (rate < MINBURST) - rate = MINBURST; - return (float)rate; + get + { + return RequestedBurst * BurstModifier(); ; } } @@ -156,7 +149,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (rate < MINDRIPRATE) rate = MINDRIPRATE; - return (float)rate; + return rate; } } @@ -192,7 +185,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP Parent = parent; RequestedDripRate = dripRate; RequestedBurst = MaxBurst; - m_lastDrip = Util.GetTimeStampMS() + 100000.0; // skip first drip + m_lastDrip = Util.GetTimeStamp() + 1000; // skip first drip } #endregion Constructor @@ -214,9 +207,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// protected float BurstModifier() { - // for now... burst rate is always m_quantumsPerBurst (constant) - // larger than drip rate so the ratio of burst requests is the - // same as the drip ratio return DripRateModifier(); } @@ -272,10 +262,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP Drip(); // If we have enough tokens then remove them and return - if (m_tokenCount - amount >= 0) + if (m_tokenCount > 0) { - // we don't have to remove from the parent, the drip rate is already - // reflective of the drip rate limits in the parent m_tokenCount -= amount; return true; } @@ -285,12 +273,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP public bool CheckTokens(int amount) { - return (m_tokenCount - amount >= 0); + return (m_tokenCount > 0); } public int GetCatBytesCanSend(int timeMS) { -// return (int)(m_tokenCount + timeMS * m_dripRate * 1e-3); return (int)(timeMS * DripRate * 1e-3); } @@ -310,14 +297,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP return; } - double now = Util.GetTimeStampMS(); - double deltaMS = now - m_lastDrip; + double now = Util.GetTimeStamp(); + double delta = now - m_lastDrip; m_lastDrip = now; - if (deltaMS <= 0) + if (delta <= 0) return; - m_tokenCount += (float)deltaMS * DripRate * m_timeScale; + m_tokenCount += (float)delta * DripRate; float burst = Burst; if (m_tokenCount > burst) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ff1e922..a0a2882 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4625,12 +4625,8 @@ Label_GroupsDone: // however to avoid a race condition crossing borders.. if (childAgentUpdate.IsChildAgent) { - uint rRegionX = (uint)(cAgentData.RegionHandle >> 40); - uint rRegionY = (((uint)(cAgentData.RegionHandle)) >> 8); - uint tRegionX = RegionInfo.RegionLocX; - uint tRegionY = RegionInfo.RegionLocY; //Send Data to ScenePresence - childAgentUpdate.UpdateChildAgent(cAgentData, tRegionX, tRegionY, rRegionX, rRegionY); + childAgentUpdate.UpdateChildAgent(cAgentData); // Not Implemented: //TODO: Do we need to pass the message on to one of our neighbors? } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4413d26..c80fba2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4846,7 +4846,7 @@ namespace OpenSim.Region.Framework.Scenes /// This updates important decision making data about a child agent /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region /// - public void UpdateChildAgent(AgentPosition cAgentData, uint tRegionX, uint tRegionY, uint rRegionX, uint rRegionY) + public void UpdateChildAgent(AgentPosition cAgentData) { if (!IsChildAgent) return; @@ -4854,6 +4854,10 @@ namespace OpenSim.Region.Framework.Scenes GodController.SetState(cAgentData.GodData); RegionHandle = cAgentData.RegionHandle; + uint rRegionX = (uint)(RegionHandle >> 40); + uint rRegionY = (((uint)RegionHandle) >> 8); + uint tRegionX = m_scene.RegionInfo.RegionLocX; + uint tRegionY = m_scene.RegionInfo.RegionLocY; //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY); int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; @@ -4863,11 +4867,19 @@ namespace OpenSim.Region.Framework.Scenes DrawDistance = cAgentData.Far; - if (cAgentData.Position != marker) // UGH!! - m_pos = cAgentData.Position + offset; - + m_pos = cAgentData.Position + offset; CameraPosition = cAgentData.Center + offset; + if (cAgentData.ChildrenCapSeeds != null && cAgentData.ChildrenCapSeeds.Count > 0) + { + if (Scene.CapsModule != null) + { + Scene.CapsModule.SetChildrenSeed(UUID, cAgentData.ChildrenCapSeeds); + } + + KnownRegions = cAgentData.ChildrenCapSeeds; + } + if ((cAgentData.Throttles != null) && cAgentData.Throttles.Length > 0) { // some scaling factor @@ -4880,24 +4892,13 @@ namespace OpenSim.Region.Framework.Scenes x = x * x + y * y; - const float distScale = 0.4f / Constants.RegionSize / Constants.RegionSize; - float factor = 1.0f - distScale * x; + float factor = 1.0f - x * 0.3f / Constants.RegionSize / Constants.RegionSize; if (factor < 0.2f) factor = 0.2f; ControllingClient.SetChildAgentThrottle(cAgentData.Throttles,factor); } - if(cAgentData.ChildrenCapSeeds != null && cAgentData.ChildrenCapSeeds.Count >0) - { - if (Scene.CapsModule != null) - { - Scene.CapsModule.SetChildrenSeed(UUID, cAgentData.ChildrenCapSeeds); - } - - KnownRegions = cAgentData.ChildrenCapSeeds; - } - //cAgentData.AVHeight; //m_velocity = cAgentData.Velocity; checkRePrioritization(); @@ -5029,7 +5030,7 @@ namespace OpenSim.Region.Framework.Scenes } if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) - ControllingClient.SetChildAgentThrottle(cAgent.Throttles); + ControllingClient.SetChildAgentThrottle(cAgent.Throttles, 1.0f); m_headrotation = cAgent.HeadRotation; Rotation = cAgent.BodyRotation; -- cgit v1.1