4.1. Hacks 4158: Introduction
The Linux domain of free software is a land flowing like milk and honey with telephony hacksthe hackers' Promised Land, so to speak. Of course, many of these hacks translate to BSD, and even to Mac OS X, since they're cast from a similar Unix mold.
In this chapter, I'll cover Asteriskthe open source telephony server designed originally for Linux, but now available for Mac OS X and BSD. Asterisk is a workhorse, a flexible, open system that's the telephony equivalent of Apache, the world's most widespread web server.
Because of its modularity and flexibility, Asterisk is as much a platform as is Linux. It's sort of become the cornerstone of Linux-based telephony, thanks to a vibrant developer community and a sound, open source foundation.
4.1.1. Getting Telephony Devices Connected to Asterisk
Besides implementing "pure VoIP"voice calls over packet networks like the Internet or your Internet Protocol local area network (IP LAN)Asterisk can also handle legacy telephone technologies, such as analog phones and phone lines, T1 lines, and various kinds of legacy signaling methods. A large and growing selection of PC expansion (PCI) cards are available that facilitate connecting analog phones and phone lines to an Asterisk server. So, if you want, you can build an Asterisk server that doesn't use VoIP at alljust legacy technologies like analog phones. Or you can build a server that bridges those previous-generation devices with Voice over IP.
The Asterisk software is maintained by Digium, Inc. (http://www.digium.com/), a manufacturer of many of the interface cards (and VoIP gateway devices) Asterisk supports. You can certainly use other interface cards with Asterisk, such as those manufactured by Sangoma and VoiceTronix. These manufacturers provide drivers for Asterisk's Zaptel driver framework that allow Asterisk to use them.
18.104.22.168. To FXO or to FXS, That Is the Question
To use traditional analog telephones and lines with an Asterisk server, you'll need to understand the difference between FXO and FXS. Their definitions are a source of some confusion, even among telecom folks. FXS (foreign exchange station) interfaces are used to connect telephones, which are FXS devices. FXS interfaces cause the Asterisk server to appear like the telephone company's central office switch when you plug in a phone. FXO (foreign exchange office) interfaces, on the other hand, are used to make your Asterisk server appear like a telephone so that you can connect it to the central office switch.
So, FXO interfaces connect your server to the phone company, and FXS interfaces connect your server to analog phones. Keep this distinction in mind as you work through the hacks in this chapter.
FXS and FXO interfaces are manufactured by many companies, including Intel, Digium, Sangoma, and Cisco, and they come in a variety of hardware flavors, too: PCI cards, rack-mountable enclosures, and tiny little single-line "converter boxes" that are reminiscent of Ethernet media converters. Though these interfaces are self-contained, standalone devices, they tend to be called media gateways, or just gateways.
22.214.171.124. And Then There Was T1
Digital circuits that employ the T1carrier (the most widespread type of digital telecommunications connectivity) can also be used to connect legacy phones to the Asterisk server, and to connect the Asterisk server to central office switches. Depending upon your needs and on what is available from your phone service provider, you might employ a primary rate interface (PRI) to hook up to 23 phone lines at a time to an Asterisk PBX, all on a single T1. Likewise, you can connect a T1 to an FXO interface box (a media gateway) to connect analog phones to the server, or you can connect a T1 to a device called a channel bank to connect 24 legacy analog phones or analog phone lines.
I've chosen hacks that will let you experiment with Asterisk while avoiding the relatively high cost and management overhead of T1s, though. I don't have a T1 in my home or in my business test lab, and I don't expect you to, either. Fortunately, though, lots of other great sources of information about T1 are available. For starters, check out T1: A Survival Guide (O'Reilly). Then, when you're ready to integrate legacy digital telecom into Asterisk, check out Switching to VoIP (O'Reilly) and Asterisk: The Future of Telephony (O'Reilly) for the details. You'll also get a much deeper exploration of Asterisk and enterprise telephony, to boot!
Now, let's get hacking, shall we?