diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs | 75 |
1 files changed, 31 insertions, 44 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs index e54d326..80d4e1b 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs | |||
@@ -182,9 +182,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
182 | m_maxRTO = maxRTO; | 182 | m_maxRTO = maxRTO; |
183 | 183 | ||
184 | // Create a token bucket throttle for this client that has the scene token bucket as a parent | 184 | // Create a token bucket throttle for this client that has the scene token bucket as a parent |
185 | m_throttleClient = new AdaptiveTokenBucket(parentThrottle, rates.TotalLimit); | 185 | m_throttleClient = new AdaptiveTokenBucket(parentThrottle, rates.Total, rates.AdaptiveThrottlesEnabled); |
186 | // Create a token bucket throttle for the total categary with the client bucket as a throttle | 186 | // Create a token bucket throttle for the total categary with the client bucket as a throttle |
187 | m_throttleCategory = new TokenBucket(m_throttleClient, rates.TotalLimit); | 187 | m_throttleCategory = new TokenBucket(m_throttleClient, rates.Total); |
188 | // Create an array of token buckets for this clients different throttle categories | 188 | // Create an array of token buckets for this clients different throttle categories |
189 | m_throttleCategories = new TokenBucket[THROTTLE_CATEGORY_COUNT]; | 189 | m_throttleCategories = new TokenBucket[THROTTLE_CATEGORY_COUNT]; |
190 | 190 | ||
@@ -195,7 +195,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
195 | // Initialize the packet outboxes, where packets sit while they are waiting for tokens | 195 | // Initialize the packet outboxes, where packets sit while they are waiting for tokens |
196 | m_packetOutboxes[i] = new OpenSim.Framework.LocklessQueue<OutgoingPacket>(); | 196 | m_packetOutboxes[i] = new OpenSim.Framework.LocklessQueue<OutgoingPacket>(); |
197 | // Initialize the token buckets that control the throttling for each category | 197 | // Initialize the token buckets that control the throttling for each category |
198 | m_throttleCategories[i] = new TokenBucket(m_throttleCategory, rates.GetLimit(type)); | 198 | m_throttleCategories[i] = new TokenBucket(m_throttleCategory, rates.GetRate(type)); |
199 | } | 199 | } |
200 | 200 | ||
201 | // Default the retransmission timeout to three seconds | 201 | // Default the retransmission timeout to three seconds |
@@ -229,26 +229,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
229 | /// <returns>Information about the client connection</returns> | 229 | /// <returns>Information about the client connection</returns> |
230 | public ClientInfo GetClientInfo() | 230 | public ClientInfo GetClientInfo() |
231 | { | 231 | { |
232 | ///<mic> | ||
233 | TokenBucket tb; | ||
234 | |||
235 | tb = m_throttleClient.Parent; | ||
236 | m_log.WarnFormat("[TOKENS] {3}: Actual={0},Request={1},TotalRequest={2}",tb.DripRate,tb.RequestedDripRate,tb.TotalDripRequest,"ROOT"); | ||
237 | |||
238 | tb = m_throttleClient; | ||
239 | m_log.WarnFormat("[TOKENS] {3}: Actual={0},Request={1},TotalRequest={2}",tb.DripRate,tb.RequestedDripRate,tb.TotalDripRequest," CLIENT"); | ||
240 | |||
241 | tb = m_throttleCategory; | ||
242 | m_log.WarnFormat("[TOKENS] {3}: Actual={0},Request={1},TotalRequest={2}",tb.DripRate,tb.RequestedDripRate,tb.TotalDripRequest," CATEGORY"); | ||
243 | |||
244 | for (int i = 0; i < THROTTLE_CATEGORY_COUNT; i++) | ||
245 | { | ||
246 | tb = m_throttleCategories[i]; | ||
247 | m_log.WarnFormat("[TOKENS] {4} <{0}:{1}>: Actual={2},Requested={3}",AgentID,i,tb.DripRate,tb.RequestedDripRate," BUCKET"); | ||
248 | } | ||
249 | |||
250 | ///</mic> | ||
251 | |||
252 | // TODO: This data structure is wrong in so many ways. Locking and copying the entire lists | 232 | // TODO: This data structure is wrong in so many ways. Locking and copying the entire lists |
253 | // of pending and needed ACKs for every client every time some method wants information about | 233 | // of pending and needed ACKs for every client every time some method wants information about |
254 | // this connection is a recipe for poor performance | 234 | // this connection is a recipe for poor performance |
@@ -260,12 +240,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
260 | info.landThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Land].DripRate; | 240 | info.landThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Land].DripRate; |
261 | info.windThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Wind].DripRate; | 241 | info.windThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Wind].DripRate; |
262 | info.cloudThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Cloud].DripRate; | 242 | info.cloudThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Cloud].DripRate; |
263 | // info.taskThrottle = m_throttleCategories[(int)ThrottleOutPacketType.State].DripRate + m_throttleCategories[(int)ThrottleOutPacketType.Task].DripRate; | ||
264 | info.taskThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Task].DripRate; | 243 | info.taskThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Task].DripRate; |
265 | info.assetThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Asset].DripRate; | 244 | info.assetThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Asset].DripRate; |
266 | info.textureThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Texture].DripRate; | 245 | info.textureThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Texture].DripRate; |
267 | info.totalThrottle = info.resendThrottle + info.landThrottle + info.windThrottle + info.cloudThrottle + | 246 | info.totalThrottle = (int)m_throttleCategory.DripRate; |
268 | info.taskThrottle + info.assetThrottle + info.textureThrottle; | ||
269 | 247 | ||
270 | return info; | 248 | return info; |
271 | } | 249 | } |
@@ -352,8 +330,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
352 | int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); | 330 | int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); |
353 | // State is a subcategory of task that we allocate a percentage to | 331 | // State is a subcategory of task that we allocate a percentage to |
354 | int state = 0; | 332 | int state = 0; |
355 | // int state = (int)((float)task * STATE_TASK_PERCENTAGE); | ||
356 | // task -= state; | ||
357 | 333 | ||
358 | // Make sure none of the throttles are set below our packet MTU, | 334 | // Make sure none of the throttles are set below our packet MTU, |
359 | // otherwise a throttle could become permanently clogged | 335 | // otherwise a throttle could become permanently clogged |
@@ -364,19 +340,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
364 | task = Math.Max(task, LLUDPServer.MTU); | 340 | task = Math.Max(task, LLUDPServer.MTU); |
365 | texture = Math.Max(texture, LLUDPServer.MTU); | 341 | texture = Math.Max(texture, LLUDPServer.MTU); |
366 | asset = Math.Max(asset, LLUDPServer.MTU); | 342 | asset = Math.Max(asset, LLUDPServer.MTU); |
367 | state = Math.Max(state, LLUDPServer.MTU); | ||
368 | 343 | ||
369 | int total = resend + land + wind + cloud + task + texture + asset + state; | 344 | //int total = resend + land + wind + cloud + task + texture + asset; |
370 | 345 | //m_log.DebugFormat("[LLUDPCLIENT]: {0} is setting throttles. Resend={1}, Land={2}, Wind={3}, Cloud={4}, Task={5}, Texture={6}, Asset={7}, Total={8}", | |
371 | //m_log.DebugFormat("[LLUDPCLIENT]: {0} is setting throttles. Resend={1}, Land={2}, Wind={3}, Cloud={4}, Task={5}, Texture={6}, Asset={7}, State={8}, Total={9}", | 346 | // AgentID, resend, land, wind, cloud, task, texture, asset, total); |
372 | // AgentID, resend, land, wind, cloud, task, texture, asset, state, total); | ||
373 | 347 | ||
374 | // Update the token buckets with new throttle values | 348 | // Update the token buckets with new throttle values |
375 | TokenBucket bucket; | 349 | TokenBucket bucket; |
376 | 350 | ||
377 | bucket = m_throttleCategory; | ||
378 | bucket.RequestedDripRate = total; | ||
379 | |||
380 | bucket = m_throttleCategories[(int)ThrottleOutPacketType.Resend]; | 351 | bucket = m_throttleCategories[(int)ThrottleOutPacketType.Resend]; |
381 | bucket.RequestedDripRate = resend; | 352 | bucket.RequestedDripRate = resend; |
382 | 353 | ||
@@ -405,22 +376,38 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
405 | m_packedThrottles = null; | 376 | m_packedThrottles = null; |
406 | } | 377 | } |
407 | 378 | ||
408 | public byte[] GetThrottlesPacked() | 379 | public byte[] GetThrottlesPacked(float multiplier) |
409 | { | 380 | { |
410 | byte[] data = m_packedThrottles; | 381 | byte[] data = m_packedThrottles; |
411 | 382 | ||
412 | if (data == null) | 383 | if (data == null) |
413 | { | 384 | { |
385 | float rate; | ||
386 | |||
414 | data = new byte[7 * 4]; | 387 | data = new byte[7 * 4]; |
415 | int i = 0; | 388 | int i = 0; |
416 | 389 | ||
417 | Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Resend].RequestedDripRate), 0, data, i, 4); i += 4; | 390 | // multiply by 8 to convert bytes back to bits |
418 | Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Land].RequestedDripRate), 0, data, i, 4); i += 4; | 391 | rate = (float)m_throttleCategories[(int)ThrottleOutPacketType.Resend].RequestedDripRate * 8 * multiplier; |
419 | Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Wind].RequestedDripRate), 0, data, i, 4); i += 4; | 392 | Buffer.BlockCopy(Utils.FloatToBytes(rate), 0, data, i, 4); i += 4; |
420 | Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Cloud].RequestedDripRate), 0, data, i, 4); i += 4; | 393 | |
421 | Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Task].RequestedDripRate), 0, data, i, 4); i += 4; | 394 | rate = (float)m_throttleCategories[(int)ThrottleOutPacketType.Land].RequestedDripRate * 8 * multiplier; |
422 | Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Texture].RequestedDripRate), 0, data, i, 4); i += 4; | 395 | Buffer.BlockCopy(Utils.FloatToBytes(rate), 0, data, i, 4); i += 4; |
423 | Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Asset].RequestedDripRate), 0, data, i, 4); i += 4; | 396 | |
397 | rate = (float)m_throttleCategories[(int)ThrottleOutPacketType.Wind].RequestedDripRate * 8 * multiplier; | ||
398 | Buffer.BlockCopy(Utils.FloatToBytes(rate), 0, data, i, 4); i += 4; | ||
399 | |||
400 | rate = (float)m_throttleCategories[(int)ThrottleOutPacketType.Cloud].RequestedDripRate * 8 * multiplier; | ||
401 | Buffer.BlockCopy(Utils.FloatToBytes(rate), 0, data, i, 4); i += 4; | ||
402 | |||
403 | rate = (float)m_throttleCategories[(int)ThrottleOutPacketType.Task].RequestedDripRate * 8 * multiplier; | ||
404 | Buffer.BlockCopy(Utils.FloatToBytes(rate), 0, data, i, 4); i += 4; | ||
405 | |||
406 | rate = (float)m_throttleCategories[(int)ThrottleOutPacketType.Texture].RequestedDripRate * 8 * multiplier; | ||
407 | Buffer.BlockCopy(Utils.FloatToBytes(rate), 0, data, i, 4); i += 4; | ||
408 | |||
409 | rate = (float)m_throttleCategories[(int)ThrottleOutPacketType.Asset].RequestedDripRate * 8 * multiplier; | ||
410 | Buffer.BlockCopy(Utils.FloatToBytes(rate), 0, data, i, 4); i += 4; | ||
424 | 411 | ||
425 | m_packedThrottles = data; | 412 | m_packedThrottles = data; |
426 | } | 413 | } |