SlideShare a Scribd company logo
1 of 11
1

Traffic Shaping

•

It is about regulating average rate of data flow.

•

It is a method of congestion control by providing shape to data flow before entering the packet into
the network.

•

At connection set-up time, the sender and carrier negotiate a traffic pattern (shape)

•

There are two types of Traffic shaping algorithm :-

▫

1. Leaky Bucket Algorithm.

▫

2. Token Bucket Algorithm
2

Leaky Bucket Algorithm

•

The Leaky Bucket Algorithm used to control rate in a network.

•

It is implemented as a single-server queue with constant service time.

•

If the bucket (buffer) overflows then packets are discarded.

•

In this algorithm the input rate can vary but the output rate remains constant.

•

This algorithm saves busty traffic into fixed rate traffic by averaging the data rate.
3
The Leaky Bucket Algorithm

(a) A leaky bucket with water.

(b) a leaky bucket with packets.
4

Leaky Bucket Algorithm
Algorithm

Step - 1 : Initialize the counter to ‘n’ at every tick of clock.

Step - 2 : If n is greater than the size of packet in the front of queue send the packet into the network and
decrement the counter by size of packet. Repeat the step until n is less than the size of packet.

Step - 3 : Reset the counter and go to Step - 1.
5
Example
Let n = 1000
Packet =. 200

700

500

450

400

200

Since n > front of Queue i.e. n>200
Therefore, n= 1000-200 = 800
Packet size of 200 is sent to the network
200

700

500

450

400

Now Again n > front of queue i.e. n > 400
Therefore, n= 800-400 = 400
Packet size of 400 is sent to the network
200

700

500

450

Since n < front of queue .
There fore, the procedure is stop.
And we initialize n = 1000 on another tick of clock.
This procedure is repeated until all the packets is sent to the network.
6
Leaky Bucket Algorithm

Example
Consider a frame relay network having a capacity of 1Mb and data is input at the rate of 25mbps.Calculate
1. What is the time needed to fill the bucket.
2. If the output rate is 2 mbps , the time needed to empty the bucket.
Ans.
Here ,
C is Capacity of bucket = 1mb
Data input rate = 25 mbps
output rate = 2mbps.
1.

T = C/input rate

= 1/25

= 40 msec

2

T = C/output rate

= ½

= 500 msec
7

Token Bucket Algorithm

•

The Token Bucket Algorithm compare to Leaky Bucket Algorithm allow the output rate vary
depending on the size of burst.

•

In this algorithm the buckets holds token to transmit a packet, the host must capture and destroy
one token.

•

Tokens are generated by a clock at the rate of one token every t sec.

•

Idle hosts can capture and save up tokens (up to the max. size of the bucket) in order to send
larger bursts later.
8
Token Bucket Algorithm

5-34

(a) Before

(b) After
9

Token Bucket Algorithm
Algorithm

Step - 1 : A token is added at every ∆t time.
Step - 2 : The bucket can hold at most b-tokens. If a token arrive when bucket is full it is discarded.
Step - 3 : When a packet of m bytes arrived m tokens are removed from the bucket and the packet is sent to
the network.
Step – 4 : If less than n tokens are available no tokens are removed from the buckets and the packet is
considered to be non conformant.
The non conformant packet may be enqueued for subsequent transmission when sufficient token have been
accumulated in the bucket.
If C is the maximum capacity of bucket and ρ is the arrival rate and M is the maximum output rate then Burst
Length S can be calculated as

C + ρS = MS
10
Token Bucket Algorithm
Example
Consider a frame relay network having a capacity of 1Mb of data is arriving at the rate of 25mbps for 40msec.The
Token arrival rate is 2mbps and the capacity of bucket is 500 kb with maximum output rate 25mbps.Calculate
1. The Burst Length.
2. Total output time.
Ans.
Here ,
C is Capacity of bucket = 500kb
M= 25 mbps
ρ = 2mbps.
1.

S= 500/((25-2)*1000) = 21.73msec ~= 22msec

2

For 22msec the output rate is 25msec after that the output rate becomes 2mbps i.e. token arrival rate.
Therefore, for another 500 kb the time taken will be.
500/(2000) = 250 msec
Therefore, total output time = 22 +250 = 272 msec.
11
DIFFERENCE BETWEEN LEAKY BUCKET AND TOKEN BUCKET ALGORITHM
TOKEN BUCKET

LEAKY BUCKET

Token dependent.

Token independent.

If bucket is full token are discarded, but not the
packet.

If bucket is full packet or data is discarded.

Packets can only transmitted when there are
enough token

Packets are transmitted continuously.

It allows large bursts to be sent faster rate after
that constant rate

It sends the packet at constant rate

It saves token to send large bursts.

It does not save token.

More Related Content

What's hot

15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
koolkampus
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back tracking
Tech_MX
 

