OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
Public Member Functions | Protected Member Functions | Protected Attributes | Properties | List of all members
OpenSim.Region.ClientStack.LindenUDP.TokenBucket Class Reference

A hierarchical token bucket for bandwidth throttling. See http://en.wikipedia.org/wiki/Token_bucket for more information More...

Inheritance diagram for OpenSim.Region.ClientStack.LindenUDP.TokenBucket:
Inheritance graph
[legend]
Collaboration diagram for OpenSim.Region.ClientStack.LindenUDP.TokenBucket:
Collaboration graph
[legend]

Public Member Functions

 TokenBucket (TokenBucket parent, float dripRate, float MaxBurst)
 Default constructor More...
 
void RegisterRequest (TokenBucket child, float request)
 Register drip rate requested by a child of this throttle. Pass the changes up the hierarchy. More...
 
void UnregisterRequest (TokenBucket child)
 Remove the rate requested by a child of this throttle. Pass the changes up the hierarchy. More...
 
bool RemoveTokens (int amount)
 Remove a given number of tokens from the bucket More...
 
bool CheckTokens (int amount)
 
int GetCatBytesCanSend (int timeMS)
 

Protected Member Functions

float DripRateModifier ()
 Compute a modifier for the MaxBurst rate. This is 1.0, meaning no modification if the requested bandwidth is less than the max burst bandwidth all the way to the root of the throttle hierarchy. However, if any of the parents is over-booked, then the modifier will be less than 1. More...
 
float BurstModifier ()
 
void Drip ()
 Add tokens to the bucket over time. The number of tokens added each call depends on the length of time that has passed since the last call to Drip More...
 

Protected Attributes

const float m_timeScale = 1e-3f
 
const float m_quantumsPerBurst = 5
 This is the number of m_minimumDripRate bytes allowed in a burst roughtly, with this settings, the maximum time system will take to recheck a bucket in ms More...
 
const float m_minimumDripRate = 1500
 
Int32 m_lastDrip
 Time of the last drip, in system ticks More...
 
float m_tokenCount
 The number of bytes that can be sent at this moment. This is the current number of tokens in the bucket More...
 
Dictionary< TokenBucket, float > m_children = new Dictionary<TokenBucket, float>()
 Map of children buckets and their requested maximum burst rate More...
 
TokenBucket m_parent
 The parent bucket of this bucket, or null if this bucket has no parent. The parent bucket will limit the aggregate bandwidth of all of its children buckets More...
 
float m_burst
 This is the maximum number of tokens that can accumulate in the bucket at any one time. This also sets the total request for leaf nodes More...
 
float m_dripRate
 The requested drip rate for this particular bucket. More...
 
float m_totalDripRequest
 The current total of the requested maximum burst rates of children buckets. More...
 

Properties

TokenBucket Parent [get, set]
 
virtual float MaxDripRate [get, set]
 
float RequestedBurst [get, set]
 
float Burst [get]
 
virtual float RequestedDripRate [get, set]
 
virtual float DripRate [get]
 
float TotalDripRequest [get, set]
 

Detailed Description

A hierarchical token bucket for bandwidth throttling. See http://en.wikipedia.org/wiki/Token_bucket for more information

Definition at line 42 of file TokenBucket.cs.

Constructor & Destructor Documentation

OpenSim.Region.ClientStack.LindenUDP.TokenBucket.TokenBucket ( TokenBucket  parent,
float  dripRate,
float  MaxBurst 
)
inline

Default constructor

Parameters
identifierIdentifier for this token bucket
parentParent bucket if this is a child bucket, or null if this is a root bucket
maxBurstMaximum size of the bucket in bytes, or zero if this bucket has no maximum capacity
dripRateRate that the bucket fills, in bytes per second. If zero, the bucket always remains full

Definition at line 189 of file TokenBucket.cs.

Member Function Documentation

float OpenSim.Region.ClientStack.LindenUDP.TokenBucket.BurstModifier ( )
inlineprotected

Definition at line 218 of file TokenBucket.cs.

bool OpenSim.Region.ClientStack.LindenUDP.TokenBucket.CheckTokens ( int  amount)
inline

Definition at line 289 of file TokenBucket.cs.

Here is the caller graph for this function:

void OpenSim.Region.ClientStack.LindenUDP.TokenBucket.Drip ( )
inlineprotected

Add tokens to the bucket over time. The number of tokens added each call depends on the length of time that has passed since the last call to Drip

Returns
True if tokens were added to the bucket, otherwise false

Definition at line 306 of file TokenBucket.cs.

float OpenSim.Region.ClientStack.LindenUDP.TokenBucket.DripRateModifier ( )
inlineprotected

Compute a modifier for the MaxBurst rate. This is 1.0, meaning no modification if the requested bandwidth is less than the max burst bandwidth all the way to the root of the throttle hierarchy. However, if any of the parents is over-booked, then the modifier will be less than 1.

