I spoke about the problems I was having with achieving good VoIP call quality some time ago. In spite of many tweaks the problems had not been going away. I changed my ADSL router for one that includes QoS, hoping this would help solve the problem. However, it has not entirely done that. I have basically been having a problem that some calls seemed to work fine, but others would have occasional delays which would ruin the voice experience.
So I decided to read up again on Quality of Service. It’s interesting that for most home users there is not a lot of documentation, or that it is incomplete. One good reference is Cisco’s Enterprise QoS Solution Network Design Guide. Not light reading but it’s pretty complete and certain things started to stand out:
First my Vigor 2820n ADSL router does support QoS but ONLY for traffic going out of the ADSL interface. I have 3 voip devices excluding my PC which runs Asterisk so a lot of the VoIP traffic is on my LAN. It suddenly became clear. There was no QoS taking place on the LAN.
While obvious to the professionals who play with this, QoS is something you only control for “outbound” traffic. That is where you have to focus. So looking at my setup it became clear that I needed to apply QoS in more than one place:
- on my Asterisk PC for outgoing VoIP traffic to external VoIP providers but also to my VoIP devices on my LAN
- on my ADSL router for external VoIP calls
- on my switch for LAN traffic. I actually bought some time ago a DLINK DES3010F 8-port managed switch which included QoS support. This needed configuring too.
Of course this required 3 completely different sets of configuration.
- The documentation on my DLINK switch is ok, but does has many different options and does not provide good examples of how to implement QoS.
- Linux uses tc. There are various tutorials but it is a bit of a pain to use and is not that intuitive.
- The Vigor router’s configuration is not too bad, and it helped a lot once I realised that the QoS applied only to the outbound ADSL interface and not to the WAN. It would have been nice if the documentation were clearer.
Then I came up across another thing. To configure QoS you need to decide which traffic needs to get the appropriate tagging for prioritisation. I’m still using IAX and SIP in Asterisk though I’d like to move over completely to SIP to simplify things. SIP is easy: it normally runs on a single port. The same is true of IAX.
RTP on the other hand, which is the protocol to carry the voice traffic, does not seem to have any recommended port ranges. As a result of that it became clear: my Asterisk configuration used one port range, my Linksys devices used another and my Siemens C470IP yet another. For configuring QoS on the RTP streams that is not helpful. Configuring based on port ranges is probably not the best way to go but seems the easiest initially. Ideally the applications all need to correctly tag their traffic and then the PC, router and switch can prioritise it.
Finally of course Quality of Service is explained in different ways: DiffServ uses one terminology and ToS another. This can be confusing if you are playing with this for the first time and do not have a good guide to help.
So I’ve modified the switch and the router, perhaps not in the best way and also the PC with tc and now the voice quality seems to have improved quite a bit. I still need to tweak this further but it’s complex and for most home users if you get this wrong or do not do it at all your voice quality can drop considerably.
So if you are having trouble with voice quality on a SOHO voip system and have internal voip devices take a look at this. It might be the cause of the issue and nothing to do with the hardware you are using.
Since writing this I thought I’d update the configuration. Based on the Cisco document I wanted to configure all voice traffic to dscp EF and call signalling to CS3.
I used wireshark to look at the traffic generated by each device and saw that my Gigaset C470IP sends signalling using the AF31 (the document mentions that some devices use this value rather than CS3) so I needed to adapt the configuration to take this into account.
Below are the changes I made.
DrayTek Vigor 2820N
The DLink switch required a few tweaks.
Then set the dscp values for EF (46), CS3 (24) and AF31 (26) to go to the highest priority (Class-3) queue.
Your setup may need more configuration but this seems to work if you only want to prioritise voip calls above everything else.
The following settings were needed in asterisk (1.4)
tos_sip=cs3 ; Sets TOS for SIP packets. tos_audio=ef ; Sets TOS for RTP audio packets.
With the current configuration I see that much incoming SIP and RTP traffic does not have the DSCP values correctly tagged. Perhaps my ISP is filtering this? The end result is that the switch will not correctly prioritise the incoming traffic and so I may suffer dropped packets. I’m not yet sure if there’s a way to fix this as the place to do it would be in the ADSP router and I don’t see that the Draytek has any way to set the DSCP values based on incoming traffic properties like destination port.