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

Congestion control
Congestion controlCongestion control
Congestion controlAman Jaiswal
 
Congestion avoidance in TCP
Congestion avoidance in TCPCongestion avoidance in TCP
Congestion avoidance in TCPselvakumar_b1985
 
Routing algorithm
Routing algorithmRouting algorithm
Routing algorithmBushra M
 
Clock synchronization in distributed system
Clock synchronization in distributed systemClock synchronization in distributed system
Clock synchronization in distributed systemSunita Sahu
 
Block Cipher and its Design Principles
Block Cipher and its Design PrinciplesBlock Cipher and its Design Principles
Block Cipher and its Design PrinciplesSHUBHA CHATURVEDI
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Ravindra Raju Kolahalam
 
2. Distributed Systems Hardware & Software concepts
2. Distributed Systems Hardware & Software concepts2. Distributed Systems Hardware & Software concepts
2. Distributed Systems Hardware & Software conceptsPrajakta Rane
 
Issues in knowledge representation
Issues in knowledge representationIssues in knowledge representation
Issues in knowledge representationSravanthi Emani
 
Multi processor scheduling
Multi  processor schedulingMulti  processor scheduling
Multi processor schedulingShashank Kapoor
 
DATA RATE LIMITS
DATA RATE LIMITSDATA RATE LIMITS
DATA RATE LIMITSChAwais15
 
Packet switching
Packet switchingPacket switching
Packet switchingasimnawaz54
 
system interconnect architectures in ACA
system interconnect architectures in ACAsystem interconnect architectures in ACA
system interconnect architectures in ACAPankaj Kumar Jain
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating SystemsRitu Ranjan Shrivastwa
 

What's hot (20)

Error control
Error controlError control
Error control
 
Snmp
SnmpSnmp
Snmp
 
Congestion control
Congestion controlCongestion control
Congestion control
 
Sliding window protocol
Sliding window protocolSliding window protocol
Sliding window protocol
 
Kerberos
KerberosKerberos
Kerberos
 
Congestion avoidance in TCP
Congestion avoidance in TCPCongestion avoidance in TCP
Congestion avoidance in TCP
 
Routing algorithm
Routing algorithmRouting algorithm
Routing algorithm
 
5. protocol layering
5. protocol layering5. protocol layering
5. protocol layering
 
Clock synchronization in distributed system
Clock synchronization in distributed systemClock synchronization in distributed system
Clock synchronization in distributed system
 
Block Cipher and its Design Principles
Block Cipher and its Design PrinciplesBlock Cipher and its Design Principles
Block Cipher and its Design Principles
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]
 
2. Distributed Systems Hardware & Software concepts
2. Distributed Systems Hardware & Software concepts2. Distributed Systems Hardware & Software concepts
2. Distributed Systems Hardware & Software concepts
 
Issues in knowledge representation
Issues in knowledge representationIssues in knowledge representation
Issues in knowledge representation
 
Multi processor scheduling
Multi  processor schedulingMulti  processor scheduling
Multi processor scheduling
 
DATA RATE LIMITS
DATA RATE LIMITSDATA RATE LIMITS
DATA RATE LIMITS
 
Packet switching
Packet switchingPacket switching
Packet switching
 
system interconnect architectures in ACA
system interconnect architectures in ACAsystem interconnect architectures in ACA
system interconnect architectures in ACA
 
The medium access sublayer
 The medium  access sublayer The medium  access sublayer
The medium access sublayer
 
Multi Head, Multi Tape Turing Machine
Multi Head, Multi Tape Turing MachineMulti Head, Multi Tape Turing Machine
Multi Head, Multi Tape Turing Machine
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
 

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

Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 

Recently uploaded (20)

Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 

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.