diff options
author | Diva Canto | 2014-12-30 20:05:33 -0800 |
---|---|---|
committer | Diva Canto | 2014-12-30 20:05:33 -0800 |
commit | 0af02efaed2e42f128f585b960550b0b8896c54f (patch) | |
tree | 886803e85dd278a62f9e42f3eca92d49bf785028 /OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs | |
parent | Add support for expansion of key values in nini config files. (diff) | |
parent | Merge branch 'mb-throttle-test' (diff) | |
download | opensim-SC_OLD-0af02efaed2e42f128f585b960550b0b8896c54f.zip opensim-SC_OLD-0af02efaed2e42f128f585b960550b0b8896c54f.tar.gz opensim-SC_OLD-0af02efaed2e42f128f585b960550b0b8896c54f.tar.bz2 opensim-SC_OLD-0af02efaed2e42f128f585b960550b0b8896c54f.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs | 59 |
1 files changed, 42 insertions, 17 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs b/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs index 4ca83ff..4616203 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs | |||
@@ -61,7 +61,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
61 | 61 | ||
62 | /// <summary> | 62 | /// <summary> |
63 | /// </summary> | 63 | /// </summary> |
64 | protected const Int32 m_minimumDripRate = 1400; | 64 | protected const Int32 m_minimumDripRate = LLUDPServer.MTU; |
65 | 65 | ||
66 | /// <summary>Time of the last drip, in system ticks</summary> | 66 | /// <summary>Time of the last drip, in system ticks</summary> |
67 | protected Int32 m_lastDrip; | 67 | protected Int32 m_lastDrip; |
@@ -392,13 +392,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
392 | } | 392 | } |
393 | 393 | ||
394 | /// <summary> | 394 | /// <summary> |
395 | /// The minimum rate for flow control. Minimum drip rate is one | 395 | /// The minimum rate for adaptive flow control. |
396 | /// packet per second. Open the throttle to 15 packets per second | ||
397 | /// or about 160kbps. | ||
398 | /// </summary> | 396 | /// </summary> |
399 | protected const Int64 m_minimumFlow = m_minimumDripRate * 15; | 397 | protected Int64 m_minimumFlow = 32000; |
400 | 398 | ||
401 | public AdaptiveTokenBucket(string identifier, TokenBucket parent, Int64 requestedDripRate, Int64 maxDripRate, bool enabled) | 399 | /// <summary> |
400 | /// Constructor for the AdaptiveTokenBucket class | ||
401 | /// <param name="identifier">Unique identifier for the client</param> | ||
402 | /// <param name="parent">Parent bucket in the hierarchy</param> | ||
403 | /// <param name="requestedDripRate"></param> | ||
404 | /// <param name="maxDripRate">The ceiling rate for adaptation</param> | ||
405 | /// <param name="minDripRate">The floor rate for adaptation</param> | ||
406 | /// </summary> | ||
407 | public AdaptiveTokenBucket(string identifier, TokenBucket parent, Int64 requestedDripRate, Int64 maxDripRate, Int64 minDripRate, bool enabled) | ||
402 | : base(identifier, parent, requestedDripRate, maxDripRate) | 408 | : base(identifier, parent, requestedDripRate, maxDripRate) |
403 | { | 409 | { |
404 | AdaptiveEnabled = enabled; | 410 | AdaptiveEnabled = enabled; |
@@ -406,34 +412,53 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
406 | if (AdaptiveEnabled) | 412 | if (AdaptiveEnabled) |
407 | { | 413 | { |
408 | // m_log.DebugFormat("[TOKENBUCKET]: Adaptive throttle enabled"); | 414 | // m_log.DebugFormat("[TOKENBUCKET]: Adaptive throttle enabled"); |
415 | m_minimumFlow = minDripRate; | ||
409 | TargetDripRate = m_minimumFlow; | 416 | TargetDripRate = m_minimumFlow; |
410 | AdjustedDripRate = m_minimumFlow; | 417 | AdjustedDripRate = m_minimumFlow; |
411 | } | 418 | } |
412 | } | 419 | } |
413 | 420 | ||
414 | // <summary> | 421 | /// <summary> |
415 | // Reliable packets sent to the client for which we never received an ack adjust the drip rate down. | 422 | /// Reliable packets sent to the client for which we never received an ack adjust the drip rate down. |
416 | // </summary> | 423 | /// <param name="packets">Number of packets that expired without successful delivery</param> |
417 | public void ExpirePackets(Int32 count) | 424 | /// </summary> |
425 | public void ExpirePackets(Int32 packets) | ||
418 | { | 426 | { |
419 | if (AdaptiveEnabled) | 427 | if (AdaptiveEnabled) |
420 | { | 428 | { |
421 | if (DebugLevel > 0) | 429 | if (DebugLevel > 0) |
422 | m_log.WarnFormat( | 430 | m_log.WarnFormat( |
423 | "[ADAPTIVEBUCKET] drop {0} by {1} expired packets for {2}", | 431 | "[ADAPTIVEBUCKET] drop {0} by {1} expired packets for {2}", |
424 | AdjustedDripRate, count, Identifier); | 432 | AdjustedDripRate, packets, Identifier); |
425 | 433 | ||
426 | AdjustedDripRate = (Int64) (AdjustedDripRate / Math.Pow(2,count)); | 434 | // AdjustedDripRate = (Int64) (AdjustedDripRate / Math.Pow(2,packets)); |
435 | |||
436 | // Compute the fallback solely on the rate allocated beyond the minimum, this | ||
437 | // should smooth out the fallback to the minimum rate | ||
438 | AdjustedDripRate = m_minimumFlow + (Int64) ((AdjustedDripRate - m_minimumFlow) / Math.Pow(2, packets)); | ||
427 | } | 439 | } |
428 | } | 440 | } |
429 | 441 | ||
430 | // <summary> | 442 | /// <summary> |
431 | // Reliable packets acked by the client adjust the drip rate up. | 443 | /// Reliable packets acked by the client adjust the drip rate up. |
432 | // </summary> | 444 | /// <param name="packets">Number of packets successfully acknowledged</param> |
433 | public void AcknowledgePackets(Int32 count) | 445 | /// </summary> |
446 | public void AcknowledgePackets(Int32 packets) | ||
434 | { | 447 | { |
435 | if (AdaptiveEnabled) | 448 | if (AdaptiveEnabled) |
436 | AdjustedDripRate = AdjustedDripRate + count; | 449 | AdjustedDripRate = AdjustedDripRate + packets * LLUDPServer.MTU; |
450 | } | ||
451 | |||
452 | /// <summary> | ||
453 | /// Adjust the minimum flow level for the adaptive throttle, this will drop adjusted | ||
454 | /// throttles back to the minimum levels | ||
455 | /// <param>minDripRate--the new minimum flow</param> | ||
456 | /// </summary> | ||
457 | public void ResetMinimumAdaptiveFlow(Int64 minDripRate) | ||
458 | { | ||
459 | m_minimumFlow = minDripRate; | ||
460 | TargetDripRate = m_minimumFlow; | ||
461 | AdjustedDripRate = m_minimumFlow; | ||
437 | } | 462 | } |
438 | } | 463 | } |
439 | } \ No newline at end of file | 464 | } \ No newline at end of file |