* 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
0.6.0-stable
Justin Clarke Casey 2008-10-03 18:06:45 +00:00
parent 1b2380db84
commit 743e336bf3
9 changed files with 158 additions and 22 deletions

View File

@ -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;
}
}

View File

@ -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
{
/// <summary>
/// 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.
/// </summary>
public class ClientStackUserSettings
{
/// <summary>
/// The settings for the throttle that governs how many packets in total are sent to the client.
/// </summary>
public ThrottleSettings TotalThrottleSettings;
}
}

View File

@ -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);

View File

@ -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();

View File

@ -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);
/// <summary>
/// Is throttling enabled at all?
/// Is queueing enabled at all?
/// </summary>
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<LLQueItem>();
AssetOutgoingPacketQueue = new Queue<LLQueItem>();
// 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);

View File

@ -48,9 +48,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// get { return m_clientManager; }
//}
public LLPacketServer(ILLClientStackNetworkHandler networkHandler)
/// <summary>
/// Tweakable user settings
/// </summary>
private ClientStackUserSettings m_userSettings;
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);
}
/// <summary>

View File

@ -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);
}
/// <summary>
@ -142,10 +144,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name="port"></param>
/// <param name="proxyPortOffsetParm"></param>
/// <param name="allow_alternate_port"></param>
/// <param name="settings"></param>
/// <param name="assetCache"></param>
/// <param name="circuitManager"></param>
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);
}
/// <summary>

View File

@ -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);

View File

@ -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
{
/// <summary>
/// Represent throttle settings for a client stack. These settings are in bytes per second
/// </summary>
public class ThrottleSettings
{
/// <summary>
/// Minimum bytes per second that the throttle can be set to.
/// </summary>
public int Min;
/// <summary>
/// Maximum bytes per second that the throttle can be set to.
/// </summary>
public int Max;
/// <summary>
/// Current bytes per second that the throttle should be set to.
/// </summary>
public int Current;
public ThrottleSettings(int min, int max, int current)
{
Min = min;
Max = max;
Current = current;
}
}
}