Linux Telephony a Short Overview
Total Page:16
File Type:pdf, Size:1020Kb
Linux Telephony A Short Overview Paul P. Komkoff Anna Anikina Roman Zhnichkov Google Ireland Ltd. Saratov State University Saratov State University [email protected] [email protected] [email protected] Abstract are obvious quality of service (QOS) requirements for signalling and data—signalling requires guaranteed de- This paper covers the topic of implementing voice ser- livery of every message, and data requires low-latency vices in packet-switched Voice Over IP (VoIP) and transmission, but can lose individual samples/frames. circuit-switched (traditional telephony) networks using Linux and commodity hardware. It contains a short 1.1 VoIP introduction into general telephony, VoIP, and Public Switched Telephony Networks (PSTN). It also provides Voice over IP (VoIP) is widely used to describe various an overview of VoIP services, including the open-source services, setups, and protocols that pass audio data in software packages used to implement them, and the ker- pseudo real-time over IP networks. Although the actual nel interfaces they include. It explains kernel support implementations are very different, the basic require- for connecting Public Switched Telephony Networks us- ments are to pass voice data in two directions and to ing digital interfaces (E1/T1) via the Zaptel framework, allow two-party conversation. VoIP is packet-switched and user-space integration issues. The conclusion ex- telephony because the underlying network is packet- amines current trends in Linux-based and open-source switched. To make conversations possible a virtual cir- telephony. cuit is built between parties. A basic understanding of networking concepts is helpful There are many protocols used for VoIP conversa- for understanding this presentation. tions. The most widespread is Session Initiation Pro- tocol (SIP). This is a signalling protocol in that it only 1 Introduction to general telephony, VoIP and handles call setup and termination. Actual session setup PSTN between endpoints is handled by SDP (Session Descrip- tion Protocol), and data is transmitted by RTP (Real- Time Protocol). SIP is described in RFC3561 and en- Although VoIP products like SkypeTM and Google TalkTM dorsed by IETF as an Internet standard. are storming the telecommunications landscape, almost everyone still owns a telephone and uses it daily. Under- Another protocol with a large user-base is H.323. While standing how telephony works is still an obscure topic SIP is designed mostly by network people it is similar for most people. As a result, we would like to begin to HTTP (its messages are text Name:Value pairs). our paper with a short introduction to telephony in gen- H.323, being endorsed by ITU—telephony people— eral, combined with two major types presently in use— looks like a traditional telephony protocol. Its messages packet-switched and circuit-switched. and information elements are described in ASN.1 (Ab- stract Syntax Notation) and coded by ASN.1 BER (Ba- Every telephony system needs to transmit data between sic Encoding Rules). H.323 is also a signalling protocol, parties, but before it can do so, it needs to find the other and also uses RTP for data transmission. party and a route to it. This is called call setup. Ac- tivity of this nature is usually performed by a signalling Inter-Asterisk Exchange (IAX) is another major VoIP protocol. Data can be passed via the same route and protocol. It was invented by the Asterisk R authors. In channel as signalling, or via the same route and a dif- this protocol, data and signalling streams are not sepa- ferent channel, or via an entirely different route. There rated, which allows easier NAT traversal. IAX is also • 231 • 232 • Linux Telephony able to pack multiple conversations into a single stream, a single protocol, but a protocol stack. It contains parts thus reducing trunking overhead. There are two versions which facilitate running SS7 itself and allows user parts of IAX, although IAX1 is deprecated, and IAX2 is used to run on top of it. The user part that is responsible for under name of IAX. voice call setup between parties is called ISUP (ISDN User Part). Services for mobile subscribers, ranging Other lesser known VoIP protocols are either proprietary from registration to SMS, are handled by MAP over SCCP ( is used in Cisco phones) or designed for specific TCAP (Mobile Application Part over Transaction Capa- MGCP purpose ( —Media Gateway Control Protocol— bilities Application Part) of SS7. used to manipulate VoIP gateways). Some protocols al- low direct conversation between endpoints while others require a server to operate. 2 Implementing VoIP services on Linux VoIP protocols define the way voice data should be To implement any voice service using VoIP, we do not transmitted. Conversion of digitized audio into pay- need any special hardware. Both clients and servers are load (portions of data to be delivered by the VoIP pro- done in software. We only need to implement a particu- tocol) is performed by voice codecs. The most popular lar VoIP protocol (SIP, H.323, IAX, MGCP, SCCP) and voice codecs are: G.711, G.723, G.726-G.729, iLBC, a particular set of voice codecs. GSM06.10, and Speex. Each has different bandwidth requirements, CPU requirements, quality, and patents After we have everything ready on the protocol and associated with them. These codecs are not all VoIP- codec sides, we can implement the voice service. For specific—G.711 is used in traditional telephony, and example, we can build a server that will handle client GSM06.10 is used in GSM mobile networks. registrations and calls to each other. This piece of soft- ware is typically called a softswitch because it func- 1.2 PSTN tions much like a hardware switch—building virtual cir- cuits between parties. Softswitches typically have the Public Switched Telephony Network (PSTN) is the tra- ability to provide optional services commonly found in ditional telephony network. Capable nodes in this traditional proprietary PBXes like conferencing, voice- network are addressed using global and unique E.164 mail, and IVR (Interactive Voice Responce) for an addi- addresses—telephone numbers. Nowadays PSTN in- tional charge. Modern opensource VoIP software logic cludes not only traditional telephones, but mobile is driven by powerful scripting languages—domain- phones as well. Most of the PSTN is digital (except specific (for building dialplans) or general purpose. This customer analog lines and very old installments in de- allows us to integrate with almost anything. For exam- veloping countries). PSTN is circuit-switched, which ple, we can try opensource speech synthesis/recognition means that the call setup procedure assembles a circuit software. between the parties on the call for the duration of the entire call. The circuit is either fixed-bandwidth digi- Many softswitches utilize special properties of partic- tal (typically 64kbps for traditional telephone networks ular VoIP protocols. For example, SIP and the H.323 and 9600bps for mobile networks) or analog—spanning architecture provide the ability to pass data directly be- multiple units of communication equipment. In digi- tween endpoints to reduce contention and minimize la- tal networks the circuit is made over E1 (for Europe) tency. Thousands of endpoints can be registered to one or T1 (America) lines, which contain 31 or 24 DS0 SIP server to control only signalling, allowing billing (64kbps) circuits, TDM-multiplexed together and thus and additional services. This is much better than sit- often called timeslots. ting in the middle of RTP streams between those clients. Moreover, sometimes it is possible to pass data directly The call management, call routing, circuit assignment between two endpoints while one of them is using SIP and maintenance procedures are performed by the sig- and another—H.323. This setup is called a signalling naling protocol. The de facto standard for intercon- proxy. necting networks is Signaling System 7 (SS7). Connec- tions to customer PBX (Private Branch Exchange) are Some softswitches are suitable only for VoIP clients (in- often performed using ISDN PRI (Primary Rate Inter- cluding VoIP-PSTN gateways acting as VoIP endpoint) face) connections and ISDN Q.931 signaling. SS7 is not while more general solutions are able to act as a switch 2007 Linux Symposium, Volume One • 233 between different VoIP protocols and PSTN itself. The Popular open source softphones include: Ekiga (pre- softswitches of the first kind are, for example, SIP viously Gnome Meeting), Kphone, and Kiax, which Express Router and sipX, while the major play- support major protocols (H.323, SIP, and IAX). The ers of the second kind are: Asterisk, CallWeaver supported voice codecs list is not as long as it might be (described later on), YATE, and FreeSwitch. due to patent issues. Even with access to an entirely free alternative like Speex, the user is forced to use patented To test the most widespread softswitch—Asterisk— codecs to connect to proprietary VoIP gateways and con- using VoIP only, download its source code from http: sumer devices. //asterisk.org, compile it, and install. With- out any additional software you have out-of-the-box SkypeTM , a very popular proprietary softphone, imple- support for SIP and IAX, a working IVR demo (in ments its own proprietary VoIP protocol. extensions.conf file), and many functions which you can attach to numbers in extensions.conf—asterisk applications. However, conferencing won’t work and 3 Connecting to PSTN music-on-hold can stutter. Call-center solutions based on Asterisk usually utilize In order to allow PSTN users to use the services de- Queue() application. Using different AGI (Asterisk scribed above, or at a minimum send and receive calls Gateway Interface) scripts and builtin applications like from other VoIP users, they need to connect to the SayNumber(), you can build an automatic answer- PSTN. There are several ways to do that: ing machine which reports the current time or account balance.