Asterisk: The Future of Telephony

Leif Madsen

Jared Smith

Jim Van Meggelen

Abstract

It may be a while before Internet telephony with VoIP (Voice over Internet Protocol) reaches critical mass, but there's already tremendous movement in that direction. A lot of organizations are not only attracted to VoIP's promise of cost savings, but its ability to move data, images, and voice traffic over the same connection. Think of it: a single Internet phone call can take information sharing to a whole new level.

That's why many IT administrators and developers are actively looking to set up VoIP-based private telephone switching systems within the enterprise. The efficiency that network users can reach with it is almost mind-boggling. And cheap, if the system is built with open source software like Asterisk. There are commercial VoIP options out there, but many are expensive systems running old, complicated code on obsolete hardware. Asterisk runs on Linux and can interoperate with almost all standards-based telephony equipment. And you can program it to your liking.

Asterisk's flexibility comes at a price, however: it's not a simple system to learn, and the documentation is lacking. Asterisk: The Future of Telephony solves that problem by offering a complete roadmap for installing, configuring, and integrating Asterisk with existing phone systems. Our guide walks you through a basic dial plan step by step, and gives you enough working knowledge to set up a simple but complete system.

What you end up with is largely up to you. Asterisk embraces the concept of standards-compliance, but also gives you freedom to choose how to implement your system. Asterisk: The Future of Telephony outlines all the options, and shows you how to set up voicemail services, call conferencing, interactive voice response, call waiting, caller ID, and more. You'll also learn how Asterisk merges voice and data traffic seamlessly across disparate networks. And you won't need additional hardware. For interconnection with digital and analog telephone equipment, Asterisk supports a number of hardware devices.

Ready for the future of telephony? We'll help you hook it up.


Table of Contents

