COMP/ELEC 429/556 Introduction to Computer Networks Weighted Fair Queuing Some slides used with permissions from Edward W. Knightly, T. S. Eugene Ng, Ion Stoica, Hui Zhang T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 1
Critical Features of TCP Increase rate until packet loss What s the problem? Use loss as indication of congestion What s the problem? Slow start to probe for initial rate What s the problem? AIMD mechanism oscillates around proper rate What s the problem? Relies on AIMD behavior of end hosts What s the problem? T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 2
Some Answers Increase rate until packet loss Drives network into congestion High queuing delay, inefficient Use loss as indication of congestion Cannot distinguish congestion from packet corruption Slow start to probe for initial rate Bad for short lived flows (e.g. most Web transfers, a lot of Internet traffic is web transfer) AIMD mechanism oscillates around proper rate Rate is not smooth Bad for streaming applications (e.g. video) Inefficient utilization Relies on AIMD behavior of end hosts for fairness People can cheat (not use AIMD) People can open many parallel connections T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 3
Can Routers Provide Bandwidth Guarantee to a Traffic Flow? If so, then sender can request for a bandwidth guarantee and knows exactly what rate to send at No packet loss, no congestion No need for probing bandwidth (slow start) No AIMD oscillation No cheating The answer is yes, but it ll add complexity to routers??? T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 4
Guaranteeing Performance Requires Flow Isolation flow 1 1 Classifier flow 2 Scheduler 2 FIFO flow queue n of packets in router memory buffer T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 5
Classifier A flow is a sequence of packets that are related Classifier takes a packet and matches it against flow definitions to decide which flow it belongs Examples: All TCP packets from Eugene s web browser on machine A to web server on machine B All packets from Rice All packets between Rice and CMU flow 1 All UDP packets from Rice ECE department Classifier A flow may be defined by bits in the packet source/destination IP address (32 bits) or address prefix source/destination port number (16 bits) protocol type (8 bits) type of service (4 bits) even bits beyond TCP and IP headers could be used flow 2 flow n Scheduler T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 6
Scheduler Decides how the output link capacity is shared by flows A chance to be smart: Transmission of packets held in queues can be *scheduled* Which stored packet goes out next? Which is more important? Impacts quality of service flow 1 Classifier flow 2 Scheduler flow n T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 7
What is Weighted Fair Queuing? Packet queues w 1 w 2 R w n A mathematical model for flow scheduling Each flow i given a weight (importance) w i WFQ guarantees a minimum service rate to flow i r i = R * w i / (w 1 + w 2 +... + w n ) Implies isolation among flows (one cannot mess up another) T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 8
What is the Intuition? Fluid Flow w 1 water pipes w 2 w 3 T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 9
Fluid Flow System: Example 1 Flow 1 (w 1 = 1) 100 Kbps Flow 2 (w 2 = 1) Packet Size (bits) Packet inter-arrival (ms) Arrival Rate (Kbps) Flow 1 1000 10 100 Flow 2 500 10 50 Flow 1 (arrival traffic) Flow 2 (arrival traffic) 1 2 3 4 5 1 2 3 4 5 6 Service in fluid flow system 1 2 3 4 5 1 2 3 4 5 6 0 10 20 30 40 50 60 70 80 (ms) T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 10
Fluid Flow System: Example 2 Red flow has packets backlogged between 0 and 10 Backlogged flow flow s queue not empty Other flows have packets continuously backlogged All packets have the same size flows weights link 5 1 1 1 1 1 0 2 4 6 8 10 15 T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 11
Service Rate and Packet Delay in Fluid Flow System WFQ guarantees a minimum service rate to flow i r i = R * w i / (w 1 + w 2 +... + w n ) What worst case delays are experienced by individual packets in the FFS? bits Service curve slope = r i Worst case packet delay Packet arrival curve (s) T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 12
Implementation in Packet System Packet (Real) system: packet transmission cannot be preempted. Why? Solution: serve packets in the order in which they would have finished being transmitted in the fluid flow system T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 13
Packet System: Example 1 Assume for this example all packets are waiting from 0 Service in fluid flow system 0 2 4 6 8 10 Select the packet that is waiting and finishes first in the fluid flow system Packet system 0 2 4 6 8 10 T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 14
Packet System: Example 2 Flow 1 (arrival traffic) Flow 2 (arrival traffic) 1 2 3 4 5 1 2 3 4 5 6 Service in fluid flow system 1 2 3 3 1 2 4 4 4 5 5 5 3 4 5 6 (ms) Select the packet that is waiting and finishes first in the fluid flow system Packet system 1 2 1 3 2 3 4 4 5 5 6 T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 15
Implementation Challenge Four flows, each with weight 1 Flow 1 Flow 2 Flow 3 Flow 4 ε Finish s computed at 0 0 1 2 3 0 1 2 3 4 Finish s re-computed at ε Note that finishing order of packets from flows 1, 2, and 3 unaffected T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 16
Implementation Challenge Need to compute the finish of a packet in the fluid flow system but the finish may change as new flows arrive! Need to update the finish s of all packets that are in service in the fluid flow system when a new flow arrives But this is very expensive; a high speed router may need to handle hundred of thousands of flows! The new finish s don t affect ordering of packets that are in service in the fluid flow system (a lot of work for nothing) Can we capture ordering without using real world finish s?? T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 17
Bit-by-Bit Round Robin Insight If flows can be served one bit at a, the fluid flow system can be approximated by bit-by-bit weighted round robin During each round from each flow that has data to send, send a number of bits equal to the flow s weight Each packet therefore requires a fixed number of rounds to finish (depends only on weight and packet size); the finishing round number does not change even when new flows arrive Packet queues 30 bits 3 20 bits 34 bits 5 17 100 bits/sec How many seconds spent in each round? Note the answer depends on the total weights T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 18
Solution: Virtual Time Solution: instead of the packet finish, maintain the round # when a packet finishes (virtual finishing ) Virtual finishing doesn t change when a new flow arrives Packet ordering based on virtual finishing is the same as that based on real finishing. Need to compute system virtual function V(t) index of the round in the bit-by-bit round robin scheme at t T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 19
Flow 1 Flow 2 Flow 3 Flow 4 ε Example All flow weight = 1 Suppose each packet is 1000 bits, so takes 1000 rounds to finish. So, first packets of F1, F2, F3 finish at virtual 1000 When packet F4 arrives at virtual 1 (after one round), the virtual finish of packet F4 is 1001 But the virtual finish of packet F1,2,3 remains 1000 Finishing order is preserved T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 20
Computing System Virtual Time (Round #): V(t) V(t) increases inversely proportionally to the sum of the weights of the backlogged flows Since round # increases slower when there are more flows to visit each round. Flow 1 (w1 = 1) Flow 2 (w2 = 1) 1 2 3 1 2 4 3 4 5 5 6 V(t) C/2 C T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 21
Weighted Fair Queuing Implementation Define F i k virtual finishing of packet k of flow i arrival of packet k of flow i length of packet k of flow i w i weight of flow i The virtual finishing of packet k+1 of flow i is / w i Smallest virtual finishing first scheduling policy T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 22
Recall in the Fluid Flow System bits Service curve slope = r i Worst case packet delay Packet arrival curve (s) T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 23
Properties of WFQ Implementation Theorem: WFQ guarantees that any packet is finished within max_packet_length/link_rate of its finish in the fluid flow system Thus WFQ can guarantee bandwidth and delay Weights assigned appropriately and admission control is performed Packets paced by sender according to guaranteed bandwidth Another way to use WFQ is to assign all flows the same weight and perform no admission control Every flow gets a max-min fair share, provides performance isolation among flows See proof at the end of the slide deck T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 24
Internet Today FIFO queues are used for most network traffic No classifier, no scheduler, best-effort Sophisticated mechanisms tend to be more common near the edge of the network E.g. At campus routers Use classifier to pick out BitTorrent packets Use scheduler to limit bandwidth consumed by BitTorrent traffic T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 25
Remainder of this set of slides are for your reference only. They will not be needed for assignments. T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 26
Proof (1) Packet p k with length L k Subscript: index of pkt sent in pkt system Fluid Flow System Behavior a k : arrival u k : finish Packet System Behavior a k : arrival t k : finish Want to prove: t k u k + L max r L max : largest allowed pkt r: network link rate T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 27
Proof (2) Let m be the largest packet index such that u m > u k but t m < t k More generally, we have u m > u k u i and t m < t i < t k Fluid Flow System Behavior......... u k u m u i Packet System Behavior t m......... t k t i T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 28
Proof (3) Packet System Behavior t m......... t k p m started transmission at t i t m L m r u m > u k u i a i,a k > t m L m r u k (...+ L i r +...+ L k r ) + t m L m r = t k L m r Thus t k u k + L max r Q.E.D. T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 29
Another Insight Recall m is the largest packet index such that u m > u k but t m < t k If no such p m exists, then simply t k u k That is, the packet system can be ahead of the fluid flow system by an unbounded amount Service in fluid flow system Packet system 0 2 4 6 8 10 T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 30