VoIP with FreeSWITCH
Talk Soft
FreeSWITCH is a powerful and versatile telephony platform that can scale from a softphone to a PBX and even to a carrier-class softswitch.
Open source projects have lowered the barrier to entry into telephony for hobbyists and businesses alike. The popular Asterisk PBX tool, for instance, is a high-functioning and low-budget telephony alternative that has proven disruptive in the world of business telephone systems [1]. Perhaps the most disruptive software of all, however, comes in the form of the scalable softswitch library called FreeSWITCH.
The FreeSWITCH website [2] says that it can be used as a "simple switching engine, a PBX, a media gateway, or a media server to host IVR applications."
True to that chameleon-like description, FreeSWITCH has appeared in production environments as a telco switch, in numerous business scenarios as a PBX, as a softphone for laptop users, and even as a voice routing engine for the OpenSim project.
Additionally, you can deploy FreeSWITCH as an application or use it as a library (libfreeswitch) that can be embedded in third-party software. This double identity is similar to the relationship between cURL (application) and libcurl (library).
FreeSWITCH has been used in some exotic scenarios; however, those new to telephony applications are best served starting out with FreeSWITCH in its default configuration as a SOHO PBX. Although you might find the numerous FreeSWITCH configuration files and settings overwhelming, in a short time, you will appreciate the power and flexibility of this versatile telephony tool.
Installing FreeSWITCH
As of this writing, the current, stable version of FreeSWITCH is 1.0.4, which can be downloaded from the project website [3], or you can use the Subversion repository to install the latest version. Unlike many projects, the SVN trunk is extremely stable, so it might be convenient for you simply to use the latest trunk.
In any case, the FreeSWITCH developers have made it very easy to update to the latest trunk, even if you have installed from the latest stable version. Some pre-compiled binaries are known to exist; however, I recommend compiling from source.
First, unpack and install the source. In this example, I will download into /usr/src and install from there:
tar zxvf freeswitch-1.0.4.tar.gz cd freeswitch-1.0.4 ./configure make install
I recommend getting the sound files:
make cd-sounds-install make cd-moh-install
FreeSWITCH comes with and can handle sound files at 8, 16, 32, and 48kHz sampling rates. Few, if any, telephony systems – open source or proprietary – can do the kinds of things FreeSWITCH can do with calls at multiple sampling rates.
The installation will take some time, so feel free to chain the commands together with the && operator.
When the process is complete, you will have a basic FreeSWITCH installation. Because it is handy to have the two main FreeSWITCH executable files available in the bin path, I use symlinks:
ln -s /usr/local/freeswitch/bin/freeswitch /usr/local/bin/freeswitch ln -s /usr/local/freeswitch/bin/fs_cli /usr/local/bin/fs_cli
To launch the application, enter freeswitch, and use the fs_cli utility to access the command line of any FreeSWITCH server to which you have access, even if it is on another server. At first, you'll see quite a bit of debug/log information, but don't worry about errors or warnings at this point.
Your New Softswitch
The first basic command is version, which displays the version of Free-SWITCH you are running, including the SVN revision. The status command shows information about your instance of FreeSWITCH, including uptime and the number of currently active sessions. Another basic command is the self-descriptive help.
To exit FreeSWITCH, type fsctl shutdown or use the shortcut command … (three periods).
If you have a sound card or headset on your system then try this:
load mod_portaudio
After several debug lines, you'll see +OK when the module is loaded. Now list the PortAudio devices available on your system:
pa devlist API CALL [pa(devlist)] output: 0;Built-in Microphone;2;0;i 1;Built-in Input;2;0; 2;Built-in Output;0;2;r,o 3;Logitech USB Headset;0;2; 4;Logitech USB Headset;1;0;
The i and o are next to the currently selected input and output devices. To change the input device, use the pa indev command with the device number,
pa indev #x
where x is the number of the input device. The output device can be changed with the pa outdev command. In my setup, I'll use device 4 as output and device 5 as input.
If you have the MOH (music on hold) files installed, this command will make a call to the MOH extension and send the MOH to the PortAudio output device:
pa call 9999
If you hear music, it was a successful call. If not, make sure the MOH files were installed properly. Hang up with the pa hangup command.
To make sure both input and output devices are working, do an echo test:
pa call 9996
Now when you speak into the input device, your voice should be echoed to the output device. The pa hangup command disconnects.
As you can see, it is possible to use Free-SWITCH and PortAudio to create a simple softphone. In this way, you will be able to use any codec that your FreeSWITCH installation supports – and there are some very high quality codecs available – without installing a softphone client.
Connecting a SIP Phone
The most common way to use Free-SWITCH is with a SIP phone. A physical handset is often called a hard phone, whereas a software-based phone is appropriately called a softphone. Numerous types of hard phones are available from manufacturers. Softphones come in both proprietary and FLOSS varieties. A popular free – but not open source – softphone is X-Lite from CounterPath [4], which is available for Linux, Mac OS X, and Windows. Even if your FreeSWITCH server runs on Linux, your softphones can run on any operating system, as long as they are SIP compliant.
Session Initiation Protocol
SIP is a TCP/IP-based Application Layer protocol used for multimedia sessions over the Internet. The text-based protocol is similar to HTTP, with requests and responses, header fields, encoding rules, and status codes. In addition to VoIP, SIP is used in instant messaging, online gaming, and distribution of streaming multimedia.
To begin, download X-Lite for your desktop or laptop operating system and perform a default install. (Installing a softphone on the same system that is running FreeSWITCH is not recommended; however, in many cases, it will work for the sake of testing.)
Now launch X-Lite and open the SIP Account Settings menu by clicking the Show Menu button. (The button is the small down-arrow at the top of the phone, just left of center.)
Only one SIP account is available in X-Lite, so click on it then click the Properties button. As shown in Figure 1, fill in the fields and use 1234 as the password for extension 1000.
Next, clear out the Dialing plan field because it is not needed with FreeSWITCH. Now click OK then Close, and the phone will attempt to register. Figure 2 shows a successful registration.
To make a test call, dial 9999 and click the green button to send. In a few moments you should hear music on hold. Figure 3 shows a call in progress to extension 9999.
To shut down FreeSWITCH, use the fsctl shutdown (…) command.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
New Slimbook EVO with Raw AMD Ryzen Power
If you're looking for serious power in a 14" ultrabook that is powered by Linux, Slimbook has just the thing for you.
-
The Gnome Foundation Struggling to Stay Afloat
The foundation behind the Gnome desktop environment is having to go through some serious belt-tightening due to continued financial problems.
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.
-
OSI and LPI Form Strategic Alliance
With a goal of strengthening Linux and open source communities, this new alliance aims to nurture the growth of more highly skilled professionals.
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.