Copyright
Foreword
Preface
1. Audience
2. Organization
3. Software
4. Conventions Used in This Book
5. Using Code Examples
6. Safari® Enabled
7. How to Contact Us
8. Acknowledgments
8.1. Leif Madsen
8.2. Jared Smith
8.3. Jim Van Meggelen
1. A Telephony Revolution
1.1. VoIP: Bridging the Gap Between Traditional Telephony and Network Telephony
1.1.1. The Zapata Telephony Project
1.2. Massive Change Requires Flexible Technology
1.3. Asterisk: The Hacker's PBX
1.4. Asterisk: The Professional's PBX
1.5. The Asterisk Community
1.5.1. The Asterisk Mailing Lists
1.5.2. The Asterisk Wiki
1.5.3. The IRC Channels
1.5.4. Asterisk User Groups
1.5.5. The Asterisk Documentation Project
1.6. The Business Case
1.7. This Book
2. Preparing a System for Asterisk
2.1. Server Hardware Selection
2.1.1. Performance Issues
2.1.2. Choosing a Processor
2.1.2.1. Small systems
2.1.2.2. Medium systems
2.1.2.3. Large systems
2.1.3. Choosing a Motherboard
2.1.4. Power Supply Requirements
2.1.4.1. Computer power supplies
2.1.4.2. Redundant power supplies
2.2. Environment
2.2.1. Power Conditioning and Uninterruptible Power Supplies
2.2.1.1. Power-conditioned UPSs
2.2.2. Grounding
2.2.3. Electrical Circuits
2.2.4. The Equipment Room
2.2.4.1. Humidity
2.2.4.2. Temperature
2.2.4.3. Dust
2.2.4.4. Security
2.3. Telephony Hardware
2.3.1. Connecting to the PSTN
2.3.1.1. Analog interface cards
2.3.1.2. Digital interface cards
2.3.1.3. Channel banks
2.3.1.4. Other types of PSTN interfaces
2.3.2. Connecting Exclusively to a Packet-Based Telephone Network
2.3.3. Echo cancellation
2.4. Types of Phones
2.4.1. Physical Telephones
2.4.1.1. Analog telephones
2.4.1.2. Proprietary digital telephones
2.4.1.3. ISDN telephones
2.4.1.4. IP telephones
2.4.2. Soft Phones
2.4.3. Telephony Adaptors
2.4.4. Communications Terminals
2.5. Linux Considerations
2.6. Conclusion
3. Installing Asterisk
3.1. What Packages Do I Need?
3.1.1. Linux Package Requirements
3.2. Obtaining the Source Code
3.2.1. Obtaining Asterisk Source Code
3.2.2. Extracting the Source Code
3.3. Menuselect
3.4. Compiling Zaptel
3.4.1. The ztdummy Driver
3.4.2. The Zapata Telephony Drivers
3.4.3. Using ztcfg and zttool
3.5. Compiling libpri
3.6. Compiling Asterisk
3.6.1. Standard Installation
3.6.2. Alternative make Arguments
3.6.2.1. make clean
3.6.2.2. make distclean
3.6.2.3. make update
3.6.2.4. make webvmail
3.6.2.5. make progdocs
3.6.2.6. make config
3.6.3. Using Precompiled Binaries
3.7. Installing Additional Prompts
3.8. Common Compiling Issues
3.8.1. Asterisk
3.8.1.1. configure: error: no acceptable C compiler found in $PATH
3.8.1.2. configure: error: C++ preprocessor "/lib/cpp" fails sanity check
3.8.1.3. configure: error: *** termcap support not found
3.8.2. Zaptel
3.8.2.1. make: cc: Command not found
3.8.2.2. FATAL: Module wctdm/fxs/fxo not found
3.8.2.3. Unresolved symbol link when loading ztdummy
3.8.2.4. Depmod errors during compilation
3.9. Loading Asterisk and Zaptel Quickly
3.10. Loading Zaptel Modules Without Scripts
3.10.1. Systems Running udevd
3.10.2. Loading Zaptel
3.10.3. Loading ztdummy
3.11. Loading libpri Without Scripts
3.12. Starting Asterisk Without Scripts
3.12.1. Console Commands
3.13. Directories Used by Asterisk
3.13.1. /etc/asterisk/
3.13.2. /usr/lib/asterisk/modules/
3.13.3. /var/lib/asterisk
3.13.4. /var/spool/asterisk/
3.13.5. /var/run/
3.13.6. /var/log/asterisk/
3.13.7. /var/log/asterisk/cdr-csv
3.14. AsteriskNOW
3.14.1. What is AsteriskNOW™
3.14.2. Before You Begin
3.14.3. What You Will Need
3.14.4. Installation
3.14.4.1. Quick Installation
3.14.4.2. Extended Procedure
3.14.5. Accessing the GUI
3.14.6. Alternate Installations
3.14.7. For More Information
3.15. Conclusion
4. Initial Configuration of Asterisk
4.1. What Do I Really Need?
4.2. Working with Interface Configuration Files
4.3. Setting up the dial plan for some test calls
4.4. FXO and FXS Channels
4.4.1. Determining the FXO and FXS Ports on Your TDM400P
4.5. Configuring an FXO Channel for a PSTN connection
4.5.1. Zaptel Hardware Configuration
4.5.2. Zapata Hardware Configuration
4.5.3. Dialplan Configuration
4.5.4. Dialing in
4.6. Configuring an FXS Channel for an analog telephone
4.6.1. Zaptel Hardware Configuration
4.6.2. Zapata Hardware Configuration
4.6.3. Dialplan Configuration
4.7. Configuring SIP telephones
4.7.1. Basic SIP telephone configuration in Asterisk
4.7.2. Configuring the Device Itself
4.7.3. Essential Server Components
4.7.3.1. DHCP Server
4.7.3.2. FTP Server
4.7.4. CounterPath's X-Lite Softphone
4.7.5. Polycom's IP 430
4.7.5.1. DHCP Server
4.7.5.2. Protocol to use for downloading
4.7.5.3. FTP
4.7.5.4. The Polycom configuration files
4.7.6. Cisco 7960 telephone
4.7.7. Linksys SPA-942
4.7.7.1. Logging into the phone
4.7.7.2. Registering your phone to Asterisk
4.7.8. Configuring the dialplan for testing
4.8. Connecting to a SIP Service Provider
4.9. Connecting two Asterisk boxes together via SIP
4.9.1. Configuring our Asterisk boxes
4.9.2. SIP phone configuration
4.9.3. Configuring the dialplan
4.10. Configuring an IAX softphone
4.10.1. Configuring the channel configuration file (iax.conf)
4.10.2. Configure the softphone
4.10.3. Configuring the dialplan for testing
4.11. Connecting to an IAX Service Provider
4.12. Connecting two Asterisk boxes together via IAX
4.12.1. Configuring our Asterisk boxes
4.12.2. IAX phone configuration
4.12.3. Configuring the dialplan
4.13. Using templates in your configuration files
4.14. Debugging
4.14.1. Connecting to the Console
4.14.2. Enabling Verbosity and Debugging
4.15. Conclusion
5. Dialplan Basics
5.1. Dialplan Syntax
5.1.1. Contexts
5.1.2. Extensions
5.1.3. Priorities
5.1.3.1. Unnumbered Priorities
5.1.3.2. Priority Labels
5.1.4. Applications
5.2. A Simple Dialplan
5.2.1. The s Extension
5.2.2. The Answer(), Playback(), and Hangup() Applications
5.2.3. Our First Dialplan
5.3. Building an Interactive Dialplan
5.3.1. The Background(), WaitExten() and Goto() Applications
5.3.2. Handling Invalid Entries and Timeouts
5.3.3. Using the Dial() Application
5.3.4. Adding a Context for Internal Calls
5.3.5. Using Variables
5.3.5.1. Global variables
5.3.5.2. Channel variables
5.3.5.3. Environment variables
5.3.5.4. Adding variables to our dialplan
5.3.6. Pattern Matching
5.3.6.1. Pattern-matching syntax
5.3.6.2. Pattern-matching examples
5.3.6.3. Using the ${EXTEN} channel variable
5.3.7. Enabling Outbound Dialing
5.3.8. Includes
5.4. Conclusion
6. More Dialplan Concepts
6.1. Expressions and Variable Manipulation
6.1.1. Basic Expressions
6.1.2. Operators
6.2. Dialplan Functions
6.2.1. Syntax
6.2.2. Examples of Dialplan Functions
6.3. Conditional Branching
6.3.1. The GotoIf() Application
6.3.2. Time-Based Conditional Branching with GotoIfTime()
6.4. Voicemail
6.4.1. Creating Mailboxes
6.4.2. Adding Voicemail to the Dialplan
6.4.3. Accessing Voicemail
6.4.4. Creating a Dial-by-Name Directory
6.5. Macros
6.5.1. Defining Macros
6.5.2. Calling Macros from the Dialplan
6.5.3. Using Arguments in Macros
6.6. Using the Asterisk Database (AstDB)
6.6.1. Storing Data in the AstDB
6.6.2. Retrieving Data from the AstDB
6.6.3. Deleting Data from the AstDB
6.6.4. Using the AstDB in the Dialplan
6.7. Handy Asterisk Features
6.7.1. Zapateller()
6.7.2. Call Parking
6.7.3. Conferencing with MeetMe()
6.8. Conclusion
7. Understanding Telephony
7.1. Analog Telephony
7.1.1. Parts of an Analog Telephone
7.1.1.1. Ringer
7.1.1.2. Dial pad
7.1.1.3. Hybrid (or network)
7.1.2. Tip and Ring
7.2. Digital Telephony
7.2.1. Pulse-Code Modulation
7.2.1.1. Digitally encoding an analog waveform
7.2.1.2. Increasing the sampling resolution and rate
7.2.1.3. Nyquist's Theorem
7.2.1.4. Logarithmic companding
7.2.1.5. Aliasing
7.3. The Digital Circuit-Switched Telephone Network
7.3.1. Circuit Types
7.3.1.1. The humble DS-0, the foundation of it all
7.3.1.2. T-carrier circuits
7.3.1.3. SONET and OC circuits
7.3.2. Digital Signaling Protocols
7.3.2.1. Channel Associated Signaling (CAS)
7.3.2.2. ISDN
7.3.2.3. Signaling System 7
7.4. Packet-Switched Networks
7.5. Conclusion
8. Protocols for VoIP
8.1. The Need for VoIP Protocols
8.2. VoIP Protocols
8.2.1. IAX (The "Inter-Asterisk eXchange" Protocol)
8.2.1.1. History
8.2.1.2. Future
8.2.1.3. Security considerations
8.2.1.4. IAX and NAT
8.2.2. SIP
8.2.2.1. History
8.2.2.2. Future
8.2.2.3. Security considerations
8.2.2.4. SIP and NAT
8.2.3. H.323
8.2.3.1. History
8.2.3.2. Future
8.2.3.3. Security considerations
8.2.3.4. H.323 and NAT
8.2.4. MGCP
8.2.5. Proprietary Protocols
8.2.5.1. Skinny/SCCP
8.2.5.2. UNISTIM
8.3. Codecs
8.3.1.
8.3.1.1. G.711
8.3.1.2. G.726
8.3.1.3. G.729A
8.3.1.4. GSM
8.3.1.5. iLBC
8.3.1.6. Speex
8.3.1.7. MP3
8.4. Quality of Service
8.4.1. TCP, UDP, and SCTP
8.4.1.1. Transmission Control Protocol
8.4.1.2. User Datagram Protocol
8.4.1.3. Stream Control Transmission Protocol
8.4.2. Differentiated Service
8.4.3. Guaranteed Service
8.4.3.1. MPLS
8.4.3.2. RSVP
8.4.4. Best Effort
8.5. Echo
8.5.1. Why Echo Occurs
8.5.2. Managing Echo on Zaptel channels
8.5.3. Hardware Echo Cancellation
8.6. Asterisk and VoIP
8.6.1. Users and Peers and Friends—Oh My!
8.6.1.1. Users
8.6.1.2. Peers
8.6.1.3. Friends
8.6.2. register Statements
8.7. VoIP Security
8.7.1. Spam over Internet Telephony (SPIT)
8.7.2. Encrypting Audio with Secure RTP
8.7.3. Spoofing
8.7.4. What can be done?
8.7.4.1. Basic Network Security
8.7.4.2. Encryption
8.7.4.3. Physical Security
8.8. Conclusion
9. The Asterisk Gateway Interface (AGI)
9.1. Fundamentals of AGI Communication
9.1.1. What Are STDIN, STDOUT, and STDERR?
9.1.2. The Standard Pattern of AGI Communication
9.1.3. Calling an AGI Script from the Dialplan
9.2. Writing AGI Scripts in Perl
9.2.1. The Perl AGI Library
9.3. Creating AGI Scripts in PHP
9.3.1. The PHP AGI Library
9.4. Writing AGI Scripts in Python
9.4.1. The Python AGI Library
9.5. Debugging in AGI
9.5.1. Debugging from the Operating System
9.5.2. Using Asterisk's agi debug Command
9.6. Conclusion
10. Asterisk Manager Interface (AMI) and Adhearsion
10.1. The Manager Interface
10.1.1. Connecting to the Manager Interface
10.1.2. Sending Commands
10.1.2.1. Transferring a Call
10.1.2.2. Reading a Configuration File
10.1.2.3. Updating configuration files
10.2. The Flash Operator Panel
10.3. Asterisk Development with Adhearsion
10.3.1. A New Approach to Dial Plans
10.3.2. Asterisk Development with Adhearsion
10.3.3. Installing Adhearsion
10.3.3.1. Installing Ruby/RubyGems on AsteriskNOW
10.3.3.2. Installing Ruby/RubyGems on Linux
10.3.3.3. Installing Ruby/RubyGems on Mac OSX
10.3.3.4. Ruby/RubyGems on Windows
10.3.3.5. Installing Adhearsion from RubyGems
10.3.4. Exploring a New Adhearsion Project
10.3.4.1. Adhearsion Dial Plan Writing
10.3.4.2. Database Integration
10.3.4.3. Distributing and reusing code
10.3.5. Integrate with your desk phone using Micromenus
10.3.6. Integrating with a Web Application
10.3.7. Using Java
10.3.8. More Information
11. The Asterisk GUI Framework
11.1. Why a GUI for Asterisk?
11.2. What is the GUI?
11.2.1. Mark Spencer talks about the GUI
11.2.2. Overview of the GUI
11.2.3. Using the GUI
11.2.4. GUI Elements
11.3. Architecture of the Asterisk GUI
11.3.1. The Big Picture
11.3.2. Components of the Asterisk GUI
11.3.2.1. Asterisk Manager Interface
11.3.2.2. Manager over HTTP and the Asterisk web server
11.3.2.3. AJAM and JavaScript
11.4. Installing the Asterisk GUI
11.4.1. Setting up httpd.conf and manager.conf
11.5. Developing for the Asterisk GUI
11.5.1. Issuing Manager commands over HTTP
11.5.1.1. LOGIN
11.5.1.2. Transferring a Call
11.5.1.3. Reading a Configuration File
11.5.1.4. Updating configuration files using UPDATECONFIG
11.5.1.5. Error Response
11.5.2. AJAX, AJAM, and Asterisk
11.5.2.1. Form Processing in a Traditional Web Application
11.5.2.2. Form Processing in an AJAX Application
11.5.2.3. The Prototype framework
11.5.3. Customization of the GUI
11.5.3.1. Adding a new tab to the GUI
11.5.3.2. Exposing configuration settings in the GUI
11.5.4. For More Information
12. Relational Database Integration
12.1. Introduction
12.2. Installing the Database
12.3. Installing and Configuring ODBC
12.3.1. Configuring res_odbc for access to our database
12.4. Using Realtime
12.4.1. Static Realtime
12.4.2. Dynamic Realtime
12.5. Storing CDR Records
12.6. Getting funky with func_odbc . . . Hot-Desking
12.7. ODBC Voicemail
12.7.1. Creating the large object type
12.7.2. Configuring voicemail.conf for ODBC storage
12.7.3. Testing ODBC Voicemail
12.8. Conclusion
13. Managing Your Asterisk System
13.1. Call Detail Recording
13.2. Managing Logs
13.3. Running Asterisk as a Non-Root User
13.4. Customizing System Prompts
13.5. Music on Hold
13.6. Conclusion
14. Potpourri
14.1. Festival
14.1.1. Getting Festival Set Up and Ready for Asterisk
14.1.2. Configuring Asterisk for Festival
14.1.3. Starting the Festival Server
14.1.4. Calling Festival from the Dialplan
14.2. Call Files
14.3. DUNDi
14.3.1. How Does DUNDi Work?
14.3.2. Configuring Asterisk for Use with DUNDi
14.3.2.1. The General Peering Agreement
14.3.2.2. General configuration
14.3.2.3. Creating mapping contexts
14.3.2.4. Defining DUNDi peers
14.3.2.5. Allowing remote connections
14.3.2.6. Configuring the dialplan
14.4. Asterisk Extension Language (AEL)
14.5. Alternative Voicemail Storage Methods
14.5.1. Storing Voicemail in an IMAP server
14.5.2. Storing voicemail in an ODBC database
14.6. Asterisk and Jabber (XMPP)
14.7. Conclusion
15. Asterisk: The Future of Telephony
15.1. The Problems with Traditional Telephony
15.1.1. Closed Thinking
15.1.2. Limited Standards Compliancy
15.1.3. Slow Release Cycles
15.1.4. Refusing to Let Go of the Past and Embrace the Future
15.2. Paradigm Shift
15.3. The Promise of Open Source Telephony
15.3.1. The Itch That Asterisk Scratches
15.3.2. Open Architecture
15.3.3. Standards Compliance
15.3.4. Lightning-Fast Response to New Technologies
15.3.5. Passionate Community
15.3.6. Some Things That Are Now Possible
15.3.6.1. Legacy PBX migration gateway
15.3.6.2. Low-barrier IVR
15.3.6.3. Conference rooms
15.3.6.4. Home automation
15.4. The Future of Asterisk
15.4.1. Speech Processing
15.4.1.1. Festival
15.4.1.2. Speech Recognition
15.4.2. High-Fidelity Voice
15.4.3. Video
15.4.3.1. The challenge of video-conferencing
15.4.3.2. Why we love video-conferencing
15.4.3.3. Why video-conferencing may never totally replace voice
15.4.4. Wireless
15.4.4.1. Wi-Fi
15.4.4.2. Wi-MAX
15.4.5. Unified Messaging
15.4.6. Peering
15.4.6.1. E.164
15.4.6.2. ENUM
15.4.6.3. e164.org
15.4.6.4. DUNDi
15.4.7. Challenges
15.4.7.1. Too much change, too few standards
15.4.7.2. VoIP spam
15.4.7.3. Fear, uncertainty, and doubt
15.4.7.4. Bottleneck engineering
15.4.7.5. Regulatory wars
15.4.7.6. Quality of Service
15.4.7.7. Complexity
15.4.8. Opportunities
15.4.8.1. Tailor-made private telecommunications networks
15.4.8.2. Low barrier to entry
15.4.8.3. Hosted solutions of similar complexity to corporate web sites
15.4.8.4. Proper integration of communications technologies
A. VoIP Channels
A.1. IAX
A.1.1. General IAX Settings
A.1.2. Registering to other servers with register Statements
A.1.3. IAX Channel Definitions
A.1.3.1. Channel-specific parameters
A.2. SIP
A.2.1. General SIP Parameters
A.2.2. SIP Channel Definitions
B. Application Reference
AddQueueMember() — Dynamically adds queue members to the specified call queue
ADSIProg() — Loads an ADSI script into an ADSI-capable phone
AgentCallbackLogin() — Enables agent login with callback
AgentLogin() — Allows a call agent to log into the system
AgentMonitorOutgoing() — Records an agent's outgoing calls
AGI() — Executes an AGI-compliant application
AlarmReceiver() — Provides support for receiving alarm reports from a burglar or fire alarm panel
AMD() — Answering Machine Detection
Answer() — Answers a channel, if it is ringing
AppendCDRUserField() — Appends a value to the user field of the Call Detail Record
Authenticate() — Requires that the caller enter a correct password before continuing
Background() — Plays a file while accepting touch-tone (DTMF) digits
BackgroundDetect() — Plays a file in the background and detects talking
Busy() — Indicates a busy condition to the channel
ChangeMonitor() — Changes the monitoring filename of a channel
ChanIsAvail() — Finds out if a specified channel is currently available
ChannelRedirect() — Redirects a channel to a new location in the dialplan
ChanSpy() — Listen to the audio on a channel, and optionally whisper to the calling channel
Congestion() — Indicates congestion on the channel
ContinueWhile() — Restart a While() loop
ControlPlayback() — Plays a file, with the ability to fast forward and rewind the file
DateTime() — Says the date and/or time in the user-specified format
DBdel() — Deletes a key from the AstDB
DBdeltree() — Deletes a family or key tree from the Asterisk database
DeadAGI() — Executes an AGI-compliant script on a dead (hung-up) channel
Dial() — Attempts to connect channels
Dictate() — Virtual dictation machine
Directory() — Provides a dialable directory of extensions
DISA() — Direct Inward System Access: allows inbound callers to make outbound calls
DumpChan() — Dumps information about the calling channel to the console
EAGI()
Echo() — Echoes inbound audio back to the caller
EndWhile() — Ends a while loop
Exec() — Executes an Asterisk application dynamically
ExecIf() — Conditionally executes an Asterisk application
ExitWhile() — Exit from a While() loop, whether or not the conditional has been satisfied
ExtenSpy() — Listen to the audio on an extension, and optionally whisper to the calling channel
ExternalIVR() — Interfaces with an external IVR application
FastAGI() — Executes an AGI-compliant script across a network connection
Festival() — Uses the Festival text-to-speech engine to read text to the caller
Flash() — Flashes a Zap trunk
FollowMe() — Find Me / Follow Me functionality
ForkCDR() — Creates an additional CDR from the current call
GetCPEID() — Gets the CPE ID from an ADSI-capable telephone
Gosub() — Branches to a new location, saving the return address.
GosubIf() — Conditionally branches to a new location, saving the return address.
Goto() — Sends the call to the specified priority, extension, and context
GotoIf() — Conditionally goes to the specified priority
GotoIfTime() — Conditionally branches, depending on the time and day
Hangup() — Unconditionally hangs up the current channel
HasNewVoicemail() — Checks to see if there is new voicemail in the indicated voicemail box
HasVoicemail() — Indicates whether there is voicemail in the indicated voicemail box
IAX2Provision() — Provisions a calling IAXy device
ICES() — Stream audio to an Icecast server
ImportVar() — Sets a variable based on a channel variable from a different channel
Log() — Log a custom message from the dialplan
LookupBlacklist() — Performs a lookup of a Caller ID name/number from the blacklist database
LookupCIDName() — Performs a lookup of a Caller ID name from the AstDB
Macro() — Calls a previously defined dialplan macro
MacroExclusive() — Runs a macro, exclusive of any other channel
MacroExit() — Explicitly return from a macro
MacroIf() — Conditionally calls a previously defined macro
MailboxExists() — Conditionally branches if the specified voicemail box exists
MeetMe() — Puts the caller into a MeetMe conference bridge
MeetMeAdmin() — Performs MeetMe conference administration
MeetMeCount() — Counts the number of participants in a MeetMe conference
Milliwatt() — Generates a 1,000-Hz tone
MixMonitor() — Records a channel in the background, mixing both directions synchronously
Monitor() — Monitors (records) the audio on the current channel
MorseCode() — Plays Morse code
MP3Player() — Plays an MP3 file or stream
MusicOnHold() — Plays Music on Hold indefinitely
NBScat() — Plays an NBS local stream
NoCDR() — Disables Call Detail Records for the current call
NoOp() — Does nothing
Page() — Opens one-way audio to multiple phones
Park() — Parks the current call
ParkAndAnnounce() — Parks the current call and announces the call over the specified channel
ParkedCall() — Answers a parked call
PauseMonitor() — Suspends monitoring of a channel
PauseQueueMember() — Temporarily blocks a queue member from receiving calls
Pickup() — Answer a ringing call from another phone
Playback() — Plays the specified audio file to the caller
Playtones() — Plays a tone list
PrivacyManager() — Requires a caller to enter his or her phone number, if no Caller ID information is received
Progress() — Indicates progress
Queue() — Places the current call into the specified call queue
QueueLog() — Writes arbitrary queue events to the queue log
Random() — Conditionally branches, based upon a probability
Read() — Reads DTMF digits from the caller and assign the result to a variable
ReadFile() — Reads the contents of a file into a variable
RealTime — Looks up information from the RealTime configuration handler
RealTimeUpdate() — Updates a value via the RealTime configuration handler
Record() — Records channel audio to a file
RemoveQueueMember() — Dynamically removes queue members
ResetCDR() — Resets the Call Detail Record
RetryDial() — Attempts to place a call, and retries on failure
Return() — Returns from a Gosub or GosubIf
Ringing() — Indicates ringing tone
SayAlpha() — Spells a string
SayDigits() — Says the specified digits
SayNumber() — Says the specified number
SayPhonetic() — Spells the specified string phonetically
SayUnixTime() — Says the specified time in a custom format
SendDTMF() — Sends arbitrary DTMF digits to the channel
SendImage() — Sends an image file
SendText() — Sends text to the channel
SendURL() — Sets a variable to the specified value
Set() — Sets a variable to the specified value
SetAMAFlags() — Sets AMA flags in the Call Detail Record
SetCallerID() — Sets the Caller ID for the channel
SetCallerPres() — Sets Caller ID presentation flags
SetCDRUserField() — Sets the Call Detail Record user field
SetGlobalVar() — Sets a global variable to the specified value
SetMusicOnHold() — Sets the default Music on Hold class for the current channel
SetTransferCapability() — Set the ISDN transfer capability of a channel
SIPAddHeader() — Adds a SIP header to the outbound call
SIPDtmfMode() — Changes the DTMF method for a SIP call
SLAStation() — Shared line appearance station
SLATrunk() — Shared line appearance trunk
SoftHangup() — Performs a soft hangup of the requested channel
StackPop() — Removes last address from Gosub stack
StartMusicOnHold() — Starts Music on Hold
StopMixMonitor() — Stops monitoring a channel
StopMonitor() — Stops monitoring a channel
StopPlaytones() — Stops playing a tone list
StopMusicOnHold() — Stops Music on Hold
System() — Executes an operating system command
Transfer() — Transfers the caller to a remote extension
TryExec() — Tries to execute an Asterisk application
TrySystem() — Tries to execute an operating system command
UnpauseMonitor() — Resumes monitoring of a channel
UnpauseQueueMember() — Unpauses a queue member
UserEvent() — Sends an arbitrary event to the Manager interface
Verbose() — Sends arbitrary text to verbose output
VMAuthenticate() — Authenticates the caller from voicemail passwords
VoiceMail() — Leaves a voicemail message in the specified mailbox
VoiceMailMain() — Enters the voicemail system
Wait() — Waits for a specified number of seconds
WaitExten() — Waits for an extension to be entered
WaitForRing() — Waits the specified number of seconds for a ring
WaitForSilence() — Waits for a specified amount of silence
WaitMusicOnHold() — Waits the specified number of seconds, playing Music on Hold
While() — Starts a while loop
Zapateller() — Uses a special information tone to block telemarketers
ZapBarge() — Barges in on (monitors) a Zap channel
ZapRAS() — Executes the Zaptel ISDN Remote Access Server
ZapScan() — Scans Zap channels to monitor calls
C. AGI Reference
ANSWER
CHANNEL STATUS
DATABASE DEL
DATABASE DELTREE
DATABASE GET
DATABASE PUT
EXEC
GET DATA
GET FULL VARIABLE
GET OPTION
GET VARIABLE
HANGUP
NOOP
RECEIVE CHAR
RECORD FILE
SAY ALPHA
SAY DATE
SAY DATETIME
SAY DIGITS
SAY NUMBER
SAY PHONETIC
SAY TIME
SEND IMAGE
SEND TEXT
SET AUTOHANGUP
SET CALLERID
SET CONTEXT
SET EXTENSION
SET MUSIC ON
SET PRIORITY
SET VARIABLE
STREAM FILE
TDD MODE
VERBOSE
WAIT FOR DIGIT
D. Configuration Files
D.1. modules.conf
D.2. adsi.conf
D.3. adtranvofr.conf
D.4. agents.conf
D.5. alarmreceiver.conf
D.6. alsa.conf
D.7. amd.conf
D.8. asterisk.conf
D.9. cdr.conf
D.10. cdr_manager.conf
D.11. cdr_odbc.conf
D.12. cdr_pgsql.conf
D.13. cdr_tds.conf
D.14. codecs.conf
D.15. dnsmgr.conf
D.16. dundi.conf
D.17. enum.conf
D.18. extconfig.conf
D.19. extensions.conf
D.20. extensions.ael
D.21. features.conf
D.22. festival.conf
D.23. followme.conf
D.24. func_odbc.conf
D.25. gtalk.conf
D.26. http.conf
D.27. iax.conf
D.28. iaxprov.conf
D.29. indications.conf
D.30. jabber.conf
D.31. logger.conf
D.31.1. [general]
D.31.2. [logfiles]
D.32. manager.conf
D.33. meetme.conf
D.34. mgcp.conf
D.35. modem.conf
D.36. musiconhold.conf
D.37. osp.conf
D.38. oss.conf
D.39. phone.conf
D.40. privacy.conf
D.41. queues.conf
D.42. res_odbc.conf
D.43. res_snmp.conf
D.44. rpt.conf
D.45. rtp.conf
D.46. say.conf
D.47. sip.conf
D.48. sip_notify.conf
D.49. skinny.conf
D.50. sla.conf
D.51. smdi.conf
D.52. udptl.conf
D.53. users.conf
D.54. voicemail.conf
D.54.1. General Voicemail Settings
D.54.2. Voicemail Zones
D.54.3. Defining Voicemail Contexts and Mailboxes
D.55. vpb.conf
D.56. zapata.conf
D.57. zaptel.conf
E. Asterisk Dial Plan Functions
AGENT — Returns information about an agent
ARRAY — Allows one to define several variables at one time
BASE64_DECODE — Decode a BASE64 encoded string
BASE64_ENCODE
BLACKLIST — Check if the callerid is on the blacklist
CALLERID — Gets or sets CallerID data on the channel.
CDR — Gets or sets CDR information for this call (which will be written to the CDR log)
CHANNEL — Gets or sets various channel parameters
CHECK_MD5 — Validate an MD5 digest
CHECKSIPDOMAIN — Checks if a domain is local
CURL — Returns the data resulting from a GET or POST to a URI
CUT — Cuts a string based on a given delimiter
DB — Read or write to AstDB, the Asterisk database
DB_DELETE
DB_EXISTS — Check AstDB for specified key
DUNDILOOKUP
ENUMLOOKUP
ENV — References environment variables
EVAL
EXISTS — Check if value is non-blank
FIELDQTY — Counts fields
FILTER — Strip string of illegal characters
GLOBAL — References global namespace
GROUP — Associate the channel into a set group
GROUP_COUNT — Counts the number of channels in the specified group
GROUP_LIST — Lists channel groups
GROUP_MATCH_COUNT — Counts channels in a matching group name
IAXPEER — Obtains IAX channel information
IF — Conditional value selection
IFTIME
ISNULL — Checks if a value is blank
KEYPADHASH — Convert letters into numbers
LANGUAGE — Access the channel language
LEN — Calculates the string length
MATH — Mathematical calculations
MD5 — Calculates MD5 digest
MUSICCLASS — Access a channel's MOH setting
QUEUE_MEMBER_COUNT — Counts queue members
QUEUE_MEMBER_LIST — Lists queue members
QUEUE_WAITING_COUNT — Count waiting calls
QUEUEAGENTCOUNT
QUOTE — Escapes a string
RAND — Random number
REALTIME — Retrieves realtime data
REGEX — Compares based upon a regular expression
SET — Sets a variable
SHA1 — SHA-1 digest
SIP_HEADER — Retrieves a SIP header
SIPCHANINFO — Retrieves info on a SIP channel
SIPPEER — Retrieves info about a SIP peer
SORT — Sorts a list
SPEECH — Retrieves info on speech recognition results
SPEECH_ENGINE — Modify speech engine property
SPEECH_GRAMMAR — Retrieves speech grammar information
SPEECH_SCORE — Retrieves speech recognition confidence score
SPEECH_TEXT — Retrieves recognized text
SPRINTF — Formats a string
STAT — Evaluates file system attributes
STRFTIME — Formats the date and time
STRPTIME — Converts a string into a date and time
TIMEOUT — Accesses channel timeout values
TXTCIDNAME — DNS lookup
URIDECODE — Decodes a URI
URIENCODE — Encodes a URI
VMCOUNT — Counts voicemail messages
F. Asterisk Manager Interface Actions
AbsoluteTimeout — Set the Absolute Timeout on a channel
AgentCallbackLogin — Sets an agent as logged into the queue system in callback mode
AgentLogoff — Sets an agent as no longer logged in
Agents — Lists agents and their status
Challenge — Obtain a challenge-response token for authentication
ChangeMonitor — Change monitoring filename of a channel
Command — Execute an Asterisk CLI command
DBGet — Get AstDB Entry
DBPut — Put DB Entry
Events — Control Event Flow
ExtensionState — Check extension status
GetConfig — Retrieve configuration
GetVar — Retrieves the value of a variable
Hangup — Hangup Channel
IAXNetstats — Show IAX statistics
IAXPeers — List IAX Peers
ListCommands — List the manager commands
Login — Log into the Asterisk Manager Interface
Logoff — Logoff Manager
MailboxCount — Check mailbox message count
MailboxStatus — Check mailbox status
MeetmeMute — Mute a Meetme user
MeetmeUnmute — Unmute a Meetme user
Monitor — Monitor a channel
Originate — Originate Call
Park — Park a channel
ParkedCalls — List parked calls
PauseMonitor
Ping — Keepalive command
PlayDTMF — Play DTMF on a channel
QueueAdd — Add a member to the specified queue
QueuePause — Makes a queue member temporarily unavailable
QueueRemove — Remove interface from queue.
QueueStatus — Queue Status
Queues — Show basic queue information
Redirect — Redirect (transfer) a channel
SIPpeers — Lists all SIP peers
SIPshowpeer — Show information about a SIP peer
SetCDRUserField — Set the CDR UserField
SetVar — Set Channel Variable
Status — Lists channel status
StopMonitor — Stop the recording of a channel
UnpauseMonitor — Unpause monitoring
UpdateConfig — Update a config file
UserEvent — Send an arbitrary event
WaitEvent — Wait for an event to occur
ZapDNDoff — Sets a Zap channel Do Not Disturb status to off
ZapDNDon — Sets a Zap channel Do Not Disturb status to on
ZapDialOffhook — Dial over Zap channel while offhook
ZapHangup — Hangup Zap Channel
ZapRestart — Fully Restart zaptel channels
ZapShowChannels — Show status zapata channels
ZapTransfer — Transfer Zap Channel
G. An example of func_odbc
Hot-Desking (extensions.conf) — The dialplan code for the hot-desking feature from Chapter 10.
Hot-Desking (func_odbc.conf) — The custom dialplan functions we created for the hot-desking feature in Chapter 10.
Hot-Desking (sip.conf) — The two sample phone configurations and sample service provider configuration used in the hot-desking example from Chapter 10.

