Bandwidth Control (QoS)

1. QoS Overview

Bandwidth control is also known as Quality of Service (QoS) control. mbox appliances (HSG/CMG/HSA) support extremely granular QoS control options, depending on the actual business requirements.

There're several mechanisms to "control" bandwidth:

There're several ways to identify/mark interesting traffic for control:

NOTE: HSG & HSA support additional bandwidth control features such as dynamic and adaptive bandwidth control.

We can refer to below topology to explain overall QoS concept. In the diagram, we have a backhaul of 1Gbps, and there are multiple internal VLANs. Each VLAN is typically mapped to different SSID for wireless networks.

2. Class-based QoS

Class-based QoS basically allocates different types of traffic into different queues/classes, where you can also control the min/max bandwidth for each queue, and dequeues/releases packets out according to their priority (class no.). 

It involves two simple steps:

2.1 Traffic marking

Traffic/packet marking is a process to “color” the packets so that we can identify the targeted/"interesting" traffic which we want to control. Marking can be based on source/destination network/subnets, or protocol & port numbers (application). 

Traffic marking is achieved using firewall-set command with the “mark” option, eg.

firewall-set <rule-no> mark <marking-value> access src/dst/tcp/udp/dport/sport

NOTE:

For example, if we want to allocate bandwidth for entire network 172.16.1.0/24, configure below rules to match the packets:

!firewall-set 10 mark 100 access src 172.16.1.0/24 remark “upload packets”firewall-set 11 mark 100 access dst 172.16.1.0/24 remark “download packets”!

If we want to do QoS for http application only, configure below rules to match the packets:

!firewall-set 20 mark 100 access tcp dport 80 remark “user http requests”firewall-set 21 mark 100 access tcp sport 80 remark “server http replies"!

2.2 Traffic control (classification, prioritization, shaping)

Classification basically arranges the colored packets into respective classes. A class identifies a network (VLAN), or type/group of application, depending on the marking criterion. All traffic with the same marking values belongs to the same class, and they’re assigned to their respective queue with desired bandwidth.

Each class has a class no (queue no), which sets the priority to dequeue the traffic when they leave mbox exit interface. The lower class no. gets higher chance to go out (therefore higher priority).

mbox traffic shaping suppresses traffic when the link or traffic class gets congested. Unlike traffic policing, shaping method queues excess packets in a buffer (till the buffer is full) before dropping packets. This is a less “drastic” and smoother mechanism to managed traffic, compared with policing which simply drops excess packets. And mbox hardware usually comes with abundant memory/RAM to support bigger buffer, making it ideal solution for applications that are sensitive to packet drops.

We use "traffic-shape" command to apply QoS control to mbox exit interface.

!traffic-shape <min-link-bandwidth> <max-link-bandwidth> class <priority1> <min-class-bandwidth> <max-class-bandwidth> match fwmark <marking-value> class <priority2> <min-class-bandwidth> <max-class-bandwidth> match fwmark <marking-value> class <priority3> <min-class-bandwidth> <max-class-bandwidth> match fwmark <marking-value>

NOTES:

Configuration prerequisites:

EXAMPLE CONFIGURATION (per VLAN QoS)

Example scenario:

step 1: Traffic marking, identify the interesting traffic

!firewall-set 1031 mark 103 access src 10.0.103.0/24 remark VLAN103-ULfirewall-set 1032 mark 103 access dst 10.0.103.0/24 remark VLAN103-DLfirewall-set 1041 mark 104 access src 10.0.104.0/24 remark VLAN104-ULfirewall-set 1042 mark 104 access dst 10.0.104.0/24 remark VLAN104-DL!

step 2: Traffic control, on both inbound and outbound interface

!interface eth0description “Interface to WAN”enableip address 172.16.0.6/24traffic-shape 1000000000 1000000000 class 103 30000000 30000000 match fwmark 103 remark “VLAN103 upload” class 104 40000000 40000000 match fwmark 104 remark “VLAN104 upload”!interface eth1description “Interface to LAN”enabletraffic-shape 1000000000 1000000000 class 103 30000000 40000000 match fwmark 103 remark “VLAN103 download” class 104 40000000 40000000 match fwmark 104 remark “VLAN104 download”!interface vlan 1 103description "Wired Network vlan103"enableip address 10.0.103.1/24!interface vlan 1 104description "Wired Network vlan104"enableip address 10.0.104.1/24!

NOTE:

Troubleshooting/Verification commands:

========================================  

1. check if packets are marked 

