0 2

BIT254 ยท 0 ยท 10 marks

Explain leaky-bucket algorithm. Illustrate with an example. What are its advantages and disadvantages?

Explain leaky-bucket algorithm. Illustrate with an example. What are its advantages and disadvantages?[10]

Network and Data CommunicationsChapter 6: Congestion Control and Traffic ManagementLeaky-bucket algorithm

Quick answer

The Leaky Bucket Algorithm is a traffic shaping and congestion control mechanism used in computer networks to control the rate at which data packets are transmitted into the network. It smooths out bursty traffic and converts it into a steady, uniform stream of packets.

Leaky Bucket Algorithm

Definition and Concept

The name comes from the analogy of a bucket with a small hole at the bottom:

  • Water (packets) poured into the bucket at any rate
  • Water leaks out from the bottom at a constant, fixed rate
  • If the bucket overflows, excess water (packets) is discarded

How It Works

The algorithm operates as follows:

  1. Incoming packets are placed into a FIFO queue (the bucket) of fixed capacity.
  2. Packets are transmitted (leak out) at a fixed rate, regardless of the input rate.
  3. If the bucket (queue) is full, any new incoming packets are discarded (dropped).
  4. If the bucket is empty, no packets are sent (output is idle).

Key Parameters:

ParameterDescription
Bucket Size (B)Maximum number of packets the queue can hold
Output Rate (r)Fixed rate at which packets leave the bucket
Input RateVariable (bursty) rate at which packets arrive

Algorithm Steps

1. Initialize bucket with capacity B and output rate r.
2. For each time slot:
   a. Receive incoming packets.
   b. If (current packets in bucket + new packets) <= B:
        Add packets to bucket.
      Else:
        Discard excess packets (overflow).
   c. If bucket is not empty:
        Transmit r packets from the bucket.

Illustration with Example

Setup:

  • Bucket size (B) = 10 packets
  • Output rate (r) = 3 packets per time slot

Simulation Table:

Time SlotPackets ArrivingPackets in Bucket (Before Output)Packets SentPackets RemainingPackets Dropped
150 + 5 = 5320
282 + 8 = 10370
367 + 6 = 13 > 10373
407 + 0 = 7340
524 + 2 = 6330
603 + 0 = 3300

Observations from the Example:

  • At Time Slot 2, the bucket fills to exactly 10 (no drop).
  • At Time Slot 3, 13 packets would be needed but bucket holds only 10, so 3 packets are dropped.
  • Output is always a constant 3 packets/slot, regardless of input bursts.
  • The bursty input is converted to a smooth, uniform output stream.

Diagram:

Bursty Input
   |||  ||||  ||||||
     |          |
     v          v
  +------------------+
  |  B U C K E T     |  <-- Fixed capacity (B)
  |  (FIFO Queue)    |
  +------------------+
          |
          | Fixed rate (r packets/slot)
          v
   Smooth Output
   |||  |||  |||  |||

Advantages of Leaky Bucket Algorithm

  1. Traffic Smoothing: Converts bursty, irregular traffic into a smooth, constant-rate output stream, reducing network congestion.

  2. Simplicity: The algorithm is simple to understand and easy to implement in hardware or software.

  3. Congestion Control: Prevents network congestion by ensuring no host can send packets faster than the allowed output rate.

  4. Predictable Output: The output rate is always fixed and predictable, making it easy for the network to plan bandwidth allocation.

  5. Fairness: Ensures that no single host monopolizes network bandwidth by enforcing a strict rate limit.


Disadvantages of Leaky Bucket Algorithm

  1. Packet Loss: When the bucket is full, incoming packets are simply dropped, which may be unacceptable for certain applications (e.g., real-time video, VoIP).

  2. Inflexibility: The output rate is always fixed, even when the network is idle and has spare capacity. It cannot take advantage of available bandwidth.

  3. Does Not Handle Bursts Well: Legitimate short bursts of traffic are not accommodated. Even if the network can handle a burst, the algorithm still enforces the fixed rate.

  4. Delay: Packets may experience variable queuing delays inside the bucket before being transmitted.

  5. No Differentiation: All packets are treated equally; there is no priority mechanism for urgent or important packets.

  6. Wasteful During Low Traffic: If the input rate is lower than the output rate, the bucket remains partially empty and the full bandwidth is not utilized.


Comparison: Leaky Bucket vs Token Bucket

FeatureLeaky BucketToken Bucket
Output rateAlways fixedVariable (up to a maximum)
Burst handlingNot allowedAllowed (up to token limit)
Packet dropOn overflowOn no token available
FlexibilityLess flexibleMore flexible

Summary

The leaky bucket algorithm is a fundamental traffic policing and shaping technique that enforces a constant output rate regardless of input burstiness. While it is simple and effective for smoothing traffic and preventing congestion, its rigidity in not accommodating bursts and its packet-dropping behavior are notable limitations. For applications requiring burst tolerance, the Token Bucket Algorithm is often preferred.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.