100% found this document useful (1 vote)
5K views

Leaky Bucket Additional Problems With Solutions

The document contains 5 problems related to modeling packet transmission using a leaky bucket algorithm. Problem 1 involves calculating the minimum bucket size needed to transmit a burst of data without loss given transmission rates. Problem 2 similarly calculates minimum bucket size and maximum burst time. Problem 3 provides a packet arrival schedule to fill out the leaky bucket state over time, including token count, departures, and queued packets. Problem 4 is another similar test case with a smaller maximum token count. Problem 5 introduces using two threads and testing an implementation of the leaky bucket algorithm.

Uploaded by

Ishan Jawa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
5K views

Leaky Bucket Additional Problems With Solutions

The document contains 5 problems related to modeling packet transmission using a leaky bucket algorithm. Problem 1 involves calculating the minimum bucket size needed to transmit a burst of data without loss given transmission rates. Problem 2 similarly calculates minimum bucket size and maximum burst time. Problem 3 provides a packet arrival schedule to fill out the leaky bucket state over time, including token count, departures, and queued packets. Problem 4 is another similar test case with a smaller maximum token count. Problem 5 introduces using two threads and testing an implementation of the leaky bucket algorithm.

Uploaded by

Ishan Jawa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

By: Eng.

Ola Abd El-


El-LAtif
Leaky Bucket Additional Problems + Solutions By: Eng.Ola Abd El-Latif

Problem 1

Computer A has 19.5MB to send on a network and transmits the data in a burst @
6 Mbps. The maximum transmission rate across routers in the network is 4 Mbps.
If Computer A's transmission is shaped using a leaky bucket, how much capacity must the
queue in the bucket hold not to discard any data? (Show your work)

Solution

6 Mb → 1 sec
(19.5MB *8) Mb → ( time for computer to transmit data)??

time for computer to transmit data = total bits / max trans rate
= (19.5 MB * 8 bits/byte) / 6 Mbps
= 156 Mb / 6 Mb/s
= 26 s

4 Mb → 1 sec
actual data sent on network ?? → 26 sec

actual data sent on network in 26 s = network rate * 26s


= 4 Mb/s * 26s
= 104 Mbits = 13 Mbytes

bucket size = 19.5 MB - 13 MB = 6.5MB(or 52Mb)


By: Eng.Ola Abd El-
El-LAtif
Leaky Bucket Additional Problems + Solutions By: Eng.Ola Abd El-Latif

Problem 2

A leaky bucket is at the host network interface. The data rate on the network is 2MByte/s
and the data rate on the link from the host to the bucket is 2.5Mbyte/s.
A. Suppose the host has 250 Mbytes to send onto the network and it sends the data
in a burst. What should be the minimum capacity of the bucket (in bytes) in order
that no data is lost?

2.5Mbyte → 1 sec
250 Mbytes → ( time for host to transmit data)??

time for computer to transmit data = total bits / max trans rate
= (250 MB* 1 sec) / 2.5 Mbyte
= 100 sec

2 Mbyte → 1 sec
actual data sent on network ?? → 100 sec

actual data sent on network in 100 s = network rate * 100s


= 2 Mbyte /s * 100s
= 200 MByte

Minimum bucket size = 250 MByte -200 MByte = 50 MByte

B. Suppose the capacity of the bucket is 100M bytes. What is the longest burst time
from the host in order that no data is lost?

bucket size =250 MByte - actual data sent on network in the time the host transmit
all the data

100 MByte =250 MByte – 15o MByte


2 Mbyte → 1 sec
15o MByte → time for computer to transmit all data ??

Time for computer to transmit all data = 150/2=75 sec


Host Max data rate?? → 1 sec


250 Mbytes → 75 sec

Host Max data rate=(250 Mbytes) /75 sec =3.33 MByte/sec


By: Eng.Ola Abd El-
El-LAtif
Leaky Bucket Additional Problems + Solutions By: Eng.Ola Abd El-Latif

Problem 3

You have constructed a Leaky bucket class in Java using a queue of length 4, a thread
and a timer. The token bucket class operates on packets, and replenishes tokens tokens at the
rate of 1token/ms .TheThe maximum token count is 3. If possible, the class replenishes tokens
before any other operations.
A. Given the following packet arrival schedule, fill in the system state: token count,
scheduled departures, and queued packets, at each packet arrival time (if a packet arrives
and is not immediately sent then Queued Packets increments by 1).
The class is fast enough such that you can assume packets are sent instantaneously, if
possible. Initially the Leaky Bucket was full.

Solution
Packet Arrival Time Departure Token Queued
umber (msec) Time Count Packets
0 3 empty
1 1 1 2 empty
2 1.1 1.1 1 empty
3 1.5 1.5 0 empty At t=2 packet 4 depart
4 2 2 0 empty
remove the generated
token
5 2.7 3 0 5
6 2.9 4 0 5,6 At t=3 packet 5 depart
7 3 5 0 6,7 and remove the
8 3.1 6 0 6,7,8 generated token
9 3.2 7 0 6,7,8,9

Note

