CBWFQ allows user-defined traffic classes as compared to standard WFQ. WFQ applies weights to identified traffic to classify traffic into conversations and allocate bandwidth to each conversation. WFQ is enabled by default on all interfaces less than or equal to 2.048 Mbps.
For CBWFQ, traffic classes are defined matching protocols, ACLs and input interfaces. Packets satisfying the match criteria for a class constitutes the traffic for that class. A FIFO queue is reserved for each class, and traffic belonging to the class is directed to the queue for that class. A maximum of 64 classes/queues can be defined by a user in CBWFQ.
The characteristics of a particular class include bandwidth of the class, weight (derived from the "bandwidth" of the class), maximum packet limit and even queue limit.
If a default class is configured with bandwidth command, all unclassified traffic is put into a single FIFO queue and given treatment according to the configured bandwidth.
If a default class is configured with a fair-queue command, all unclassified traffic is flow classified and given best-effort treatment.
The mechanics behind "bandwidth" command:
1) CBWFQ shares interface bandwidth inversely proportional to flow weights. If there are N number of flows and flow(i) has weight value Weight(i), then CBWFQ guarantees flow(i) the following share of bandwidth: Share(i) = ( Weight(1) + .... + Weight(i) + ... + Weight(N) )/ Weight(i) 2) CBWQF assigns weights to dynamic conversations (non-user defined classes) using the formula-
Weight(i) = 32384/ (IP_Prec(i) + 1)
3) CBWFQ assigns weights to user-defined classes using the formula-
Weight(i) = Constant * Interface_BW / Class_BW if the bandwidth of the class is configured explicitly OR Weight(i) = Constant * 100 / BW_percent is the bandwidth of the class is configured as bandwidth percent or bandwidth remaining percent commands.
The Constant depends on the number of flow queues in WFQ.
Number of flows
The queues are allocated to different classes as below- if N is the number of dynamic flows of CBWFQ.