Weighted Fair Queuing

Weighted fair queuing differs from PQ and CQ in several significant ways. The most outwardly obvious difference is that WFQ does not allow classification options to be configured. WFQ automatically classifies packets based on flows, with each flow being placed into a separate queue. For WFQ purposes, a flow is defined as all packets with the same values for the following:

■ Source IP address

■ Destination IP address

■ Transport layer protocol (TCP or UDP)

■ TCP or UDP destination port

■ IP Precedence

Because WFQ puts packets of different flows in different queues, it necessarily has a much larger number of queues than any of the non-flow-based queuing tools. The WFQ scheduler uses logic that is quite different from the logic of other queuing tools so that it can deal with the larger number of queues. However, the overall goals of the WFQ scheduler are straightforward, and are summarized as follows:

■ Flows with the same IPP should be given the same amount of bandwidth, regardless of how many bytes are sent in each flow.



■ For flows with different IPP values, give flows with higher IPP a proportionally higher amount of bandwidth.

■ The result: WFQ favors lower-volume, higher IPP flows.

For instance, if WFQ is currently managing ten flows with equal IPP values, on a 128-kbps interface, each flow effectively gets 12.8 kbps. Queues start to lengthen for flows that offer more than 12.8 kbps of traffic, meaning longer queuing delays. Queues shorten for flows that offer less than 12.8 kbps— in fact, the queues may empty, and WFQ will then allocate additional bandwidth to the other queues. The result is that the lower-volume flows prosper, and the higher-volume flows suffer.

The second goal of the WFQ scheduler is to provide more bandwidth to flows with higher IPP values. To do so, the flows are weighted based on IPP plus 1. In other words, precedence 7 flows get eight times more bandwidth than do precedence 0 flows, because (7 + 1) / (0 + 1) = 8. For another example, if you compare precedence 3 to precedence 0, the ratio is (3 + 1) / (0 + 1) = 4.

WFQ Scheduler: The Process

To achieve WFQ's goals for allocating link bandwidth, WFQ uses a scheduler that is actually pretty simple. The WFQ scheduler takes the packet with the lowest sequence number (SN) (also sometimes called finish time, or FT) when it needs to move the next packet to the hardware queue. WFQ assigns each packet an SN when the packet is added to a WFQ flow queue. The SN assignment process is actually the more interesting part of the scheduler.

The WFQ scheduler includes both the packet length and IPP when calculating the SN. The formula for calculating the SN for a packet is as follows:

Previous_SN + (weight * new_packet_length) Where weight is calculated as follows:

The formula considers the length of the new packet, the weight of the flow, and the previous SN. By considering the packet length, the SN calculation results in a higher number for larger packets, and a lower number for smaller packets. By including the SN of the previous packet enqueued into that queue, the formula assigns a larger number for packets in queues that already have a larger number of packets enqueued. And by putting the weight (IPP + 1) in the denominator, packets with higher IPP values end up with lower SNs. Figure 15-3 shows how two packets are assigned their sequence numbers.

Calculating the SN for the packet of an existing flow in Figure 15-3 is relatively straightforward. However, the first packet in a new flow does not have a previous SN to use in the formula. The figure shows that the SN of the last packet moved to the hardware queue is used as the new flow's previous SN.

Figure 15-3 WFQ Sequence Number Assignment Example

Existing: Flow 1

Figure 15-3 WFQ Sequence Number Assignment Example

Existing: Flow 1

New Flow: Flow 2

New Flow: Flow 2

Once the sequence numbers are assigned, the scheduler's job in choosing which packet to take next is simple: it takes the packet with the lowest SN among all the queues.

WFQ Drop Policy, Number of Queues, and Queue Lengths

WFQ uses a two-step process called modified tail drop to choose when to drop packets. First, WFQ considers the absolute limit on the number of packets enqueued among all queues; this limit is called the hold-queue limit. If a new packet arrives, and the hold-queue limit has been reached, the packet is discarded. That part of the decision is based not on a single queue, but on the whole WFQ queuing system for the interface.

Second, WFQ considers the length of the queue into which the newly arrived packet will be placed. Before adding a new packet to its queue, the congestive discard threshold (CDT) is checked against the actual length of that queue. If that queue is longer than CDT packets long, one packet is discarded—but maybe not the newly arrived packet. Figure 15-4 depicts the WFQ drop decision process.

Figure 15-4 WFQ Modified Tail Drop and Congestive Discard Threshold

