Asterisk QoS markings and Cisco Low Latency Queueing – LLQ
March 10th, 2010 by
admin

Few days ago we finally got our new optical connection. It is working like a charm. Having optical connection and Cisco router from one side and Asterisk server from the other side was a clear sign that we could/should implement QoS for voice traffic. By default, Asterisk is using port range 10000 to 20000 for RTP streams (which is adjustable in /etc/asterisk/rtp.conf) so you have several solutions how to implement Low Latency Queuing – LLQ on Cisco router. You can:
- use Network Based Application Recognition NBAR to recognize your RTP traffic by using command ‘match protocol rtp’ within required class map;
- create access control list which would comprehend all the traffic which is working as UDP in port range 10000 to 20000 by executing command ‘access-list 101 permit udp any range 10000 20000 any’ and then call that access control list within class map by using command ‘match access-group 101′;
- make your Asterisk mark your SIP or RTP traffic by default.
From above listed solutions to this problem, third solution was most logical to me, although all solutions would work. Since there is recommendation to mark traffic as close to source as possible third option was very logical thing to go for. If you are using Asterisk which is working on Linux as root user (in most cases it is working with asterisk user by default) you will need to edit your sip.conf and within section [general] you will need to add following:
tos_sip=cs3
tos_audio=ef
Once done with that, save your configuration, reload asterisk and you are ready to go for Cisco configuration.
As I already mentioned, in most cases Asterisk is using user asterisk for the Asterisk daemon. If that is a case, above listed solution won’t work for you because Linux as operating system won’t allow you to mark your packages as non root user. That is very logical since we would be able to mark our web or some peer to peer traffic packages as EF (expedited forwarding) and obtain priority which is not desired at all. But, there is very powerful solution by using iptables. As root, you will need to execute following:
iptables -A OUTPUT -t mangle -p udp -m udp –dport 5060 -j DSCP –set-dscp 0×28
iptables -A OUTPUT -t mangle -p udp -m udp –sport 10000:20000 -j DSCP –set-dscp 0×28
By executing above commands you will mark your SIP and RTP traffic as DSCP CS5 (IP Precedence 5). You can verify that by catching a trace using snoop/tcpdump.
In case that you would like to set different DSCP values for some traffic, please find partial list here:
Expedited Forwarding, DSCP = 0×2E
CS5, DSCP = 0×28
CS6, DSCP = 0×30
CS7, DSCP = 0×38
Now last thing that we would need to do on the Linux side is to add those iptables rules to load on boot. Edit /etc/rc.local using your favorite text editor and paste above listed iptables lines and save it. Please note that rc.local file is loaded after the network, so if you are planning to put some firewall lines beside those that mark sip and trp traffic you might end up without your firewall rules for few seconds (otherwise, you can execute ‘iptables-save >/etc/iptables.rules‘ and then you would just need to add following line ‘pre-up iptables-restore < /etc/iptables.rules‘ to ‘/etc/network/interfaces‘ by using your favorite text editor to be loaded with network).
On the Cisco router side, we will configure Low Latency Queueing – LLQ to put some priority onto our CS5 marked packages. First thing that we need to do is to create class map from the global configuration mode by executing following commands:
router>enable
router#conf t
router(config)#class-map match-any voice
router(config-cmap)#match ip dscp cs5
router(config-cmap)#exit
router(config)#
By creating class map as listed above we would select our Asterisk marked cs5 packages. Next thing that we need to do is to define what we want to do with above selected cs5 marked packages. We are doing that by creating policy map as follows:
router(config)#policy-map llq
router(config-pmap)#class voice
router(config-pmap-c)#priority percent 20
router(config-pmap-c)#exit
router(config-pmap)#class class-default
router(config-pmap-c)#fair-queue
As per above configuration we are creating policy map called llq, and within that we are specifying 20 percent of available bandwidth for class voice. Please note that we need to have correct bandwidth statement under interface which is connected to WAN. Also, please note that we have enabled fair queueing on class-default (all data which is not selected by some other class map).
Last thing to do in regards to configuration is to enable policy map on interface which is facing connection towards your Internet Service Provider (WAN interface). We can do that by navigating to interface configuration mode and applying service policy in output direction as per following example:
router(config-pmap-c)#exit
router(config-pmap)#exit
router(config)#interface fastEthernet0/1
router(config-if)#service-policy output llq
And that is all. Now, we need to check results of our work by executing following command:
router#show policy-map interface fastEthernet 0/1
FastEthernet0/1Service-policy output: llq
queue stats for all priority classes:
Queueing
queue limit 64 packets
(queue depth/total drops/no-buffer drops) 0/0/0
(pkts output/bytes output) 947031/193919404Class-map: voice (match-any)
856803 packets, 170900643 bytes
1 minute offered rate 22000 bps, drop rate 0 bps
Match: ip dscp cs5 (40)
856803 packets, 170900643 bytes
1 minute rate 0 bps
Priority: 20% (400 kbps), burst bytes 15000, b/w exceed drops: 0Class-map: class-default (match-any)
5321936 packets, 1534281066 bytes
1 minute offered rate 20000 bps, drop rate 0 bps
Match: any
Queueing
queue limit 64 packets
(queue depth/total drops/no-buffer drops/flowdrops) 0/0/0/0
(pkts output/bytes output) 5322316/1531545858
Fair-queue: per-flow queue limit 16
Please note packet counts under voice class on this policy. That means that we have deployed working configuration which will improve your voip experience. Your voip traffic will get priority among other aggressive traffic flows. Please find some additional information below, and feel free to contact me in order that you have additional questions.
Posted in IT, cisco, debian, linux, networks, voip |
No Comments »




Please fill all required fields (fields indicated with *). Also, make sure to put COP file in root directory of your FTP server, so that CallManager is able to find it as valid upgrade option. You will need to provide Directory (put / for root on your FTP server), Server (IP address of your FTP server), Username and Password (valid user information) and Transfer protocol which can be SFTP and FTP.
Once done with filling up required field, press Next and Call Manager will attempt to contact FTP server. If there is valid COP file (valid upgrade option), and if we are working with proper user information and running FTP server, Call Manager will list valid upgrade options as per following screenshot:
Please note that valid COP file for Nokia S60 phone type is called cmterm-nokia_s60_001-sccp.cop.sgn. If that is what you have listed, press Next and importing process will start (downloading):
Once it is downloaded you will be presented with MD5 hash value which you can compare with one provided by Nokia from security reasons:
Once you press Next, import process will start and you will be presented with progress as follows:




Now, assuming that you have installed Call Connect client (.sis) on your Nokia Eseries device and that it works fine, we can continue with configuration. In this section, we will add new phone with phone type device Nokia S60 as listed above. Please notice that product type is now listed as Nokia S60 and that Device protocol is Skinny:
We will needed to select Phone Button Template and Commong Phone Profile fields since they are required. Also, that includes Presence Groups and Device Security Profile fields as shown on following screenshot:
Once done with basic configuration, we need to save changes by hiting Save button. Then, we need to configure associated information which includes configuration of directory numbers as per following:
Once done with directory number configuration, click on Save and you will have your new Nokia S60 phone configured and listed on phone list, as follows:
Once we are done with configuring Cisco Unified Communications Manager side which includes importing COP file and configuring new phone, we can start configuring Call Connect client which we installed on Nokia Eseries phone.















