i cant understand how seconds are calculated in the above example. why is 10s for 20mbps?

if 100mb traffic can pass through at an unrestricted speed, why is 20mbps for 10s?

is there an excel formula so we calculate easy how many mb or sec will be the burst result?

Because in 10 seconds, you will have earned another 100M of tokens.

It only takes 5sec @ 20M/s to spend 100M of tokens....

BUT during that 5 sec, you also earned 50M more tokens....

That 50M takes 2.5 sec to spend, while earning another 25M of tokens...

etc...

If you want a formula, it's basically this:

Time to empty/full = absval(Bucket Size * Token Rate / (Data Rate - Token Rate))

Time means "fill from empty" if the data rate is below the token rate, and it means "empty from full" if data rate is greater than token rate.

If they're the same, it's divide by zero, so avoid that.

Obviously this formula assumes a silly thing - a constant data rate.

Ultimately, though, it's not right to think in those terms - data rates are almost never constant, and it's impossible to predict whether a stream will "save up" its tokens or use them constantly, etc.