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

Routing algorithm
Routing algorithmRouting algorithm
Routing algorithmBushra M
 
Chapter 4 data link layer
Chapter 4 data link layerChapter 4 data link layer
Chapter 4 data link layerNaiyan Noor
 
Leaky bucket algorithm
Leaky bucket algorithmLeaky bucket algorithm
Leaky bucket algorithmUmesh Gupta
 
Principle source of optimazation
Principle source of optimazationPrinciple source of optimazation
Principle source of optimazationSiva Sathya
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Ravindra Raju Kolahalam
 
Peephole optimization techniques in compiler design
Peephole optimization techniques in compiler designPeephole optimization techniques in compiler design
Peephole optimization techniques in compiler designAnul Chaudhary
 
Issues in routing protocol
Issues in routing protocolIssues in routing protocol
Issues in routing protocolPradeep Kumar TS
 
Congestion control
Congestion controlCongestion control
Congestion controlAman Jaiswal
 
2. Distributed Systems Hardware & Software concepts
2. Distributed Systems Hardware & Software concepts2. Distributed Systems Hardware & Software concepts
2. Distributed Systems Hardware & Software conceptsPrajakta Rane
 
wireless network IEEE 802.11
 wireless network IEEE 802.11 wireless network IEEE 802.11
wireless network IEEE 802.11Shreejan Acharya
 
Congetion Control.pptx
Congetion Control.pptxCongetion Control.pptx
Congetion Control.pptxNaveen Dubey
 
Network Layer,Computer Networks
Network Layer,Computer NetworksNetwork Layer,Computer Networks
Network Layer,Computer Networksguesta81d4b
 
Network Layer design Issues.pptx
Network Layer design Issues.pptxNetwork Layer design Issues.pptx
Network Layer design Issues.pptxAcad
 
Congestion avoidance in TCP
Congestion avoidance in TCPCongestion avoidance in TCP
Congestion avoidance in TCPselvakumar_b1985
 

What's hot (20)

Routing algorithm
Routing algorithmRouting algorithm
Routing algorithm
 
Chapter 4 data link layer
Chapter 4 data link layerChapter 4 data link layer
Chapter 4 data link layer
 
Computer networks - Channelization
Computer networks - ChannelizationComputer networks - Channelization
Computer networks - Channelization
 
Leaky bucket algorithm
Leaky bucket algorithmLeaky bucket algorithm
Leaky bucket algorithm
 
Distance vector routing
Distance vector routingDistance vector routing
Distance vector routing
 
Congestion control in TCP
Congestion control in TCPCongestion control in TCP
Congestion control in TCP
 
Principle source of optimazation
Principle source of optimazationPrinciple source of optimazation
Principle source of optimazation
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]
 
Peephole optimization techniques in compiler design
Peephole optimization techniques in compiler designPeephole optimization techniques in compiler design
Peephole optimization techniques in compiler design
 
Issues in routing protocol
Issues in routing protocolIssues in routing protocol
Issues in routing protocol
 
Congestion control
Congestion controlCongestion control
Congestion control
 
2. Distributed Systems Hardware & Software concepts
2. Distributed Systems Hardware & Software concepts2. Distributed Systems Hardware & Software concepts
2. Distributed Systems Hardware & Software concepts
 
wireless network IEEE 802.11
 wireless network IEEE 802.11 wireless network IEEE 802.11
wireless network IEEE 802.11
 
Congetion Control.pptx
Congetion Control.pptxCongetion Control.pptx
Congetion Control.pptx
 
Network Layer,Computer Networks
Network Layer,Computer NetworksNetwork Layer,Computer Networks
Network Layer,Computer Networks
 
Network Layer design Issues.pptx
Network Layer design Issues.pptxNetwork Layer design Issues.pptx
Network Layer design Issues.pptx
 
PAC Learning
PAC LearningPAC Learning
PAC Learning
 
Csma cd and csma-ca
Csma cd and csma-caCsma cd and csma-ca
Csma cd and csma-ca
 
Congestion avoidance in TCP
Congestion avoidance in TCPCongestion avoidance in TCP
Congestion avoidance in TCP
 
Ethernet
EthernetEthernet
Ethernet
 

Similar to Leaky Bucket & Tocken Bucket - Traffic shaping

Congestion control algorithms.pptx
Congestion control algorithms.pptxCongestion control algorithms.pptx
Congestion control algorithms.pptxujjwalmatoliya
 
Congestion control
Congestion controlCongestion control
Congestion controlNithin Raj
 
congestion ujjwal matoliya.pptx
congestion ujjwal matoliya.pptxcongestion ujjwal matoliya.pptx
congestion ujjwal matoliya.pptxujjwalmatoliya
 
RIPE 80: Buffers and Protocols
RIPE 80: Buffers and ProtocolsRIPE 80: Buffers and Protocols
RIPE 80: Buffers and ProtocolsAPNIC
 
Example problems
Example problemsExample problems
Example problemsdeepakps22
 
Switching Problems.pdf
Switching Problems.pdfSwitching Problems.pdf
Switching Problems.pdfSenthil Vit
 
Congestion control 1
Congestion control 1Congestion control 1
Congestion control 1Aman Jaiswal
 
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.pdfMayankRaj687571
 
Tcp Congestion Avoidance
Tcp Congestion AvoidanceTcp Congestion Avoidance
Tcp Congestion AvoidanceRam Dutt Shukla
 
Availability Computer Communication Network .pdf
Availability Computer Communication Network .pdfAvailability Computer Communication Network .pdf
Availability Computer Communication Network .pdfYashShirude1
 
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 BBRAPNIC
 
Transmission
TransmissionTransmission
Transmissionmrhaken
 
Computer Networks Module 2.pdf
Computer Networks Module 2.pdfComputer Networks Module 2.pdf
Computer Networks Module 2.pdfShanthalaKV
 
Qo s metrics
Qo s metricsQo s metrics
Qo s metricswael-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

latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answersdalebeck957
 
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.pptxDr. Ravikiran H M Gowda
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
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_.pdfSherif Taha
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111GangaMaiya1
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfstareducators107
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
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_...Pooja Bhuva
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationNeilDeclaro1
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactisticshameyhk98
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningMarc Dusseiller Dusjagr
 

Recently uploaded (20)

latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answers
 
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
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
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
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
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_...
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactistics
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 

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.