Subscribe to TXLAB feed TXLAB
Just another hacking blog
Updated: 1 hour 1 min ago

Quality Assurance for VoIP calls

Tue, 06/02/2015 - 10:52

A customer has requested to set up a QA service that would continuously monitor the voice quality in their telephony infrastructure. They use a number of telephony carriers, and a set of applications on top of Plivo and FreeSWITCH. Also the conference module in FreeSWITCH is actively used.

Measuring jitter and packet loss, like it’s done in VoIPmonitor, is not sufficient, as we need to monitor end-to-end performance, including that of the FreeSWITCH server itself. So, there has to be a software component that compares the source audio with the recording on the other end of a call.

There are currently two major player on the market for voice quality measurements:

  1. ITU-T PESQ algorithm is proposed as an ITU recommendation P.862. Its source code is available at the ITU website and on Github. But the algorithm is patented, and the source code license does not allow any production use. The evaluation went quite smoothly, and the algorithm was able to detect even minor distortions, like one 20ms frame loss in a 2-minute call. The PESQ algorithm is designed and calibrated to be used for audio files of 6 to 20 seconds in length. Processing of a 2-minute recording takes approximately 5 seconds on a modern Xeon CPU. Commercial software is provided by OPTICOM and PsyTechnics.
  2. Sevana Oy is a Finnish/Estonian company that provides their own algorithms and software product for voice quality assessment. Their AQuA (Audio Quality Analyzer) software provides a fast and reliable way to compare the audio files: processing of a 2-minutes recording took about half a second on a modern CPU. Sevana has kindly provided a 10-days evaluation license and a fully functional software package, and the customer decided to go ahead with purchasing the license.

The simplest single-server license for Sevana AQuA allows running only one AQuA process at a time, so we wrapped its execution into a Perl script that utilizes a simple exclusive locking mechanism and performs audio file processing one at a time.

AQuA produces two scores in each measurement: the similarity percentage, and the MOS score. Both metrics are useful for quality analysis (for example, a 20ms frame added or lost inside of a silent pause influences the similarity score more significantly than MOS). It also takes a number of command-line options which can increase its tolerance to certain types of distortions, such as frequencies outside of G.711 range.

FreeSWITCH software is used as the SIP server for sending and terminating voice calls and for recording the received audio. It allows recording in several different formats: a) raw codec recording, done in the same thread as RTP processing; b) 16-bit signed PCM in WAV format, and file writing is done in a separate thread; c) compressed voice in a number of formats. The first two options produce similar results (raw codec recording had difficulties in the beginning). In case of raw codec recording, an additional step is required to convert the input files into 16-bit PCM WAV.

The call recording server requires to have a precise clock reference, so a baremetal hardware is required. Virtualized environments add up some uncontrollable imprecision to the virtual machines, although a thorough lab test is requires to verify this. It also depends on the type of hypervisor, as they implement the system clock differently.

The Linux kernel provides access to various clock sources. TSC is commonly used as default, and there is also HPET clock on modern hardware platforms. HPET is supposed to provide a more precise clock source, but it appears that it depends on CPU load: we accidentally discovered that audio recording in FreeSWITCH is significantly distorted when there’s some CPU activity is done in parallel (Debian package builder was working on the same 8-core machine). So far, TSC clock on a baremetal server provided the most reliable results.

The recording is done into a tmpfs mounted partition, in order to avoid any dependency on I/O load. The processing script performs the quality assessment on recorded files, and then moves or deletes them, depending on the measured score.

The SIP service was attached to an unusual UDP port, as port 5060 is frequently accessed by port scanners in public Internet. The DNS NAPTR and SRV records are used in order to use a universal SIP URI string, without having to reconfigure the remote servers if the IP address or UDP port changes.

Jitter buffer is disabled by default in FreeSWITCH, and it has to be activated whenever the calls are terminated on the server. In our case, the “jitterbuffer_msec” variable is set to “50:50″ in the dialplan before answering and recording the call. With this, the jitter buffer is not allowed to grow dynamically above 50ms. So, we tolerate most of typical Internet-imposed jitter, but clock drift on the sending side would cause packet drop on the receiver.

The dialplan is designed to accept direct SIP calls from remote servers, and PSTN calls from telephony providers. If a remote server calls our QA service directly, it encodes the source name in the user part of the SIP URI. Also there are two options for a QA call: it can playback the test audio, or send silence. In case of PSTN calls, the caller ID is used as the source identifier. The dialplan activates audio recording into a WAV file on a tmpfs partition, and launches the processing script after the hangup.

The conference dialer is used for testing the conferencing performance on a production FreeSWITCH server. It requires a conferencing profile that does not play any greetings to conference participants. Also in case of more than two participants, only one has to be chosen as a speaker, and all others would be listeners. A dedicated SIP URI on the QA server is reserved to playback the test audio and not to perform any recording.

Each measurement result for QA calls is stored in an SQL database for further processing, and also sent to Syslog for real-time monitoring.

The test audio is a concatenation of speech samples from ITU-T Recommendation P.50 Appendix I, resampled from 16KHz to 8KHz and stored as 16-bit signed PCM audio.


Filed under: Networking Tagged: freeswitch, monitoring, network monitoring, pbx, testing, voip

Simulating NAT with two Linux boxes

Tue, 04/28/2015 - 17:20

I needed to test some master-slave software in a situation that the master communicated to the slave over NAT (master’s IP address was replaced with the firewall’s external address), and then NAT would be removed, keeping master and slave addresses the same, but the slave would see the master directly.

This is the test scenario that worked on my desk, without having to add any routing to the LAN.

atom02 is the computer that emulates the slave system. It is connected back-to-back to alix102, and has only one IP address to communicate to:

ip link set dev eth0 up ip addr add dev eth0

