Download presentation
Presentation is loading. Please wait.
1
Token Bucket
2
Traffic regulator Receiver Sender Traffic regulator
Goal: Traffic entering the network should comply to a given envelope
3
Traffic regulators Traffic exceeding the envelope is non-compliant.
What do to with non-compliant traffic ? Buffer Traffic shaping Drop Traffic policing Allow, but assign low priority Traffic marking We focus on Traffic shapers © Jörg Liebeherr, 2006 ECE 1545
4
Traffic shapers Envelope
Traffic shaper enforces that the departures D comply to a traffic envelope E Non-compliant traffic is stored in a FIFO buffer Buffered traffic is released as soon as allowed This type of shaper is called “Greedy Shaper” Envelope
5
Token Bucket Token Bucket is a traffic regulation mechanism to enforce that departures comply to the envelope Traffic Time interval b Slope r
6
Token Bucket Tokens are added at rate r up to a maximum size of TBmax
7
Token Bucket Assume: Packet can depart if enough tokens are available.
Tokens are removed tokens when packet departs (Here: 10 tokens are needed)
8
Token Bucket Assume: Packet removes 10 tokens from buffer
(Number of tokens is associated with packet size)
9
Token Bucket Packet must wait until enough tokens are available
10
Token Bucket (fluid flow version)
For an analysis we work with a fluid flow version of the token bucket (Traffic can depart in arbitrary small chunks)
11
TBmax = b = 2 r = 1
12
TBmax = b = 2 r = 1 A+TB-B
13
Implementation
14
Implementation in Lab 2 (a+b)
TokenBucket
15
Token Bucket in Lab 2 (a+b)
TokenBucketReceiver (BR) TokenBucketSender (BS) if (buffer_is_empty && not(sendingInProgress) && enough_tokens_available) consume tokens; send packet; else add packet to buffer; If (buffer_is_not_empty) if (enough_tokens) consume tokens; sendingInProgress = true; remove packet from buffer; send packet; sendingInProgress = false; else get expected time when there will be enough tokens; sleep for this time; wait for packet to arrive to buffer;
16
Alternative implementation for Token Bucket?
Idea: instead of counting tokens (and compute timestamps from tokens), work directly with timestamps VC : release time of packet (init: VC = 0) l : packet size now : current time TDTp : Target departure time of packet p b TokenBucketSender (BS) TokenBucketReceiver (BR) If (buffer_is_not_empty) if (TDThead_of_buffer ≤ now) sendingInProgress = true; remove packet from buffer; send packet; sendingInProgress = false; else sleep for now - TDThead_of_buffer ; wait for packet to arrive to buffer; VC = max {VC, now} + l/r; if ( buffer_is_empty && not(sendingInProgress) && VC - b/r ≤ now ) send packet; else Set TDTp = VC - b/r; add packet to buffer;
17
Peak Rate Constrained Token Bucket
Adds a constraint on the maximum (“peak”) rate of traffic: Is implemented with 2 token buckets in series. Traffic Slope r b Slope P Time interval
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.