public void TestClientThrottlePerClientAndRegionLimited() { TestHelpers.InMethod(); //TestHelpers.EnableLogging(); int resendBytes = 4000; int landBytes = 6000; int windBytes = 8000; int cloudBytes = 10000; int taskBytes = 12000; int textureBytes = 14000; int assetBytes = 16000; // current total 70000 int totalBytes = resendBytes + landBytes + windBytes + cloudBytes + taskBytes + textureBytes + assetBytes; Scene scene = new SceneHelpers().SetupScene(); TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(scene); udpServer.ThrottleRates.Total = (int)(totalBytes * 1.1); udpServer.Throttle.RequestedDripRate = (int)(totalBytes * 1.5); ScenePresence sp1 = ClientStackHelpers.AddChildClient( scene, udpServer, TestHelpers.ParseTail(0x1), TestHelpers.ParseTail(0x2), 123456); LLUDPClient udpClient1 = ((LLClientView)sp1.ControllingClient).UDPClient; udpClient1.ThrottleDebugLevel = 1; SetThrottles( udpClient1, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes); AssertThrottles( udpClient1, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes, totalBytes, 0, totalBytes * 1.1); // Now add another client ScenePresence sp2 = ClientStackHelpers.AddChildClient( scene, udpServer, TestHelpers.ParseTail(0x10), TestHelpers.ParseTail(0x20), 123457); LLUDPClient udpClient2 = ((LLClientView)sp2.ControllingClient).UDPClient; udpClient2.ThrottleDebugLevel = 1; SetThrottles( udpClient2, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes); AssertThrottles( udpClient1, resendBytes * 0.75, landBytes * 0.75, windBytes * 0.75, cloudBytes * 0.75, taskBytes * 0.75, textureBytes * 0.75, assetBytes * 0.75, totalBytes * 0.75, 0, totalBytes * 1.1); AssertThrottles( udpClient2, resendBytes * 0.75, landBytes * 0.75, windBytes * 0.75, cloudBytes * 0.75, taskBytes * 0.75, textureBytes * 0.75, assetBytes * 0.75, totalBytes * 0.75, 0, totalBytes * 1.1); }
public void TestSingleClientThrottleRegionLimited() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); int resendBytes = 6000; int landBytes = 8000; int windBytes = 10000; int cloudBytes = 12000; int taskBytes = 14000; int textureBytes = 16000; int assetBytes = 18000; int totalBytes = (int)((resendBytes + landBytes + windBytes + cloudBytes + taskBytes + textureBytes + assetBytes) / 2); Scene scene = new SceneHelpers().SetupScene(); TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(scene); udpServer.Throttle.RequestedDripRate = totalBytes; ScenePresence sp1 = ClientStackHelpers.AddChildClient( scene, udpServer, TestHelpers.ParseTail(0x1), TestHelpers.ParseTail(0x2), 123456); LLUDPClient udpClient1 = ((LLClientView)sp1.ControllingClient).UDPClient; SetThrottles( udpClient1, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes); AssertThrottles( udpClient1, resendBytes / 2, landBytes / 2, windBytes / 2, cloudBytes / 2, taskBytes / 2, textureBytes / 2, assetBytes / 2, totalBytes, 0, 0); // Test: Now add another client ScenePresence sp2 = ClientStackHelpers.AddChildClient( scene, udpServer, TestHelpers.ParseTail(0x10), TestHelpers.ParseTail(0x20), 123457); LLUDPClient udpClient2 = ((LLClientView)sp2.ControllingClient).UDPClient; // udpClient.ThrottleDebugLevel = 1; SetThrottles( udpClient2, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes); AssertThrottles( udpClient1, resendBytes / 4, landBytes / 4, windBytes / 4, cloudBytes / 4, taskBytes / 4, textureBytes / 4, assetBytes / 4, totalBytes / 2, 0, 0); AssertThrottles( udpClient2, resendBytes / 4, landBytes / 4, windBytes / 4, cloudBytes / 4, taskBytes / 4, textureBytes / 4, assetBytes / 4, totalBytes / 2, 0, 0); }
private void SetThrottles( LLUDPClient udpClient, int resendBytes, int landBytes, int windBytes, int cloudBytes, int taskBytes, int textureBytes, int assetBytes) { byte[] throttles = new byte[28]; Array.Copy(BitConverter.GetBytes((float)resendBytes * 8), 0, throttles, 0, 4); Array.Copy(BitConverter.GetBytes((float)landBytes * 8), 0, throttles, 4, 4); Array.Copy(BitConverter.GetBytes((float)windBytes * 8), 0, throttles, 8, 4); Array.Copy(BitConverter.GetBytes((float)cloudBytes * 8), 0, throttles, 12, 4); Array.Copy(BitConverter.GetBytes((float)taskBytes * 8), 0, throttles, 16, 4); Array.Copy(BitConverter.GetBytes((float)textureBytes * 8), 0, throttles, 20, 4); Array.Copy(BitConverter.GetBytes((float)assetBytes * 8), 0, throttles, 24, 4); udpClient.SetThrottles(throttles); }
private void AssertThrottles( LLUDPClient udpClient, double resendBytes, double landBytes, double windBytes, double cloudBytes, double taskBytes, double textureBytes, double assetBytes, double totalBytes, double targetBytes, double maxBytes) { ClientInfo ci = udpClient.GetClientInfo(); // Console.WriteLine( // "Resend={0}, Land={1}, Wind={2}, Cloud={3}, Task={4}, Texture={5}, Asset={6}, TOTAL = {7}", // ci.resendThrottle, ci.landThrottle, ci.windThrottle, ci.cloudThrottle, ci.taskThrottle, ci.textureThrottle, ci.assetThrottle, ci.totalThrottle); Assert.AreEqual((int)resendBytes, ci.resendThrottle, "Resend"); Assert.AreEqual((int)landBytes, ci.landThrottle, "Land"); Assert.AreEqual((int)windBytes, ci.windThrottle, "Wind"); Assert.AreEqual((int)cloudBytes, ci.cloudThrottle, "Cloud"); Assert.AreEqual((int)taskBytes, ci.taskThrottle, "Task"); Assert.AreEqual((int)textureBytes, ci.textureThrottle, "Texture"); Assert.AreEqual((int)assetBytes, ci.assetThrottle, "Asset"); Assert.AreEqual((int)totalBytes, ci.totalThrottle, "Total"); Assert.AreEqual((int)targetBytes, ci.targetThrottle, "Target"); Assert.AreEqual((int)maxBytes, ci.maxThrottle, "Max"); }
public void TestClientThrottlePerClientLimited() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); int resendBytes = 4000; int landBytes = 6000; int windBytes = 8000; int cloudBytes = 10000; int taskBytes = 12000; int textureBytes = 14000; int assetBytes = 16000; int totalBytes = (int)((resendBytes + landBytes + windBytes + cloudBytes + taskBytes + textureBytes + assetBytes) / 2); Scene scene = new SceneHelpers().SetupScene(); TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(scene); udpServer.ThrottleRates.Total = totalBytes; ScenePresence sp = ClientStackHelpers.AddChildClient( scene, udpServer, TestHelpers.ParseTail(0x1), TestHelpers.ParseTail(0x2), 123456); LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient; // udpClient.ThrottleDebugLevel = 1; SetThrottles( udpClient, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes); AssertThrottles( udpClient, resendBytes / 2, landBytes / 2, windBytes / 2, cloudBytes / 2, taskBytes / 2, textureBytes / 2, assetBytes / 2, totalBytes, 0, totalBytes); }
public void TestClientThrottleSetNoLimit() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); Scene scene = new SceneHelpers().SetupScene(); TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(scene); ScenePresence sp = ClientStackHelpers.AddChildClient( scene, udpServer, TestHelpers.ParseTail(0x1), TestHelpers.ParseTail(0x2), 123456); LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient; udpServer.Throttle.DebugLevel = 1; udpClient.ThrottleDebugLevel = 1; int resendBytes = 1000; int landBytes = 2000; int windBytes = 3000; int cloudBytes = 4000; int taskBytes = 5000; int textureBytes = 6000; int assetBytes = 7000; SetThrottles( udpClient, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes); // We expect this to be lower because of the minimum bound set by MTU int totalBytes = LLUDPServer.MTU + landBytes + windBytes + cloudBytes + taskBytes + textureBytes + assetBytes; AssertThrottles( udpClient, LLUDPServer.MTU, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes, totalBytes, 0, 0); }
/// <summary> /// Show throttle data /// </summary> /// <param name="showParams"></param> /// <returns></returns> protected string GetThrottlesReport(string[] showParams) { bool showChildren = false; string pname = ""; if (showParams.Length > 2 && showParams[2] == "full") { showChildren = true; } else if (showParams.Length > 3) { pname = showParams[2] + " " + showParams[3]; } StringBuilder report = new StringBuilder(); int columnPadding = 2; int maxNameLength = 18; int maxRegionNameLength = 14; int maxTypeLength = 4; int totalInfoFieldsLength = maxNameLength + columnPadding + maxRegionNameLength + columnPadding + maxTypeLength + columnPadding; report.Append(GetColumnEntry("User", maxNameLength, columnPadding)); report.Append(GetColumnEntry("Region", maxRegionNameLength, columnPadding)); report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding)); report.AppendFormat( "{0,8} {1,8} {2,7} {3,8} {4,7} {5,7} {6,7} {7,7} {8,9} {9,7}\n", "Max", "Target", "Actual", "Resend", "Land", "Wind", "Cloud", "Task", "Texture", "Asset"); report.AppendFormat("{0,-" + totalInfoFieldsLength + "}", ""); report.AppendFormat( "{0,8} {1,8} {2,7} {3,8} {4,7} {5,7} {6,7} {7,7} {8,9} {9,7}\n", "kb/s", "kb/s", "kb/s", "kb/s", "kb/s", "kb/s", "kb/s", "kb/s", "kb/s", "kb/s"); report.AppendLine(); lock (m_scenes) { foreach (Scene scene in m_scenes.Values) { scene.ForEachClient( delegate(IClientAPI client) { if (client is LLClientView) { LLClientView llClient = client as LLClientView; bool isChild = client.SceneAgent.IsChildAgent; if (isChild && !showChildren) { return; } string name = client.Name; if (pname != "" && name != pname) { return; } string regionName = scene.RegionInfo.RegionName; LLUDPClient llUdpClient = llClient.UDPClient; ClientInfo ci = llUdpClient.GetClientInfo(); report.Append(GetColumnEntry(name, maxNameLength, columnPadding)); report.Append(GetColumnEntry(regionName, maxRegionNameLength, columnPadding)); report.Append(GetColumnEntry(isChild ? "Cd" : "Rt", maxTypeLength, columnPadding)); report.AppendFormat( "{0,8} {1,8} {2,7} {3,8} {4,7} {5,7} {6,7} {7,7} {8,9} {9,7}\n", ci.maxThrottle > 0 ? ((ci.maxThrottle * 8) / 1000).ToString() : "-", llUdpClient.FlowThrottle.AdaptiveEnabled ? ((ci.targetThrottle * 8) / 1000).ToString() : (llUdpClient.FlowThrottle.TotalDripRequest * 8 / 1000).ToString(), (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); } }); } } return(report.ToString()); }
public override void SendPacket( LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting, UnackedPacketMethod method) { PacketsSent.Add(packet); }
/// <summary> /// Show throttle data /// </summary> /// <param name="showParams"></param> /// <returns></returns> protected string GetThrottlesReport(string[] showParams) { bool showChildren = false; if (showParams.Length > 2 && showParams[2] == "full") { showChildren = true; } StringBuilder report = new StringBuilder(); int columnPadding = 2; int maxNameLength = 18; int maxRegionNameLength = 14; int maxTypeLength = 4; int totalInfoFieldsLength = maxNameLength + columnPadding + maxRegionNameLength + columnPadding + maxTypeLength + columnPadding; report.Append(GetColumnEntry("User", maxNameLength, columnPadding)); report.Append(GetColumnEntry("Region", maxRegionNameLength, columnPadding)); report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding)); report.AppendFormat( "{0,7} {1,8} {2,7} {3,7} {4,7} {5,7} {6,9} {7,7}\n", "Total", "Resend", "Land", "Wind", "Cloud", "Task", "Texture", "Asset"); report.AppendFormat("{0,-" + totalInfoFieldsLength + "}", ""); report.AppendFormat( "{0,7} {1,8} {2,7} {3,7} {4,7} {5,7} {6,9} {7,7}", "kb/s", "kb/s", "kb/s", "kb/s", "kb/s", "kb/s", "kb/s", "kb/s"); report.AppendLine(); bool firstClient = true; lock (m_scenes) { foreach (Scene scene in m_scenes.Values) { scene.ForEachClient( delegate(IClientAPI client) { if (client is LLClientView) { LLClientView llClient = client as LLClientView; if (firstClient) { report.AppendLine(GetServerThrottlesReport(llClient.UDPServer)); firstClient = false; } bool isChild = scene.PresenceChildStatus(client.AgentId); if (isChild && !showChildren) { return; } string name = client.Name; string regionName = scene.RegionInfo.RegionName; LLUDPClient llUdpClient = llClient.UDPClient; ClientInfo ci = llUdpClient.GetClientInfo(); report.Append(GetColumnEntry(name, maxNameLength, columnPadding)); report.Append(GetColumnEntry(regionName, maxRegionNameLength, columnPadding)); report.Append(GetColumnEntry(isChild ? "Cd" : "Rt", maxTypeLength, columnPadding)); report.AppendFormat( "{0,7} {1,8} {2,7} {3,7} {4,7} {5,7} {6,9} {7,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); report.AppendLine(); } }); } } return(report.ToString()); }
public void TestClientThrottleAdaptiveNoLimit() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); Scene scene = new SceneHelpers().SetupScene(); IniConfigSource ics = new IniConfigSource(); IConfig config = ics.AddConfig("ClientStack.LindenUDP"); config.Set("enable_adaptive_throttles", true); config.Set("adaptive_throttle_min_bps", 32000); TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(scene, ics); ScenePresence sp = ClientStackHelpers.AddChildClient( scene, udpServer, TestHelpers.ParseTail(0x1), TestHelpers.ParseTail(0x2), 123456); LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient; udpServer.Throttle.DebugLevel = 1; udpClient.ThrottleDebugLevel = 1; // Total is 275000 int resendBytes = 5000; // this is set low to test the minimum throttle override int landBytes = 20000; int windBytes = 30000; int cloudBytes = 40000; int taskBytes = 50000; int textureBytes = 60000; int assetBytes = 70000; int totalBytes = resendBytes + landBytes + windBytes + cloudBytes + taskBytes + textureBytes + assetBytes; SetThrottles( udpClient, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes); // Ratio of current adaptive drip rate to requested bytes, minimum rate is 32000 double commitRatio = 32000.0 / totalBytes; AssertThrottles( udpClient, LLUDPServer.MTU, landBytes * commitRatio, windBytes * commitRatio, cloudBytes * commitRatio, taskBytes * commitRatio, textureBytes * commitRatio, assetBytes * commitRatio, udpClient.FlowThrottle.AdjustedDripRate, totalBytes, 0); // Test an increase in target throttle, ack of 20 packets adds 20 * LLUDPServer.MTU bytes // to the throttle, recompute commitratio from those numbers udpClient.FlowThrottle.AcknowledgePackets(20); commitRatio = (32000.0 + 20.0 * LLUDPServer.MTU) / totalBytes; AssertThrottles( udpClient, LLUDPServer.MTU, landBytes * commitRatio, windBytes * commitRatio, cloudBytes * commitRatio, taskBytes * commitRatio, textureBytes * commitRatio, assetBytes * commitRatio, udpClient.FlowThrottle.AdjustedDripRate, totalBytes, 0); // Test a decrease in target throttle, adaptive throttle should cut the rate by 50% with a floor // set by the minimum adaptive rate udpClient.FlowThrottle.ExpirePackets(1); commitRatio = (32000.0 + (20.0 * LLUDPServer.MTU) / Math.Pow(2, 1)) / totalBytes; AssertThrottles( udpClient, LLUDPServer.MTU, landBytes * commitRatio, windBytes * commitRatio, cloudBytes * commitRatio, taskBytes * commitRatio, textureBytes * commitRatio, assetBytes * commitRatio, udpClient.FlowThrottle.AdjustedDripRate, totalBytes, 0); }
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; } }); } } }