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

FreeSWITCH startup for FusionPBX

Mon, 05/16/2016 - 04:23

If you install FreeSWITCH 1.6 on Debian 8 from official .deb packages, and then add FusionPBX on top, the server boot sequence needs a modification: now FreeSWITCH configuration depends on the presence of Postgresql server, and it would load an empty configuration if the database service is not available at the moment of start.

This fixup adds a dependency on FreeSWITCH systemd service, so that it launches only after Postgresql has started:

mkdir /etc/systemd/system/freeswitch.service.d/ cat  >/etc/systemd/system/freeswitch.service.d/fusionpbx.conf <<'EOT' [Unit] After=syslog.target network.target local-fs.target postgresql.service EOT
Filed under: Networking Tagged: freeswitch, linux, pbx, voip

tcpkali, TCP load generator

Thu, 05/05/2016 - 23:47

tcpkali is a lightweight and  easy-to-use tool that allows you to generate a traffic load with multiple TCP sessions. You push the load in one or both directions at the same time. Also the tool works easily over a NAT’ed connection. This tool is great if you need to test QoS for VoIP applications.

Here’s an example of a bidirectional load test:

# listening machine: listen on tcp port 8000, send traffic, and use 4 threads. # the program will exit in 1 hour. tcpkali -l 8000  --listen-mode=active -m X -T 1h -w 4 # connecting machine: send traffic using 4 threads and 10 simultaneous sessions # for 1 minute tcpkali -m Y -c 10 -T1m -w 4

The above test between directly connected PC Engines APU2 boards has shown 1Gbps of traffic, and the average CPU load was about 50%.

Filed under: Networking Tagged: linux, networking, pcengines, testing, voip

Novatel E371 WWAN LTE modem for APU

Mon, 04/04/2016 - 01:57

Novatel E371 (also known as Dell DW5804) is sold for less than $30 at Aliexpress, and it’s so far the cheapest 4G/LTE WWAN card suitable for PC-Engines APU.

The initialization is fairly simple, although it was tricky to find the right command (AT$NWQMICONNECT=,,).

cat >/etc/chatscripts/lte_on.E371 <<'EOT' ABORT BUSY ABORT 'NO CARRIER' ABORT ERROR TIMEOUT 10 '' ATZ OK 'AT+CFUN=1' OK 'AT+CMEE=1' OK 'AT\$NWQMICONNECT=,,' OK EOT cat >/etc/chatscripts/lte_off.E371 <<'EOT' ABORT ERROR TIMEOUT 5 '' AT\$NWQMIDISCONNECT OK AT+CFUN=0 OK EOT cat >/etc/network/interfaces.d/wwan0 <<'EOT' allow-hotplug wwan0 iface wwan0 inet dhcp     pre-up /usr/sbin/chat -v -f /etc/chatscripts/lte_on.E371 >/dev/ttyUSB0 </dev/ttyUSB0     post-down /usr/sbin/chat -v -f /etc/chatscripts/lte_off.E371 >/dev/ttyUSB0 </dev/ttyUSB0 EOT
Filed under: Networking Tagged: 3G, lte, pcengines, UMTS

One more 3G modem (Gobi2000) and a watchdog script

Sun, 04/03/2016 - 01:54

Qualcomm Gobi 2000 is quite old (released 2009), but decent 3G modem, able to deliver up to 7Mbps in downstream in PPP mode. These modems in mini-pcie packaging are available at Aliexpress for less than $10, and make up a great option for 3G connectivity for PC Engines APU boards.

The modem needs a binary firmware to be loaded at the start. Numerous sources in Internet describe the ways to retrieve these files. The kernel driver in Debian 8 recognizes the modem as generic Qualcomm one, and sets up a QMI device (wwan0). But this model does not support packet mode, and you need to run PPP over ttyUSB1 device.

apt-get install -y gobi-loader wvdial mkdir /lib/firmware/gobi cd /lib/firmware/gobi wget --no-check-certificate -nd -nc https://www.nerdstube.de/lenovo/treiber/gobi/{amss.mbn,apps.mbn,UQCN.mbn} cat >/etc/wvdial.conf <<'EOT' [Dialer Defaults] Init1 = ATZ Init2 = AT+CGDCONT=1,"IP","internet" Phone = *99# New PPPD = yes Modem = /dev/ttyUSB1 Dial Command = ATDT Baud = 9600 Username = '' Password = '' Ask Password = 0 Stupid Mode = 1 Compuserve = 0 Idle Seconds = 0 ISDN = 0 Auto DNS = 1  EOT cat >/etc/network/interfaces.d/ppp0 <<'EOT' auto ppp0 iface ppp0 inet wvdial EOT

Also this script is useful for 3G connections, because with some providers, the Internet connection gets stalled every few days and needs to be re-connected.

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

Quality Assurance for VoIP calls: integration scripts

Tue, 03/08/2016 - 10:36

The scripts for integrating FreeSWITCH with Sevana AQuA software are now available at github: https://github.com/voxserv/fsqa

More details on what they are doing are available in this older post: https://txlab.wordpress.com/2015/06/02/quality-assurance-for-voip-calls-2/

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

Quick IP prefix calculation

Mon, 06/08/2015 - 12:24

It’s a quite common task that you need to translate an IP address into a prefix — for example, when creating an IP prefix list from a set of addresses. Here’s a simple Perl script that helps it:

sudo apt-get install libnetaddr-ip-perl cat >getprefix.pl <<'EOT' use strict; use warnings; use NetAddr::IP; if( scalar(@ARGV) == 0 ) {     die("Usage: $0 PREFIX ..."); } foreach my $pref (@ARGV) {     my $ip = NetAddr::IP->new($pref) or         die("Cannot create NetAddr::IP from $pref");     print $ip->network()->cidr(), "\n"; } EOT # testing cat >/tmp/x <<'EOT' EOT cat /tmp/x | xargs perl getprefix.pl | awk '{print "set ", $1}' set set
Filed under: Networking Tagged: network management, networking, perl

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


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.