The information posted here is a summerized version of the Cisco AVVID QoS Design Guide. The person who posted this is not liable for any network problems or any damage caused by configuring their router to the following specification. If in doubt, ask the Cisco forum for any advice but they accept no liability for any recommendations made which are then implemented. If in doubt, open up a Cisco TAC case where a Cisco Engineer will get in touch to help you implement or troubleshoot your design or issue respectively.
The example below is using a Cisco 79xx IP Phone, 2924 Switch (12.0(5)XU EN, and a 2600 Router (12.2(11)T IP/FW/IDS PLUS IPSEC 56). Make sure the versions of IOS that you're running support the commands used before implementing in a production environment. It also assumes that you are using seperate VLANs for data and voice (VLAN 100 for data, and 101 for voice).
This example assumes the following network setup: PC--->79xx---->2924---->2600---->Internet
Configuring the 2924 Switch: ! interface FastEthernet0/1 switchport trunk encapsulation dot1q switchport trunk native vlan 100 !this is the data vlan switchport mode trunk switchport voice vlan 101 !the vlan for voice spanning-tree portfast switchport priority extend cos 0 speed auto !
The above port configuration allows for both voice and data traffic from seperate vlans. Cisco IP Phones automatically support 802.1q trunking and 802.1p COS tagging, which will tag all outgoing voice traffic with an L2 COS of 5, and a L3 IP Precedence of 5. The 'switchport priority extend cos 0' ensures that all data traffic has it's L2 COS tag re-classified as 0. This will ensure a PC connected to the phone is not also classifying it's traffic.
Additionally, if your switch supports inline power, add the following to the above configuration: 'power inline auto'
NOTE: The 'speed auto' command is extremely important. Cisco IP phones default to auto-negotiation for speed and duplex.If the switch port is set to 100baseT full-duplex, the IP phone automatically sets it's port to 100baseT half-duplex, causing a duplex mismatch.
Configuring the 2600 router:
The first thing we need to do is define access-lists to match our voice traffic. We will create 2 extended ACLs, one for the voice RTP traffic, and one for the voice signaling traffic.
For Skinny, H.323, MGCP: !signaling traffic access-list 101 permit tcp any any range 2000 2002 access-list 101 permit tcp any any eq 1720 access-list 101 permit tcp any any range 11000 11999 access-list 101 permit udp any any eq 2427 ! !RTP traffic access-list 102 permit udp any any range 32767
For SIP/IAX/IAX2: !signaling traffic access-list 101 permit udp any any eq 4569 access-list 101 permit udp any any eq 5036 access-list 101 permit udp any any eq 5060 ! !RTP traffic access-list 102 permit udp any any range 16384 32767
NOTE: You may also use a 'permit ip 1.1.1.0 0.0.0.255 any' command on the signaling access-list to match all hosts in a particular subnet, assuming all IP phones are on the same subnet and their own vlan.
Next, we create class maps for each type of traffic: ! class-map match-all voice-traffic match access-group 102 ! class-map match-all voice-signaling match access-group 101 !
Then create a policy map for the classes: ! policy-map qos-voice class voice-traffic priority 240 class voice-signaling bandwidth 16 class class-defult fair-queue !
The policy-map on the router places all voice traffic into the Priority Queue, which is given 240kbps of bandwidth. All signaling traffic is in a class-based queue with 16kbps of bandwidth. And all other traffic is queued using Weighted Fair Queing.
To determine how much bandwidth to give to voice traffic: Number of simultaneous calls X 80 (for g711u) Number of simultaneous calls X 11 (for g729)
Finally, apply the policy to the interface: ! interface FastEthernet0/0 service-policy output qos-voice !
NOTE: If you are using sub-interfaces, applying the policy to the fa0/0 interface will also apply it to all sub-interfaces (i.e. fa0/0.1, fa0/0.2 etc.) To apply a QoS service-policy to a specific sub-interface refer to: »www.cisco.com/warp/public/105/qo···int.html
As Qos is generally configured on outgoing traffic, it will help if you have control over both sides of the link. You can also apply rate limiting to inbound traffic if you so choose, however it will only work with TCP traffic. ! interface Serial0/0 rate-limit input 1408000 8000 8000 conform-action transmit exceed-action drop
This will allow no more than 1408kbps through; any excess will be dropped. Again, this only works for TCP traffic, since dropped packets will cause the sender to back off and try again slower.
said by mplex :Since I have done a lot of QoS at work lately, I wanted to post a good solution that home users can use to improve the performance of their high speed connection when your outbound traffic rate is congested. It could be congested due to P2P traffic, a home server or anything. Regardless, if your upstream traffic is congested (and that is likely with the pathetic upload speeds on most home connections), latency will increase and everything will be sluggish. Hopefully, this will help.
Below are two qos queuing strategies for home users with slow uplinks on cable and DSL Internet. The first one is simple to implement generally performs well (fair queuing). Fair queuing is complicated to explain but easy to understand. It divides traffic in to flows and throttles heavy flows to allow room for smaller ones. In general, this will keep pings, ssh/telnet, VPN traffic etc responsive while cutting back P2P traffic and other aggressive traffic to make room.
For all of this to work, you have to tell the router how much upstream bandwidth you have, otherwise it will think you have a 10mbit or 100mbit link rather than a 256k WAN link. The best way to achieve this that I have found is Hierarchical Class Based Weighted Fair Queuing (CBWFQ). It's a mouth-full for sure, but in reality it is a simple flexible system for implementing QoS.
The first solution does no classification at all, rather it implements the fair queueing strategy in hopes that it can differentiate between different traffic and give everything a fair share.
!! This policy sets up your general queuing strategy for your WAN interface, which is only fair-queue in this case
policy-map fair-queue-child class class-default fair-queue 128 !! 128 allows more active flows than default
!! This policy queues the above policy at a specified rate of 200k
policy-map fair-queue-parent class class-default shape average 200000 service-policy fair-queue-child
!! Apply the policy to the physical outbound interface on your router interface Fa0 service-policy output fair-queue-parent
If you need to change the shape average rate to a lower number, you have to first remove and reapply the policy on the interface for it to take effect.
Note: The command shape average 200000 is extremely important. This is the rate at which outbound traffic will leave your router. This only takes in to account IP packets, and none of the Ethernet/DOCSIS/PPP overhead that is included in that number your ISP quotes as your upload speed. You may also find that the amount of upstream bandwidth you can reliably get may very depending on time of day. This is just your ISP cheating you and the downside of shared bandwidth. Regardless, you will need to tweak your speed to a rate you are happy with. I usually load up a P2P program, then start pinging a reliable router upstream. When it's all said and done, with my 384k connection, the above number of 200k is the only reliable amount of bandwidth I get in the area I live now so don't be suprised to find out your ISP is no good. Here are the results I get without the fair-queue-parent policy applied:
Adapt Queue Packets Bytes Packets Bytes Shaping Active Depth Delayed Delayed Active - 63 2780 1638576 2768 1635385 yes
Service-policy : fair-queue-child
Class-map: class-default (match-any) 2888 packets, 1763229 bytes 30 second offered rate 185000 bps, drop rate 2000 bps Match: any Queuing Flow Based Fair Queuing Maximum Number of Hashed Queues 128 (total queued/total drops/no-buffer drops) 63/43/0
The average pings dropped to 150ms; that would be voice quality if it wasn't for the jitter. Still, most people will see a marked improvement implementing fair queuing. If you are a hardcore gamer or remote shell user, you won't be happy until performance is a consistent sub 100ms. For that, it gets a little more complicated.
You could do something like this:
!! Make an access list to match your game/shell traffic etc (This isn't enough to do it) access-list 101 permit icmp any any access-list 101 permit udp any any
!! Make a class for that traffic to match your ACLs class-map match-any important match access-group 101
!! Edit your existing policy to add the new class policy-map fair-queue-child class important priority [or bandwidth] percent 50
Then remove and re-add the policy to the interface. See it working with the sh policy-map interface fa0 command.
That will setup a strict priority queue for that traffic and always service it first. The downside to using priority is that during times of congestion, priority acts as a policer and caps the traffic class to 50% of the total bandwidth under the parent policy. One way to get around this is setting priority at something like 80%. All the unused bandwidth will be shared proportionally among other classes including the default class. One thing to remember is that you can only have one priority queue. You need to use the bandwidth command under all other classes (otherwise, everything using priority will share the same queue). The bandwidth command uses a round robin mechanism to service the queues proportional to the percentage of bandwidth they have. The default class always gets what's left.
In the real world, the difference between priority and bandwidth is small and some routers don't support it. The policing action is enough to scare me away from using it for anything but udp traffic and small tcp traffic if at all. I also would not use it for large TCP packets since it will share space with your low latency traffic like game traffic and slow it down if it gets ahead of it in the queue.
Using a similiar but more complicated strategy (it still queues low latency for icmp), I get these results with a fully congested link:
60 packets transmitted, 60 received, 0% packet loss, time 59075ms rtt min/avg/max/mdev = 30.732/60.634/107.809/17.917 ms
So I cut my ping rates by more than half. The average ping rates with no traffic is about 40ms to that location so there is roughly 20ms of overhead on a congested link. Those delays are more likely to be from the docsis timings rather than my router so this is likely the best performance I would think you could get. I can get a little better if I police my P2P traffic at a lower rate as seen below.
The policy below is the one I use. To be honest, it's a mess. Some of the descriptions are wrong and some traffic is probably in the wrong place, but that's because I've edited it so many times for my setup. I would only base your own policy loosly on this one and make your own classes. Just remember to have a maximum of 4 or so classes. Anymore will have strange results. You have to think of how the your traffic will compete for different classes at different times and whether you want that.
access-list 110 remark Management access-list 110 permit icmp any any echo access-list 110 permit icmp any any echo-reply access-list 110 permit tcp any any range 22 telnet access-list 110 permit tcp any range 22 telnet any access-list 110 permit tcp any any eq 3389 access-list 110 permit tcp any eq 3389 any access-list 110 deny udp any eq 10000 any !! I want VPN in a seperate class access-list 110 deny udp any any eq 10000 access-list 110 permit udp any any ! access-list 120 remark VPN access-list 120 permit udp any any eq 10000 ! access-list 130 remark Web access-list 130 permit tcp any any eq www access-list 130 permit tcp any eq www any ! access-list 140 remark File Sharing (FS) access-list 140 permit tcp any any range 6881 6886 access-list 140 permit tcp any range 6881 6886 any access-list 140 permit tcp any any eq 2234 access-list 140 permit tcp any eq 2234 any access-list 140 permit tcp any range 4661 4662 any access-list 140 permit tcp any any range 4661 4662 access-list 140 permit tcp any any eq 1214 access-list 140 permit tcp any any eq 6880 access-list 140 permit tcp any eq 6880 any
class-map match-any nbar-fs match protocol bittorrent match protocol kazaa2 match protocol gnutella match protocol fasttrack match protocol edonkey match access-group 140
class-map match-all class2 description [VPN/UDP] match access-group 120
class-map match-all class3 description [web traffic/other tcp] match access-group 130
class-map match-all class1 description [SSH/ICMP/RDP] match access-group 110
policy-map shaped class nbar-fs bandwidth percent 5 police cir 140000 bc 1500 conform-action transmit exceed-action drop violate-action drop class class1 priority percent 30 class class2 bandwidth percent 30 queue-limit 16 class class3 bandwidth percent 25 queue-limit 32 class class-default fair-queue
policy-map shaper class class-default shape average 220000 service-policy shaped
Should work on any hardware. Works fine on my cheapo 827. Pre-requisites: the router supports named ACLs the router has a 12.4 IOS (not sure about other versions, feel free to try and let me know)
The configuration supposes you assign IP range 192.168.254.0/24 to the LAN 192.168.254.129 to 192.168.254.191 are assigned by DHCP to non static IP machines 192.168.254.11 is assigned to the VoIP ATA (in the exemple below, a Wengo ATA called Wenbox
192.168.254.1 is my Server for DNS, WINS, NTP and TFTP. Replace by the correct IPs (Local LAN or your ISP addresses)
Notes on Outbound Policy Shaping Implementation: * Ethernet0 is the physical interface LAN side that receive the traffic * ATM0 is the physical interface WAN side that send the traffic out to the ISP * Dialer1 is the logical interface WAN side that controls the Layer-2/3 (PPP and IP) management of the ATM0 interface * Since the physical WAN interface is the ATM0, then you need to implement outbound policy shaping on the ATM0 to actually execute the queueing/shaping/policing functions * Implement outbound policy shaping on Dialer1 interface (the logical WAN interface) won't make differences. The issue is that once the data has been encapsulated into PPPoX (PPPoA or PPPoE) there is no proper identification as the traffic goes out the Dialer interface. By tagging the packets as they come into the inside interface with a unique precedence or DSCP value prior encapsulation, it should provide the ability for proper decision making as the packets exit the outside interface.