Last lecture -- Open-loop Rate-based flow control, Traffic descriptor, Example of a traffic shaper -- leaky/token bucket algorithm Today -- further discussion of token bucket, queuing disciplines ---------------------------------------------------------------------- A token bucket algorithm is described by 2 parameters: a token rate r and a bucket depth B. It works as follows: Each token represents a unit of data. A source needs to have a token to send a unit of data (e.g. a byte). To send a packet of length N, a source needs to collect N tokens. A source starts with no tokens and accumulates them at a rate of r per second. Further, a source can accumulate no more than B tokens. This implies that a source can send a burst of as many as B units of data into the network as fast it can, but over a sufficiently long interval, it can't send more than r units of data per second. Example given to illustrate the idea of token-bucket traffic shaper. The above discussion on traffic shaping pertains to mechanism implemented at a source (or a router/switch at the edge of a network). The following discussion on queuing discipline applies to how packets are stored in a buffer and transmitted from a router/switch. FIFO (first-in-first-out) queuing discipline - all traffic flows are buffered at a single queue - if packet A arrives at the buffer earlier than B, then A is to be transmitted before B (assume no packet drop). - advantage: simple to implement - disadvantage: an ill-behaved flow could flood the router with its own packets, causing other flows' packets to be discarded. (This problem can be alleviated by selectively dropping a newly arriving packet (e.g. that belongs to an ill-behaved flow), rather than dropping every newly arriving packet.) Fair queuing - maintain a separate queue for each flow, so that traffic flows are isolated from one another. A given traffic source cannot arbitrarily increase its share of the network's capacity at the expense of other flows. - enforce fairness by serving one packet from each flow in a round robin fashion. Problem with this approach: packets are not of the same length. - Ideally, we want bit-by-bit round robin to enforce fairness. Fair queuing is a mechanism to emulate/approximate bit-by-bit round robin behavior. How does fair queuing work? First consider the behavior of a single flow, and imagine a clock that ticks onnce each time a bit is transmitted from this flow. Let S_i = time when the router starts to transmit packet i F_i = time when the router finishes transmitting packet i P_i = length of packet i, expressed in terms of how many clock ticks it takes to transmit packet i Then F_i = S_i + P_i Obviously, the service time of a packet must follow its arrival time and the finishing time of transmitting a previous packet. So if A_i = time when packet i arrives at the router, then S_i = Max{ F_(i-1), A_i } Thus, F_i = Max{ F_(i-1), A_i } + P_i When there are more than one flows, we compute F_i for each packet that arrives and use F_i as a timestamp. The next packet to transmit is always the packet that has the minimum time-stamp, i.e., the packet that should finish transmission before all others. Note: with fair queuing, it could happen that a short packet from a flow is served before another flow's long packet, though the short packet may arrive after the long packet.