Package DebTorrent :: Module RateLimiter
[hide private]
[frames] | no frames]

Module RateLimiter

source code

Limit the upload rate.

All the constants below are only for the automatic upload rate adjustment.

Classes [hide private]
  RateLimiter
Limit the upload rate.
Variables [hide private]
logging.Logger logger = logging.getLogger('DebTorrent.RateLimiter')
the logger to send all log messages to for this module
float MAX_RATE_PERIOD = 20.0
maximum amount of time to guess the current rate estimate represents
float MAX_RATE = 100000000000.0
the (very large) limit to use to not limit the upload rate
float PING_BOUNDARY = 1.2
maximum ping time to consider still working
int PING_SAMPLES = 7
minimum number of pings to require
int PING_DISCARDS = 1
number of initial pings to discard
int PING_THRESHHOLD = 5
number of pings that exceed PING_BOUNDARY before the connection is assumed to be flooded
int PING_DELAY = 5
not used
int PING_DELAY_NEXT = 2
not used
float ADJUST_UP = 1.05
fraction to adjust up the upload rate by
float ADJUST_DOWN = 0.95
fraction to adjust down the upload rate by
int UP_DELAY_FIRST = 5
number of cycles after an adjust down before adjusting up the upload rate
int UP_DELAY_NEXT = 2
number of cycles after an adjust up before adjusting up the upload rate again
int SLOTS_STARTING = 6
the starting number of upload slots to use
float SLOTS_FACTOR = 0.00166
factor to use in calculating the number of upload slots

Imports: logging, binascii.b2a_hex, clock.clock, CurrentRateMeasure.Measure, cStringIO.StringIO, math.sqrt