Here if we use a queue of length 3 → packet 9 will be dropped and discarded because at
t=3.2 the queue was full=6,7,8 and there is no enough space to queued 9th packet.

Problem 4
You have constructed a Leaky bucket class in Java using a queue of length 3, a thread and a
timer. The token bucket class operates on packets, and replenishes tokens at the rate of
1token/ms .The maximum token count is 2. If possible, the class replenishes tokens before any
other operations.
Given the following packet arrival schedule, fill in the system state: token count, scheduled
departures, and queued packets, at each packet arrival time (if a packet arrives and is not
immediately sent then Queued Packets increments by 1). The class is fast enough such that you
can assume packets are sent instantaneously, if possible. Initially the Leaky Bucket was full.
By: Eng.Ola Abd El-
El-LAtif
Leaky Bucket Additional Problems + Solutions By: Eng.Ola Abd El-Latif

Solution
Packet Arrival Time Departure Token Queued
umber (msec) Time Count Packets
0 2 empty
1 1 1 1 empty
2 1.1 1.1 0 empty
3 1.4 2 0 3
4 1.6 3 0 3,4
5 2.3 4 0 4,5
6 2.8 5 0 4,5,6
7 7.1 7.1 1 empty
8 8 8 1 empty
9 8.5 8.5 0 empty

To make it easily to understand we expand the table:


Packet Arrival Time Departure Token Queued
umber (msec) Time Count Packets
0 2 empty
1 1 1 1 empty
2 1.1 1.1 0 empty
3 1.4 2 0 3
4 1.6 3 0 3,4 At t=2 packet 3 depart
remove the generated
- 2 - 0 4
token
5 2.3 4 0 4,5
At t=3 packet 4 depart
6 2.8 5 0 4,5,6
remove the generated
- 3 - 0 5,6
token
- 4 - 0 6
- 5 - 0 empty At t=4 packet 5 depart
- 6 - 1 empty
remove the generated
token
- 7 - 2 empty
7 7.1 7.1 1 empty At t=5 packet 6 depart
8 8 8 1 empty remove the generated
token
9 8.5 8.5 0 empty
By: Eng.Ola Abd El-
El-LAtif
Leaky Bucket Additional Problems + Solutions By: Eng.Ola Abd El-Latif

Problem 5
You have constructed a Leaky bucket class in Java using a queue length of 3, two threads and a
timer. The Leaky bucket class operates on packets, one thread reads packets in and writes them
out if tokens are available. A second thread replenishes tokens at the rate of 1 token/2 time slot.
The maximum token count is 2. If possible. Given this packet arrival schedule,

Packet Arrive time


number slot
1 0
2 0
3 0
4 1
5 3
6 3
7 3
8 4
9 6
10 6

A. fill in the system state: token count, schedule departures, and queue packets, dropped
packets at each packet arrival time. The class is fast enough such that you can assume packets
are sent instantaneously, if possible. Initially the Leaky Bucket was full.
Solution

Time Packets Packets Token count Queue Dropped


slot arrived departure packets
0 1,2,3 1,2 0 3 -
1 4 - 0 3,4 -
2 - 3 0 4 -
3 5,6,7 - 0 4,5,6 7
4 8 4 0 5,6,8 -
5 - - 0 5,6,8 -
6 9,10 5 0 6,8,9 10
7 - - 0 6,8,9 -
8 - 6 0 8,9 -
9 - - 0 8,9 -
10 - 8 0 9 -
11 - - 0 9 -
12 - 9 0 - -
By: Eng.Ola Abd El-
El-LAtif
Leaky Bucket Additional Problems + Solutions By: Eng.Ola Abd El-Latif

B. Now consider the generation rate is changed to be 3 token/ time slot. What will differ??
Solution
Time Packets Packets Token count Queue Dropped
slot arrived departure packets
0 1,2,3 1,2 0 3 -
1 4 3,4 0 - -
2 - - 2 - -
3 5,6,7 5,6 0 7 -
4 8 7,8 0 - -
5 - - 2 - -
6 9,10 9,10 0 - -

Problem 6
The following packets arrive at the output port of a switch using a leaky bucket algorithm.
The bucket can contain up to 3000 bytes.

A. The leaky bucket operates on packets, and can send 1 packet every 3 milliseconds.
Assuming no packet arrives past time 10, show when packets leave and what
packet(s) are left in the buffer, if any, at time 10.
By: Eng.Ola Abd El-
El-LAtif
Leaky Bucket Additional Problems + Solutions By: Eng.Ola Abd El-Latif

B. If the leaky bucket operates on bytes, show the departure schedule if the algorithm
can send 1200 bytes every 3 milliseconds.

Solution

The algorithm can send

1200 bytes every 3 milliseconds

At t=4 2nd &3rd packets depart

400+400=800<1200

but 4th packet stay in the buffer


because

400+400+1000=1800>1200

Problem 7
Computer A has 240Mb to send on a network and transmits the data in bursts of
6 Mbps. The minimum sustainable transmission rate across routers in the network is
5 Mbps. If Computer A’s transmission is shaped using a leaky bucket, what is the
minimum size of the queue to prevent lost data? (Show your work)

Sol : The same idea as problem 1.

You might also like