Modelling data networks stochastic processes and Markov chains

Similar documents
Modelling data networks stochastic processes and Markov chains

Recap. Probability, stochastic processes, Markov chains. ELEC-C7210 Modeling and analysis of communication networks

Solutions For Stochastic Process Final Exam

MARKOV PROCESSES. Valerio Di Valerio

reversed chain is ergodic and has the same equilibrium probabilities (check that π j =

Math 304 Handout: Linear algebra, graphs, and networks.

Lecture 7: Simulation of Markov Processes. Pasi Lassila Department of Communications and Networking

4452 Mathematical Modeling Lecture 16: Markov Processes

Introduction to Queuing Networks Solutions to Problem Sheet 3

Online Social Networks and Media. Link Analysis and Web Search

Part I Stochastic variables and Markov chains

Statistics 253/317 Introduction to Probability Models. Winter Midterm Exam Friday, Feb 8, 2013

Stochastic process. X, a series of random variables indexed by t

Introduction to Markov Chains, Queuing Theory, and Network Performance

Lecture Notes 7 Random Processes. Markov Processes Markov Chains. Random Processes

Introduction to queuing theory

Networking = Plumbing. Queueing Analysis: I. Last Lecture. Lecture Outline. Jeremiah Deng. 29 July 2013

The story of the film so far... Mathematics for Informatics 4a. Continuous-time Markov processes. Counting processes

Online Social Networks and Media. Link Analysis and Web Search

IEOR 6711: Stochastic Models I, Fall 2003, Professor Whitt. Solutions to Final Exam: Thursday, December 18.

Lecture 20: Reversible Processes and Queues

Figure 10.1: Recording when the event E occurs

Markov Chain Model for ALOHA protocol

DATA MINING LECTURE 13. Link Analysis Ranking PageRank -- Random walks HITS

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science

Question Points Score Total: 70

Law of large numbers for Markov chains

COMP9334 Capacity Planning for Computer Systems and Networks

Birth-Death Processes

CS 798: Homework Assignment 3 (Queueing Theory)

Markov chains. 1 Discrete time Markov chains. c A. J. Ganesh, University of Bristol, 2015

CS 237: Probability in Computing

Markov Processes and Queues

PageRank. Ryan Tibshirani /36-662: Data Mining. January Optional reading: ESL 14.10

LECTURE #6 BIRTH-DEATH PROCESS

MAT SYS 5120 (Winter 2012) Assignment 5 (not to be submitted) There are 4 questions.

Readings: Finish Section 5.2

Introduction to Queuing Theory. Mathematical Modelling

Lab 8: Measuring Graph Centrality - PageRank. Monday, November 5 CompSci 531, Fall 2018

MITOCW MIT6_041F11_lec17_300k.mp4

Random walks, Markov chains, and how to analyse them

Let (Ω, F) be a measureable space. A filtration in discrete time is a sequence of. F s F t

Stochastic Processes

Data analysis and stochastic modeling

Introduction to Algebra: The First Week

Stochastic Modelling Unit 1: Markov chain models

MAS275 Probability Modelling Exercises

NICTA Short Course. Network Analysis. Vijay Sivaraman. Day 1 Queueing Systems and Markov Chains. Network Analysis, 2008s2 1-1

Stochastic Models in Computer Science A Tutorial

Continuous-time Markov Chains

Performance Evaluation of Queuing Systems

EE126: Probability and Random Processes

Notes on Continuous Random Variables

FDST Markov Chain Models

MATH 56A: STOCHASTIC PROCESSES CHAPTER 1

Class 11 Non-Parametric Models of a Service System; GI/GI/1, GI/GI/n: Exact & Approximate Analysis.

Homework 4 due on Thursday, December 15 at 5 PM (hard deadline).

arxiv: v1 [math.ho] 25 Feb 2008

Graph Models The PageRank Algorithm

Introduction to Queueing Theory

Markov Chains. Arnoldo Frigessi Bernd Heidergott November 4, 2015

Lecture Notes of Communication Network I y: part 5. Lijun Qian. Rutgers The State University of New Jersey. 94 Brett Road. Piscataway, NJ

STOCHASTIC PROCESSES Basic notions

1 Ways to Describe a Stochastic Process

Statistics 433 Practice Final Exam: Cover Sheet and Marking Sheet

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science

Queueing Theory. VK Room: M Last updated: October 17, 2013.

Lesson Plan. AM 121: Introduction to Optimization Models and Methods. Lecture 17: Markov Chains. Yiling Chen SEAS. Stochastic process Markov Chains

Link Mining PageRank. From Stanford C246

Answers to selected exercises

Stat 150 Practice Final Spring 2015

ISE/OR 760 Applied Stochastic Modeling

Queuing Networks: Burke s Theorem, Kleinrock s Approximation, and Jackson s Theorem. Wade Trappe

1/2 1/2 1/4 1/4 8 1/2 1/2 1/2 1/2 8 1/2 6 P =

Queuing Networks. - Outline of queuing networks. - Mean Value Analisys (MVA) for open and closed queuing networks

Link Models for Circuit Switching

Introduction to Queueing Theory

Degree Distribution: The case of Citation Networks

Methodology for Computer Science Research Lecture 4: Mathematical Modeling

CPSC 531: System Modeling and Simulation. Carey Williamson Department of Computer Science University of Calgary Fall 2017

MATH 521, WEEK 2: Rational and Real Numbers, Ordered Sets, Countable Sets

Page rank computation HPC course project a.y

Probability and Statistics Concepts

NANYANG TECHNOLOGICAL UNIVERSITY SEMESTER I EXAMINATION MH4702/MAS446/MTH437 Probabilistic Methods in OR

Chapter 5. Continuous-Time Markov Chains. Prof. Shun-Ren Yang Department of Computer Science, National Tsing Hua University, Taiwan

Queueing Theory I Summary! Little s Law! Queueing System Notation! Stationary Analysis of Elementary Queueing Systems " M/M/1 " M/M/m " M/M/1/K "

CDA5530: Performance Models of Computers and Networks. Chapter 3: Review of Practical

Session-Based Queueing Systems

Review of Queuing Models

Guidelines for Solving Probability Problems

Examination paper for TMA4265 Stochastic Processes

The Theory behind PageRank

T 1. The value function v(x) is the expected net gain when using the optimal stopping time starting at state x:

Queueing systems. Renato Lo Cigno. Simulation and Performance Evaluation Queueing systems - Renato Lo Cigno 1

A Study on Performance Analysis of Queuing System with Multiple Heterogeneous Servers

The exponential distribution and the Poisson process

ECEN 689 Special Topics in Data Science for Communications Networks

MITOCW MIT6_041F11_lec15_300k.mp4

Link Analysis. Leonid E. Zhukov

SOLUTIONS IEOR 3106: Second Midterm Exam, Chapters 5-6, November 8, 2012

Transcription:

Modelling data networks stochastic processes and Markov chains a 1, 3 1, 2 2, 2 b 0, 3 2, 3 u 1, 3 α 1, 6 c 0, 3 v 2, 2 β 1, 1 Richard G. Clegg (richard@richardclegg.org) December 2011 Available online at http://www.richardclegg.org/lectures accompanying printed notes provide full bibliography. (Prepared using LATEX and beamer.)

Introduction to stochastic processes and Markov chains Stochastic processes A stochastic process describes how a system behaves over time an arrival process describes how things arrive to a system. Markov chains Markov chains describe the evolution of a system in time in particular they are useful for queuing theory. (A markov chain is a stochastic process).

Stochastic processes Stochastic process Let X (t) be some value (or vector of values) which varies in time t. Think of the stochastic process as the rules for how X (t) changes with t. Note: t may be discrete (t = 0, 1, 2,...) or continuous. Poisson process A process where the change in X (t) from time t 1 to t 2 is a Poisson distribution, that is X (t 2 ) X (t 2 ) follows a Poisson distribution.

A simple stochastic process the drunkard s walk Random walk or drunkard s walk A man walks home from the pub. He starts at a distance X (0) from some point. At every step he (randomly) gets either one unit closer (probability p) or one unit further away. { X (t) + 1 probability p X (t + 1) = X (t) 1 probability 1 p. Can answer questions like where, on average, will he be at time t?

Drunkard s walk p = 0.5, X (0) = 0

Drunkard s walk p = 0.5, X (0) = 0 What is the expected value of X (t), that is, E [X (t)]? E [X (t)] = 0.5(X (t 1) + 1) + 0.5(X (t 1) 1) = 0.5(X (t 1) + X (t 1)) + 0.5(1 1) = X (t 1).

Drunkard s walk p = 0.5, X (0) = 0 What is the expected value of X (t), that is, E [X (t)]? E [X (t)] = 0.5(X (t 1) + 1) + 0.5(X (t 1) 1) = 0.5(X (t 1) + X (t 1)) + 0.5(1 1) = X (t 1). Therefore E [X (t)] = X (0) = 0 the poor drunk makes no progress towards his house (on average).

Drunkard s walk p = 0.5, X (0) = 0 What is the expected value of X (t), that is, E [X (t)]? E [X (t)] = 0.5(X (t 1) + 1) + 0.5(X (t 1) 1) = 0.5(X (t 1) + X (t 1)) + 0.5(1 1) = X (t 1). Therefore E [X (t)] = X (0) = 0 the poor drunk makes no progress towards his house (on average). E [ X (t) 2] = 0.5(X (t 1) + 1) 2 + 0.5(X (t 1) 1) 2 = X (t 1) 2 + 1. Therefore E [ X (t) 2] = t on average the drunk does get further from the starting pub.

Drunkard s walk p = 0.5, X (0) = 0 What is the expected value of X (t), that is, E [X (t)]? E [X (t)] = 0.5(X (t 1) + 1) + 0.5(X (t 1) 1) = 0.5(X (t 1) + X (t 1)) + 0.5(1 1) = X (t 1). Therefore E [X (t)] = X (0) = 0 the poor drunk makes no progress towards his house (on average). E [ X (t) 2] = 0.5(X (t 1) + 1) 2 + 0.5(X (t 1) 1) 2 = X (t 1) 2 + 1. Therefore E [ X (t) 2] = t on average the drunk does get further from the starting pub. This silly example has many uses in physics and chemistry (Brownian motion) not to mention gambling (coin tosses).

The Poisson process The Poisson process Let X (t) with (t 0) and X (0) = 0 be a Poisson process with rate λ. Let t 2, t 1 be two times such that t 2 > t 1. Let τ = t 2 t 1. [ ] (λτ) n P [X (t 2 ) X (t 1 ) = n] = exp[ (λτ)], n! for n = 0, 1, 2,.... In other words, the number of arrivals in some time period τ follows a Poisson distribution with rate λτ.

The special nature of the Poisson process The Poisson process is in many ways the simplest stochastic process of all. This is why the Poisson process is so commonly used. Imagine your system has the following properties: The number of arrivals does not depend on the number of arrivals so far. No two arrivals occur at exactly the same instant in time. The number of arrivals in time period τ depends only on the length of τ. The Poisson process is the only process satisfying these conditions (see notes for proof).

Some remarkable things about Poisson processes The mean number of arrivals in a period τ is λτ (see notes). If two Poisson processes arrive together with rates λ 1 and λ 2 the arrival process is a Poisson process with rate λ 1 + λ 2. In fact this is a general result for n Poisson processes. If you randomly sample a Poisson process e.g. pick arrivals with probability p, the sampled process is Poisson, rate pλ. This makes Poisson processes easy to deal with. Many things in computer networks really are Poisson processes (e.g. people logging onto a computer or requesting web pages). The Poisson process is also memoryless as the next section explains.

The interarrival time the exponential distribution The exponential distribution An exponential distribution for a variable T takes this form: { 1 exp[ (λt)], t 0, P [T t] = 0 t < 0. The time between packets is called the interarrival time the time between arrivals. For a Poisson process this follows the exponential distribution (above). This is easily shown the probability of an arrival occuring before time t is one minus the probability of no arrivals occuring up until time t. The probability of no arrivals occuring during a time period t is (λt) 0 exp[ (λt)]/0! = exp[ (λt)]. The mean interarrival time is 1/λ.

The memoryless nature of the Poisson process There is something strange to be noticed here the distribution of our interarrival time T was given by P [T t] = 1 exp[ (λt) for t 0. However, if looked at the Poisson process at any instant and asked how long must we wait for the next arrival? the answer is just the same 1/λ. Exactly the same argument can be made for any arrival time. The probability of no arrivals in the next t seconds does not change because an arrival has just happened. The expected waiting time for the next arrival does not change if you have been waiting for just one second, or for an hour or for many years the average time to the next arrival is still the same 1/λ.

The Poisson bus dilemma X (t) Consider you arrive at the bus stop at a random time. Buses arrive as a Poisson process with a given rate λ. Buses are (on average) 30 minutes apart 1/λ = 30 minutes. How long do you wait for the bus on average?

The Poisson bus dilemma X (t) Consider you arrive at the bus stop at a random time. Buses arrive as a Poisson process with a given rate λ. Buses are (on average) 30 minutes apart 1/λ = 30 minutes. How long do you wait for the bus on average? Bus passenger 1: Obviously 15 minutes the buses are 30 minutes apart, on average I arrive half way through that period.

The Poisson bus dilemma X (t) Consider you arrive at the bus stop at a random time. Buses arrive as a Poisson process with a given rate λ. Buses are (on average) 30 minutes apart 1/λ = 30 minutes. How long do you wait for the bus on average? Bus passenger 1: Obviously 15 minutes the buses are 30 minutes apart, on average I arrive half way through that period. Bus passenger 2: Obviously 30 minutes the buses are a Poisson process and memoryless. The average waiting time is 30 minutes no matter when the last bus was or when I arrive.

The Poisson bus dilemma X (t) Consider you arrive at the bus stop at a random time. Buses arrive as a Poisson process with a given rate λ. Buses are (on average) 30 minutes apart 1/λ = 30 minutes. How long do you wait for the bus on average? Bus passenger 1: Obviously 15 minutes the buses are 30 minutes apart, on average I arrive half way through that period. Bus passenger 2: Obviously 30 minutes the buses are a Poisson process and memoryless. The average waiting time is 30 minutes no matter when the last bus was or when I arrive. So, who is correct?

The Poisson bus dilemma solution So, is the answer 15 minutes, 30 minutes or something else.

The Poisson bus dilemma solution So, is the answer 15 minutes, 30 minutes or something else. 30 minutes is the correct answer (as the Poisson process result show us). To see why the 15 minutes answer is wrong consider the diagram. The average gap between buses is 30 minutes. The average passenger does wait for half of the interarrival gap he or she arrives during. However, the average passenger is likely to arrive in a larger than average gap (see diagram). We do not need to prove that the answer is 30 minutes the proof is already there for the Poisson process. long gaps short gaps time

Introducing Markov chains Markov Chains Markov chains are an elegant and useful mathematical tool used in many applied areas of mathematics and engineer but particularly in queuing theory. Useful when a system can be in a countable number of states (e.g. number of people in a queue, number of packets in a buffer and so on). Useful when transitions between states can be considered as a probabilistic process. Helps us analyse queues.

Introducing Markov chains the hippy hitchhiker A 3/4 1/3 1/4 1/2 1/2 C B 2/3 The hippy hiker moves between A-town, B-town and C-town. He moves once and only once per day. He does not remember what town he has been in (short term memory issues) He moves with probabilities as shown on the diagram.

The hippy hitcher (2) Want to answer questions such as: What is probability he is in A-town on day n? Where is he most likely to B 2/3 end up? First step make system formal. Numbered states for towns 0, 1 2 for A, B, C. Let p ij be the probability of moving from town i to j on a day (p ii = 0). Let λ i,j be the probability he is in town j on day i. Let λ i = (λ i,0, λ i,1, λ i,2 ) be the vector of probabilities for day i. For example λ 0 = (1, 0, 0) means definitely in A town (0) on day 0. 3/4 1/3 A 1/2 1/4 1/2 C

The hippy hitcher (3) Define the probability transition matrix P. Write down the equation for day n in terms of day n + 1. We have: λ j,n = i λ i,n 1p ij. Transition matrix P = 3/4 B 1/3 p 00 p 01 p 02 p 10 p 11 p 12 p 20 p 21 p 22 A 1/2 1/4 2/3. 1/2 C Matrix equation is λ i = λ i 1 P.

Equilibrium probabilities The matrix equation lets us calculate probabilities on a given day but where does hippy end up. Define equilibrium probabilities for states π i = lim n λ n,i. Think of this as probability hippy is in town i as time goes on. Define equilibrium vector π = (π 0, π 1, π 2 ). Can be shown that for a finite connected aperiodic chain this vector exists is unique and does not depend on start. From λ i = λ i 1 P then π = πp. This vector and the requirement that probabilities sum to one uniquely defines π i for all i.

Equilibrium probabilities balance equations The matrix equation for π can also be thought of as balance equations. That is in equilbrium, at every state the flow in a state is the sum of the flow going into it. π j = i p ijπ i for all j (in matrix terms π = πp). This and i π i = 1 are enough to solve the equations for π i.

Equilibrium probabilities balance equations The matrix equation for π can also be thought of as balance equations. That is in equilbrium, at every state the flow in a state is the sum of the flow going into it. π j = i p ijπ i for all j (in matrix terms π = πp). This and i π i = 1 are enough to solve the equations for π i. π 0 + π 1 + π 2 = 1 probabilities sum to one π 1 p 10 + π 2 p 20 = π 0 balance for city 0 π 0 p 01 + π 2 p 21 = π 1 balance for city 1 π 0 p 02 + π 2 p 12 = π 2 balance for city 2 Solves as π 0 = 16/55, π 1 = 21/55 and π 2 = 18/55 for hippy.

Markov chain summary A Markov chain is defined by a set of states and the probability of moving between them. This type of Markov chain is a discrete time homogeneous markov chain. Continuous time Markov chains allow transitions at any time not just once per day. Heterogenous Markov chains allow the transition probabilities to vary as time changes. Like the Poisson process, the Markov chain is memoryless. Markov chains can be used in many types of problem solving, particularly queues.

Markov recap Before going on to do some examples, a recap. p ij is the transition probability the probability of moving from state i to state j the next iteration of the chain. The transition matrix P is the matrix of the p ij. π i is the equilibrium probability the probability that after a long time the chain will be in state i. The sum of π i must be one (the chain must be in some state). Each state has a balance equation π i = j π jp ji. The balance equations together with the sum of π i will solve the chain (one redundant equation why?).

The talking on the phone example If I am talking on the phone, there is a probability t (for talk) that I will still be talking on the phone in the next minute. If I am not talking on the phone, there is a probability c (for call) that I will call someone in the next minute. Taking things minute by minute, what is the probability I am talking on the phone in a given minute? Unsurprisingly this can be modelled as a Markov chain. This example may seem trivial but several such chains could be use to model how occupied the phone network is.

The talking on the phone example 1-t t 0 1 talking c not talking 1-c Our chain has two states 0 and 1 and the transition matrix: [ ] t 1 t P =. c 1 c The balance equations are π 0 = p 00 π 0 + p 10 π 1 π 1 = p 01 π 0 + p 11 π 1,

The talking on the phone example 1-t t 0 1 talking c not talking 1-c Our chain has two states 0 and 1 and the transition matrix: [ ] t 1 t P =. c 1 c The balance equations are which become π 0 = p 00 π 0 + p 10 π 1 π 1 = p 01 π 0 + p 11 π 1, π 0 = tπ 0 + cπ 1 π 1 = (1 t)π 0 + (1 c)π 1.

The talking on the phone example 1-t t 0 1 talking c not talking 1-c π 0 = tπ 0 + cπ 1. We also know π 0 + π 1 = 1 therefore π 0 = tπ 0 + c(1 π 0 )

The talking on the phone example 1-t t 0 1 talking c not talking 1-c π 0 = tπ 0 + cπ 1. We also know π 0 + π 1 = 1 therefore π 0 = tπ 0 + c(1 π 0 ) and π 0 (1 + c t) = c.

The talking on the phone example 1-t t 0 1 talking c not talking 1-c π 0 = tπ 0 + cπ 1. We also know π 0 + π 1 = 1 therefore π 0 = tπ 0 + c(1 π 0 ) and π 0 (1 + c t) = c. Therefore π 0 = c/(1 + c t) and π 1 = (1 t)/(1 + c t).

The google page rank example Did you know google owes part of its success to Markov chains? Pagerank (named after Larry Page) was how google originally ranked search queries. Pagerank tries to work out which web page matching a search term is the most important. Pages with many links to them are very important but it is also important that the importance of the linking page counts. Here we consider a very simplified version. (Note that Larry Page is now a multi-billionaire thanks to Markov chains).

kittenweb pagerank example My bumper web page about cats 0 Kitten pics 1 Cat web Lol Cats 2 3 Imagine these four web pages are every web page about kittens and cats on the web. An arrow indicates a link from one page to another e.g. Lol cats and Cat web link to each other.

Kittenweb pagerank example My bumper web page about cats 0 Kitten pics 1 Cat web 2 Lol Cats 3 Now think of a user randomly clicking on cats/kittens links. What page will the user visit most often this is a Markov chain. Lolcats links to two other pages so 1/2 probability of visiting Cat web next. Cat web only links to Lol cats so probability 1 of visiting that next.

Kittenweb pagerank example My bumper web page about cats 0 Kitten pics 1 Cat web 2 Lol Cats 3 P = 0 0 0 1 1/2 0 0 1/2 0 0 0 1 0 1/2 1/2 0.

Kittenweb pagerank example My bumper web page about cats 0 Kitten pics 1 Cat web Lol Cats 2 3 P = 0 0 0 1 1/2 0 0 1/2 0 0 0 1 0 1/2 1/2 0. π 0 = π 1 /2 π 1 = π 3 /2 π 2 = π 3 /2 miss equation for π 3 π 0 + π 1 + π 2 + π 3 = 1

Kittenweb pagerank example My bumper web page about cats 0 Kitten pics 1 Cat web Lol Cats 2 3 π 0 = π 1 /2 π 1 = π 3 /2 π 2 = π 3 /2 miss equation for π 3 π 0 + π 1 + π 2 + π 3 = 1

Kittenweb pagerank example My bumper web page about cats 0 Kitten pics 1 Cat web Lol Cats 2 3 π 0 = π 1 /2 π 1 = π 3 /2 π 2 = π 3 /2 miss equation for π 3 π 0 + π 1 + π 2 + π 3 = 1 π 1 = π 2 from lines 2 and 3.

Kittenweb pagerank example My bumper web page about cats 0 Kitten pics 1 Cat web Lol Cats 2 3 π 0 = π 1 /2 π 1 = π 3 /2 π 0 + π 1 + π 2 + π 3 = 1 π 1 = π 2 from lines 2 and 3. π 1 = 2π 0 = π 3 /2 from line 1 and 3. π 2 = π 3 /2 miss equation for π 3

Kittenweb pagerank example My bumper web page about cats 0 Kitten pics 1 Cat web Lol Cats 2 3 π 0 = π 1 /2 π 1 = π 3 /2 π 0 + π 1 + π 2 + π 3 = 1 π 2 = π 3 /2 miss equation for π 3 π 1 = π 2 from lines 2 and 3. π 1 = 2π 0 = π 3 /2 from line 1 and 3. π 1 /2 + π 1 + π 1 + 2π 1 = 1 from line 4 and above lines.

Kittenweb pagerank example My bumper web page about cats 0 Kitten pics 1 Cat web Lol Cats 2 3 π 0 = π 1 /2 π 1 = π 3 /2 π 0 + π 1 + π 2 + π 3 = 1 π 2 = π 3 /2 miss equation for π 3 π 1 = π 2 from lines 2 and 3. π 1 = 2π 0 = π 3 /2 from line 1 and 3. π 1 /2 + π 1 + π 1 + 2π 1 = 1 from line 4 and above lines. π 1 = 2/9 π 0 = 1/9 π 2 = 2/9 π 3 = 4/9

Kittenweb pagerank example My bumper web page about cats 0 Kitten pics 1 Cat web 2 Lol Cats 3 π 1 = 2/9 π 0 = 1/9 π 2 = 2/9 π 3 = 4/9 So this page shows Lol Cats is the most important page, followed by Cat web and Kitten pics equally important. Note that pages 0,1 and 2 all have only one incoming link but are not equally important. Nowadays google has made many optimisations to their algorithm (and this is a simplified version anyway). Nonetheless this random walk on a graph priniciple remains important in many network models.

Queuing analysis of the leaky bucket model A leaky bucket is a mechanism for managing buffers and to smooth downstream flow. What is described here is sometimes known as a token bucket. A queue holds a stock of permit generated at a rate r (one permit every 1/r seconds) up to a maximum of W. A packet cannot leave the queue without a permit each packet takes one permit. The idea is that a short burst of traffic can be accommodated but a longer burst is smoothed to ensure that downstream can cope. Assume that packets arrive as a Poisson process at rate λ. A Markov model will be used [Bertsekas and Gallager page 515].

Modelling the leaky bucket Use a discrete time Markov chain where we stay in each state for time 1/r seconds (the time taken to generate one permit). Let a k be the probability that k packets arrive in one time period. Since arrivals are Poisson, a k = e λ/r (λ/r) k. k! Queue of permits (arrive every 1/r seconds) Rest of internet Poisson input to queue Exit queue for packets with permits

A Markov chain model of the situation In one time period (length 1/r secs) one token is generated (unless W exist) and some may be used sending packets. States i {0, 1,..., W } represent no packets waiting and W i permits available. States i {W + 1, W + 2,...} represent 0 tokens and i W packets waiting. If k packets arrive we move from state i to state i + k 1 (except from state 0). Transition probabilities from i to j, p i,j given by a 0 + a 1 i = j = 0 p i,j = a j i+1 j i 1 0 otherwise

Solving the Markov model Let π i be the equilibrium probability of state i. Now, we can calculate the probability flows in and out of each state. For state one π 0 = a 0 π 1 + (a 0 + a 1 )π 0 π 1 = (1 a 0 a 1 )π 0 /a 0. For state i > 0 then π i = i+1 j=0 a i j+1π j. Therefore, π 1 = a 2 π 0 + a 1 π 1 + a 0 π 2 π 2 = π 0 a 0 ( (1 a0 a 1 )(1 a 1 ) a 0 a 2 ). In a similar way, we can get π i in terms of π 0, π 1,..., π i 1.

Solving the Markov model (part 2) We could use i=0 π i = 1 to get result but this is difficult. Note that permits are generated every step except in state 0 when no packets arrived (W permits exist and none used up). This means permits arrive at rate (1 π 0 a 0 )r. Rate of tokens arriving must equal λ unless the queue grows forever (each packet gets a permit). Therefore π 0 = (r λ)/(ra 0 ). Given this we can then get π 1, π 2 and so on.

Completing the model Want to calculate T average delay of a packet. If we are in states {0, 1,..., W } packet exits immediately with no delay. If we are in states i {W + 1, W + 2,...} then we must wait for i W tokens (i W )/r seconds to get a token. The proportion of the time spent in state i is π i. The final expression for the delay is T = 1 r j=w +1 π j (j W ). For more analysis of this model see Bertsekas and Gallagher page 515.