From 743e336bf340f623a50bebd53d98798c04eb0345 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Fri, 3 Oct 2008 18:06:45 +0000
Subject: * Put in some infrastructure to allow tweaking of packet queue
throttle values for the total throttle (the one that throttles all packet
output) * Not complete yet
---
OpenSim/Region/ClientStack/ClientStackManager.cs | 17 +++++--
.../Region/ClientStack/ClientStackUserSettings.cs | 43 ++++++++++++++++
OpenSim/Region/ClientStack/IClientNetworkServer.cs | 4 +-
.../ClientStack/LindenUDP/LLPacketHandler.cs | 4 +-
.../Region/ClientStack/LindenUDP/LLPacketQueue.cs | 19 ++++++--
.../Region/ClientStack/LindenUDP/LLPacketServer.cs | 13 ++++-
.../Region/ClientStack/LindenUDP/LLUDPServer.cs | 16 +++---
.../Region/ClientStack/RegionApplicationBase.cs | 7 ++-
OpenSim/Region/ClientStack/ThrottleSettings.cs | 57 ++++++++++++++++++++++
9 files changed, 158 insertions(+), 22 deletions(-)
create mode 100644 OpenSim/Region/ClientStack/ClientStackUserSettings.cs
create mode 100644 OpenSim/Region/ClientStack/ThrottleSettings.cs
(limited to 'OpenSim/Region/ClientStack')
diff --git a/OpenSim/Region/ClientStack/ClientStackManager.cs b/OpenSim/Region/ClientStack/ClientStackManager.cs
index b5cd06a..0b0c07f 100644
--- a/OpenSim/Region/ClientStack/ClientStackManager.cs
+++ b/OpenSim/Region/ClientStack/ClientStackManager.cs
@@ -43,10 +43,11 @@ namespace OpenSim.Region.Environment
private Type plugin;
private Assembly pluginAssembly;
- public ClientStackManager(string dllName) {
+ public ClientStackManager(string dllName)
+ {
m_log.Info("[CLIENTSTACK]: Attempting to load " + dllName);
- plugin=null;
+ plugin = null;
pluginAssembly = Assembly.LoadFrom(dllName);
foreach (Type pluginType in pluginAssembly.GetTypes())
@@ -65,16 +66,22 @@ namespace OpenSim.Region.Environment
}
}
- public IClientNetworkServer CreateServer(IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, AssetCache assetCache, AgentCircuitManager authenticateClass)
+ public IClientNetworkServer CreateServer(
+ IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, ClientStackUserSettings settings,
+ AssetCache assetCache, AgentCircuitManager authenticateClass)
{
if (plugin != null)
{
IClientNetworkServer server =
(IClientNetworkServer) Activator.CreateInstance(pluginAssembly.GetType(plugin.ToString()));
- server.Initialise(_listenIP, ref port, proxyPortOffset, allow_alternate_port, assetCache, authenticateClass);
+
+ server.Initialise(
+ _listenIP, ref port, proxyPortOffset, allow_alternate_port, settings, assetCache, authenticateClass);
+
return server;
}
- m_log.Error("[CLIENTSTACK] Couldn't initialize a new server");
+
+ m_log.Error("[CLIENTSTACK]: Couldn't initialize a new server");
return null;
}
}
diff --git a/OpenSim/Region/ClientStack/ClientStackUserSettings.cs b/OpenSim/Region/ClientStack/ClientStackUserSettings.cs
new file mode 100644
index 0000000..d34ae34
--- /dev/null
+++ b/OpenSim/Region/ClientStack/ClientStackUserSettings.cs
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSim Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace OpenSim.Region.ClientStack
+{
+ ///
+ /// Allow users to tweak parameters for the client stack.
+ ///
+ /// At the moment this is very incomplete - other tweakable settings could be added. This is also somewhat LL client
+ /// oriented right now.
+ ///
+ public class ClientStackUserSettings
+ {
+ ///
+ /// The settings for the throttle that governs how many packets in total are sent to the client.
+ ///
+ public ThrottleSettings TotalThrottleSettings;
+ }
+}
diff --git a/OpenSim/Region/ClientStack/IClientNetworkServer.cs b/OpenSim/Region/ClientStack/IClientNetworkServer.cs
index 817e8af..fcec1b8 100644
--- a/OpenSim/Region/ClientStack/IClientNetworkServer.cs
+++ b/OpenSim/Region/ClientStack/IClientNetworkServer.cs
@@ -35,7 +35,9 @@ namespace OpenSim.Region.ClientStack
{
public interface IClientNetworkServer
{
- void Initialise(IPAddress _listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, AssetCache assetCache, AgentCircuitManager authenticateClass);
+ void Initialise(
+ IPAddress _listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, ClientStackUserSettings settings,
+ AssetCache assetCache, AgentCircuitManager authenticateClass);
Socket Server { get; }
bool HandlesRegion(Location x);
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs
index 78a916d..da62a80 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs
@@ -219,12 +219,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Constructors
//
- public LLPacketHandler(IClientAPI client, LLPacketServer server)
+ public LLPacketHandler(IClientAPI client, LLPacketServer server, ClientStackUserSettings userSettings)
{
m_Client = client;
m_PacketServer = server;
- m_PacketQueue = new LLPacketQueue(client.AgentId);
+ m_PacketQueue = new LLPacketQueue(client.AgentId, userSettings);
m_AckTimer.Elapsed += AckTimerElapsed;
m_AckTimer.Start();
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs
index e4e5e9a..1e03c88 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs
@@ -34,6 +34,7 @@ using OpenMetaverse.Packets;
using OpenSim.Framework;
using OpenSim.Framework.Statistics;
using OpenSim.Framework.Statistics.Interfaces;
+using OpenSim.Region.ClientStack;
using Timer=System.Timers.Timer;
@@ -45,7 +46,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
= log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
///
- /// Is throttling enabled at all?
+ /// Is queueing enabled at all?
///
private bool m_enabled = true;
@@ -88,7 +89,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private UUID m_agentId;
- public LLPacketQueue(UUID agentId)
+ public LLPacketQueue(UUID agentId, ClientStackUserSettings userSettings)
{
// While working on this, the BlockingQueue had me fooled for a bit.
// The Blocking queue causes the thread to stop until there's something
@@ -108,7 +109,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
TextureOutgoingPacketQueue = new Queue();
AssetOutgoingPacketQueue = new Queue();
-
// Set up the throttle classes (min, max, current) in bytes
ResendThrottle = new LLPacketThrottle(5000, 100000, 16000);
LandThrottle = new LLPacketThrottle(1000, 100000, 2000);
@@ -117,9 +117,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
TaskThrottle = new LLPacketThrottle(1000, 800000, 3000);
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. (256kbps per client)
- TotalThrottle = new LLPacketThrottle(0, 1500000, 28000);
+ // Number of bytes allowed to go out per second.
+ ThrottleSettings totalThrottleSettings = userSettings.TotalThrottleSettings;
+ if (null == totalThrottleSettings)
+ {
+ totalThrottleSettings = new ThrottleSettings(0, 1500000, 28000);
+ }
+
+ TotalThrottle
+ = new LLPacketThrottle(
+ totalThrottleSettings.Min, totalThrottleSettings.Max, totalThrottleSettings.Current);
throttleTimer = new Timer((int) (throttletimems/throttleTimeDivisor));
throttleTimer.Elapsed += new ElapsedEventHandler(ThrottleTimerElapsed);
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs
index 1261666..e2d2226 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs
@@ -47,10 +47,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
//{
// get { return m_clientManager; }
//}
+
+ ///
+ /// Tweakable user settings
+ ///
+ private ClientStackUserSettings m_userSettings;
- public LLPacketServer(ILLClientStackNetworkHandler networkHandler)
+ public LLPacketServer(ILLClientStackNetworkHandler networkHandler, ClientStackUserSettings userSettings)
{
+ m_userSettings = userSettings;
m_networkHandler = networkHandler;
+
m_networkHandler.RegisterPacketServer(this);
}
@@ -90,7 +97,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
UUID agentId, UUID sessionId, uint circuitCode, EndPoint proxyEP)
{
return
- new LLClientView(remoteEP, scene, assetCache, packServer, authenSessions, agentId, sessionId, circuitCode, proxyEP);
+ new LLClientView(
+ remoteEP, scene, assetCache, packServer, authenSessions, agentId, sessionId, circuitCode, proxyEP,
+ m_userSettings);
}
///
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index c20c7bc..8643382 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -130,9 +130,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
}
- public LLUDPServer(IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, AssetCache assetCache, AgentCircuitManager authenticateClass)
+ public LLUDPServer(
+ IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, ClientStackUserSettings userSettings,
+ AssetCache assetCache, AgentCircuitManager authenticateClass)
{
- Initialise(_listenIP, ref port, proxyPortOffset, allow_alternate_port, assetCache, authenticateClass);
+ Initialise(_listenIP, ref port, proxyPortOffset, allow_alternate_port, userSettings, assetCache, authenticateClass);
}
///
@@ -142,10 +144,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
///
///
///
+ ///
///
///
public void Initialise(
- IPAddress _listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, AssetCache assetCache, AgentCircuitManager circuitManager)
+ IPAddress _listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, ClientStackUserSettings userSettings,
+ AssetCache assetCache, AgentCircuitManager circuitManager)
{
proxyPortOffset = proxyPortOffsetParm;
listenPort = (uint) (port + proxyPortOffsetParm);
@@ -153,7 +157,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Allow_Alternate_Port = allow_alternate_port;
m_assetCache = assetCache;
m_circuitManager = circuitManager;
- CreatePacketServer();
+ CreatePacketServer(userSettings);
// Return new port
// This because in Grid mode it is not really important what port the region listens to as long as it is correctly registered.
@@ -161,9 +165,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
port = (uint)(listenPort - proxyPortOffsetParm);
}
- protected virtual void CreatePacketServer()
+ protected virtual void CreatePacketServer(ClientStackUserSettings userSettings)
{
- new LLPacketServer(this);
+ new LLPacketServer(this, userSettings);
}
///
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
index cee7ffa..4db2907 100644
--- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs
+++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
@@ -123,7 +123,12 @@ namespace OpenSim.Region.ClientStack
// listenIP = IPAddress.Parse("0.0.0.0");
uint port = (uint) regionInfo.InternalEndPoint.Port;
- clientServer = m_clientStackManager.CreateServer(listenIP, ref port, proxyOffset, regionInfo.m_allow_alternate_ports, m_assetCache, circuitManager);
+
+ clientServer
+ = m_clientStackManager.CreateServer(
+ listenIP, ref port, proxyOffset, regionInfo.m_allow_alternate_ports, new ClientStackUserSettings(),
+ m_assetCache, circuitManager);
+
regionInfo.InternalEndPoint.Port = (int)port;
Scene scene = CreateScene(regionInfo, m_storageManager, circuitManager);
diff --git a/OpenSim/Region/ClientStack/ThrottleSettings.cs b/OpenSim/Region/ClientStack/ThrottleSettings.cs
new file mode 100644
index 0000000..ca537c6
--- /dev/null
+++ b/OpenSim/Region/ClientStack/ThrottleSettings.cs
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSim Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace OpenSim.Region.ClientStack
+{
+ ///
+ /// Represent throttle settings for a client stack. These settings are in bytes per second
+ ///
+ public class ThrottleSettings
+ {
+ ///
+ /// Minimum bytes per second that the throttle can be set to.
+ ///
+ public int Min;
+
+ ///
+ /// Maximum bytes per second that the throttle can be set to.
+ ///
+ public int Max;
+
+ ///
+ /// Current bytes per second that the throttle should be set to.
+ ///
+ public int Current;
+
+ public ThrottleSettings(int min, int max, int current)
+ {
+ Min = min;
+ Max = max;
+ Current = current;
+ }
+ }
+}
--
cgit v1.1