aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs51
1 files changed, 35 insertions, 16 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs b/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs
index d215595..c0cdff6 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs
@@ -392,13 +392,29 @@ 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;
398 public Int64 MinimumFlow
399 {
400 get { return m_minimumFlow; }
401 set
402 {
403 m_minimumFlow = value;
404 TargetDripRate = Math.Max(m_minimumFlow, TargetDripRate);
405 AdjustedDripRate = Math.Max(m_minimumFlow, AdjustedDripRate);
406 }
407 }
400 408
401 public AdaptiveTokenBucket(string identifier, TokenBucket parent, Int64 requestedDripRate, Int64 maxDripRate, bool enabled) 409 /// <summary>
410 /// Constructor for the AdaptiveTokenBucket class
411 /// <param name="identifier">Unique identifier for the client</param>
412 /// <param name="parent">Parent bucket in the hierarchy</param>
413 /// <param name="requestedDripRate"></param>
414 /// <param name="maxDripRate">The ceiling rate for adaptation</param>
415 /// <param name="minDripRate">The floor rate for adaptation</param>
416 /// </summary>
417 public AdaptiveTokenBucket(string identifier, TokenBucket parent, Int64 requestedDripRate, Int64 maxDripRate, Int64 minDripRate, bool enabled)
402 : base(identifier, parent, requestedDripRate, maxDripRate) 418 : base(identifier, parent, requestedDripRate, maxDripRate)
403 { 419 {
404 AdaptiveEnabled = enabled; 420 AdaptiveEnabled = enabled;
@@ -406,34 +422,37 @@ namespace OpenSim.Region.ClientStack.LindenUDP
406 if (AdaptiveEnabled) 422 if (AdaptiveEnabled)
407 { 423 {
408// m_log.DebugFormat("[TOKENBUCKET]: Adaptive throttle enabled"); 424// m_log.DebugFormat("[TOKENBUCKET]: Adaptive throttle enabled");
425 m_minimumFlow = minDripRate;
409 TargetDripRate = m_minimumFlow; 426 TargetDripRate = m_minimumFlow;
410 AdjustedDripRate = m_minimumFlow; 427 AdjustedDripRate = m_minimumFlow;
411 } 428 }
412 } 429 }
413 430
414 // <summary> 431 /// <summary>
415 // Reliable packets sent to the client for which we never received an ack adjust the drip rate down. 432 /// Reliable packets sent to the client for which we never received an ack adjust the drip rate down.
416 // </summary> 433 /// <param name="packets">Number of packets that expired without successful delivery</param>
417 public void ExpirePackets(Int32 count) 434 /// </summary>
435 public void ExpirePackets(Int32 packets)
418 { 436 {
419 if (AdaptiveEnabled) 437 if (AdaptiveEnabled)
420 { 438 {
421 if (DebugLevel > 0) 439 if (DebugLevel > 0)
422 m_log.WarnFormat( 440 m_log.WarnFormat(
423 "[ADAPTIVEBUCKET] drop {0} by {1} expired packets for {2}", 441 "[ADAPTIVEBUCKET] drop {0} by {1} expired packets for {2}",
424 AdjustedDripRate, count, Identifier); 442 AdjustedDripRate, packets, Identifier);
425 443
426 AdjustedDripRate = (Int64) (AdjustedDripRate / Math.Pow(2,count)); 444 AdjustedDripRate = (Int64) (AdjustedDripRate / Math.Pow(2,packets));
427 } 445 }
428 } 446 }
429 447
430 // <summary> 448 /// <summary>
431 // Reliable packets acked by the client adjust the drip rate up. 449 /// Reliable packets acked by the client adjust the drip rate up.
432 // </summary> 450 /// <param name="bytes">Number of bytes acknowledged</param>
433 public void AcknowledgePackets(Int32 count) 451 /// </summary>
452 public void AcknowledgePackets(Int32 bytes)
434 { 453 {
435 if (AdaptiveEnabled) 454 if (AdaptiveEnabled)
436 AdjustedDripRate = AdjustedDripRate + count; 455 AdjustedDripRate = AdjustedDripRate + bytes;
437 } 456 }
438 } 457 }
439} \ No newline at end of file 458} \ No newline at end of file