Weighted Fair Queueing
A
flow is loosely defined as the stream of packets associated with a single
session of a single application. The common IP implementations of Fair Queueing
(FQ) and WFQ assume that two packets are part of the same flow if they have the
same source and destination IP addresses, the same source and destination TCP or
UDP port numbers, and the same IP protocol field value. The algorithms combine
these five values into a hash number, and sort the queued packets by this hash
number.
The router then assigns sequence numbers to the queued packets.
In the FQ algorithm, this process of sequencing the packets is optimized so that
each flow gets a roughly equal share of the available bandwidth. As it receives
each packet, the router assigns a sequence number based on the length of this
packet, and the total number of bytes associated with this same flow that are
already in the queue.
This has a similar effect to a flow-based Round Robin (RR)
queueing algorithm, in which all of the flows are assigned to different queues.
These queues are then processed a certain number of bytes at a time until enough
bytes have accumulated for a given queue to send a whole packet. Although this
is a useful way of picturing the algorithm mentally, it is important to remember
that the Cisco implementations of FQ and WFQ do not actually work this way. They
keep all of the packets in a single queue. So, if there is a serious congestion
problem, you will still get global tail drops.
This distinction is largely irrelevant for FQ, but for WFQ it's
quite important. WFQ introduces another factor besides flow and packet size into
the sequence numbers. The new factor is the weight, (W), which is
calculated from the IP Precedence (P) value as follows. For IOS levels after
12.0(5)T, the formula is:
W = 32768/(P+1)
For all earlier IOS levels, the weight is lower by a factor of
4,096:
W = 4096/(P+1)
Cisco increased the value to allow for finer control over
weighting granularity.
The weight number for each packet is multiplied by the length
of the packet when calculating sequence numbers. The result is that the router
gives flows with higher IP Precedence values a larger share of the bandwidth
than those with lower precedence. In fact, it is easy to calculate the relative
scaling of the bandwidth shares of flows with different precedence values.
Table
B-4 shows, for example, that a flow with Flash Override Precedence will get
five times the bandwidth of a packet with Routine Precedence. However, if all of
the flows have the same Precedence, then WFQ behaves exactly the same as FQ.