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 chan_iax2.c: Peer 'NuFone2' is now UNREACHABLE! Time: 49 Sep 19 21:50:09 NOTICE chan_iax2.c: Peer 'NuFone2' is now REACHABLE! Time: 49 Sep 20 07:16:38 NOTICE chan_iax2.c: Peer 'NuFone2' is now TOO LAGGED (769 ms)! Sep 20 07:16:48 NOTICE chan_iax2.c: Peer 'NuFone2' is now REACHABLE! Time: 50 Sep 20 12:09:31 NOTICE chan_iax2.c: Peer 'teliax' is now TOO LAGGED (2923 ms)! Sep 20 12:17:27 NOTICE 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.