VoIP with FreeSWITCH

Outside the Local Switch

One advantage of VoIP is that you can make free or very low cost phone calls on the Internet. FreeSWITCH can route calls to and from the Internet, even if it is behind a NAT device. NAT devices cause all sorts of trouble for SIP calls; however, FreeSWITCH does a good job of working around these issues.

In many cases, the default configuration will work without any changes. A simple test is to call the FreeSWITCH public conference server. The SIP URI of this server is sip:888@conference.freeswitch.org, and the default Dialplan will connect your phone if you simply dial 9888.

If your call is successful, you will hear a text-to-speech (TTS) voice announce your caller ID name or number. If you are the only person in the conference, you will also hear a recording saying so.

To call the conference with PortAudio, enter:

pa call sip:888@conference.freeswitch.org

A number of service providers offer connection services to give you access to and from the public switched telephone network (PSTN) or simple SIP accounts. FreeSWITCH uses the concept of "gateways" to establish connections to these service providers. Gateways are used for outbound registrations to providers. If you already have a SIP provider, you will want to use the settings for that provider. The FreeSWITCH wiki has sample configurations for a number of providers [5]. In this example, I will show you how to set up a gateway for iptel.org, which offers free SIP accounts.

First, create an account on the iptel.org website [6] and note your username and password. Next, create a new file called iptel.org.xml in $CONF/sip_profiles/external. Be sure to put your username and password in the appropriate fields. The file should look like Listing 2.

Listing 2

Setting Up a Gateway for a SIP Account

 

Now save the file, then at the Free-SWITCH prompt, issue the command:

sofia profile external restart reloadxml

"Sofia" is the name of the SIP library [7] used by FreeSWITCH and is also the name of the command to perform SIP-related functions. (Just type sofia to see the syntax.) The above command tells FreeSWITCH to restart the external profile after reloading the XML data. The reloadxml is optional; however, if you've made changes to the XML data (by creating or editing a file), you will want those changes loaded when restarting the profile.

To see whether your system registered with iptel.org, issue the command:

sofia status

If your registration was successful, you will see a line like the following:

iptel gateway sip:myusername@sip.iptel.org REGED

The REGED state means that the gateway is successfully registered to the provider. If you see FAIL_WAIT, then most likely you have a configuration problem.

The last step to receiving calls is to allow incoming calls in the Dialplan. The default configuration has a "public" Dialplan context that treats incoming calls from the Internet as inherently untrusted.

First you need to allow calls to your new iptel.org user, then you need to specify where to route those calls. To do so, create a new file called $CONF/dialplan/public/00_inbound_iptel.xml (or make a copy of the example file named 00_inbound_did.xml). It should look like Listing 3.

Listing 3

00_inbound_iptel.xml

 

Be sure to specify your iptel.org username in the regular expression. Your username is the destination number. (Destination numbers are not restricted to numeric characters.)

The call is routed to the extension specified in parameters that are fed to the transfer application.

In my case, I routed to the MOH extension for the sake of testing. Also, you can route to your SIP phone. If you are registered as 1000, then the transfer destination is 1000 XML default. Save the file and then go to the FreeSWITCH prompt and press F6 (or type reloadxml) at the FreeSWITCH prompt.

To receive a call on your new account, you will need someone to make a SIP call to your new iptel.org SIP URI. In a pinch, you can test with PortAudio. At the FreeSWITCH prompt type:

pa call sip:myusername@sip.iptel.org

A successful call will ring the destination extension.

High-Quality Codecs

Traditional telephone calls are of marginal sound quality and mobile phone calls are worse. FreeSWITCH delivers high-quality, voice-quality calls with free and open source codecs. The CELT [8] open source codec is high quality and lossless.

Also included with FreeSWITCH are the Siren [9] codecs from Polycom. These high-quality codecs are closed source but royalty free. The default configuration loads the Siren codecs.

To load the CELT codec, issue the load mod_celt command.

One thing to keep in mind is that higher quality codecs could expose limitations in your headset equipment. Most newer headsets and those that are listed as "Skype certified" will generally perform well with the higher quality codecs. Personally, I use a Logitech Clear Chat Pro USB headset with good success.

For testing, I recommend making a call to a friend who also has Free-SWITCH installed.

To start, make a PSTN or mobile phone call, then hang up and immediately make a call with a high-quality codec. With the use of PortAudio, it is easy to test. First, edit $CONF/autoload_configs/portaudio.xml. Locate the line <param name="sample-rate" value ="8000"/>, change the value to 48000, and save the file.

At the FreeSWITCH prompt issue these commands:

reloadxml
reload mod_portaudio

Now make a call to your friend or call the FreeSWITCH conference:

pa call 9888

The audio quality should be much better, especially if you have a fast Internet connection. FreeSWITCH conferences can mix calls of any codec and any sampling rate. In fact, you can call in to the Free-SWITCH conference via the PSTN by dialing +1-213-799-1400 and compare the difference between the high-quality VoIP codecs and the low quality of the PSTN.

Where to Go Next

This brief introduction to FreeSWITCH barely scratches the surface of what this open source software can do. One way to put FreeSWITCH to practical use is presented by IBM's Rob Smart, who wrote a tutorial called "Home VOIP system using FreeSwitch and a Linksys 3102 voice gateway" [10] on how to set up FreeSWITCH as a home communications server in the UK.

A vibrant and growing community offers support to newcomers and veterans alike, so join this community and continue learning about the amazing possibilities of VoIP.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Post-PRISM Privacy

    Linux users didn't need the recent NSA eavesdropping scandal to convince them that securing communication was a good idea. Free software developers have been creating secure tools for years that offer similar functionalities to all of those popular but very leaky services with ridiculous names.

  • FreeSWITCH 1.0.2 with New Codecs and Fax for VoIP

    Free VoIP platform software FreeSWITCH is now in version 1.0.2. Enhancements include a fax module and new codecs for higher sampling rates.

comments powered by Disqus
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.

Learn More

News