Figure 15-4 WFQ Modified Tail Drop and Congestive Discard Threshold

Scheduler Logic Cbwfq

Note that each newly arriving packet goes through this process, but in one branch of the logic, the newly arrived packet is not discarded—another one is discarded. Essentially, if the new packet needs to go into a queue that has exceeded CDT, WFQ discards the highest-SN packet from any of the queues.

NOTE CDT must be set to a power of 2; IOS will not accept any other values.

Types of WFQ Queues

WFQ can be configured for a maximum of 4096 queues, called dynamic queues in WFQ show command output. Interestingly, the allowed configurable values are powers of 2, between 16 and 4096, inclusive. IOS restricts the values because WFQ performs a hash algorithm to classify traffic, and the hash algorithm only works when the number of queues is one of these valid values. Additionally, WFQ keeps eight hidden queues for overhead traffic generated by the router. WFQ uses a very low weight for these queues to give preference to the overhead traffic.

Also, some of the up to 4096 queues can be used by the Resource Reservation Protocol (RSVP) to reserve bandwidth. RSVP uses signaling to reserve a minimum bandwidth for particular flows in a network, relying on queuing tools to actually implement the bandwidth reservations. WFQ, CBWFQ, and LLQ support RSVP.

WFQ Configuration

WFQ requires very little configuration—in fact, it is on by default on E1-and-slower serial links. So, with default settings, WFQ literally requires no configuration commands. Table 15-4 lists the commands related to WFQ. Of particular importance, note that the fair-queue command allows setting of the CDT, number of queues, and number of RSVP queues, and the hold-queue command sets the number of packets allowed in all queues on the interface.

Table 15-4 Command Reference for WFQ


Mode and Function

fair-queue [congestive-discard-threshold [dynamic-queues [reservable-queues]]]

Interface mode; enables WFQ and changes defaults

hold-queue length out

Interface mode; changes the length of the hold queue

show queue interface-name interface-number [vc [vpi/] vci]]

Lists information about the packets waiting in a queue

show queueing [custom | fair | priority | random-detect [interface atm-subinterface [vc [[vpi/] vci]]]]

Lists configuration and statistical information about the queuing tool

Example 15-3 shows a basic configuration that defines non-default settings, along with show commands. To configure WFQ as simply as possible, the command fair-queue would be used, with no parameters, and the hold-queue command would not be needed at all.

Example 15-3 WFQ Configuration and show Commands

! Below, CDT is set to 100, number of queues to 64, number of RSVP queues to 10, ! and the overall limit (hold queue) of 500. R3# configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

R3(config-if)# fair-queue 100 64 10

R3(config-if)# hold-queue 500 out

! The output below does not match typical WFQ terminology in some cases. The ! "max total" is the hold queue size, with "threshold" being CDT, and "size" ! being the actual number of packets enqueued at that time. R3# show interface serial 0/0 Serial0/0 is up, line protocol is up !lines omitted for brevity Queueing strategy: weighted fair

Output queue: 95/500/100/12474 (size/max total/threshold/drops) Conversations 5/6/64 (active/max active/max total) Reserved Conversations 0/0 (allocated/max allocated) Available Bandwidth 1158 kilobits/sec ! lines omitted for brevity

! Below, details for a VoIP flow queue are shown, with statistics for queue ! depth and weight. The weight is listed as 5397, which was calculated as ! (32,384 / ((IPP of 5) + 1)). R3# sh queue s 0/0

Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 13567 Queueing strategy: weighted fair

Output queue: 125/500/100/13567 (size/max total/threshold/drops) Conversations 5/7/64 (active/max active/max total) Reserved Conversations 0/0 (allocated/max allocated) Available Bandwidth 1158 kilobits/sec

(depth/weight/total drops/no-buffer drops/interleaves) 61/5397/654/0/0 Conversation 61, linktype: ip, length: 64

source:, destination:, id: 0x0134, ttl: 253, TOS: 184 prot: 17, source port 16638, destination port 19476 ! lines omitted for brevity

The most interesting show command for WFQ is the show queue command. Note that a summary section is listed first, followed by a stanza of output for each active flow queue. The details of the flow are listed, as well as statistics for the flow queue.

Was this article helpful?

+1 0
Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook


  • pimpernel
    What is the wighted fair queue in cisco?
    11 months ago
  • julie
    Where is weighted fair queuing defined?
    7 months ago
  • mauri tolonen
    What is WFQ with example?
    5 months ago

Post a comment