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.cs52
1 files changed, 26 insertions, 26 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs b/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs
index cac57b2..1daf091 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs
@@ -44,24 +44,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 private static Int32 m_counter = 0; 46 private static Int32 m_counter = 0;
47 47
48// private Int32 m_identifier; 48// private Int32 m_identifier;
49 49
50 protected const float m_timeScale = 1e-3f; 50 protected const float m_timeScale = 1e-3f;
51 51
52 /// <summary> 52 /// <summary>
53 /// This is the number of m_minimumDripRate bytes 53 /// This is the number of m_minimumDripRate bytes
54 /// allowed in a burst 54 /// allowed in a burst
55 /// roughtly, with this settings, the maximum time system will take 55 /// roughtly, with this settings, the maximum time system will take
56 /// to recheck a bucket in ms 56 /// to recheck a bucket in ms
57 /// 57 ///
58 /// </summary> 58 /// </summary>
59 protected const float m_quantumsPerBurst = 5; 59 protected const float m_quantumsPerBurst = 5;
60 60
61 /// <summary> 61 /// <summary>
62 /// </summary> 62 /// </summary>
63 protected const float m_minimumDripRate = 1500; 63 protected const float m_minimumDripRate = 1500;
64 64
65 /// <summary>Time of the last drip</summary> 65 /// <summary>Time of the last drip</summary>
66 protected double m_lastDrip; 66 protected double m_lastDrip;
67 67
@@ -76,7 +76,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
76 /// </summary> 76 /// </summary>
77 77
78 protected Dictionary<TokenBucket, float> m_children = new Dictionary<TokenBucket, float>(); 78 protected Dictionary<TokenBucket, float> m_children = new Dictionary<TokenBucket, float>();
79 79
80#region Properties 80#region Properties
81 81
82 /// <summary> 82 /// <summary>
@@ -92,7 +92,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
92 } 92 }
93 /// <summary> 93 /// <summary>
94 /// This is the maximum number 94 /// This is the maximum number
95 /// of tokens that can accumulate in the bucket at any one time. This 95 /// of tokens that can accumulate in the bucket at any one time. This
96 /// also sets the total request for leaf nodes 96 /// also sets the total request for leaf nodes
97 /// </summary> 97 /// </summary>
98 protected float m_burst; 98 protected float m_burst;
@@ -127,14 +127,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
127 return (float)rate; 127 return (float)rate;
128 } 128 }
129 } 129 }
130 130
131 /// <summary> 131 /// <summary>
132 /// The requested drip rate for this particular bucket. 132 /// The requested drip rate for this particular bucket.
133 /// </summary> 133 /// </summary>
134 /// <remarks> 134 /// <remarks>
135 /// 0 then TotalDripRequest is used instead. 135 /// 0 then TotalDripRequest is used instead.
136 /// Can never be above MaxDripRate. 136 /// Can never be above MaxDripRate.
137 /// Tokens are added to the bucket at any time 137 /// Tokens are added to the bucket at any time
138 /// <seealso cref="RemoveTokens"/> is called, at the granularity of 138 /// <seealso cref="RemoveTokens"/> is called, at the granularity of
139 /// the system tick interval (typically around 15-22ms)</remarks> 139 /// the system tick interval (typically around 15-22ms)</remarks>
140 protected float m_dripRate; 140 protected float m_dripRate;
@@ -170,12 +170,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
170 /// The current total of the requested maximum burst rates of children buckets. 170 /// The current total of the requested maximum burst rates of children buckets.
171 /// </summary> 171 /// </summary>
172 protected float m_totalDripRequest; 172 protected float m_totalDripRequest;
173 public float TotalDripRequest 173 public float TotalDripRequest
174 { 174 {
175 get { return m_totalDripRequest; } 175 get { return m_totalDripRequest; }
176 set { m_totalDripRequest = value; } 176 set { m_totalDripRequest = value; }
177 } 177 }
178 178
179#endregion Properties 179#endregion Properties
180 180
181#region Constructor 181#region Constructor
@@ -191,7 +191,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
191 /// zero if this bucket has no maximum capacity</param> 191 /// zero if this bucket has no maximum capacity</param>
192 /// <param name="dripRate">Rate that the bucket fills, in bytes per 192 /// <param name="dripRate">Rate that the bucket fills, in bytes per
193 /// second. If zero, the bucket always remains full</param> 193 /// second. If zero, the bucket always remains full</param>
194 public TokenBucket(TokenBucket parent, float dripRate, float MaxBurst) 194 public TokenBucket(TokenBucket parent, float dripRate, float MaxBurst)
195 { 195 {
196 m_counter++; 196 m_counter++;
197 197
@@ -240,7 +240,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
240 foreach (KeyValuePair<TokenBucket, float> cref in m_children) 240 foreach (KeyValuePair<TokenBucket, float> cref in m_children)
241 m_totalDripRequest += cref.Value; 241 m_totalDripRequest += cref.Value;
242 } 242 }
243 243
244 // Pass the new values up to the parent 244 // Pass the new values up to the parent
245 if (m_parent != null) 245 if (m_parent != null)
246 m_parent.RegisterRequest(this, Math.Min(RequestedDripRate, TotalDripRequest)); 246 m_parent.RegisterRequest(this, Math.Min(RequestedDripRate, TotalDripRequest));
@@ -265,7 +265,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
265 if (Parent != null) 265 if (Parent != null)
266 Parent.RegisterRequest(this,Math.Min(RequestedDripRate, TotalDripRequest)); 266 Parent.RegisterRequest(this,Math.Min(RequestedDripRate, TotalDripRequest));
267 } 267 }
268 268
269 /// <summary> 269 /// <summary>
270 /// Remove a given number of tokens from the bucket 270 /// Remove a given number of tokens from the bucket
271 /// </summary> 271 /// </summary>
@@ -302,7 +302,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
302 302
303 /// <summary> 303 /// <summary>
304 /// Add tokens to the bucket over time. The number of tokens added each 304 /// Add tokens to the bucket over time. The number of tokens added each
305 /// call depends on the length of time that has passed since the last 305 /// call depends on the length of time that has passed since the last
306 /// call to Drip 306 /// call to Drip
307 /// </summary> 307 /// </summary>
308 /// <returns>True if tokens were added to the bucket, otherwise false</returns> 308 /// <returns>True if tokens were added to the bucket, otherwise false</returns>
@@ -315,7 +315,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
315 m_log.WarnFormat("[TOKENBUCKET] something odd is happening and drip rate is 0 for {0}", m_counter); 315 m_log.WarnFormat("[TOKENBUCKET] something odd is happening and drip rate is 0 for {0}", m_counter);
316 return; 316 return;
317 } 317 }
318 318
319 double now = Util.GetTimeStampMS(); 319 double now = Util.GetTimeStampMS();
320 double deltaMS = now - m_lastDrip; 320 double deltaMS = now - m_lastDrip;
321 m_lastDrip = now; 321 m_lastDrip = now;
@@ -333,13 +333,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
333 333
334 public class AdaptiveTokenBucket : TokenBucket 334 public class AdaptiveTokenBucket : TokenBucket
335 { 335 {
336 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 336 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
337 337
338 public bool AdaptiveEnabled { get; set; } 338 public bool AdaptiveEnabled { get; set; }
339 339
340 /// <summary> 340 /// <summary>
341 /// The minimum rate for flow control. Minimum drip rate is one 341 /// The minimum rate for flow control. Minimum drip rate is one
342 /// packet per second. 342 /// packet per second.
343 /// </summary> 343 /// </summary>
344 344
345 protected const float m_minimumFlow = 50000; 345 protected const float m_minimumFlow = 50000;
@@ -361,7 +361,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
361 private bool m_enabled = false; 361 private bool m_enabled = false;
362 362
363 // <summary> 363 // <summary>
364 // Adjust drip rate in response to network conditions. 364 // Adjust drip rate in response to network conditions.
365 // </summary> 365 // </summary>
366 public float AdjustedDripRate 366 public float AdjustedDripRate
367 { 367 {
@@ -374,10 +374,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
374 m_parent.RegisterRequest(this, m_dripRate); 374 m_parent.RegisterRequest(this, m_dripRate);
375 } 375 }
376 } 376 }
377 377
378 378
379 // <summary> 379 // <summary>
380 // 380 //
381 // </summary> 381 // </summary>
382 public AdaptiveTokenBucket(TokenBucket parent, float maxDripRate, float maxBurst, bool enabled) 382 public AdaptiveTokenBucket(TokenBucket parent, float maxDripRate, float maxBurst, bool enabled)
383 : base(parent, maxDripRate, maxBurst) 383 : base(parent, maxDripRate, maxBurst)
@@ -393,7 +393,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
393 if (m_parent != null) 393 if (m_parent != null)
394 m_parent.RegisterRequest(this, m_dripRate); 394 m_parent.RegisterRequest(this, m_dripRate);
395 } 395 }
396 396
397 /// <summary> 397 /// <summary>
398 /// Reliable packets sent to the client for which we never received an ack adjust the drip rate down. 398 /// Reliable packets sent to the client for which we never received an ack adjust the drip rate down.
399 /// <param name="packets">Number of packets that expired without successful delivery</param> 399 /// <param name="packets">Number of packets that expired without successful delivery</param>
@@ -406,7 +406,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
406 } 406 }
407 407
408 // <summary> 408 // <summary>
409 // 409 //
410 // </summary> 410 // </summary>
411 public void AcknowledgePackets(Int32 count) 411 public void AcknowledgePackets(Int32 count)
412 { 412 {