/// <summary> /// Default constructor /// </summary> public WSAgent(WebSockets server, TokenBucket parentThrottle, ThrottleRates rates, UUID agentID, UUID sessionID, Socket socket, bool isChildAgent) { m_id = agentID; m_server = server; m_interestList = new InterestList(this, 200); IsChildPresence = isChildAgent; m_localID = m_server.Scene.CreateLocalID(); //TextureEntry = new Primitive.TextureEntry(DEFAULT_AVATAR_TEXTURE); SessionID = sessionID; Socket = socket; // Create a token bucket throttle for this client that has the scene token bucket as a parent m_throttle = new TokenBucket(parentThrottle, rates.ClientTotalLimit, rates.ClientTotal); // Create an array of token buckets for this clients different throttle categories m_throttleCategories = new TokenBucket[THROTTLE_CATEGORY_COUNT]; for (int i = 0; i < THROTTLE_CATEGORY_COUNT; i++) { ThrottleCategory type = (ThrottleCategory)i; // Initialize the message outboxes, where messages sit while they are waiting for tokens m_messageOutboxes[i] = new LocklessQueue <OutgoingMessage>(); // Initialize the token buckets that control the throttling for each category m_throttleCategories[i] = new TokenBucket(m_throttle, rates.GetLimit(type), rates.GetRate(type)); } // Initialize this to a sane value to prevent early disconnects TickLastMessageReceived = Util.TickCount(); }
public LLUDPServer(LLUDP udp, IScene scene, IPAddress bindAddress, int port, IConfigSource configSource, IScheduler scheduler) : base(bindAddress, port) { m_udp = udp; Scene = scene; Scheduler = scheduler; IConfig throttleConfig = configSource.Configs["LLUDP"]; m_throttleRates = new ThrottleRates(LLUDPServer.MTU, throttleConfig); m_resendTimer = new TimedEvent(100); m_ackTimer = new TimedEvent(500); m_pingTimer = new TimedEvent(5000); m_httpServer = Scene.Simian.GetAppModule <IHttpServer>(); IConfig config = configSource.Configs["LLUDP"]; if (config != null) { m_asyncPacketHandling = config.GetBoolean("AsyncPacketHandling", true); m_recvBufferSize = config.GetInt("SocketReceiveBufferSize", 0); } m_throttle = new TokenBucket(null, m_throttleRates.SceneTotalLimit, m_throttleRates.SceneTotal); PacketEvents = new PacketEventDictionary(Scheduler); Scene.OnPresenceRemove += PresenceRemoveHandler; }
protected string GetServerThrottlesReport(LLUDPServer udpServer) { StringBuilder report = new StringBuilder(); int columnPadding = 2; int maxNameLength = 18; int maxRegionNameLength = 14; int maxTypeLength = 4; string name = "SERVER AGENT RATES"; report.Append(GetColumnEntry(name, maxNameLength, columnPadding)); report.Append(GetColumnEntry("-", maxRegionNameLength, columnPadding)); report.Append(GetColumnEntry("-", maxTypeLength, columnPadding)); ThrottleRates throttleRates = udpServer.ThrottleRates; report.AppendFormat( "{0,7} {1,8} {2,7} {3,7} {4,7} {5,7} {6,9} {7,7}", (throttleRates.Total * 8) / 1000, (throttleRates.Resend * 8) / 1000, (throttleRates.Land * 8) / 1000, (throttleRates.Wind * 8) / 1000, (throttleRates.Cloud * 8) / 1000, (throttleRates.Task * 8) / 1000, (throttleRates.Texture * 8) / 1000, (throttleRates.Asset * 8) / 1000); return(report.ToString()); }
public WebSocketServer(WebSockets server) { m_server = server; m_receiveBufferSize = MTU; m_readPool = new ObjectPool <SocketAsyncEventArgs>(0, CreateSocketArgs); // TODO: Support throttle config m_throttleRates = new ThrottleRates(MTU, null); m_throttle = new TokenBucket(null, m_throttleRates.SceneTotalLimit, m_throttleRates.SceneTotal); }
public LLUDPServer(LLUDP udp, IScene scene, IPAddress bindAddress, int port, IConfigSource configSource, IScheduler scheduler) : base(bindAddress, port) { m_udp = udp; Scene = scene; Scheduler = scheduler; IConfig throttleConfig = configSource.Configs["LLUDP"]; m_throttleRates = new ThrottleRates(LLUDPServer.MTU, throttleConfig); m_resendTimer = new TimedEvent(100); m_ackTimer = new TimedEvent(500); m_pingTimer = new TimedEvent(5000); m_httpServer = Scene.Simian.GetAppModule<IHttpServer>(); IConfig config = configSource.Configs["LLUDP"]; if (config != null) { m_asyncPacketHandling = config.GetBoolean("AsyncPacketHandling", true); m_recvBufferSize = config.GetInt("SocketReceiveBufferSize", 0); } m_throttle = new TokenBucket(null, m_throttleRates.SceneTotalLimit, m_throttleRates.SceneTotal); PacketEvents = new PacketEventDictionary(Scheduler); Scene.OnPresenceRemove += PresenceRemoveHandler; }
/// <summary> /// Default constructor /// </summary> public WSAgent(WebSockets server, TokenBucket parentThrottle, ThrottleRates rates, UUID agentID, UUID sessionID, Socket socket, bool isChildAgent) { m_id = agentID; m_server = server; m_interestList = new InterestList(this, 200); IsChildPresence = isChildAgent; m_localID = m_server.Scene.CreateLocalID(); //TextureEntry = new Primitive.TextureEntry(DEFAULT_AVATAR_TEXTURE); SessionID = sessionID; Socket = socket; // Create a token bucket throttle for this client that has the scene token bucket as a parent m_throttle = new TokenBucket(parentThrottle, rates.ClientTotalLimit, rates.ClientTotal); // Create an array of token buckets for this clients different throttle categories m_throttleCategories = new TokenBucket[THROTTLE_CATEGORY_COUNT]; for (int i = 0; i < THROTTLE_CATEGORY_COUNT; i++) { ThrottleCategory type = (ThrottleCategory)i; // Initialize the message outboxes, where messages sit while they are waiting for tokens m_messageOutboxes[i] = new LocklessQueue<OutgoingMessage>(); // Initialize the token buckets that control the throttling for each category m_throttleCategories[i] = new TokenBucket(m_throttle, rates.GetLimit(type), rates.GetRate(type)); } // Initialize this to a sane value to prevent early disconnects TickLastMessageReceived = Environment.TickCount & Int32.MaxValue; }
public WebSocketServer(WebSockets server) { m_server = server; m_receiveBufferSize = MTU; m_readPool = new ObjectPool<SocketAsyncEventArgs>(0, CreateSocketArgs); // TODO: Support throttle config m_throttleRates = new ThrottleRates(MTU, null); m_throttle = new TokenBucket(null, m_throttleRates.SceneTotalLimit, m_throttleRates.SceneTotal); }
/// <summary> /// Default constructor /// </summary> /// <param name="server">Reference to the UDP server this client is connected to</param> /// <param name="rates">Default throttling rates and maximum throttle limits</param> /// <param name="parentThrottle">Parent HTB (hierarchical token bucket) /// that the child throttles will be governed by</param> /// <param name="circuitCode">Circuit code for this connection</param> /// <param name="agentID">AgentID for the connected agent</param> /// <param name="sessionID">SessionID for the connected agent</param> /// <param name="secureSessionID">SecureSessionID for the connected agent</param> /// <param name="defaultRTO">Default retransmission timeout, in milliseconds</param> /// <param name="maxRTO">Maximum retransmission timeout, in milliseconds</param> /// <param name="remoteEndPoint">Remote endpoint for this connection</param> /// <param name="isChildAgent">True if this agent is currently simulated by /// another simulator, otherwise false</param> public LLAgent(LLUDPServer server, ThrottleRates rates, TokenBucket parentThrottle, uint circuitCode, UUID agentID, UUID sessionID, UUID secureSessionID, IPEndPoint remoteEndPoint, int defaultRTO, int maxRTO, bool isChildAgent) { m_id = agentID; m_udpServer = server; m_scene = m_udpServer.Scene; PacketArchive = new IncomingPacketHistoryCollection(200); NeedAcks = new UnackedPacketCollection(); PendingAcks = new LocklessQueue<uint>(); EventQueue = new LLEventQueue(); m_nextOnQueueEmpty = 1; m_defaultRTO = 1000 * 3; m_maxRTO = 1000 * 60; m_packetOutboxes = new LocklessQueue<OutgoingPacket>[THROTTLE_CATEGORY_COUNT]; m_nextPackets = new OutgoingPacket[THROTTLE_CATEGORY_COUNT]; m_interestList = new InterestList(this, 200); IsChildPresence = isChildAgent; m_localID = m_scene.CreateLocalID(); TextureEntry = new Primitive.TextureEntry(DEFAULT_AVATAR_TEXTURE); SessionID = sessionID; SecureSessionID = secureSessionID; RemoteEndPoint = remoteEndPoint; CircuitCode = circuitCode; if (defaultRTO != 0) m_defaultRTO = defaultRTO; if (maxRTO != 0) m_maxRTO = maxRTO; // Create a token bucket throttle for this client that has the scene token bucket as a parent m_throttle = new TokenBucket(parentThrottle, rates.ClientTotalLimit, rates.ClientTotal); // Create an array of token buckets for this clients different throttle categories m_throttleCategories = new TokenBucket[THROTTLE_CATEGORY_COUNT]; for (int i = 0; i < THROTTLE_CATEGORY_COUNT; i++) { ThrottleCategory type = (ThrottleCategory)i; // Initialize the packet outboxes, where packets sit while they are waiting for tokens m_packetOutboxes[i] = new LocklessQueue<OutgoingPacket>(); // Initialize the token buckets that control the throttling for each category m_throttleCategories[i] = new TokenBucket(m_throttle, rates.GetLimit(type), rates.GetRate(type)); } // Default the retransmission timeout to three seconds RTO = m_defaultRTO; // Initialize this to a sane value to prevent early disconnects TickLastPacketReceived = Util.TickCount(); IsConnected = true; }
/// <summary> /// Default constructor /// </summary> /// <param name="server">Reference to the UDP server this client is connected to</param> /// <param name="rates">Default throttling rates and maximum throttle limits</param> /// <param name="parentThrottle">Parent HTB (hierarchical token bucket) /// that the child throttles will be governed by</param> /// <param name="circuitCode">Circuit code for this connection</param> /// <param name="agentID">AgentID for the connected agent</param> /// <param name="sessionID">SessionID for the connected agent</param> /// <param name="secureSessionID">SecureSessionID for the connected agent</param> /// <param name="defaultRTO">Default retransmission timeout, in milliseconds</param> /// <param name="maxRTO">Maximum retransmission timeout, in milliseconds</param> /// <param name="remoteEndPoint">Remote endpoint for this connection</param> /// <param name="isChildAgent">True if this agent is currently simulated by /// another simulator, otherwise false</param> public LLAgent(LLUDPServer server, ThrottleRates rates, TokenBucket parentThrottle, uint circuitCode, UUID agentID, UUID sessionID, UUID secureSessionID, IPEndPoint remoteEndPoint, int defaultRTO, int maxRTO, bool isChildAgent) { m_id = agentID; m_udpServer = server; m_scene = m_udpServer.Scene; PacketArchive = new IncomingPacketHistoryCollection(200); NeedAcks = new UnackedPacketCollection(); PendingAcks = new LocklessQueue <uint>(); EventQueue = new LLEventQueue(); m_nextOnQueueEmpty = 1; m_defaultRTO = 1000 * 3; m_maxRTO = 1000 * 60; m_packetOutboxes = new LocklessQueue <OutgoingPacket> [THROTTLE_CATEGORY_COUNT]; m_nextPackets = new OutgoingPacket[THROTTLE_CATEGORY_COUNT]; m_interestList = new InterestList(this, 200); IsChildPresence = isChildAgent; m_localID = m_scene.CreateLocalID(); TextureEntry = new Primitive.TextureEntry(DEFAULT_AVATAR_TEXTURE); SessionID = sessionID; SecureSessionID = secureSessionID; RemoteEndPoint = remoteEndPoint; CircuitCode = circuitCode; if (defaultRTO != 0) { m_defaultRTO = defaultRTO; } if (maxRTO != 0) { m_maxRTO = maxRTO; } // Create a token bucket throttle for this client that has the scene token bucket as a parent m_throttle = new TokenBucket(parentThrottle, rates.ClientTotalLimit, rates.ClientTotal); // Create an array of token buckets for this clients different throttle categories m_throttleCategories = new TokenBucket[THROTTLE_CATEGORY_COUNT]; for (int i = 0; i < THROTTLE_CATEGORY_COUNT; i++) { ThrottleCategory type = (ThrottleCategory)i; // Initialize the packet outboxes, where packets sit while they are waiting for tokens m_packetOutboxes[i] = new LocklessQueue <OutgoingPacket>(); // Initialize the token buckets that control the throttling for each category m_throttleCategories[i] = new TokenBucket(m_throttle, rates.GetLimit(type), rates.GetRate(type)); } // Default the retransmission timeout to three seconds RTO = m_defaultRTO; // Initialize this to a sane value to prevent early disconnects TickLastPacketReceived = Util.TickCount(); IsConnected = true; }
protected void HandleClientKpi(string module, string[] cmd) { s_log.Debug("[CLIENTKPI] Showing Client KPI:"); // Getting Priority Queues Report int columnPadding = 2; int maxNameLength = 18; int maxRegionNameLength = 14; int maxTypeLength = 4; int totalInfoFieldsLength = maxNameLength + columnPadding + maxRegionNameLength + columnPadding + maxTypeLength + columnPadding; StringBuilder reportline = new StringBuilder(); bool firstClient = true; lock (m_scenes) { foreach (Scene scene in m_scenes.Values) { scene.ForEachClient( delegate(IClientAPI client) { if (client is LLClientView) { bool isChild = client.SceneAgent.IsChildAgent; string name = client.Name; string regionName = scene.RegionInfo.RegionName; reportline.Append("[PQUEUE] "); reportline.AppendFormat("AgentName:{0},RegionName:{1},isChild:{2},", name, regionName, isChild ? "Cd" : "Rt"); reportline.Append(((LLClientView)client).EntityUpdateQueue.ToString()); s_log.Debug(reportline); reportline.Length = 0; reportline.Append("[QUEUE] "); reportline.AppendFormat("AgentName:{0},RegionName:{1},isChild:{2},", name, regionName, isChild ? "Cd" : "Rt"); if (client is IStatsCollector) { IStatsCollector stats = (IStatsCollector)client; reportline.Append(stats.Report()); } s_log.Debug(reportline); reportline.Length = 0; LLClientView llClient = client as LLClientView; if (firstClient) { reportline.Append("[THROTTLE] SERVER_AGENT_RATES:"); ThrottleRates throttleRates = llClient.UDPServer.ThrottleRates; reportline.AppendFormat( "{0},{1},{2},{3},{4},{5},{6},{7}", (throttleRates.Total * 8) / 1000, (throttleRates.Resend * 8) / 1000, (throttleRates.Land * 8) / 1000, (throttleRates.Wind * 8) / 1000, (throttleRates.Cloud * 8) / 1000, (throttleRates.Task * 8) / 1000, (throttleRates.Texture * 8) / 1000, (throttleRates.Asset * 8) / 1000); s_log.Debug(reportline); reportline.Length = 0; firstClient = false; } LLUDPClient llUdpClient = llClient.UDPClient; ClientInfo ci = llUdpClient.GetClientInfo(); reportline.Append("[THROTTLE] "); reportline.AppendFormat("AgentName:{0},RegionName:{1},isChild:{2},", name, regionName, isChild ? "Cd" : "Rt"); reportline.AppendFormat( "{0},{1},{2},{3},{4},{5},{6},{7}", (ci.totalThrottle * 8) / 1000, (ci.resendThrottle * 8) / 1000, (ci.landThrottle * 8) / 1000, (ci.windThrottle * 8) / 1000, (ci.cloudThrottle * 8) / 1000, (ci.taskThrottle * 8) / 1000, (ci.textureThrottle * 8) / 1000, (ci.assetThrottle * 8) / 1000); s_log.Debug(reportline); reportline.Length = 0; } }); } } }