Queuing Analysis of the Leaky Bucket • A “leaky bucket” is a mechanism for managing buffers to smooth the downstream flow. • What is described here is what is sometimes called a “token bucket”. • A queue holds a stock of “permits” which arrive at a rate r (one every 1/r seconds) up to W permits may be held. • A packet cannot leave the queue if there is no permit stored. • The idea is that the scheme limits downstream flow but can deal with bursts of traffic. Modelling the Leaky Bucket • Let us assume that the arrival process is a Poisson process with a rate • Consider how many packets arrive in 1/r seconds. The prob ak that k packets arrive is: Queue of permits (arrive at 1/r seconds) Queue of packets (Poisson) e / r ( / r ) k ak k! Exit queue for packets with permits Exit of buffer A Markov Model • Model this as a Markov Chain which changes state every 1/r seconds. • States 0iW represent no packets waiting and i-W permits available. States W+i (where i > 1) represent 0 permits and i packets waiting. a0 a1 i j 0 • Transition probabilities: pij ai j 1 j i 1 0 otherwise a2 0 a0+a1 a0 a2 1 a1 a0 2 a1 ... a2 W a1 a0 W+1 a1 ... Solving the Markov Model • By solving the balance equations we get: 0 a0 1 (a0 a1 ) 0 i 1 i ai j 1 j i 1 j 0 1 (1 a0 a1 ) 0 / a0 1 a2 0 a1 1 a0 2 0 (1 a0 a1 )(1 a1 ) 2 a2 a0 a0 Similarly, we can get expressions for 3 in terms of 2 ,1 and 0. And so on... Solving the Markov Model (2) • Normally we would solve this using the remaining balance equation: i 1 • This is difficult analytically in this case. i 0 • Instead we note that permits are generated every step except when we are in state 0 and no packets arrive (W permits none used). • This means permits are generated at a rate (1-0a0)r • This must be equal to since each packet gets a permit (assume none dropped while waiting). r 0 ra0 And Finally • The average delay for a packet to get a permit is given by: No of iterations Time taken for each iteration of chain Amount of time spent in given state taken to get out of queue from state j 1 T j ( j W ) r j W 1 For those states with queue • Of course this is not a closed form expression. To complete this analysis, look at Bertsekas P515