Definition at line 210 of file TokenBucket.cs.

int OpenSim.Region.ClientStack.LindenUDP.TokenBucket.GetCatBytesCanSend ( int  timeMS)
inline

Definition at line 294 of file TokenBucket.cs.

void OpenSim.Region.ClientStack.LindenUDP.TokenBucket.RegisterRequest ( TokenBucket  child,
float  request 
)
inline

Register drip rate requested by a child of this throttle. Pass the changes up the hierarchy.

Definition at line 230 of file TokenBucket.cs.

bool OpenSim.Region.ClientStack.LindenUDP.TokenBucket.RemoveTokens ( int  amount)
inline

Remove a given number of tokens from the bucket

Parameters
amountNumber of tokens to remove from the bucket
Returns
True if the requested number of tokens were removed from the bucket, otherwise false

Definition at line 272 of file TokenBucket.cs.

Here is the caller graph for this function:

void OpenSim.Region.ClientStack.LindenUDP.TokenBucket.UnregisterRequest ( TokenBucket  child)
inline

Remove the rate requested by a child of this throttle. Pass the changes up the hierarchy.

Definition at line 250 of file TokenBucket.cs.

Member Data Documentation

float OpenSim.Region.ClientStack.LindenUDP.TokenBucket.m_burst
protected

This is the maximum number of tokens that can accumulate in the bucket at any one time. This also sets the total request for leaf nodes

Definition at line 98 of file TokenBucket.cs.

Dictionary<TokenBucket, float> OpenSim.Region.ClientStack.LindenUDP.TokenBucket.m_children = new Dictionary<TokenBucket, float>()
protected

Map of children buckets and their requested maximum burst rate

Definition at line 78 of file TokenBucket.cs.

float OpenSim.Region.ClientStack.LindenUDP.TokenBucket.m_dripRate
protected

The requested drip rate for this particular bucket.

0 then TotalDripRequest is used instead. Can never be above MaxDripRate. Tokens are added to the bucket at any time

See Also
RemoveTokens

is called, at the granularity of the system tick interval (typically around 15-22ms)

Definition at line 135 of file TokenBucket.cs.

Int32 OpenSim.Region.ClientStack.LindenUDP.TokenBucket.m_lastDrip
protected

Time of the last drip, in system ticks

Definition at line 66 of file TokenBucket.cs.

const float OpenSim.Region.ClientStack.LindenUDP.TokenBucket.m_minimumDripRate = 1500
protected

Definition at line 63 of file TokenBucket.cs.

TokenBucket OpenSim.Region.ClientStack.LindenUDP.TokenBucket.m_parent
protected

The parent bucket of this bucket, or null if this bucket has no parent. The parent bucket will limit the aggregate bandwidth of all of its children buckets

Definition at line 87 of file TokenBucket.cs.

const float OpenSim.Region.ClientStack.LindenUDP.TokenBucket.m_quantumsPerBurst = 5
protected

This is the number of m_minimumDripRate bytes allowed in a burst roughtly, with this settings, the maximum time system will take to recheck a bucket in ms

Definition at line 59 of file TokenBucket.cs.

const float OpenSim.Region.ClientStack.LindenUDP.TokenBucket.m_timeScale = 1e-3f
protected

Definition at line 50 of file TokenBucket.cs.

float OpenSim.Region.ClientStack.LindenUDP.TokenBucket.m_tokenCount
protected

The number of bytes that can be sent at this moment. This is the current number of tokens in the bucket

Definition at line 72 of file TokenBucket.cs.

float OpenSim.Region.ClientStack.LindenUDP.TokenBucket.m_totalDripRequest
protected

The current total of the requested maximum burst rates of children buckets.

Definition at line 167 of file TokenBucket.cs.

Property Documentation

float OpenSim.Region.ClientStack.LindenUDP.TokenBucket.Burst
get

Definition at line 117 of file TokenBucket.cs.

virtual float OpenSim.Region.ClientStack.LindenUDP.TokenBucket.DripRate
get

Definition at line 150 of file TokenBucket.cs.

virtual float OpenSim.Region.ClientStack.LindenUDP.TokenBucket.MaxDripRate
getset

Definition at line 100 of file TokenBucket.cs.

TokenBucket OpenSim.Region.ClientStack.LindenUDP.TokenBucket.Parent
getset

Definition at line 89 of file TokenBucket.cs.

float OpenSim.Region.ClientStack.LindenUDP.TokenBucket.RequestedBurst
getset

Definition at line 103 of file TokenBucket.cs.

virtual float OpenSim.Region.ClientStack.LindenUDP.TokenBucket.RequestedDripRate
getset

Definition at line 138 of file TokenBucket.cs.

float OpenSim.Region.ClientStack.LindenUDP.TokenBucket.TotalDripRequest
getset

Definition at line 169 of file TokenBucket.cs.


The documentation for this class was generated from the following file: