分享

Basic QoS on Vyatta with DSCP for VoIP

 Frank_Chia 2009-06-27

How To: Basic QoS on Vyatta with DSCP for VoIP

Synopsis

So you’ve setup a VoIP phone system, but now you want to setup QoS on your router to prioritize your VoIP packets. This is imperative if you intend on running VoIP over any kind of WAN links like I do. Call quality might suffer otherwise - especially when that staff member decides he wants to donwload that 300mb service pack at work instead of using his own connection at home. I’ll show you here how you can solve this problem by using QoS on your Vyatta router.

My network looks something like this:

As you can see, I have 5 independent sites, the left side being my datacenter, and the right being individual sites where are staff work out of. Each site on the right has a Vyatta VC4 router running as its gateway and each of these sites are running Aastra IP phones which connect to our Asterisk PBX server running in the data center.

Anyways… onto the nitty gritty. Click the article title or the read more link below to read on.

Things You Need to Know

  1. The maximum data rates for your WAN interface
  2. The interface name of your WAN interface
  3. The Differentiated Services Code Point (DSCP) / Type of Service (ToS) values that your IP phones are setting. Most will use the values I use below - 46 for RTP / RTCP and 26 for SIP

Creating the qos-policy

The first thing we’ll do is create a qos-policy on Vyatta, to do this first log into your Vyatta CLI. We will create a qos-policy that contains 2 class identifications - one for the Session Initiation Protocol (SIP) signalling, and one for the Real-Time Transport Protocol (RTP) / Real-Time Transport Control Protocol (RTCP). SIP-based telephones essentially use SIP for the call setup, and RTP / RTCP for transport of the actual audio or video. We’d like RTP packets to have top priority on our network, otherwise your audio might get choppy, essentially you want to treat these packets like liquid gold. The SIP packets we feel are important too, but lets face it, if call setup takes an extra few milliseconds because there are alot of RTP streams going on… its not the end of the world.

First create the qos-policy:

[edit]

vyatta@tho1-ncgc1# edit qos-policy traffic-shaper DSCP

note that the “DSCP” in the above line is the name of this policy - feel free to change it.

Next we need to tell this policy how much bandwidth it has to available to it - this is going to be the upstream data rate of you WAN interface, in my case its 10mbit:

[edit qos-policy traffic-shaper DSCP]
vyatta@tho1-ncgc1# set bandwidth 10mbit

I’d also recomend setting the description field for your own purposes:

[edit qos-policy traffic-shaper DSCP]
vyatta@tho1-ncgc1# set description “This policy enforces DSCP-based queuing”

Then we’ll create our first class, this one will be used for the RTP / RTCP packets:

[edit qos-policy traffic-shaper DSCP]
vyatta@tho1-ncgc1# edit class 10

Note: the 10 again is an identifier, feel free to use any number you wish.

Next we set the minimum amount of bandwidth we want available to this class. I like doing this using percentages, then if my WAN interface gets upgraded, I only need to change it in the main qos-policy section:

[edit qos-policy traffic-shaper DSCP class 10]
vyatta@tho1-ncgc1# set bandwidth 90%
[edit qos-policy traffic-shaper DSCP class 10]
vyatta@tho1-ncgc1# set description “Matches DSCP 46 - used for RTP & RTCP for VoIP - set by IP Phone & Asterisk”

Now the class itself needs to be setup on which packets actually enter the class, we do this using the “match” configuration

[edit qos-policy traffic-shaper DSCP class 10]
vyatta@tho1-ncgc1# set match DSCP-46 ip dscp 46

Thats it for class 10! You’ll then need to repeat this creating a new class for DSCP 26 (see my full qos-policy below).

We are not quite done yet though… now that we have classes created that match DSCP 26 and 46, what about everything else? All those people surfing the web, watching YouTube, or checking their facebook… Well, one last thing we need to do in our qos-policy is create the default restrictions, we do this by creating a node under the qos-policy (at the same level as the classes)

[edit qos-policy traffic-shaper DSCP]
vyatta@tho1-ncgc1# set default bandwidth 5%

Important: Whenever we have set bandwidth values above, we have only set minimum bandwidths that are guarenteed for that class. In my case I have guarenteed 90% of my bandwidth to IP phone audio streams, 5% to call-setup packets, and the last 5% to everything else. Its important to remember that if your audio streams are not actually using their 90%, that bandwidth will be available for the other purposes. However, Vyatta can limit these by setting ceiling values - see the Vyatta command reference on how to do this, or leave me a comment if you wish.

Here is what my full qos-policy looks like:

qos-policy {
traffic-shaper DSCP {
bandwidth 10mbit
class 10 {
bandwidth 90%
description "Matches DSCP 46 - used for RTP & RTCP for VoIP"
match DSCP-46 {
ip {
dscp 46
}
}
}
class 30 {
bandwidth 5%
description "Matches DSCP 26 - used for SIP for VoIP"
match DSCP-26 {
ip {
dscp 26
}
}
}
default {
bandwidth 5%
}
description "This policy enforces DSCP queuing"
}
}

Now that we have our policy created, the last thing we need to do is apply the policy to our WAN interface, in my case eth1 is my WAN interface, so all we need to do is:

set interfaces ethernet eth1 qos-policy out DSCP

Thats it, were done! Your Vyatta router will now prioritize all packets going out your WAN interface to give priority to all your VoIP traffic.

If you have any questions or comments, feel free to leave a comment here and I’ll get back to you.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多