ELEC3506

Topics

Quality of ServiceLecture 10 PDF15 min

Traffic shaping

How the leaky bucket smooths bursty traffic into a fixed rate, how the token bucket allows a controlled burst by letting idle hosts save credit, and the lecture's bound on how much a token bucket lets through.

By the end of this page you should be able to

  • Explain what traffic shaping controls and name the two techniques the lecture gives
  • Describe the leaky bucket and say why the lecture calls it restrictive
  • Describe the token bucket and say how it differs from the leaky bucket
  • Apply the maximum-packets and maximum-average-rate formulas for a token bucket

The idea

A host that sends in sudden bursts can swamp a router even if its average rate is modest. The fix is to control the traffic at the source of the problem before it enters the network. Traffic shaping controls the amount and the rate of the traffic sent into the network, and the lecture gives two techniques: the leaky bucket and the token bucket.

How it works

Leaky bucket

The leaky bucket shapes bursty traffic into fixed-rate traffic by averaging the data rate. It may drop packets if the bucket is full, and it also prevents congestion.

Bursty data goes into the bucket and leaves at a fixed rate. The lecture’s algorithm figure does not survive text extraction. Its verdict is that the leaky bucket is very restrictive. It does not credit an idle host: if a host is not sending for a while, its bucket becomes empty. The lecture also labels it as unaware of buffer or queue status.

How it works

Token bucket

The leaky bucket imposes a hard limit on the data transmission rate. The token bucket allows a certain amount of burstiness while imposing a limit on the average data transmission rate. It allows bursty traffic at a regulated maximum rate, and it allows idle hosts to accumulate credit for the future in the form of tokens. The lecture labels it as aware of buffer or queue status.

How it works:

  1. The bucket contains tokens.
  2. Tokens are added periodically at the desired maximum average rate.
  3. Packets can only be sent when there are tokens in the bucket.
  4. Tokens are removed when packets are sent.
Leaky bucketToken bucket
OutputFixed rateBursts allowed, average rate limited
Idle hostGets no credit, the bucket becomes emptyAccumulates tokens as credit for the future
Packets droppedMay drop if the bucket is fullNot stated in the lecture
Queue statusUnawareAware
The exam question is usually the difference between them, and the answer is how each treats idle time.

How it works

Token bucket analysis

The lecture’s analysis uses two symbols: the capacity of the bucket c tokens and the token rate r tokens per second entering the bucket. The system removes one token for every cell of data sent. In any interval of length t:

Maximum number of packets
r
Token rate in tokens per second
t
Interval length in seconds
c
Bucket capacity in tokens

The maximum average rate follows by dividing by t:

Maximum average rate
r
Token rate in tokens per second
t
Interval length in seconds
c
Bucket capacity in tokens

Worked example

Token bucket limits over 2 seconds

  1. Given (our own numbers, the lecture gives none): c = 10 tokens, r = 5 tokens/s, t = 2 s.

  2. Tokens arriving in the interval: r x t = 5 x 2 = 10 tokens.

  3. Add the full bucket: 10 + 10 = 20 tokens, so at most 20 packets enter the network.

  4. Average rate: 20 / 2 = 10 packets per second.

  5. Compare with the token rate: 10 is above r = 5. The excess is the burst that the saved credit allows. As t grows, c / t shrinks and the average approaches r.

AnswerUp to 20 packets, an average of 10 packets per second.

Where marks get lost

The limit is on average, not on instants

The token bucket does not cap each second at r. It caps the long-run average near r, and lets a full bucket go out at once. If an answer says the token bucket gives a fixed output rate, that is the leaky bucket.

In the exam

  • Both are traffic shaping techniques that control the amount and rate of traffic sent to the network.
  • Leaky bucket: fixed output, drops when full, no credit for idle hosts.
  • Token bucket: tokens at rate r, capacity c, one token per cell, bursts allowed, idle time banked.
  • Formulas: maximum packets r x t + c, maximum average rate (r x t + c) / t.

Check yourself

  • Shaping controls the amount and rate of traffic going into the network.
  • Leaky bucket gives fixed-rate output and does not credit idle hosts.
  • Token bucket banks tokens while idle and allows bursts within an average limit.
  • Over time t a token bucket passes at most r x t + c packets.

Check yourself

  1. A host stays silent for a long time and then sends a burst. Which shaper lets it send a burst above its steady rate?
  2. Which statement describes the leaky bucket output?
  3. A token bucket has capacity c = 10 tokens and a token rate r = 5 tokens per second. Using the lecture's formula, what is the maximum number of packets that can enter the network in t = 2 seconds?
  4. What is the maximum average rate in the same example?