7 - Rate Limiting and Traffic Shaping Flashcards
Traffic Shaping Approaches
Leaky Bucket, (r, T) Traffic Shaper, Token Bucket, Composite using all 3
Motivation for Traffic Shaping
resource control, ensure flows don’t exceed rate.
Data Traffic can be
bursty, periodic, regular
Audio traffic is
continuous, strongly periodic
Video Traffic is
continuous, bursty do to the nature of how video is compressed, periodic
The two classes of traffic
Constant Bit Rate source (CBR) - Traffic arrives at regular intervals. Packets are the same size as the arrive. Audio is this.
Variable Bit Rate (VBR) - video, data, shaped according to both an averate rate, and a peak rate. Where the average rate might be a small fraction of the peak rate. You can see that at certain times, the peak rate might well exceed the avg.
Leaky Bucket Traffic Shaping (Isochronous)
Each flow has its own bucket
Data arrives in a bucket of size beta, and drains at rate rho. rho controls the avg rate, data can arrive faster or slower into the bucket but can’t drain faster than rho. So the max avg rate that traffic can be sent is the smooth rate rho. The size of thebucket controls the max burst size that can be sent for a flow. So even though the avg rate can’t exceed rho, sometimes the sender can send at a faster rate as long as the burst isn’t exceed the bucket size. The bucket allows for periodical bursts, and the regulator ensures the avg rage doesnt exceed the drain rate. Setting a larger bucket size can allow a larger burst rate. A larger rho value can make for faster avg packet rate.
(r, T) Traffic Shaping
Traffic is dividedinto T-bit frames.
Flow can inject <= to r bits in any T-bit frame. If you want to send more than one packet of r bits, you have to wait for the next T-bit frame. This obeys the (t, T) smooth traffic shape.
In this, you can’t send a packet that’s bigger than r bits long.
Unless T is long, the max packet size may be small. So the range is limited to fixed rate flows. Variable flows must request data rates that are equal to the peak rate, and that’s wasteful.
This traffic shaper is relaxed from the simple leaky bucket bc rather than sending one packet every time unit, the flow can send a certain number of bits every time unit.
When a flow exceeds it’s rate, the excess packets in that flow are given a lower priority. If the network is heavily congested, the packets may be dropped.
Priorities might be assigned by the sender or the network. The sender’s app would mark the packets since it knows which ones are important.
Routers that mark packet priorities is called policing.
Shaping bursty traffic patterns (Token Bucket)
To shape bursty traffic, allowing for bursts but still making sure the flow doesn’t exceed an avg rate. The Token Bucket is good for this.
Tokens arrive in a bucket at rate rho, and beta is the capacity of the bucket.
Traffic can arrive at an avg rate, lambda avg, and a peak rate lambda peak. Traffic can be sent by the regulator as long as there are tokens in the bucket.
The difference between Token Bucket and Leaky Bucket
Consider sending a packet of size b that’s less than beta.
- If the token bucket is full, packet is sent, and b tokens are removed.
- if the bucket is empty, the packet must wait until b tokens drip into the bucket.
- If the bucket is partially full, then it depends. If the number of tokens in the bucket exceed b then the packet is sent immediately. Otherwise, we have to wait until there are b tokens in the bucket before we can send the packet.
Token vs Leaky Bucket Cont (Token Bucket explained)
Token Bucket
- permits burstiness, but bounds it by the rate rho.
- The bound is:
- If bucket size beta, then we know that at any interval, T, then the rat is always less than beta, that is the max number of tokens that can be accumulated in the bucket. Plus the rate at which tokens accumulate, times that interval.
- We also know that the long term rate will always be less than rho.
- No discard, or policies
- More flexible since it has additional params that we can use to configure the burst size.
- One of the limitations is that at any traffic level of length T, the flow can send beta plus T times rho tokens of data. If a network tries to plice the flows by simply measuring their traffic over intervals of length T. The flow can cheat by sending this amount of data each interval.
- Consider, for example, an interval of twice this length. If the flow can send data plus T times rho in each interval.
- Then over 2T the flow can consume 2 times betwa plus tau times rho tokens. But actually this is greater than how much the flow is actually supposed to be able to send which is beta plus 2T times rho. So policing traffic being sent by token buckets is actually rather difficult. So token buckets allow for long bursts. And if the bursta are high priority traffic, they are difficult to police and may interfere with other high priority traffic. So there’s some need to limit how long a token bucket sender can monopolize the network.
Token Bucket vs Leaky Bucket (Token Bucket more…)
- Permits burstiness, but bounds it to the rate rho.
- The bound is:
- if the bucket size, beta then we know that at any interval, T, then the rate is always less than beta, that is the max number of tokens that can be accumulated in the bucket. Plus the rate at which tokens accumulate, times that time interval.
- No discard or priority policies.
- More flexible since it has additional params that we can use to configure the burst size.
- One of the limitations is that at any traffic level of length T, the flow can simply send beta plus T time rho tokens of data. If a network tries to police the flows by simply measuring their traffic over intervals of length T. The flow can cheat by sending this amount of data in each interval.
- Consider, for example an interval of twice this length. If the flow can send beta plus T times rho in each interval. Then over 2T the flow can consume 2 times beta plus tau times rho tokens. But actually, this greater than how much the flow is at actually supposed to be able to send which is beta plus 2T times rho. So policing traffic being sent by token buckets is rather difficult. So token buckets allow for long bursts. And if the bursts are of high priority traffic, they are difficult to police and may interfere with other high priority traffic. So there’s some need to limit how long a token bucket sender can monopolize the network.
Token Bucket vs Leaky Bucket (Leaky Bucket)
- Forces the bursty traffic to be smoothed
- Implement priority policies for flows that exceed the smoothing rate.
Policing With Token Buckets
- In order to police Token buckets, a Composite Shaper is used.
- Composite Shaper: to combine a Token bucket shaper with a leaky bucket.
- The combination of the token bucket shaper with the leaky bucket shaper allow for good policing. Confirming that the flows data rate does not exceed the avg data rate allowed by the smooth leaky bucket is easy.. But the implementation is more complex since each bucket flow now requires two counters, and two timers. One timer and one counter for each bucket.
Quiz Token Bucket Shaper:
The size of the bucket (beta) is 100KB, rho is 10 packets/second, and that packets are 1KB. Assume that we are talking about an interval of 1 second. Remember that an any given interval, a flow can never send more than beta plus tau times rho bits of data. Give your answer in kilobits per second kepping in mind that 1 byte is 8 bits.
The max rate would be 100KB times 1 second plus 10 packets/second times 10KB, or 110KB, which is 880 kbs/second.