List of Figures

2.1. Visual identification of PCI slots
2.2. One way you might connect a Channel bank
3.1. Branches created from the Trunk
3.2. Sample menuselect screen
3.3. List of modules to be built
3.4. Layers of device interaction with Asterisk
3.5. /var/spool/asterisk/ directory structure
4.1. A TDM400P with an FXS module (1 across) and an FXO module (2 across)
4.2. X-Lite Configuration
4.3. X-Lite User Configuration
4.4. SPA-942 keypad
4.5. SIP trunking topology
4.6. idefisk
4.7. idefisk Account Options screen
4.8. IAX2 trunking topology
7.1. Tip and Ring
7.2. A simple sinusoidal (sine) wave
7.3. Sampling our sine wave using four bits
7.4. PCM encoded waveform
7.5. Plotted PCM signal
7.6. Delineated signal
7.7. The same waveform, on a higher-resolution overlay
7.8. The same waveform at double the resolution
7.9. Five-bit plotted PCM signal
7.10. Waveform delineated from five-bit PCM
7.11. Five-bit companding
7.12. Quantized and companded at 5-bit resolution
8.1. The SIP trapezoid
8.2. Call origination relationships of users, peers, and friends to Asterisk
10.1. The Flash Operator Panel management interface
11.1.
12.1. Relationships between func_odbc.conf, res_odbc.conf, /etc/odbc.ini (unixODBC), and the database connection
15.1. Asterisk as a PBX gateway
15.2. Find-me-follow-me
15.3. VoIP-enabling a legacy PBX
A.1. Trunking disabled
A.2. Trunking enabled

List of Tables

2.1. System requirement guidelines
2.2. Simple test results for SIPp default scenario utilizing simple Wait() and Playback() application. SIPp echoed media back to Asterisk.
3.1. List of packages required to compile libpri, Zaptel, and Asterisk
3.2. Non-Linux zaptel drivers
3.3. Asterisk Initialization Script Options
3.4. Zaptel Initialization Script Options
7.1. DTMF digits
7.2. T-carrier circuits
7.3. OC circuits
8.1. Codec quick reference