600 likes | 772 Views
Handout # 3: Probabilities Review; Switches and Queues; Link Scheduling. CSC 2203 – Packet Switch and Network Architectures. Professor Yashar Ganjali Department of Computer Science University of Toronto yganjali@cs.toronto.edu http://www.cs.toronto.edu/~yganjali.
E N D
Handout # 3: Probabilities Review; Switches and Queues; Link Scheduling CSC 2203 – Packet Switch and Network Architectures Professor Yashar Ganjali Department of Computer Science University of Toronto yganjali@cs.toronto.edu http://www.cs.toronto.edu/~yganjali TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.:
Announcements • Read papers [3] and [4] (see class web page) before next class. • Contact me if you can’t find the papers. • Are you on the mailing list? University of Toronto – Fall 2012
Final Projects • Project topics posted on class web site. • Meant as a starting point. • You can also choose your own topic. • Draft proposal (1 page) • Due: Fri. Oct. 5th at 5pm • Feedback: Tue. Oct. 9th • Final proposal (2 pages) • Due: Fri. Oct. 12th at 5pm • You need to talk to me about the topic before submitting a proposal. University of Toronto – Fall 2012
Today • Basic Probability Theory Review • Sample spaces, events • Random variables • Discrete: Bernoulli, geometric, binomial • Continuous: Poisson, exponential • Switches and Queues • Output Link Scheduling • Max-Min Fairness • Bit by Bit Weighted Fair Queueing • Deficit Round-Robin University of Toronto – Fall 2012
Suggested Books • Ross. Introduction to Probability Models • Hoel, Port, and Stone. Introduction to Stochastic Processes • Wolff. Stochastic Modeling and the Theory of Queues University of Toronto – Fall 2012
Sample Spaces and Events • Sample space S: • Set of all possible outcomes of an experiment • Packets on ingress line: {arrival, no arrival} • Next packet arrival: {1, 2, 3, …} • Event E: • Any subset E of sample space S • Example: no packet arrival for 5 time slots. University of Toronto – Fall 2012
Probabilities • Consider sample space S, and event E. • P(E) is a number assigned to event E such that: • 0 ≤ P(E) ≤ 1. • P(S) = 1. • If E1, E2, … are mutually exclusive we have: P(E1 U E2 U …) = P(E1) + P(E2) + …. • P(E) is called the probability of event E. University of Toronto – Fall 2012
Example • Die tossing • Assume die is fair • We have P({1}) = P({2}) = … = P({6}) = 1/6 • What is the probability of getting an even number? • P({2,4,6}) = 1/6 + 1/6 + 1/6 University of Toronto – Fall 2012
Random Variable • Consider a random experiment with set of outcomes S. • A random variable is a function from set of outcomes to real numbers X(a): S S a University of Toronto – Fall 2012
Example • Indicator random variable: University of Toronto – Fall 2012
Bernoulli Random Variable • Experiment outcome: “arrival” or “no-arrival” • Random variable X: • Arrival 1 • No-arrival 0 • Probability of arrival = p • p(1) = P{X = 1} = p • p(0) = P{X = 0} = 1 - p • We call function p(a) of X defined by p(a) = P{X=a} the probability mass function. University of Toronto – Fall 2012
CDF and PDF • Discrete random variable: • The possible values are discrete (countable) • Continuous random variable: • The random variable can take a range of values in R • Cumulative Distribution Function (CDF): • PDF and PMF: University of Toronto – Fall 2012
Expectation and higher moments • Expectation (mean): • If X > 0: • Variance: University of Toronto – Fall 2012
Independence • For two events A and B: • Two random variables University of Toronto – Fall 2012
Stochastic Processes • A stochastic process {X(t), t T} is a collection of random variables. • For each t T, X(t) is a random variable. • X(t) is the state of the process at time t. • Example: number of packets in a queue • Discrete-time: T is a countable set • Continuous-time:T is an interval of real line University of Toronto – Fall 2012
Bernoulli IID Arrivals • Probability of arrival at each time slot: p • Independent of other slots • IID: Independent, and Identically Distributed 3 2 1 Ingress line Time University of Toronto – Fall 2012
Geometric Distribution • Repeated Trials: Number of trials till some event occurs 3 2 1 University of Toronto – Fall 2012
Binomial Distribution • Repeated Trials: • Repeat the same random experiment n times. (Experiments are independent of each other) • Number of times an event A happens among n trials has Binomial distribution • (e.g., number of heads in n coin tosses, number of arrivals in n time slots,…) • Binomial is sum of n IID Bernoulli RVs University of Toronto – Fall 2012
Binomial - Example n=4 p=0.2 n=10 n=20 n=40 University of Toronto – Fall 2012
Binomial – Example (ball-bin) • There are B bins, n balls are randomly dropped into bins. • : Probability that a ball goes to bin i • : Number of balls in bin i after n drops University of Toronto – Fall 2012
Poisson Process • Increase the number of slots, reduce probability so that the rate if fixed. 3 2 1 Bernoulli 6 5 4 3 2 1 Poisson Time University of Toronto – Fall 2012
Poisson Distribution • Used to model number of arrivals University of Toronto – Fall 2012
Poisson Example l=.5 l=1 l=4 l=10 University of Toronto – Fall 2012
Poisson as limit of Binomial • Poisson is the limit of Binomial(n, p) as • Let University of Toronto – Fall 2012
Poisson and Binomial n=5,p=4/5 Poisson(4) n=10,p=.4 n=20, p=.2 n=50,p=.08 University of Toronto – Fall 2012
Merging Poisson Processes • Let’s consider two Poisson processes with rates λ and μ. • What if we merge the two? We will get a Poisson process with rate λ + μ. University of Toronto – Fall 2012
Splitting Poisson Processes • Consider a Poisson process with rate λ. • We split it by flipping a coin with probability p: • Heads (probability p): process 1 • Tails (probability 1-p): process 2 We will get two Poisson processes with rates pλand (1-p)λ. University of Toronto – Fall 2012
Question • What if we merge two Bernoulli IID processes? University of Toronto – Fall 2012
Exponential Distribution • Continuous random variable • Models lifetime, inter-arrivals,… University of Toronto – Fall 2012
Memoryless Property • True for Geometric and Exponential Dist.: • The coin does not remember that it came up tails l times • Root cause of Markov Property. University of Toronto – Fall 2012
Queueing Theory • We can model arrivals to queues as • Bernoulli • Poisson • … • Departure process can be modeled similarly. • Queueing theory studies queue occupancy, delay, … for various arrivals and departures. • More on this … next week. University of Toronto – Fall 2012
Today • Basic Probability Theory Review • Sample spaces, events • Random variables • Discrete: Bernoulli, geometric, binomial • Continuous: Poisson, exponential • Switches and Queues • Output Link Scheduling • Max-Min Fairness • Bit by Bit Weighted Fair Queueing • Deficit Round-Robin University of Toronto – Fall 2012
Queue Terminology • Arrival process, A(t): • In continuous time, usually the cumulative number of arrivals in [0, t], • In discrete time, usually an indicator function as to whether or not an arrival occurred at time t=nT. • The arrival rate l is the expected number of arriving packets (or bits) per second. • Queue occupancy, Q(t): • Number of packets (or bits) in queue at time t. • Service discipline, S: • Indicates the sequence of departure: e.g. FIFO/FCFS, LIFO, … • Service distribution: • Indicates the time taken to process each packet: e.g. deterministic, exponentially distributed service time. • The service rate m is the expected number of served packets (or bits) per second. • Departure process, D(t): • In continuous time, usually the cumulative number of departures in [0, t], • In discrete time, usually an indicator function as to whether or not a departure occurred at time t=nT. A(t), l D(t) S,m Q(t) University of Toronto – Fall 2012
More Terminology • Customer: queueing theory usually refers to queued entities as “customers”. In class, customers will usually be packets or bits. • Work: each customer is assumed to bring some work which affects its service time. For example, packets may have different lengths, and their service time might be a function of their length. • Waiting time: time that a customer waits in the queue before beginning service. • Delay: time from when a customer arrives until it has departed. University of Toronto – Fall 2012
Arrival Processes • Examples of deterministic arrival processes: • E.g. 1 arrival every second; or a burst of 4 packets every other second. • A deterministic sequence may be designed to be adversarial to expose some weakness of the system. • Examples of random arrival processes: • (Discrete time) Bernoulli i.i.d. arrival process: • Let A(t) = 1 if an arrival occurs at time t, where t = nT, n=0,1,… • A(t) = 1 w.p. pand 0 w.p.1-p. • Series of independent coin tosses with p-coin. • (Continuous time) Poisson arrival process: • Exponentially distributed inter-arrival times. University of Toronto – Fall 2012
If our design goal was to not drop packets, then a simple discrete time adversarial arrival process is one in which: A1(t) = A2(t) = … = Ak+1(t) = 1, and All packets are destined to output t mod N. Adversarial Arrival ProcessesExample for “Knockout” Switch Memory write bandwidth = k.R < N.R 1 R R 2 R R 3 R R N R R University of Toronto – Fall 2012
Bernoulli Arrival Process Memory write bandwidth = N.R 1 A1(t) R R 2 A2(t) R R 3 A3(t) R R N AN(t) R R • Assume Ai(t) = 1 w.p. p, else 0. • Assume each arrival picks an output independently, uniformly and at random. • Some simple results follow: • 1. Probability that at time t a packet arrives to input i destined to output j is p/N. • 2. Probability that two consecutive packets arrive to input i is the same as the probability that packets arriveto inputs i and j simultaneously, equals p2. • Questions: • 1. What is the probability that two arrivals occur at input i in any three time slots? • 2. What is the probability that two arrivals occur for output j in any three time slots? • 3. What is the probability that queue i holds k packets? University of Toronto – Fall 2012
Simple Deterministic Model Cumulative number of bits that arrived up until time t. A(t) A(t) Cumulative number of bits D(t) Q(t) R Service process time D(t) • Properties of A(t), D(t): • A(t), D(t) are non-decreasing • A(t) >= D(t) Cumulative number of departed bits up until time t. University of Toronto – Fall 2012
Simple Deterministic Model Cumulative number of bits d(t) A(t) Q(t) D(t) time Queue occupancy: Q(t) = A(t) - D(t). Queueing delay, d(t), is the time spent in the queue by a bit that arrived at time t, (assuming that the queue is served FCFS/FIFO). University of Toronto – Fall 2012
Today • Basic Probability Theory Review • Sample spaces, events • Random variables • Discrete: Bernoulli, geometric, binomial • Continuous: Poisson, exponential • Switches and Queues • Output Link Scheduling • Max-Min Fairness • Bit by Bit Weighted Fair Queueing • Deficit Round-Robin University of Toronto – Fall 2012
FIFO Queue Problems • In order to maximize its chances of success, a source has an incentive to maximize the rate at which it transmits. • When many flows pass through it, a FIFO queue is “unfair” – it favors the most greedy flow. • It is hard to control the delay of packets through a network of FIFO queues. Fairness Delay Guarantees University of Toronto – Fall 2012
Fairness 10 Mb/s 0.55 Mb/s A 1.1 Mb/s 100 Mb/s C R1 e.g. an http flow with a given (IP SA, IP DA, TCP SP, TCP DP) 0.55 Mb/s B What is the “fair” allocation: (0.55Mb/s, 0.55Mb/s) or (0.1Mb/s, 1Mb/s)? University of Toronto – Fall 2012
Fairness 10 Mb/s A 1.1 Mb/s R1 100 Mb/s D B 0.2 Mb/s What is the “fair” allocation? C University of Toronto – Fall 2012
Movie Upload – 1Gbps VoIP – 64Kbps Fairness and Delay 54Mbps 5Mbps University of Toronto – Fall 2012
Max-Min Fairness • N flows share a link of rate C. Flow f wishes to send at rate W(f), and is allocated rate R(f). • Pick the flow, f, with the smallest requested rate. • If W(f) < C/N, then set R(f) = W(f). • If W(f) > C/N, then set R(f) = C/N. • Set N = N – 1. • Set C = C – R(f). • If N > 0 repeat for the rest of flows. University of Toronto – Fall 2012
Round 1: Set R(f1) = 0.1 Round 2: Set R(f2) = 0.9/3 = 0.3 Round 3: Set R(f4) = 0.6/2 = 0.3 Round 4: Set R(f3) = 0.3/1 = 0.3 Max-Min Fairness - Example W(f1) = 0.1 1 W(f2) = 0.5 C R1 W(f3) = 10 W(f4) = 5 University of Toronto – Fall 2012
Max-Min Fairness • How can an Internet router “allocate” different rates to different flows? • First, let’s see how a router can allocate the “same” rate to different flows… University of Toronto – Fall 2012
Fair Queueing • Packets belonging to a flow are placed in a FIFO. This is called “per-flow queueing”. • FIFOs are scheduled one bit at a time, in a round-robin fashion. • This is called Bit-by-Bit Fair Queueing. Flow 1 Bit-by-bit round robin Classification Scheduling Flow N University of Toronto – Fall 2012
Weighted Bit-by-Bit Fair Queueing • Likewise, flows can be allocated different rates by servicing a different number of bits for each flow during each round. R(f1) = 0.1 1 R(f2) = 0.3 C R1 R(f3) = 0.3 R(f4) = 0.3 Order of service for the four queues: … f1, f2, f2, f2, f3, f3, f3, f4, f4, f4, f1,… Also called “Generalized Processor Sharing (GPS)” University of Toronto – Fall 2012
Packetized Weighted Fair Queueing • Problem: We need to serve a whole packet at a time. • Solution: • Determine what time a packet, p, would complete if we served flows bit-by-bit. Call this the packet’s finishing time, F. • Serve packets in the order of increasing finishing time. • Theorem: Packet p will depart before F + Tmax Also called “Packetized Generalized Processor Sharing (PGPS)” University of Toronto – Fall 2012