How to evaluate VoIP providers with Asterisk

There are many options when selecting a VoIP provider to terminate your Asterisk PBX.  One of the most important factors in this selection is the quality of the internet connection between your PBX and the VoIP provider.  The route between you and your VoIP provider is one of the most important considerations when selecting a provider.  This article details a simple method for evaluating this connection using Asterisk.

Asterisk includes a feature that can be used to monitor the latency between your system and a peer or friend.  This feature is enabled by setting the qualify setting in the iax.conf configuration file.  Valid options are yes, no, or a time in milliseconds.  If qualify is enabled, NOTIFY messages are sent periodically to the peer and the latency between replies is measured.  The peer is determined unreachable if the number of milliseconds is greater than the qualify value or 2,000 if qualify  is set to yes.  If a peer is unreachable, events are logged in /var/log/asterisk/messages as shown below:

Sep 19 21:48:19 NOTICE[752] chan_iax2.c: Peer 'NuFone2' is now UNREACHABLE! Time: 49
Sep 19 21:50:09 NOTICE[752] chan_iax2.c: Peer 'NuFone2' is now REACHABLE! Time: 49
Sep 20 07:16:38 NOTICE[752] chan_iax2.c: Peer 'NuFone2' is now TOO LAGGED (769 ms)!
Sep 20 07:16:48 NOTICE[752] chan_iax2.c: Peer 'NuFone2' is now REACHABLE! Time: 50
Sep 20 12:09:31 NOTICE[752] chan_iax2.c: Peer 'teliax' is now TOO LAGGED (2923 ms)!
Sep 20 12:17:27 NOTICE[752] chan_iax2.c: Peer 'teliax' is now REACHABLE! Time: 83

I am currently using two different VoIP providers and I get qualify notice messages about once every day or two with the qualify set to 400ms.  This is a very useful information as it allows me to determine which provider has the most reliable route from my office.  If you get very few qualify NOTICE messages, you can probably assume your VoIP connection will be fairly reliable.

Have connections with two different providers also tells me when the congestion is with my Internet connection or if it is something beyond my connection.  If both providers go out at the same time, it is most likely the internet connection at my office or problems with my ISP.  I rarely if ever see this scenario, so I can conclude that my internet connection is fairly reliable and the congestion problems are most likely between me and the VoIP provider or problems at the VoIP provider.

Overall, things are now working fairly well.  As we continue to resolve problems, VoIP is now starting to become a very usable option for us.


Implenting QoS for VOIP in a Linksys router

In our quest to implement an Asterisk PBX in our office, we are evaluating several VOIP (Voice Over IP) providers.  VOIP provides several benefits over traditional phone lines including:

  • low cost (typically around $0.02 per minute)
  • available in pre-paid plans
  • can support concurrent concurrent calls on the same number

However, implementing VOIP successfully is not trivial.  You must have a reliable internet connection and we have found you must implement some type of Quality of Service (QoS) in the router. The first problem I ran into was calls sounded great to me, but people I called mentioned the calls sometimes sounded garbled to them.  This article discusses the diagnosis of this problem and how to implement QoS in a Linksys router to fix this issue.

Our connection is a standard DSL connection — 5Mb/sec down and 640Kb/sec up.  There is plenty of bandwidth for incoming voice, but bandwidth for outgoing voice is much more limited.  A few tests confirmed this — when a ftp upload or some other bulk transfer was occurring, the outgoing voice sounded really bad.

The solution to this problem is to implement some type of Quality of Service (QoS) mechanism that prioritizes the VOIP traffic over all other types of traffic.  Vonage and other “boxed” solutions no doubt do this as they recommend placing their box between the modem and the router. It turns out that QoS can be implemented in a standard Linksys router/firewall.  I spent some time trying to get QoS working using a Linksys WRT54G v5 router with no success, I ended up loading the dd-wrt firmware ( on an older Linksys router I had laying around.  The dd-wrt firmware is quite nice and is worthy of consideration if you have a v4 or earlier Linksys router or the WRT54GL version.   QoS may have worked on the WRT54G v5 with Linksys firmware with some more effort, but after trying dd-wrt, I’m not going back.

Setting up QOS

The QoS settings can be found under Applications & Gaming -> QoS.

There are many ways to assign priority to your VOIP system.  I just used the IP address as shown below. is the LAN private IP of the Asterisk system.


With the priority of the Asterisk box set to high, we should be all set.  It turns out that unless you cap the bandwidth, you will still have QoS problems.  Enter around 85% of your up and down bandwidth in the Uplink and Downlink boxes.  Capping the bandwidth is required to keep the latency low.  Otherwise, your bandwidth is filled up with large packets and the priority settings are not effective for VOIP traffic.  See for more information.


With the above settings, VOIP calls are now clear even with other concurrent activities.


Several people have reported being able to install dd-wrt on v6 WRT54 routers and the QoS configuration is the same.


Implementing Asterisk

Over the past month, we have been working on implementing Asterisk in our office.  Asterisk ( ) is a complete software PBX (Private Branch Exchange) that runs on top of Linux.  Asterisk supports a number of features commonly found in a PBX including voicemail, hosted conferencing, call queuing, and many other features.  Having a real PBX provides many benefits for a business and has the potential to improve our service and lower our costs.  Over the next couple months we will be writing about our experiences implementing Asterisk, tips for setting it up etc.

One of the most amazing things about Asterisk is its flexibility.  You can mix and match IP phones, traditional analog phones, soft phones, traditional PSTN lines, and VOIP services in about any way you want.  Our setup is fairly simple — IP phones and connections to the outside world using our PSTN land line.  We are also evaluating several VOIP providers and trying to determine if VOIP is viable.  Stay tuned …