What's hot (20)

Error Detection And Correction
Error Detection And CorrectionError Detection And Correction
Error Detection And Correction
 
Chess board problem(divide and conquer)
Chess board problem(divide and conquer)Chess board problem(divide and conquer)
Chess board problem(divide and conquer)
 
Computer network switching
Computer network switchingComputer network switching
Computer network switching
 
Network Layer,Computer Networks
Network Layer,Computer NetworksNetwork Layer,Computer Networks
Network Layer,Computer Networks
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
 
Congestion control
Congestion controlCongestion control
Congestion control
 
Multiplexing
MultiplexingMultiplexing
Multiplexing
 
Framing in data link layer
Framing in data link layerFraming in data link layer
Framing in data link layer
 
Flow control in Computer Network
Flow control in Computer NetworkFlow control in Computer Network
Flow control in Computer Network
 
Stop and-wait protocol
Stop and-wait protocolStop and-wait protocol
Stop and-wait protocol
 
Learning set of rules
Learning set of rulesLearning set of rules
Learning set of rules
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back tracking
 
Issues in routing protocol
Issues in routing protocolIssues in routing protocol
Issues in routing protocol
 
Cloud computing protocol
Cloud computing protocolCloud computing protocol
Cloud computing protocol
 
Routing algorithm
Routing algorithmRouting algorithm
Routing algorithm
 
Message passing in Distributed Computing Systems
Message passing in Distributed Computing SystemsMessage passing in Distributed Computing Systems
Message passing in Distributed Computing Systems
 
Computer networks - Channelization
Computer networks - ChannelizationComputer networks - Channelization
Computer networks - Channelization
 
2. forward chaining and backward chaining
2. forward chaining and backward chaining2. forward chaining and backward chaining
2. forward chaining and backward chaining
 
First order predicate logic (fopl)
First order predicate logic (fopl)First order predicate logic (fopl)
First order predicate logic (fopl)
 
Transport layer protocol
Transport layer protocolTransport layer protocol
Transport layer protocol
 

Similar to Leaky Bucket & Tocken Bucket - Traffic shaping

Availability Computer Communication Network .pdf
Availability Computer Communication Network .pdfAvailability Computer Communication Network .pdf
Availability Computer Communication Network .pdf
YashShirude1
 
Transmission
TransmissionTransmission
Transmission
mrhaken
 
Qo s metrics
Qo s metricsQo s metrics
Qo s metrics
wael-b1
 

Similar to Leaky Bucket & Tocken Bucket - Traffic shaping (20)

Leaky bucket A
Leaky bucket ALeaky bucket A
Leaky bucket A
 
Congestion control algorithms.pptx
Congestion control algorithms.pptxCongestion control algorithms.pptx
Congestion control algorithms.pptx
 
Congestion control
Congestion controlCongestion control
Congestion control
 
Part9-congestion.pptx
Part9-congestion.pptxPart9-congestion.pptx
Part9-congestion.pptx
 
9_Network.ppt
9_Network.ppt9_Network.ppt
9_Network.ppt
 
congestion ujjwal matoliya.pptx
congestion ujjwal matoliya.pptxcongestion ujjwal matoliya.pptx
congestion ujjwal matoliya.pptx
 
RIPE 80: Buffers and Protocols
RIPE 80: Buffers and ProtocolsRIPE 80: Buffers and Protocols
RIPE 80: Buffers and Protocols
 
Conjestion control
Conjestion controlConjestion control
Conjestion control
 
Example problems
Example problemsExample problems
Example problems
 
Switching Problems.pdf
Switching Problems.pdfSwitching Problems.pdf
Switching Problems.pdf
 
Congestion control 1
Congestion control 1Congestion control 1
Congestion control 1
 
CN Module 5 part 2 2022.pdf
CN Module 5 part 2 2022.pdfCN Module 5 part 2 2022.pdf
CN Module 5 part 2 2022.pdf
 
Tcp Congestion Avoidance
Tcp Congestion AvoidanceTcp Congestion Avoidance
Tcp Congestion Avoidance
 
QoSintro.PPT
QoSintro.PPTQoSintro.PPT
QoSintro.PPT
 
Availability Computer Communication Network .pdf
Availability Computer Communication Network .pdfAvailability Computer Communication Network .pdf
Availability Computer Communication Network .pdf
 
NZNOG 2020: Buffers, Buffer Bloat and BBR
NZNOG 2020: Buffers, Buffer Bloat and BBRNZNOG 2020: Buffers, Buffer Bloat and BBR
NZNOG 2020: Buffers, Buffer Bloat and BBR
 
Transmission
TransmissionTransmission
Transmission
 
Quality of service
Quality of serviceQuality of service
Quality of service
 
Computer Networks Module 2.pdf
Computer Networks Module 2.pdfComputer Networks Module 2.pdf
Computer Networks Module 2.pdf
 