alix102 is a Linux box with multiple Ethernet ports: eth0 is connected to my home LAN and has a DHCP address Also eth1 ( is connected directly to atom02.

The following configuration makes alix102 answer to ARP requests for and forward packets to atom02, replacing the source address with Also atom02 can make an SSH connection to and it will be connected to another box in the LAN that emulates the software master (

# enable IP forwarding echo 1 > /proc/sys/net/ipv4/ip_forward # Bring up eth1 ip link set dev eth1 up ip addr add dev eth1 # Enable proxy ARP on eth0 echo 1 > /proc/sys/net/ipv4/conf/eth0/proxy_arp # Set up the NAT translation iptables -t nat -A POSTROUTING -o eth1 -j SNAT --to iptables -t nat -A PREROUTING -p tcp --dport 3022 -i eth1 -j DNAT --to

After that, atom02 can be re-connected directly into the LAN, keeping the address with /24 network mask, and the software can be tested with direct communication. Alix102 has to be disconnected from the LAN, so that it does not pollute it with proxy ARP responses.

Filed under: Networking Tagged: linux

Linux reboot freezes on Acer Aspire One

Tue, 04/28/2015 - 11:16

I needed to install CentOS 6 on one an old Acer Aspire One notebook (with Intel Atom CPU) for some software testing. The problem is, that it could not perform a reboot, and I needed to press the power button every time. These instructions for reboot=X parameter for kernel did not help at all.

What really helped, is `kernel-ml` package from elrepo.org repositories. At the moment of writing, it was version `4.0.0-1.el6.elrepo.x86_64`.

Keep in mind that after installing kernnel-ml package, you need to edit /etc/grub.conf and make this new kernel as default. No additional boot options are required.

Filed under: Hardware Tagged: linux

Testing FreeSWITCH performance on Scaleway C1

Sat, 04/11/2015 - 02:23

The dedicated ARM hosting servers at Scaleway appear to be a decent platform for a mid-sized PBX.

In short, the platform displays the following results in performance tests:

  • OPUS<->PCMA transcoding: 16 simultaneous calls with  at about 95% total CPU load and no noticeable distortions.
  • SILK<->PCMA transcoding: 72 simultaneous calls were going without distortions, with average total CPU load at 63%. Higher number of calls resulted in noticeable distortions.
  • G722<->PCMA transcoding: 96 simultaneous calls without distortions, at 76% CPU load, and noticeable distortions for higher numbers.

Test 1: sequential transcoding

The following tests are a slight modification of my previous test scenario: it appears that a channel in OPUS codec cannot execute `echo` or `delay_echo` FreeSWITCH applications, as they copy RTP frames, and the OPUS codec is stateful and does not accept such copying. So, an extra bridge is made to ensure that echo is always executed on a PCMA channel.

XML dialplan in public context (here IPADDR is the public address on the Scaleway host):

  <!-- Extension 100 accepts the initial call, plays echo,        and on pressing *1 it transfers to 101  -->   <extension name="100">     <condition field="destination_number" expression="^100$">       <action application="answer"/>       <action application="bind_meta_app" data="1 a si transfer::101 XML ${context}"/>       <action application="delay_echo" data="1000"/>     </condition>   </extension>       <!-- Extension 101 plays a beep, then makes an outgoing SIP call to        our own external profile and extension 200  -->   <extension name="101">     <condition field="destination_number" expression="^101$">       <action application="playback" data="tone_stream://%(100,100,1400,2060,2450,2600)"/>       <action application="unbind_meta_app" data=""/>       <action application="bridge"               data="{absolute_codec_string=PCMA}sofia/external/200@IPADDR:5080"/>     </condition>   </extension>   <!-- Extension 200 enforces transcoding and sends the call to 201 -->   <extension name="200">     <condition field="destination_number" expression="^200$">       <action application="answer"/>       <action application="bridge"               data="{max_forwards=65}{absolute_codec_string=OPUS}sofia/external/201@IPADDR:5080"/>     </condition>   </extension>       <!-- Extension 201 returns the call to 100, guaranteeing it to be in PCMA -->   <extension name="201">     <condition field="destination_number" expression="^201$">       <action application="answer"/>       <action application="bridge"               data="{max_forwards=65}{absolute_codec_string=PCMA}sofia/external/100@IPADDR:5080"/>     </condition>   </extension>

The initial call is sent to extension 100 in the public context, and then by pressing *1, 6 additional channels are created, of which two calls perform the transcoding from PCMA to OPUS and back. So, if “show channels” shows 43 total channels, it corresponds to 42 = 6*7 test channels plus the incoming one, or 14 transcoding calls.

#### Good quality #### # fs_cli -x 'show channels' | grep total 43 total. # mpstat -P ALL 10                       Linux 3.19.3-192 (scw01)    04/10/2015      _armv7l_        (4 CPU) 10:08:41 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle 10:08:51 PM  all   82.67    0.00    2.75    0.00    0.00    1.30    0.00    0.00   13.28 10:08:51 PM    0   92.80    0.00    1.30    0.00    0.00    5.20    0.00    0.00    0.70 10:08:51 PM    1   95.30    0.00    1.60    0.00    0.00    0.00    0.00    0.00    3.10 10:08:51 PM    2   89.90    0.00    2.50    0.00    0.00    0.00    0.00    0.00    7.60 10:08:51 PM    3   52.70    0.00    5.60    0.00    0.00    0.00    0.00    0.00   41.70 10:08:51 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle 10:09:01 PM  all   84.88    0.00    2.43    0.00    0.00    1.23    0.00    0.00   11.47 10:09:01 PM    0   94.50    0.00    0.50    0.00    0.00    4.90    0.00    0.00    0.10 10:09:01 PM    1   97.60    0.00    1.50    0.00    0.00    0.00    0.00    0.00    0.90 10:09:01 PM    2   87.70    0.00    2.20    0.00    0.00    0.00    0.00    0.00   10.10 10:09:01 PM    3   59.70    0.00    5.50    0.00    0.00    0.00    0.00    0.00   34.80 #### quite OK quality, with some minor distortions #### # fs_cli -x 'show channels' | grep total 49 total. # mpstat -P ALL 10                       Linux 3.19.3-192 (scw01)    04/10/2015      _armv7l_        (4 CPU) 10:10:29 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle 10:10:39 PM  all   95.65    0.00    2.40    0.00    0.00    0.83    0.00    0.00    1.12 10:10:39 PM    0   95.30    0.00    1.20    0.00    0.00    3.30    0.00    0.00    0.20 10:10:39 PM    1   96.90    0.00    2.20    0.00    0.00    0.00    0.00    0.00    0.90 10:10:39 PM    2   95.80    0.00    3.50    0.00    0.00    0.00    0.00    0.00    0.70 10:10:39 PM    3   94.60    0.00    2.70    0.00    0.00    0.00    0.00    0.00    2.70 10:10:39 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle 10:10:49 PM  all   91.55    0.00    1.55    0.00    0.00    0.78    0.00    0.00    6.12 10:10:49 PM    0   89.90    0.00    1.20    0.00    0.00    3.10    0.00    0.00    5.80 10:10:49 PM    1   96.60    0.00    0.70    0.00    0.00    0.00    0.00    0.00    2.70 10:10:49 PM    2   90.60    0.00    1.70    0.00    0.00    0.00    0.00    0.00    7.70 10:10:49 PM    3   89.10    0.00    2.60    0.00    0.00    0.00    0.00    0.00    8.30 #### bad quality, barely audible #### # fs_cli -x 'show channels' | grep total 55 total.

If OPUS codec is replaced with SILK in the above configuration, the test is not usable, as SILK appears not to tolerate multiple transcodings, and after 4 transcodings the sound is almost not propagated at all. Also further transcoding sessions treat the input as silence, and do not load CPU.

If G722 is used, 36 transcoded calls still leave plenty of CPU resources for other tasks:

# fs_cli -x 'show channels' | grep total 109 total. # mpstat -P ALL 10                       Linux 3.19.3-192 (scw01)    04/10/2015      _armv7l_        (4 CPU) 10:37:31 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle 10:37:41 PM  all   19.75    0.00    5.40    0.00    0.00    0.00    0.00    0.00   74.85 10:37:41 PM    0   27.00    0.00   12.10    0.00    0.00    0.00    0.00    0.00   60.90 10:37:41 PM    1    4.30    0.00    9.50    0.00    0.00    0.00    0.00    0.00   86.20 10:37:41 PM    2   47.60    0.00    0.00    0.00    0.00    0.00    0.00    0.00   52.40 10:37:41 PM    3    0.10    0.00    0.00    0.00    0.00    0.00    0.00    0.00   99.90 10:37:41 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle 10:37:51 PM  all   17.57    0.00    7.42    0.00    0.00    0.00    0.00    0.00   75.00 10:37:51 PM    0    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00 10:37:51 PM    1   20.30    0.00   29.70    0.00    0.00    0.00    0.00    0.00   50.00 10:37:51 PM    2   50.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00   50.00 10:37:51 PM    3    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00  Test 2: parallel transcoding

The following piece of public dialplan takes the call at extension 300, makes a call in OPUS to extension 301, and then the call is bridged to 302 in PCMA where a speech test file is played endlessly. Thus, a call to 300 produces 5 channels, which are equivalent of two transcoded calls.

  <extension name="300">     <condition field="destination_number" expression="^300$">       <action application="answer"/>       <action application="bridge"               data="{absolute_codec_string=OPUS}sofia/external/301@IPADDR:5080"/>     </condition>   </extension>       <extension name="301">     <condition field="destination_number" expression="^301$">       <action application="answer"/>       <action application="bridge"               data="{absolute_codec_string=PCMA}sofia/external/302@IPADDR:5080"/>     </condition>   </extension>       <extension name="302">     <condition field="destination_number" expression="^302$">       <action application="answer"/>       <action application="endless_playback" data="/var/tmp/t02.wav"/>     </condition>   </extension>

In parallel to a call to 300 from outside, additional endless calls were produced from fs_cli:

originate sofia/external/300@IPADDR:5080 &endless_playback(/var/tmp/t02.wav)

This originate command produced 6 new channels, equivalent to two transcoded calls. The command was repeated until the human caller hears any distortions.

OPUS transcoding was functioning fine with 16 transcoded calls and 95% average CPU load, while SILK and G722 started showing distortions at around 65-75% of CPU load.



Filed under: Networking Tagged: arm, freeswitch, pbx, scaleway, voip

Installing FreeSWITCH on Scaleway C1

Wed, 04/08/2015 - 13:13

Scaleway (a cloud service by online.net) offers ARM-based dedicated servers for EUR9.99/month, and the first month free. The platform is powerful enough to run a small or FreeSWITCH server, and it shows nice results in voice quality tests.

These instructions are for Debian Wheezy distribution.

By default, the server is created with Linux kernel 3.2.34, and this kernel version does not have a high-resolution timer. You need to choose 3.19.3 in server settings.

At Scaleway, you get a dedicated public IP address and 1:1 NAT to a private IP address on your server. So, FreeSWITCH SIP profiles need to be updated (“ext-rtp-ip” and “ext-sip-ip” to point to you rpublic IP address).

FreeSWITCH compiles and links “mpg123-1.13.2″ library, which fails to compile on ARM architecture.  You need to edit the corresponding files to point to “mpg123-1.19.0″ and commit back to Git, because the build scripts check if any modified and uncommitted files exist in the source tree. Also the patch forces to use gcc-4.7, as 4.6 is known with some problems on ARM architecture.

apt-get update && apt-get install -y make curl git sox flac mkdir -p /usr/src/freeswitch cd /usr/src/freeswitch/ git clone https://gist.github.com/b27f4e41cc02f49d31a0.git git clone -b v1.4 https://stash.freeswitch.org/scm/fs/freeswitch.git /usr/src/freeswitch/src cd src git apply ../b27f4e41cc02f49d31a0/freeswitch-arm.patch git add --all git commit -m 'mpg123-1.19.0.patch' ./debian/util.sh build-all -i -z1 -aarmhf -cwheezy # This will run for about 4 hours, and you can build the sound packages in parallel in another terminal. mkdir /usr/src/freeswitch-sounds cd /usr/src/freeswitch-sounds git clone https://github.com/traviscross/freeswitch-sounds.git music-default cd music-default ./debian/bootstrap.sh -p freeswitch-music-default ./debian/rules get-orig-source tar -xv --strip-components=1 -f *_*.orig.tar.xz && mv *_*.orig.tar.xz ../ dpkg-buildpackage -uc -us -Zxz -z1 cd /usr/src/freeswitch-sounds git clone https://github.com/traviscross/freeswitch-sounds.git sounds-en-us-callie cd sounds-en-us-callie ./debian/bootstrap.sh -p freeswitch-sounds-en-us-callie ./debian/rules get-orig-source tar -xv --strip-components=1 -f *_*.orig.tar.xz && mv *_*.orig.tar.xz ../ dpkg-buildpackage -uc -us -Zxz -z1 cd /usr/src/freeswitch-sounds dpkg -i *.deb cd /usr/src/freeswitch # this will fail because dependencies are not installed dpkg -i freeswitch-all_* # this will add dependencies apt-get -f install # finally, install FreeSWITCH dpkg -i freeswitch-all_* # Minimal configuration that you can use cd /etc git clone https://github.com/voxserv/freeswitch_conf_minimal.git freeswitch # edit sip_profiles/*.xml and put the public IP address into "ext-rtp-ip" and "ext-sip-ip" insserv freeswitch service freeswitch start
Filed under: Networking Tagged: arm, freeswitch, pbx, scaleway, voip

Simple PBX tutorial for FreeSWITCH

Thu, 03/19/2015 - 01:53

Here is a short tutorial that helps building a PBX with FreeSWITCH.

Filed under: Networking Tagged: freeswitch, pbx, sip, voip

3G connectivity for PC Engines APU (MU609)

Sun, 02/22/2015 - 04:01

HUAWEI MU609 Mini-PCIe card is available at aliexpress.com for about $40. Comparing to DW5550 card, MU609 is more expensive, but it”s a current hardware, actively supported by the manufacturer.

MU609 supports the traditional PPP interface, as well as CDC Ethernet interface for Linux.

It also has a built-in support for mobile voice calls, but its audio is only available on the physical PCM GPIO interface, which is wired to pins 45, 47, 49, and 51 on the Mini-PCIe plug. These pins are not standardized and marked as “reserved” in Mini-PCIe specification. The PC Engines APU board does not connect these pins to anything.

The card initializes 5 serial-USB devices (ttyUSB0 – ttyUSB4). ttyUSB0 can be used for modem control with AT commands. Detailed documentation for the rest of devices is available at Huawei website. The CDC Ethernet card is initialized as eth3 (because eth0-eth2 are onboard Ethernet adapters).

Setting up the card for automatic startup under Debian:

apt-get install -y picocom ppp cat >/etc/chatscripts/sunrise.MU609 <<'EOT' ABORT BUSY ABORT 'NO CARRIER' ABORT ERROR TIMEOUT 10 '' ATZ OK 'AT+CFUN=1' OK 'AT+CMEE=1' OK 'AT\^NDISDUP=1,1,"internet"' OK EOT cat >/etc/chatscripts/gsm_off.MU609 <<'EOT' ABORT ERROR TIMEOUT 5 '' AT+CFUN=0 OK EOT vi /etc/network/interfaces allow-hotplug eth3 iface eth3 inet dhcp     pre-up /usr/sbin/chat -v -f /etc/chatscripts/sunrise.MU609 >/dev/ttyUSB0 </dev/ttyUSB0     post-down /usr/sbin/chat -v -f /etc/chatscripts/gsm_off.MU609 >/dev/ttyUSB0 </dev/ttyUSB0
Filed under: Networking Tagged: 3G, GSM, linux, pcengines, UMTS

Call generator for performance tests

Thu, 02/05/2015 - 02:00

Here I wrote a simple call generator for FreeSWITCH, and it can be used for performance tests:


Filed under: Networking Tagged: freeswitch, pbx, sip, voip

3G connectivity for PC Engines APU (DW5550)

Wed, 01/14/2015 - 01:43

In addition to Sierra Wireless MC8775 3G modem, there’s now a new offering for Dell DW5550 (or Ericsson F5521gw, which is the same hardware) mini-PCIe 3G cards at Aliexpress.com, in the price range of $20. This is a newer hardware (the ones I received were manufactured in mid-2012), and it supports higher UMTS speeds and an CDC Ethernet interface in Linux.

This page refers to Ericsson F3507g card, but all instructions are relevant for DW5550. The device identifies itself as Dell DW5550, firmware version R3B01 (Command for retrieving the version: AT+CGMR).

Default Linux kernel 3.2.0 in Debian Wheezy names the CDC Ethernet interface as usb0, and 3.16.0 from Wheezy backports names it as wwan0. Other than that, everything else works the same.

Out of 3 ordered cards, two worked immediately, and one was broken. The seller has kindly offered a replacement for additional $10.

for n in `ls /sys/class/*/*{ACM,wdm,usb0}*/device/interface`;do echo $(echo $n|awk -F '/' '{print $5}') : $(cat $n);done usb0 : Dell Wireless 5550 HSPA+ Mobile Broadband Mini-Card Network Adapter ttyACM0 : Dell Wireless 5550 HSPA+ Mobile Broadband Mini-Card Modem ttyACM1 : Dell Wireless 5550 HSPA+ Mobile Broadband Mini-Card Data Modem ttyACM2 : Dell Wireless 5550 HSPA+ Mobile Broadband Mini-Card GPS Port cdc-wdm0 : Dell Wireless 5550 HSPA+ Mobile Broadband Mini-Card Device Management cdc-wdm1 : Dell Wireless 5550 HSPA+ Mobile Broadband Mini-Card USIM Port

The following commands initiate a 3G connection for a sunrise.ch SIM card:

apt-get install -y picocom ppp picocom -b 115200 /dev/ttyACM1 AT+CFUN=1 AT+CGDCONT=1,"IP","internet" AT*ENAP=1,1 Ctrl-a Ctrl-x dhclient usb0

This Debian wiki page explains how to bring up the connection automatically at Linux startup:

cat >/etc/chatscripts/sunrise.DW5550 <<'EOT' ABORT BUSY ABORT 'NO CARRIER' ABORT ERROR TIMEOUT 10 '' AT+CFUN=1 OK \dAT+CGDCONT=1,"IP","internet" OK \d\d\dAT*ENAP=1,1 OK EOT cat >/etc/chatscripts/gsm_off.DW5550 <<'EOT' ABORT ERROR TIMEOUT 5 '' AT+CFUN=4 OK EOT vi /etc/network/interfaces allow-hotplug usb0 iface usb0 inet dhcp     pre-up /usr/sbin/chat -v -f /etc/chatscripts/sunrise.DW5550 >/dev/ttyACM0 </dev/ttyACM0     post-down /usr/sbin/chat -v -f /etc/chatscripts/gsm_off.DW5550 >/dev/ttyACM0 </dev/ttyACM0
Filed under: Networking Tagged: 3G, GSM, linux, pcengines, UMTS

Connecting Yeastar TG200 GSM gateway to FreeSWITCH

Mon, 12/22/2014 - 14:53

I needed to connect a GSM gateway to my FreeSWITCH PBX, in order to receive SMS and mobile calls and emulate a normal mobile phone. I’ve got the Yeastar Neogate TG200 V2 for this purpose (Firmware Version:, running Asterisk on an ARM processor).

This blog entry has helped a lot and saved a bunch of time.

The box supports OpenVPN, so you can place it in some remote location behind NAT, and manage it via the VPN connection. The client version is rather old (2.0.5), so it does not support embedded certificates in the client config, and also “topology subnet” option is not supported. You need to pack your vpn.conf and the certificates and pivate key into a TAR archive and upload to Neogate via its web interface.

It’s sufficient to configure one SIP trunk to your PBX, and manipulate the To: header in order to distinguish between SIM cards on incoming calls.

When the SIP trunk was configured (FreeSWITCH as a registrar), I started receiving the following warnings on FreeSWITCH, and the registration status was quickly removed after neogate’s REGISTER message:

2014-12-22 12:29:42.208567 [WARNING] sofia.c:5721 Sip user 'gsm01@xxxxx.net' is now Unreachable 2014-12-22 12:29:42.208567 [WARNING] sofia.c:5732 Expire sip user 'gsm01@xxxxx.net' due to options failure

My FreeSWITCH was sending SIP OPTIONS requests to all registered users and removed the registrations unless the clients responded with status 200 or 468. Neogate responds with 404 Not Found on such requests toward the trunk SIP user. I had to disable “unregister-on-options-fail” option in FreeSWITCH internal SIP profile.

In SIP trunk configuration, “Advanced->Caller ID” was automatically set to my trunk’s registration user name. Because of this, all incoming calls had this name as the caller ID, and the original caller number was lost. After setting this field to blank, the problem was resolved.

In “Mobile to IP” rules, you can set a different rule for each SIM card. The “Hotline” field should not be blank, and should contain some distinguishing number. It will be used in To field in the SIP INVITE on incoming calls. If you leave “Hotline” empty, the Neogate will respond with dial tone and collect DTMF digits before placing the call to your SIP trunk. So far I could not find any documentation that describes this.

Also in trunk configuration, sometimes I had to reboot the box in order for my changes to take effect.

The box uses the standard Asterisk management interface for sending and receiving SMS, and I’m planning to use this Perl module through the VPN connection.

Filed under: Networking Tagged: freeswitch, GSM, pbx, voip

Inspiration projects for next-generation Torrus

Sat, 11/15/2014 - 23:46

It’s not yet clear when I can start working on a new-generation Torrus, but here are some nice software projects which would probably inspire the new design, or probably be part of the new design. I haven’t looked into them in depth though.

  • Bosun is a distributed monitoring system produced by StackExchange. It uses distributed collector agents which write data into OpenTSDB. Bosun and its collector are written in Go, and OpenTSDB is written in Java.
  • InfluxDB is a time-series database written in Go.

and yes, the new project will most probably have its core in Go. But the SNMP discovery engine will most probably remain in Perl because of a big list of supported vendors.

Filed under: Programming Tagged: monitoring, network management, network monitoring, torrus

Using Voxbeam for outbound calls with FreeSWITCH

Tue, 10/21/2014 - 18:53

Voxbeam is providing worldwide PSTN connectivity at competitive rates, and it allows you to use any Caller ID, which is very convenient for call forwarding. The Voxbeam gateway authenticates the clients by their IP addresses only, so you need a static IP address, and no username or password are required. The FreeSWITCH configuration shown below allows you to control which destinations should be routed to Voxbeam. With a bit of further extension, you can also control which destinations would use different tariff plans at Voxbeam. This configuration covers only their Standard pricing plan. Here INTERNALDOMAIN is a name of the SIP realm that is used for registered users. We assume that the variable “outbound_caller_id_number” is set elsewhere above in the dialplan.

--- File: ip_profiles/external/voxbeam.xml --- <include>   <gateway name="voxbeam_outbound">     <param name="realm" value="sbc.voxbeam.com" />     <param name="register" value="false" /> <!-- important, so that your caller ID is transmitted properly -->     <param name="caller-id-in-from" value="true"/>   </gateway> </include> --- File: dialplan/INTERNALDOMAIN/05_pstn_outbound.xml --- <include> <!-- Express destination and caller numbers in E.164 notation without leading plus sign. Note that we treat numbers with one leading zero as local Swiss numbers -->   <extension name="pstn_normalize" continue="true">     <condition field="destination_number" expression="^00([1-9]\d+)$" break="never">       <action inline="true" application="set" data="e164_dest=$1"/>     </condition>     <condition field="destination_number" expression="^0([1-9]\d+)$" break="never">       <action inline="true" application="set" data="e164_dest=41$1"/>     </condition>     <condition field="${outbound_caller_id_number}" expression="^00([1-9]\d+)$" break="never">       <action inline="true" application="set" data="e164_cid=$1"/>     </condition>     <condition field="${outbound_caller_id_number}" expression="^0([1-9]\d+)$" break="never">       <action inline="true" application="set" data="e164_cid=41$1"/>     </condition>   </extension> <!-- Here we define that calls to Russia and Ukraine should go through Voxbeam -->   <extension name="pstn_select_itsp" continue="true">     <condition field="${e164_dest}" expression="^(7|38)" break="on-true">       <action inline="true" application="set" data="outbound_itsp=voxbeam"/>     </condition>   </extension>   <!-- send matched calls to Voxbeam -->   <extension name="pstn_voxbeam">     <condition field="${outbound_itsp}" expression="^voxbeam$" break="on-false">       <action application="set" data="effective_caller_id_number=${e164_cid}"/>       <action application="bridge" data="sofia/gateway/voxbeam_outbound/0011103${e164_dest}"/>     </condition>   </extension> <!-- send everything else to Sipcall.ch -->   <extension name="pstn_sipcall">     <condition field="destination_number" expression="^(0\d+)$">       <action application="set" data="effective_caller_id_number=${outbound_caller_id_number}"/>       <action application="bridge" data="sofia/gateway/sipcall/$1"/>     </condition>   </extension> </include>

This is a very simple example, and a bit more logic can be introduced, such as looking up in some kind of a database for least cost routing, and so on.


Filed under: Networking Tagged: freeswitch, pbx, sip, voip

Installing Go 1.3 in debian wheezy

Mon, 09/15/2014 - 12:58

The original script is found here: http://www.snip2code.com/Snippet/79027/How-to-install-Go-1-3-in-debian-wheezy

The original script is a bit dated, and now 1.3-1 is the latest version:

## File: go1.3-install-deb.sh
apt-get install devscripts build-essential
apt-get build-dep golang-go

wget http://ftp.de.debian.org/debian/pool/main/g/golang/golang_1.3-3.dsc
wget http://ftp.de.debian.org/debian/pool/main/g/golang/golang_1.3.orig.tar.gz
wget http://ftp.de.debian.org/debian/pool/main/g/golang/golang_1.3-3.debian.tar.xz

dpkg-source -x golang_1.3-3.dsc
cd golang-1.3/
debuild -us -uc
cd ..
dpkg -i \
golang-go_1.3-3_amd64.deb \
golang-src_1.3-3_amd64.deb \
golang-go-linux-amd64_1.3-3_amd64.deb \

echo Finished

Filed under: Programming Tagged: go, golang

mSATA drives for PC Engines APU

Tue, 08/05/2014 - 18:35

Drives with problems:

  1. KingSpec 16GB (Model Number: KingSpec KSM-mSATA.7i-016MJ, Firmware Revision:  SVN454): quite often, the kernel times out to boot at the start.
  2. SuperSSpeed S238: with the old firmware, TRIM operation erased the boot sector. The newer firmware disables TRIM.

Drives without problems (everything works fine with TRIM)

  1. MyDigitalSSD Super Boot Drive (Model Number:  SB mSATA SSD, Firmware Revision: S9FM01.8)
  2. SanDisk X110 (Model Number: SanDisk SD6SF1M032G1022I, Firmware Revision: X231200)
  3. Kingston Now (Model Number: KINGSTON SMS200S330G, Firmware Revision: 524ABBF0)

The testing procedure is quite simple: a background process is massively creating and deleting a small file, and another process calls fstrim every few seconds. Then the health of the filesystem is checked after an hour or so.

while true; do echo xxxxxxxxxxxxxxxxxxxxxxxx >xxx; done & while true; do fstrim -v /; sleep 10; done


Filed under: Hardware Tagged: linux, pcengines

3G connectivity for PC Engines APU (MC8775)

Sat, 06/21/2014 - 02:21

PC Engines’ APU board has its mPCIe slot 2 wired to the SIM card socket, which allows using any standard mPCIe 3G modem. Most of modern modems are quite expensive, but there are plenty of Sierra Wireless MC8775 cards at aliexpress.com for around $20 apiece. This is a decent hardware, manufactured around 2007-2011. It doesn’t deliver the highest UMTS speeds possible, but still can be used in situations where speed is unimportant.

The cards that I bought came with firmware version 1_1_8_15, dated 2007/07/17. I didn’t test it fully, but there are some failure reports in the internet.

The firmware upgrade requires an adapter with a SIM card slot. I got mine from this eBay seller.

This page describes the firmware upgrade process. The links to istudioz.net are still valid, but you need to remove # (%23) from the URLs. The 3G watcher for the AirCard 875 is unavailable at its original place, but easy to find with Google. I got mine at this site. The upgrade requires a 32bit Windows machine, and takes about 20 minutes. I upgraded the firmware successfully with my old Vista laptop.

Also I bought the 3G antenna and the pigtail cable at aliexpress.

After inserting the 3G modem into mPCIe slot 2 and booting Debian Wheezy, the device was immediately visible as three serial USB interfaces (/dev/ttyUSB0  /dev/ttyUSB1  /dev/ttyUSB2). ttyUSB0 is used for data, and ttyUSB2 can be used for controlling the device with AT commands. The command “AT^CARDMODE” will tell if the SIM card is inserted, and “AT!GSTATUS?” displays the network status information. “AT+GMR” displays the current firmware version. Ctrl-a Ctrl-x sequence will finish the picocom session.

apt-get install -y wvdial picocom picocom -b 115200 /dev/ttyUSB2 AT^CARDMODE AT!GSTATUS? AT+GMR Ctrl-a Ctrl-x

The following /etc/wvdial.conf works with Sunrise.ch 3G network:

[Dialer Defaults] Modem = /dev/ttyUSB0 Baud = 460800 Init1 = ATZ Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 Phone = *99# Username = '' Password = '' Ask Password = 0 Stupid Mode = 1 Compuserve = 0 Idle Seconds = 0 ISDN = 0 Auto DNS = 1

Execute “wvdial” comand from the command line, and it should immediately connect to the internet. The rest is easy: you can place wvdial into a startup script and execute it automatically at boot time.

Filed under: Networking Tagged: 3G, GSM, linux, networking, pcengines, UMTS

Simple performance test for FreeSWITCH conferencing

Thu, 05/08/2014 - 02:39

This is a simple test that gives you an estimation of audio conferencing scalability of FreeSWITCH on your hardware.

  1. You need one or two FreeSWITCH servers, and one of them should answer to sip:moh@IPADDR:5080. The fastest way is to install this FreeSWITCH configuration: https://github.com/xlab1/voip_qos_probe
  2. Edit vars.xml and remove G722 codec (or leave or replace it, if you want to test transcoding performance at the same time).
  3. Start FreeSWITCH: service freeswitch start
  4. Create conference participants by calling the MOH extension on the remote or the same server. This command will add a few dozens of participants in one go: timeout 2 sh -c "while true; do fs_cli -x 'conference xx dial sofia/internal/moh@IPADDR:5080'; done"
  5. check the number of participants: fs_cli -x 'show channels'
  6. run “top” or “mpstat -P ALL 1″ to see the CPU load, and add more batches of participants.

This test differs from real world because in a real conference, one speaks and others are listening. Here everyone speaks at the same time. FreeSWITCH evaluates the energy level to find the active speaker before replicating their voice, so I guess the real conference would take less CPU power (need to look into the source code).

Some test results: PC Engines APU platform with 50 conference participants had the CPU usage about 60%. A single core VPS at digitalocean.com was busy at around 50% during a test with 200 participants.

UPD1: (thanks bob bowles) Call out to yourself and monitor the sound quality with your own ear:

fs_cli -x 'conference human dial sofia/external/user@sip.domain.com'
Filed under: Networking Tagged: freeswitch, voip

End-to-end VoIP quality testing probes

Sun, 04/27/2014 - 02:50

This is a result of a project where we needed to measure voice QoS parameters (jitter and packet loss) in the customer network. I’ve set up small probe computers (old 10″ Intel Atom netbooks like Acer Aspire One) with FreeSWITCH and a few scripts for test automation. Each test consists of a 30-second call (producing approximately 1500 RTP packets in each direction), and tshark is measuring the received jitter and loss on each side.

Test details and the installation procedure are outlined on Github:



Filed under: Networking Tagged: freeswitch, network monitoring, sip, voip, xlab1

FreeSWITCH performance test on PC Engines APU

Sat, 04/19/2014 - 02:08

This test is analogous to the one I described for Intel Atom CPU.This time it’s the new APU board from PC Engines, the maker of famous ALIX and WRAP boards. APU is a fanless appliance board, with a dual-core 1GHz AMD G series CPU. The overall performance is comparable to that of Intel Atom.

In these tests, FreeSWITCH was forwarding the call to itself on request by pressing *1. Each such forwarding resulted in creating four new channels in G722 and G711, thus resulting in transcoding to G711 and back. For example, if “show channels” shows 5 channels, it’s equivalent to 2 simultaneous calls with transcoding.

Test result: 57 channels were running completely fine, 65 channels had slight distortions, and with 85 channels the speech was still recognizable, but with significant distortions. With Speex instead of G722, distortions were quite annoying at 25 channels. Thus, the APU platform can easily be used as a small-to-medium business PBX for  20-30 simultaneous calls if there’s not too much transcoding.

Test details follow.

Debian Wheezy was installed as described in my previous post. Then, GFreeSWITCH version 1.2.23 was installed from packages, as follows:

apt-get install -y curl git sysstat cat >/etc/apt/sources.list.d/freeswitch.list <<EOT deb http://files.freeswitch.org/repo/deb/debian/ wheezy main EOT curl http://files.freeswitch.org/repo/deb/debian/freeswitch_archive_g0.pub | apt-key add - apt-get update apt-get install -y freeswitch-meta-all cd /etc git clone https://github.com/xlab1/freeswitch_conf_minimal.git freeswitch

Then, /etc/freeswitch/dialplan/public/05_test.xml was added as follows:

<include> <!-- Extension 100 accepts the initial call, plays echo, and on pressing *1 it transfers to 101 -->     <extension name="100">       <condition field="destination_number" expression="^100$">         <action application="answer"/>         <action application="bind_meta_app" data="1 a si transfer::101 XML ${context}"/>         <action application="delay_echo" data="1000"/>       </condition>     </extension>     <!-- Extension 101 plays a beep, then makes an outgoing SIP call from our internal profile to our own external profile and extension 200 -->     <extension name="101">       <condition field="destination_number" expression="^101$">         <action application="playback" data="tone_stream://%(100,100,1400,2060,2450,2600)"/>         <action application="unbind_meta_app" data=""/>         <action application="bridge"                 data="{absolute_codec_string=PCMA}sofia/internal/200@${sip_local_network_addr}:5080"/>       </condition>     </extension> <!-- Extension 200 returns the call to 100 as a new outgoing SIP call from our internal profile to our own external profile -->     <extension name="200">       <condition field="destination_number" expression="^200$">         <action application="answer"/>         <action application="bridge"                 data="{max_forwards=65}{absolute_codec_string=G722}sofia/internal/100@${sip_local_network_addr}:5080"/>       </condition>     </extension>     </include>

After sending the initial call from a SIP phone to extension 100 at our APU’s IP address and port 5080, after pressing *1 we get 2 new channels with transcoding. Below are results of “mpstat -P ALL 1″ command during the test:

# quite clear sound root@apu:/etc/freeswitch# fs_cli -x 'show channels' | grep total 57 total. 11:35:07 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle 11:35:08 PM  all   41.71    0.00    8.00    0.00    0.00    0.57    0.00    0.00   49.71 11:35:08 PM    0   43.68    0.00    5.75    0.00    0.00    1.15    0.00    0.00   49.43 11:35:08 PM    1   40.45    0.00   10.11    0.00    0.00    0.00    0.00    0.00   49.44 # slight distortions root@apu:/etc/freeswitch# fs_cli -x 'show channels' | grep total 65 total. 11:36:27 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle 11:36:28 PM  all   55.98    0.00    8.70    0.00    0.00    0.54    0.00    0.00   34.78 11:36:28 PM    0   55.91    0.00    7.53    0.00    0.00    2.15    0.00    0.00   34.41 11:36:28 PM    1   55.43    0.00    9.78    0.00    0.00    0.00    0.00    0.00   34.78 # significant distortions root@apu:/etc/freeswitch# fs_cli -x 'show channels' | grep total 85 total. 11:37:34 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle 11:37:35 PM  all   71.13    0.00    9.28    0.00    0.00    2.06    0.00    0.00   17.53 11:37:35 PM    0   71.72    0.00    9.09    0.00    0.00    2.02    0.00    0.00   17.17 11:37:35 PM    1   71.58    0.00    9.47    0.00    0.00    2.11    0.00    0.00   16.84

If G722 is replaced with Speex codec, the CPU load is significantly higher, and already with 25 channels the distortions are quite significant:

# speex 8kHz, distortions root@apu:/etc/freeswitch# fs_cli -x 'show channels' | grep total 25 total. 12:59:46 AM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle 12:59:47 AM  all   54.10    0.00    1.64    0.00    0.00    0.00    0.00    0.00   44.26 12:59:47 AM    0   53.85    0.00    2.20    0.00    0.00    0.00    0.00    0.00   43.96 12:59:47 AM    1   54.95    0.00    1.10    0.00    0.00    0.00    0.00    0.00   43.96
Filed under: Networking Tagged: freeswitch, pbx, pcengines, sip, voip

PC Engines APU board: installing Debian on mSATA drive

Sun, 04/06/2014 - 06:58

PC Engines started shipping its new APU board in 2014. It can boot from an SD card (slow on writes), and it can also have an mSATA drive and boot from it (fast read-write, and more write cycles). Voyage Linux is well optimized for SD card.

Here I started my scripts for building a Debian CD and installing it on APU’s mSATA drive: https://github.com/ssinyagin/pcengines-apu-debian-cd


Filed under: Networking Tagged: debian, linux, pcengines

Call forwarding/redirection in FreeSWITCH

Sun, 02/16/2014 - 06:57

Consider you have two different contexts in your dialplan for inbound and outbound calls: the “public” context transfers the calls into “XXX_inbound” (XXX being your organization name), and the user directory has “XXX_outbound” as “user_context” variable.

Having two contexts, you have more flexibility in defining the short dial strings and outbound destinations.

But there’s a little problem: if the SIP client redirects the ringing call, or if the user makes an attended transfer, FreeSWITCH would initiate a new outbound leg in the same context where the call was bridged toward the SIP client.

As a solution, you need to define a new extension in your XXX_inbound context which would match PSTN outbound numbers. The channel will already have all custom variables which were set before bridging toward the SIP client, so you can set an additional condition criteria to make sure that this is the redirected call. This example would be placed at the bottom of the inbound context, and “directory_ext” is the variable that was earlier in the same context before the call was bridged to the SIP client:

    <extension name="call_forward">       <condition field="destination_number" expression="^\d+$"/>       <condition field="${directory_ext}" expression="^70\d$">         <action application="set" data="hangup_after_bridge=true"/>         <action application="set" data="continue_on_fail=false"/>         <action application="bridge" data="${outgw}/${destination_number}"/>       </condition>             </extension>
Filed under: Networking Tagged: freeswitch, pbx, sip, voip


Using the greatness of Parallax

Phosfluorescently utilize future-proof scenarios whereas timely leadership skills. Seamlessly administrate maintainable quality vectors whereas proactive mindshare.

Dramatically plagiarize visionary internal or "organic" sources via process-centric. Compellingly exploit worldwide communities for high standards in growth strategies.

Get free trial

Wow, this most certainly is a great a theme.

John Smith
Company name

Startup Growth Lite is a free theme, contributed to the Drupal Community by More than Themes.