mbox# show firewall set-listChain PREROUTING (policy ACCEPT 15M packets, 14G bytes)pkts bytes target     prot opt in     out     source               destination          Chain INPUT (policy ACCEPT 383K packets, 94M bytes)pkts bytes target     prot opt in     out     source               destination         Chain FORWARD (policy ACCEPT 15M packets, 14G bytes)pkts bytes target     prot opt in     out     source               destination         417K  684M MARK       all  --  *      *       10.0.103.0/24          0.0.0.0/0            /* set-list 1031 */ MARK set 0x67348K  819M MARK       all  --  *      *       0.0.0.0/0            10.0.103.0/24          /* set-list 1032 */ MARK set 0x67454K  695M MARK       all  --  *      *       10.0.104.0/24         0.0.0.0/0            /* set-list 1041 */ MARK set 0x68329K  693M MARK       all  --  *      *       0.0.0.0/0            10.0.104.0/24         /* set-list 1042 */ MARK set 0x68

2. check if packets are matched and shaped.

mbox# show interface traffic-shape

3. Host-based QoS (rate-limiting)

In our earlier section, we explained class-based QoS. Note that per class bandwidth refers to total available bandwidth for that class, shared by all user within the network. Host-based control basically limits (or rate limiting) maximum bandwidth per IP host based on the configured policies. 

Because some “bursty” users can exhaust the entire bandwidth and cause congestion to the class, especially during virus/storm outbreak, it is useful to be able to cap (or rate limit) per user or per host bandwidth so that all users or applications within the network can fairly share the available upstream pipe. Rate limiting is particularly important in public Wi-Fi networks, where attacker could use the free network (with huge backhaul) to launch DDoS attack against another victim networks. 

To control per host bandwidth, we use firewall-limit command. It is like a typical firewall rule but setting a bandwidth to this connection. This also means we can define very granular options to match a very specific host connection only.

!firewall-limit <rule_no> <max_bandwidth, Kbps> <direction> <src/dst> <Proto/Port or IP or subnet> !

NOTE:

For example, if we configure below rules, it means “each host within subnet 172.16.1.0/24 will be rate-limited to 2Mbps upload and download, for all applications, going through all interfaces.”

!firewall-limit 10 2048 all src 172.16.1.0/24 remark ULfirewall-limit 11 2048 all dst 172.16.1.0/24 remark DL!

If we configure below rules, it means “each host within subnet 172.16.1.0/24 will be rate-limited to 2Mbps upload and download, for http traffic only, going through all interfaces.”

!firewall-limit 10 2048 all tcp src 172.16.1.0/24 dport 80 remark UL-httpfirewall-limit 11 2048 all tcp sport 80 dst 172.16.1.0/24 remark DL-http!

CONFIGURATION EXAMPLE

It is possible to combine class-based QoS and Host-based QoS together. For example, we can set a total bandwidth for a network, then further rate limit per host bandwidth within that network. 

In this example, we are trying to achieve below objectives:


!interface eth0description "Link to WAN/Internet"enableip address dhcptraffic-shape 100000 100000 class 1 50000 50000 match fwmark 110!interface eth1 description "connection to LAN-eth1" enable ip address 172.16.1.1/24 dhcp-server  dns 8.8.8.8 8.8.4.4  router 172.16.1.1  range 172.16.1.5 172.16.1.100  enabletraffic-shape 50000 50000 class 1 50000 50000 match fwmark 110!ip name-server 8.8.8.8 8.8.4.4!firewall-set 10 mark 110 access src 172.16.1.0/24 remark Network-ULfirewall-set 11 mark 110 access dst 172.16.1.0/24 remark Network-DL!firewall-limit 10 2048 all src 172.16.1.0/24 remark "host UL"firewall-limit 11 2048 all dst 172.16.1.0/24 remark "host DL"!firewall-snat 10 overload outbound eth0!

4. User-based QoS

Per user bandwidth control/allocation provides the granularity to assign bandwidth based on user’s identity. This feature is only available when hotspot service is enable (HSG and HSA). And this requires HSG/HSA to work with local or external RADIUS server, where we can configure different user profiles, and attach the desirable access profile to specific users to map to our access policies, eg. user1 is assigned with 2Mbps upload/download, user2 can be assigned with 4Mbps upload/download.

NOTES:

Configuration prerequisites:

Please refer to this video demo on how it works.

5. Layer 2 QoS (CoS)

CMG and HSG support QoS at layer 2 by setting class of service (CoS) for Ethernet frames. CoS (as in IEEE P802.1P) is a 3-bit field called the Priority Code Point (PCP) within an Ethernet frame header when using VLAN tagged frames as defined by IEEE 802.1Q. It specifies a priority value of between 0 and 7 inclusive that can be used by QoS disciplines to differentiate traffic.

In mbox, when configuring a VLAN interface, there're two command options we can use

!interface vlan 0 10 enable set cos <default-outbound-priority> <mapped-priority> match cost <default-in-bound-priority> <mapped-priority>!

NOTE:

NOTE:

Some ISPs require to set CoS for CPE WAN interface when trunking is configured. Below is an example of Cisco CoS config and mbox CoS config.

Cisco IOS config:

!policy-map COS class class-default  set cos 1!interface FastEthernet0.1103 encapsulation dot1Q 1103 ip address dhcp service-policy output COS!

mbox config:

!interface vlan 0 1103 enable set cos 0 1 ip address dhcp!