Re: Capping of sockets
Re: Capping of sockets
- Subject: Re: Capping of sockets
- From: "David Aames" <email@hidden>
- Date: Fri, 9 Jun 2006 23:30:10 +0100
On 6/9/06, james woodyatt <email@hidden> wrote:
[snip]
It sounds like you want to implement rate limiting in the application
layer. The "traditional family values" approach to this problem is
not to limit the rate at which you *read* octets, but rather to limit
the rate at which you *write* them.
The algorithm you want is called a "token bucket". Every N
milliseconds or so, you put a constant quantity of tokens "into" the
bucket. If the bucket "overflows" you dump the "extra" tokens on the
floor. Whenever you have octets to write, you pull enough tokens out
of the bucket to cover the cost of transmitting them. If there
aren't enough tokens in the bucket, you queue whatever octets you
can't afford to transmit. If the holding queue has octets in it when
it's time to add tokens to the bucket, you spend the tokens
immediately instead by transmitting from the queue. If the holding
queue gets too long, then you either need to throttle back on the
octet source or decide which octets to drop.
Thanks for your insightful reply. I think I will manage to implement rate limitting for uploading. I've also just found an article (
http://doc.trolltech.com/qq/qq17-ratecontrol.html
) which implements up/down rate limitting. The interesting part is where they set a maximum buffer of the socket - if this is reached the socket will stop receiving data. Is this even possible with BSD sockets? Or I would have to resort to kernel extensions?
Thanks
HTH...
--
james woodyatt <
email@hidden>
member of technical staff
apple computer, inc.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden