# Token Bucket

1.7k views
Token Bucket mechanism is used for congestion control at router. Bucket capacity in 700 Bytes (initially full), token arrival rate is 200 Bytes/sec and maximum output rate is 300 Bytes/sec. The amount of time (in sec) required to transmit 3000 Bytes file is _____.

edited

700B Capacity of bucket which is initially filled.
Tokean Arrival Rate = 200 Bytes/Sec
Max Output Rate= 300 Bytes

Time to transmit 3000 Bytes?

Bursty Traffic Time =
C + P*S = M*S   (C=Bucket Capacity, P=Token Generating Rate, S=Bursty Time, M=Output Rate)
700 + 200*S = 300*S
S = 700/100 = 7 Seconds
For 7 seconds system will generate tokens at full speed of 300 Bytes/Sec, and after that it will switch to 200Bytes/Sec.

In 7 seconds at the speed of 300 Bytes/Sec, 2100 Bytes have been sent and left 900 bytes will be sent at the speed of

200 Bytes/sec which requires further 4.5 seconds.

So, Total time to send 3000 Bytes, it will take 7 + 4.5 = 11.5 Seconds

selected
0
why will it switch to 200 Bps after 7 seconds as 200Bps is arrival rate and not the output rate ?
1

This is the main difference between leaky bucket and token bucket. Token bucket algorithm allows idle hosts to accumulate while leaky bucket doesn't.
I mean to say here that, when host was idle and not sending data that time 700 bytes were filled in bucket so token bucket will take care of this data, later it will switch to normal and constant rate.

0
Thanks, I got it. My question is shouldn't the data be output as 300 Bps as it is the output rate ?
0
"shouldn't the data be output as 300 Bps as it is the output rate" then what is the use of token bucket?
0
Got it, thank you :)
0
@Manu Thankur bro from what i  undertsood the maximum output rate is the rate at which u can transfer at maximum and is set as per network the rate initially say for 2seconds is  700+200*2=1100/2 =550 bytes/sec but due to network limitation of max out put rate of 300 bytes/sec we can send only 300 bytes/sec rate and immedeatly the rate doesnt come down to 200 bytes/sec after 7 seconds it takes time infinite amount of time

Lt t---->infinity     (C+R*t)/t = R (input rate of tokens )

i think it is better to use this approach initially 700 bytes can be transmitted at time t=0 itself and for remaining 2300 bytes it takes 2300/200 =11.5 seconds so total 11.5 seconds just check this and correct me if i am wrong
0
Thanks buddy !
0

Can you please tell why token generation rate is taken as $300 Bps$, In question it has been given that token generation rate is 200 $BPS$ and from buket output data can go with a rate of $300Bps$.

As shown in the figure, $r$ tokens/sec is the token generation rate which is $200 Bps$ and Remove token rate is $300Bps$

3
For, the first 7 sec the bucket will be full of tokens.So, it will pump the data at the max O/p rate i.e. 300Bps.

After this 7 sec the tokens will get totally consumed so thenafter the o/p rate will equal to the Token Generation Rate i.e. 200Bps.

{ The Token generation rate is not 300Bps it is 200Bps...but for the first 7 sec (to calculate this time i.e. how long the transmission will be at max o/p rate, we apply the formula  ) the data is transmitted at the max o/p rate , that's it :) }

Hope This Helped ...
0

@Manu Thakur

if the token bucket is not initially filled then what will be the time?

1

If the token bucket is initially empty then :

Time to transmit 3000B= 3000/200 sec = 15 sec

0

@Nandkishor3939

so if the token bucket is initially empty then the transmission will not occur at max rate?

0
yes
0

After 5 sec it is returning to 200MBPS . Where am I doing wrong??

## Related questions

1
609 views
I want to understand the Token Bucket and Leaky Bucket algorithms in detail. Please provide links to reliable resources. Please do not provide link to Wikipedia, because there it is not explained properly
1 vote