Qo s metrics
Qo s metricsQo s metrics
Qo s metrics
 

Recently uploaded

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Recently uploaded (20)

TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 

Leaky Bucket & Tocken Bucket - Traffic shaping

  • 1. 1 Traffic Shaping • It is about regulating average rate of data flow. • It is a method of congestion control by providing shape to data flow before entering the packet into the network. • At connection set-up time, the sender and carrier negotiate a traffic pattern (shape) • There are two types of Traffic shaping algorithm :- ▫ 1. Leaky Bucket Algorithm. ▫ 2. Token Bucket Algorithm
  • 2. 2 Leaky Bucket Algorithm • The Leaky Bucket Algorithm used to control rate in a network. • It is implemented as a single-server queue with constant service time. • If the bucket (buffer) overflows then packets are discarded. • In this algorithm the input rate can vary but the output rate remains constant. • This algorithm saves busty traffic into fixed rate traffic by averaging the data rate.
  • 3. 3 The Leaky Bucket Algorithm (a) A leaky bucket with water. (b) a leaky bucket with packets.
  • 4. 4 Leaky Bucket Algorithm Algorithm Step - 1 : Initialize the counter to ‘n’ at every tick of clock. Step - 2 : If n is greater than the size of packet in the front of queue send the packet into the network and decrement the counter by size of packet. Repeat the step until n is less than the size of packet. Step - 3 : Reset the counter and go to Step - 1.
  • 5. 5 Example Let n = 1000 Packet =. 200 700 500 450 400 200 Since n > front of Queue i.e. n>200 Therefore, n= 1000-200 = 800 Packet size of 200 is sent to the network 200 700 500 450 400 Now Again n > front of queue i.e. n > 400 Therefore, n= 800-400 = 400 Packet size of 400 is sent to the network 200 700 500 450 Since n < front of queue . There fore, the procedure is stop. And we initialize n = 1000 on another tick of clock. This procedure is repeated until all the packets is sent to the network.
  • 6. 6 Leaky Bucket Algorithm Example Consider a frame relay network having a capacity of 1Mb and data is input at the rate of 25mbps.Calculate 1. What is the time needed to fill the bucket. 2. If the output rate is 2 mbps , the time needed to empty the bucket. Ans. Here , C is Capacity of bucket = 1mb Data input rate = 25 mbps output rate = 2mbps. 1. T = C/input rate = 1/25 = 40 msec 2 T = C/output rate = ½ = 500 msec
  • 7. 7 Token Bucket Algorithm • The Token Bucket Algorithm compare to Leaky Bucket Algorithm allow the output rate vary depending on the size of burst. • In this algorithm the buckets holds token to transmit a packet, the host must capture and destroy one token. • Tokens are generated by a clock at the rate of one token every t sec. • Idle hosts can capture and save up tokens (up to the max. size of the bucket) in order to send larger bursts later.
  • 9. 9 Token Bucket Algorithm Algorithm Step - 1 : A token is added at every ∆t time. Step - 2 : The bucket can hold at most b-tokens. If a token arrive when bucket is full it is discarded. Step - 3 : When a packet of m bytes arrived m tokens are removed from the bucket and the packet is sent to the network. Step – 4 : If less than n tokens are available no tokens are removed from the buckets and the packet is considered to be non conformant. The non conformant packet may be enqueued for subsequent transmission when sufficient token have been accumulated in the bucket. If C is the maximum capacity of bucket and ρ is the arrival rate and M is the maximum output rate then Burst Length S can be calculated as C + ρS = MS
  • 10. 10 Token Bucket Algorithm Example Consider a frame relay network having a capacity of 1Mb of data is arriving at the rate of 25mbps for 40msec.The Token arrival rate is 2mbps and the capacity of bucket is 500 kb with maximum output rate 25mbps.Calculate 1. The Burst Length. 2. Total output time. Ans. Here , C is Capacity of bucket = 500kb M= 25 mbps ρ = 2mbps. 1. S= 500/((25-2)*1000) = 21.73msec ~= 22msec 2 For 22msec the output rate is 25msec after that the output rate becomes 2mbps i.e. token arrival rate. Therefore, for another 500 kb the time taken will be. 500/(2000) = 250 msec Therefore, total output time = 22 +250 = 272 msec.
  • 11. 11 DIFFERENCE BETWEEN LEAKY BUCKET AND TOKEN BUCKET ALGORITHM TOKEN BUCKET LEAKY BUCKET Token dependent. Token independent. If bucket is full token are discarded, but not the packet. If bucket is full packet or data is discarded. Packets can only transmitted when there are enough token Packets are transmitted continuously. It allows large bursts to be sent faster rate after that constant rate It sends the packet at constant rate It saves token to send large bursts. It does not save token.