9780596517342
index.html

Asterisk™: The Definitive Guide

Leif Madsen

Jim Van Meggelen

Russell Bryant

Printed in the United States of America.


Foreword
Preface
Audience
Organization
Software
Conventions Used in This Book
Using Code Examples
Safari Books Online
How to Contact Us
Acknowledgments
Leif Madsen
Jim Van Meggelen
Russell Bryant
1. A Telephony Revolution
Asterisk and VoIP: Bridging the Gap Between Traditional and Network Telephony
The Zapata Telephony Project
Massive Change Requires Flexible Technology
Asterisk: The Hacker’s PBX
Asterisk: The Professional’s PBX
The Asterisk Community
The Asterisk Mailing Lists
Asterisk Wiki Sites
The IRC Channels
Asterisk User Groups
The Asterisk Documentation Project
The Business Case
Conclusion
2. Asterisk Architecture
Modules
Applications
Bridging Modules
Call Detail Recording Modules
Channel Event Logging Modules
Channel Drivers
Codec Translators
Format Interpreters
Dialplan Functions
PBX Modules
Resource Modules
Addon Modules
Test Modules
File Structure
Configuration Files
Modules
The Resource Library
The Spool
Logging
The Dialplan
Hardware
Asterisk Versioning
Previous Release Methodologies
The New Release Methodology
Conclusion
3. Installing Asterisk
Installation Cheat Sheet
Distribution Installation
CentOS Server
Ubuntu Server
Software Dependencies
Downloading What You Need
Getting the Source via Subversion
Getting the Source via wget
How to Install It
LibPRI
DAHDI
Asterisk
Setting File Permissions
Base Configuration
Disable SELinux
Initial Configuration
make menuselect
Updating Asterisk
Common Issues
-bash: wget: command not found
configure: error: no acceptable C compiler found in $PATH
make: gcc: command not found
configure: error: C++ preprocessor “/lib/cpp” fails sanity check
configure: error: *** Please install GNU make. It is required to build Asterisk!
configure: *** XML documentation will not be available because the ‘libxml2’ development package is missing.
configure: error: *** termcap support not found
You do not appear to have the sources for the 2.6.18-164.6.1.el5 kernel installed.
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
Upgrading Asterisk
Conclusion
4. Initial Configuration Tasks
asterisk.conf
The [directories] Section
The [options] Section
The [files] Section
The [compat] Section
modules.conf
The [modules] Section
indications.conf
musiconhold.conf
Converting Music to a Format That Works Best with Asterisk
Conclusion
5. User Device Configuration
Telephone Naming Concepts
Hardphones, Softphones, and ATAs
Configuring Asterisk
How Channel Configuration Files Work with the Dialplan
sip.conf
iax.conf
Modifying Your Channel Configuration Files for Your Environment
Loading Your New Channel Configurations
The Asterisk CLI
Testing to Ensure Your Devices Have Registered
Analog Phones
A Basic Dialplan to Test Your Devices
Under the Hood: Your First Call
Conclusion
6. Dialplan Basics
Dialplan Syntax
Contexts
Extensions
Priorities
Applications
The Answer(), Playback(), and Hangup() Applications
A Simple Dialplan
Hello World
Building an Interactive Dialplan
The Goto(), Background(), and WaitExten() Applications
Handling Invalid Entries and Timeouts
Using the Dial() Application
Using Variables
Pattern Matching
Includes
Conclusion
7. Outside Connectivity
The Basics of Trunking
Fundamental Dialplan for Outside Connectivity
PSTN Circuits
Traditional PSTN Trunks
Installing PSTN Trunks
VoIP
PSTN Termination
PSTN Origination
VoIP to VoIP
Configuring VoIP Trunks
Emergency Dialing
Conclusion
8. Voicemail
Comedian Mail
The [general] Section
The [zonemessages] Section
The Contexts Section
An Initial voicemail.conf File
Dialplan Integration
The VoiceMail() Dialplan Application
The VoiceMailMain() Dialplan Application
Creating a Dial-by-Name Directory
Using a Jitterbuffer
Storage Backends
Linux Filesystem
ODBC
IMAP
Using Asterisk As a Standalone Voicemail Server
Integrating Asterisk into a SIP Environment As a Standalone Voicemail Server
SMDI (Simplified Message Desk Interface)
Conclusion
9. Internationalization
Devices External to the Asterisk Server
PSTN Connectivity, DAHDI, Digium Cards, and Analog Phones
DAHDI Drivers
Asterisk
Caller ID
Language and/or Accent of Prompts
Time/Date Stamps and Pronunciation
Conclusion—Easy Reference Cheat Sheet
10. Deeper into the Dialplan
Expressions and Variable Manipulation
Basic Expressions
Operators
Dialplan Functions
Syntax
Examples of Dialplan Functions
Conditional Branching
The GotoIf() Application
Time-Based Conditional Branching with GotoIfTime()
Macros
Defining Macros
Calling Macros from the Dialplan
Using Arguments in Macros
GoSub()
Defining Subroutines
Calling Subroutines from the Dialplan
Using Arguments in Subroutines
Returning from a Subroutine
Local Channels
Using the Asterisk Database (AstDB)
Storing Data in the AstDB
Retrieving Data from the AstDB
Deleting Data from the AstDB
Using the AstDB in the Dialplan
Handy Asterisk Features
Zapateller()
Call Parking
Conferencing with MeetMe()
Conclusion
11. Parking and Paging
features.conf
The [general] section
The [featuremap] Section
The [applicationmap] Section
Application Map Grouping
Parking Lots
Overhead and “Underchin” Paging (a.k.a. Public Address)
Places to Send Your Pages
Zone Paging
Conclusion
12. Internet Call Routing
DNS and SIP URIs
The SIP URI
SRV Records
Accepting Calls to Your System
Dialing SIP URIs from Asterisk
ENUM and E.164
E.164 and the ITU
ENUM
Asterisk and ENUM
ISN, ITAD, and freenum.org
Got ISN?
ITAD Subscriber Numbers (ISNs)
Management of Internet Numbering
IP Telephony Administrative Domains (ITADs)
Create a DNS Entry for Your ITAD
Testing Your ITAD
Using ISNs in Your Asterisk System
Security and Identity
Toll Fraud
Spam over Internet Telephony (SPIT)
Distributed Denial of Service Attacks
Phishing
Security Is an Ongoing Process
Conclusion
13. Automatic Call Distribution (ACD) Queues
Creating a Simple ACD Queue
Queue Members
Controlling Queue Members via the CLI
Controlling Queue Members with Dialplan Logic
Automatically Logging Into and Out of Multiple Queues
An Introduction to Device State
The queues.conf File
The agents.conf File
Advanced Queues
Priority Queue (Queue Weighting)
Queue Member Priority
Changing Penalties Dynamically (queuerules.conf)
Announcement Control
Overflow
Using Local Channels
Queue Statistics: The queue_log File
Conclusion
14. Device States
Device States
Checking Device States
Extension States
Hints
Checking Extension States
SIP Presence
Asterisk Configuration
Using Custom Device States
An Example
Distributed Device States
Using OpenAIS
Using XMPP
Shared Line Appearances
Installing the SLA Applications
Configuration Overview
Key System Example with Analog Trunks
Key System Example with SIP Trunks
Shared Extension Example
Additional Configuration
Limitations
Conclusion
15. The Automated Attendant
An Auto Attendant Is Not an IVR
Designing Your Auto Attendant
The Greeting
The Main Menu
Timeout
Invalid
Dial by Extension
Building Your Auto Attendant
Recording Prompts
The Dialplan
Delivering Incoming Calls to the Auto Attendant
IVR
Conclusion
16. Relational Database Integration
Installing and Configuring PostgreSQL and MySQL
Installing PostgreSQL for CentOS
Installing PostgreSQL for Ubuntu
Installing MySQL for CentOS
Installing MySQL for Ubuntu
Configuring PostgreSQL
Configuring MySQL
Installing and Configuring ODBC
Configuring ODBC for PostgreSQL
Configuring ODBC for MySQL
Configuring ODBC for Microsoft SQL
Validating the ODBC Connector
Configuring res_odbc to Allow Asterisk to Connect Through ODBC
Managing Databases
Troubleshooting Database Issues
A Gentle Introduction to func_odbc
Getting Funky with func_odbc: Hot-Desking
Using Realtime
Static Realtime
Dynamic Realtime
Storing Call Detail Records (CDRs)
ODBC Voicemail
Creating the Large Object Type for PostgreSQL
ODBC Voicemail Storage Table Layout
Configuring voicemail.conf for ODBC Storage
Testing ODBC Voicemail
Conclusion
17. Interactive Voice Response
What Is IVR?
Components of an IVR
IVR Design Considerations
Do
Don’t
Asterisk Modules for Building IVRs
CURL
func_odbc
AGI
AMI
A Simple IVR Using CURL
Installing the cURL Module
The Dialplan
A Prompt-Recording Application
Speech Recognition and Text-to-Speech
Text-to-Speech
Speech Recognition
Conclusion
18. External Services
Calendar Integration
Compiling Calendaring Support into Asterisk
Configuring Calendar Support for Asterisk
Triggering Calendar Reminders to Your Phone
Controlling Calls Based on Calendar Information
Writing Call Information to a Calendar
Conclusion
VoiceMail IMAP Integration
Compiling IMAP VoiceMail Support into Asterisk
Using XMPP (Jabber) with Asterisk
Compiling Jabber Support into Asterisk
Jabber Dialplan Commands
chan_gtalk
Skype Integration
Installation of Skype for Asterisk
Using Skype for Asterisk
LDAP Integration
Configuring OpenLDAP
Compiling LDAP Support into Asterisk
Configuring Asterisk for LDAP Support
Text-to-Speech Utilities
Festival
Cepstral
Conclusion
19. Fax
What Is a Fax?
Ways to Handle Faxes in Asterisk
spandsp
Obtaining spandsp
Compiling and Installing spandsp
Adding the spandsp Library to Your libpath
Recompiling Asterisk with spandsp Support
Disabling spandsp (Should You Want to Test Digium Fax)
Digium Fax For Asterisk
Obtaining Digium FFA
Disabling Digium FFA (Should You Want to Test spandsp)
Incoming Fax Handling
Fax to TIFF
Fax to Email
Fax Detection
Outgoing Fax Handling
Transmitting a Fax from Asterisk
File Format for Faxing
An Experiment in Email to Fax
Fax Pass-Through
Using Fax Buffers in chan_dahdi.conf
Conclusion
20. Asterisk Manager Interface (AMI)
Quick Start
AMI over TCP
AMI over HTTP
Configuration
manager.conf
http.conf
Protocol Overview
Message Encoding
AMI over HTTP
Development Frameworks
CSTA
Interesting Applications
AsteriskGUI
Flash Operator Panel
Conclusion
21. Asterisk Gateway Interface (AGI)
Quick Start
AGI Variants
Process-Based AGI
DeadAGI Is Dead
FastAGI—AGI over TCP
Async AGI—AMI-Controlled AGI
AGI Communication Overview
Setting Up an AGI Session
Commands and Responses
Ending an AGI Session
Development Frameworks
Conclusion
22. Clustering
Traditional Call Centers
Hybrid Systems
Pure Asterisk, Nondistributed
Asterisk and Database Integration
Single Database
Replicated Databases
Asterisk and Distributed Device States
Distributing Device States over a LAN
Distributing Device States over a WAN
Multiple Queues, Multiple Sites
Conclusion
23. Distributed Universal Number Discovery (DUNDi)
How Does DUNDi Work?
The dundi.conf File
Configuring Asterisk for Use with DUNDi
General Configuration
Initial DUNDi Peer Definition
Creating Mapping Contexts
Using Mapping Contexts with Peers
Allowing Remote Connections
Controlling Responses
Performing Lookups from the Dialplan
Conclusion
24. System Monitoring and Logging
logger.conf
Reviewing Asterisk Logs
Logging to the Linux syslog Daemon
Verifying Logging
Call Detail Records
CDR Contents
Dialplan Applications
cdr.conf
Backends
Example Call Detail Records
Caveats
CEL (Channel Event Logging)
Channel Event Types
Channel Event Contents
Dialplan Applications
cel.conf
Backends
Example Channel Events
SNMP
Installing the SNMP Module for Asterisk
Configuring SNMP for Asterisk Using OpenNMS
Monitoring Asterisk with OpenNMS
Conclusion
25. Web Interfaces
Flash Operator Panel
Queue Status and Reporting
Queue Status Display
Queue Reporting
Call Detail Records
A2Billing
Conclusion
26. Security
Scanning for Valid Accounts
Authentication Weaknesses
Fail2ban
Installation
Configuration
Encrypted Media
Dialplan Vulnerabilities
Securing Asterisk Network APIs
IAX2 Denial of Service
Other Risk Mitigation
Resources
Conclusion—A Better Idiot
27. Asterisk: A Future for Telephony
The Problems with Traditional Telephony
Closed Thinking
Limited Standards Compliancy
Slow Release Cycles
Refusing to Let Go of the Past and Embrace the Future
Paradigm Shift
The Promise of Open Source Telephony
The Itch That Asterisk Scratches
Open Architecture
Standards Compliance
Lightning-Fast Response to New Technologies
Passionate Community
Some Things That Are Now Possible
The Future of Asterisk
Speech Processing
High-Fidelity Voice
Video
Wireless
Unified Messaging
Peering
Challenges
Opportunities
A. Understanding Telephony
Analog Telephony
Parts of an Analog Telephone
Tip and Ring
Digital Telephony
Pulse-Code Modulation
The Digital Circuit-Switched Telephone Network
Circuit Types
Digital Signaling Protocols
Packet-Switched Networks
Conclusion
B. Protocols for VoIP
The Need for VoIP Protocols
VoIP Protocols
IAX (The “Inter-Asterisk eXchange” Protocol)
SIP
H.323
MGCP
Proprietary Protocols
Codecs
G.711
G.726
G.729A
GSM
iLBC
Speex
G.722
MP3
Quality of Service
TCP, UDP, and SCTP
Differentiated Service
Guaranteed Service
Best Effort
Echo
Why Echo Occurs
Managing Echo on DAHDI Channels
Hardware Echo Cancellation
Asterisk and VoIP
Users and Peers and Friends—Oh My!
register Statements
VoIP Security
Spam over Internet Telephony (SPIT)
Encrypting Audio with Secure RTP
Spoofing
What Can Be Done?
Conclusion
C. Preparing a System for Asterisk
Server Hardware Selection
Performance Issues
Choosing a Processor
Choosing a Motherboard
Power Supply Requirements
Environment
Power Conditioning and Uninterruptible Power Supplies
Grounding
Electrical Circuits
The Equipment Room
Telephony Hardware
Connecting to the PSTN
Connecting Exclusively to a Packet-Based Telephone Network
Echo Cancellation
Types of Phones
Physical Telephones
Softphones
Telephony Adaptors
Communications Terminals
Linux Considerations
Conclusion
Index
Site last updated on: September 27, 2011 at 10:30:41 AM PDT
Cover for Asterisk: The Definitive Guide

