diff options
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 7 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs | 58 |
2 files changed, 64 insertions, 1 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 8ca0b1f..610067e 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | |||
@@ -251,7 +251,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
251 | /// </summary> | 251 | /// </summary> |
252 | public long MaxTotalDripRate { get { return Throttle.RequestedDripRate; } } | 252 | public long MaxTotalDripRate { get { return Throttle.RequestedDripRate; } } |
253 | 253 | ||
254 | /// <summary>Bandwidth throttle rates for this UDP server</summary> | 254 | /// <summary>Per client throttle rates enforced by this server</summary> |
255 | /// <remarks> | ||
256 | /// If the total rate is non-zero, then this is the maximum total throttle setting that any client can ever have. | ||
257 | /// The other rates (resend, asset, etc.) are the defaults for a new client and can be changed (and usually | ||
258 | /// do get changed immediately). They do not need to sum to the total. | ||
259 | /// </remarks> | ||
255 | public ThrottleRates ThrottleRates { get; private set; } | 260 | public ThrottleRates ThrottleRates { get; private set; } |
256 | 261 | ||
257 | /// <summary>Manages authentication for agent circuits</summary> | 262 | /// <summary>Manages authentication for agent circuits</summary> |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs index 31ea328..d7cbaba 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs | |||
@@ -102,5 +102,63 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
102 | Assert.AreEqual(assetBits / 8, ci.assetThrottle); | 102 | Assert.AreEqual(assetBits / 8, ci.assetThrottle); |
103 | Assert.AreEqual(totalBits / 8, ci.totalThrottle); | 103 | Assert.AreEqual(totalBits / 8, ci.totalThrottle); |
104 | } | 104 | } |
105 | |||
106 | /// <summary> | ||
107 | /// Test throttle setttings where max client throttle has been limited server side. | ||
108 | /// </summary> | ||
109 | [Test] | ||
110 | public void TestClientThrottleLimited() | ||
111 | { | ||
112 | TestHelpers.InMethod(); | ||
113 | // TestHelpers.EnableLogging(); | ||
114 | |||
115 | float resendBytes = 4000; | ||
116 | float landBytes = 6000; | ||
117 | float windBytes = 8000; | ||
118 | float cloudBytes = 10000; | ||
119 | float taskBytes = 12000; | ||
120 | float textureBytes = 14000; | ||
121 | float assetBytes = 16000; | ||
122 | int totalBytes | ||
123 | = (int)((resendBytes + landBytes + windBytes + cloudBytes + taskBytes + textureBytes + assetBytes) / 2); | ||
124 | |||
125 | Scene scene = new SceneHelpers().SetupScene(); | ||
126 | TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(scene); | ||
127 | udpServer.ThrottleRates.Total = totalBytes; | ||
128 | |||
129 | ScenePresence sp | ||
130 | = ClientStackHelpers.AddChildClient( | ||
131 | scene, udpServer, TestHelpers.ParseTail(0x1), TestHelpers.ParseTail(0x2), 123456); | ||
132 | |||
133 | LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient; | ||
134 | // udpClient.ThrottleDebugLevel = 1; | ||
135 | |||
136 | byte[] throttles = new byte[28]; | ||
137 | |||
138 | Array.Copy(BitConverter.GetBytes(resendBytes * 8), 0, throttles, 0, 4); | ||
139 | Array.Copy(BitConverter.GetBytes(landBytes * 8), 0, throttles, 4, 4); | ||
140 | Array.Copy(BitConverter.GetBytes(windBytes * 8), 0, throttles, 8, 4); | ||
141 | Array.Copy(BitConverter.GetBytes(cloudBytes * 8), 0, throttles, 12, 4); | ||
142 | Array.Copy(BitConverter.GetBytes(taskBytes * 8), 0, throttles, 16, 4); | ||
143 | Array.Copy(BitConverter.GetBytes(textureBytes * 8), 0, throttles, 20, 4); | ||
144 | Array.Copy(BitConverter.GetBytes(assetBytes * 8), 0, throttles, 24, 4); | ||
145 | |||
146 | udpClient.SetThrottles(throttles); | ||
147 | ClientInfo ci = udpClient.GetClientInfo(); | ||
148 | |||
149 | // Console.WriteLine( | ||
150 | // "Resend={0}, Land={1}, Wind={2}, Cloud={3}, Task={4}, Texture={5}, Asset={6}, TOTAL = {7}", | ||
151 | // ci.resendThrottle, ci.landThrottle, ci.windThrottle, ci.cloudThrottle, ci.taskThrottle, ci.textureThrottle, ci.assetThrottle, ci.totalThrottle); | ||
152 | |||
153 | // We expect this to be lower because of the minimum bound set by MTU | ||
154 | Assert.AreEqual(resendBytes / 2, ci.resendThrottle); | ||
155 | Assert.AreEqual(landBytes / 2, ci.landThrottle); | ||
156 | Assert.AreEqual(windBytes / 2, ci.windThrottle); | ||
157 | Assert.AreEqual(cloudBytes / 2, ci.cloudThrottle); | ||
158 | Assert.AreEqual(taskBytes / 2, ci.taskThrottle); | ||
159 | Assert.AreEqual(textureBytes / 2, ci.textureThrottle); | ||
160 | Assert.AreEqual(assetBytes / 2, ci.assetThrottle); | ||
161 | Assert.AreEqual(totalBytes, ci.totalThrottle); | ||
162 | } | ||
105 | } | 163 | } |
106 | } \ No newline at end of file | 164 | } \ No newline at end of file |