Open Source Telephony with Asterisk

139

Most people think of Voice over IP (VoIP) in reference to software phones like those used by the popular Skype service, but the term encompasses any technology that lets people speak in real time across the Internet, including softphones on the low end and full replacements for multi-line office telephone systems featuring voice mail, intercom, and conference calling on the high end.

At the center of the VoIP market sits Asterisk, a flexible open source telephony server. Asterisk can turn a Linux box into a telephone router for softphones, an interactive voice response (IVR) service for business, or anything in between. Asterisk can interface with the land-line phone system using special-purpose hardware, or can run a software-only service on a low-cost home wireless router.

The company that sponsors Asterisk’s development is Digium, which manufactures hardware for building high-density Asterisk servers. Such hardware includes multi-port PCI cards used to connect office phone lines to the Asterisk server, and cards to connect the server to the traditional public switched telephone network (PSTN). It also sells pre-built servers and embedded devices for those needing a turnkey solution.

Home users not in need of a dedicated server need not worry, though–Asterisk supports a range of other VoIP devices, including IP telephones from major vendors like Cisco and low-cost USB handsets and adapters.

Asterisk uses its own protocol to set up calls and to transmit full-duplex audio, called Inter-Asterisk Exchange (IAX). IAX is used between Asterisk servers, including between distributed Asterisk servers serving the same network, but it is not the only protocol Asterisk can speak. It also supports the standard Session Initiation Protocol (SIP) and Real-time Transport Protocol (RTP) used by most other VoIP products, and the standard H.323 stack commonly found in older hardware. For audio itself, Asterisk can use a wide range of standard audio codecs.

Getting It

To build an Asterisk system capable of handling a dozen or fewer concurrent phone lines, any modern PC will serve as a more than adequate platform. Larger systems and multi-site deployments demand that you consider CPU requirements in depth, because handling real-time processing of voice codecs can consume many processor cycles, and should not be interrupted by other running processes if call quality is to be maintained.

On the software side, Asterisk packages are available from most mainstream Linux distributions, and source code releases are provided directly by the Asterisk project. In addition, there are several Asterisk-centric distributions designed to quickly set up a dedicated Asterisk server, such as Trixbox and Elastix. The Asterisk server software has three main components: the Zapata telephony hardware drivers (originally named Zaptel, but now called DAHDI), the libPRI library for interfacing with external digital phone networks, and the Asterisk package itself. Lower level dependencies like OpenSSL and bison are standard components in any Linux distribution.

An alternative to running Asterisk on a traditional Linux PC or server is to install and run the package on a Linux-powered router. Popular free router distributions like DD-WRT and OpenWRT provide Asterisk packages for Linksys hardware, although you must be careful to check the hardware requirements: these routers tend to have very limited storage space for add-on software, and unlike PCs can be difficult to repair if something goes wrong. In addition, the limited RAM and comparatively low-power processors in most routers limit their usage to small, home office Asterisk setups. Still, if you have modest needs, running Asterisk on a router can be an inexpensive alternative, and one that keeps PC resources free for other tasks.

Configuration

Asterisk is configured through a set of text files stored in /etc/asterisk/. The file format is simple and human-readable, allowing you to configure and update your Asterisk server even over a remote SSH connection. Configuration files let you determine which modules and the server loads (to handle core functionality like connecting to the public telephone network or to SIP services), how incoming and outgoing calls are routed, and special services like IVR and intra-office voice mail. You can configure Asterisk to route calls based on pattern-matching, so that outgoing calls are routed to different outbound services depending on the time of day, whether the number dialed is local or long distance, or any other system you devise.

Asterisk deployment and management is a growing field for contractors, and as a result there are numerous front-end packages to make installing, monitoring, and maintaining Asterisk easier than the traditional text configuration file method. The Voip-Info.org wiki maintains a list of these front-ends; some are designed for simple call log accounting, some for full Asterisk administration, and some for full operating system-level server administration. Several are commercial products, but there are many free, open source projects in each category.

Add-Ons

In addition to the mundane call-routing and voice mail features that constitute the bulk of running a stable phone service, Asterisk is extensible, and there are add-on packages to enable other features. Add-on modules can integrate Asterisk with a company LDAP directory server, add fax support, management of calling card accounts, or tie in to the proprietary Skype network.

Security

Users accustomed to the proprietary, vendor-controlled networks used by the public telephone system and cellular services expect a measure of privacy on their phone calls. Unfortunately, privacy and security do not come free when building a VoIP system, so every Asterisk administrator needs to take a conscious look at the encryption and authentication schemes used. Asterisk supports encrypted session set-up and audio transport for calls, but setting up a secure service still requires attention to detail.

The best place to begin learning about Asterisk in depth is through the Asterisk project Web site. The documentation is thorough, including tutorials, a Knowledge Base, and community-written guides, plus you have access to a large user forum, where other Asterisk users can answer questions and you can find professional contractors if you decide you need a higher level of support.