View 4 comments

  1. Michael S Collins – Posted Oct. 20, 2010

    Congrats on the new book. Are you keeping the starfish, or has that been relegated to the legacy TFOT?

    The author has indicated that the issue raised in this comment has been resolved.

  2. Russell Bryant – Posted Oct. 20, 2010

    Thanks! We're keeping the starfish, as far as I know.

    The author has indicated that the issue raised in this comment has been resolved.

  3. Leif Madsen – Posted Oct. 20, 2010

    Ya that's the cover we're going with. This is the 3rd edition of the TFOT book -- we're just updating it so extensively we're changing the title :) (Plus Asterisk is here now. The future has already arrived, so the title is out of date!)

    The author has indicated that the issue raised in this comment has been resolved.

  4. Phil Hughes – Posted Jan. 22, 2011

    I have tech edited a few O'Reilly books, know a lot about Linux and telcom. I happen to be starting a project with Asterisk (which I have never worked with before) and decided to see how things went with this book.

    There is a lot of great information in the book--I expect everyting I need to know. But, for me, what is missing is something that gives me the big picture. That is, a look at what design options I have.

    For example, in my application I will have multiple small systems but one bigger one which will need accounting info from the small ones and be able to send some updates (basically dialplan and costing updates) back the other way.

    I find myself looking all over the book trying to decide on the approach to take as it involves, configuration, logging, probably a relational database and such.

    What I am looking for may be no more than a few pages of summary with pointers to details but it seems important for a systems designer.

    The author has indicated that the issue raised in this comment has been resolved.