Asterisk: The Future of Telephony

Book description

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

  1. Asterisk: The Future of Telephony
    1. Foreword
    2. 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
        1. Leif Madsen
        2. Jared Smith
        3. Jim Van Meggelen
    3. 1. A Telephony Revolution
      1. VoIP: Bridging the Gap Between Traditional Telephony and Network Telephony
        1. The Zapata Telephony Project
      2. Massive Change Requires Flexible Technology
      3. Asterisk: The Hacker’s PBX
      4. Asterisk: The Professional’s PBX
      5. The Asterisk Community
        1. The Asterisk Mailing Lists
        2. The Asterisk Wiki
        3. The IRC Channels
        4. The Asterisk Documentation Project
      6. The Business Case
      7. This Book
    4. 2. Preparing a System for Asterisk
      1. Server Hardware Selection
        1. Performance Issues
        2. Choosing a Processor
          1. Small systems
          2. Medium systems
          3. Large systems
        3. Choosing a Motherboard
        4. Power Supply Requirements
          1. Computer power supplies
          2. Redundant power supplies
      2. Environment
        1. Power Conditioning and Uninterruptible Power Supplies
          1. Power-conditioned UPSs
        2. Grounding
        3. Electrical Circuits
        4. The Equipment Room
          1. Humidity
          2. Temperature
          3. Dust
          4. Security
      3. Telephony Hardware
        1. Connecting to the PSTN
          1. Analog interface cards
          2. Digital interface cards
          3. Channel banks
          4. Other types of PSTN interfaces
        2. Connecting Exclusively to a Packet-Based Telephone Network
      4. Types of Phone
        1. Physical Telephones
          1. Analog telephones
          2. Proprietary digital telephones
          3. ISDN telephones
          4. IP telephones
        2. Soft Phones
        3. Telephony Adaptors
        4. Communications Terminals
      5. Linux Considerations
      6. Conclusion
    5. 3. Installing Asterisk
      1. What Packages Do I Need?
        1. Package Requirements
      2. Obtaining the Source Code
        1. Obtaining Asterisk Source Code from FTP
        2. Extracting the Source Code
        3. Obtaining Asterisk Source Code from CVS
      3. Compiling Zaptel
        1. The ztdummy Driver
        2. The Zapata Telephony Drivers
        3. Using ztcfg and zttool
        4. The zconfig.h File
          1. Boost ringer
          2. Disable μ-law/A-law precomputation
          3. Enable MMX optimization
          4. Choose echo cancellation method
          5. Enable aggressive suppression
          6. Disable echo cancellation
          7. Enable HDLC
          8. Enable ZapRAS
          9. Enable Zaptel’s watchdog
          10. Set default tone zone
          11. Enable CAC ground start signaling
          12. TDM400P Revision H PCI ID workaround
        5. Passing Module Parameters to Configure Zaptel
      4. Compiling libpri
      5. Compiling Asterisk
        1. Standard Installation
        2. Alternative make Arguments
          1. make clean
          2. make update
          3. make upgrade
          4. make webvmail
          5. make progdocs
          6. make mpg123
          7. make config
        3. Editing the Makefile
          1. Enabling GSM optimizations
          2. Disabling configuration file overwrites
          3. Enabling debug profiling information
          4. Specifying where to install Asterisk after compiling
          5. Changing the staging directory
          6. Compiling on VIA motherboards
        4. Using Precompiled Binaries
      6. Installing Additional Prompts
      7. Updating Your Source Code
      8. Common Compiling Issues
        1. Asterisk
          1. C compiler cannot create executables
          2. bison: command not found
          3. /usr/bin/ld: cannot find -lssl
          4. rpmbuild: command not found
        2. Zaptel
          1. make: cc: Command not found
          2. FATAL: Module wctdm/fxs/fxo not found
          3. Unresolved symbol link when loading ztdummy
          4. Depmod errors during compilation
      9. Loading Zaptel Modules
        1. Systems Running udevd
        2. Loading Zaptel
        3. Loading ztdummy
      10. Loading libpri
      11. Loading Asterisk
        1. CLI Commands
        2. Red Hat-Style Initialization Script
        3. The safe_asterisk Script
      12. Directories Used by Asterisk
        1. /etc/asterisk/
        2. /usr/lib/asterisk/modules/
        3. /var/lib/asterisk
        4. /var/spool/asterisk/
        5. /var/run/
        6. /var/log/asterisk/
        7. /var/log/asterisk/cdr-csv
      13. Conclusion
    6. 4. Initial Configuration of Asterisk
      1. What Do I Really Need?
      2. Working with Interface Configuration Files
      3. FXO and FXS Channels
        1. Determining the FXO and FXS Ports on Your TDM400P
      4. Configuring an FXO Channel
        1. Zaptel Hardware Configuration
        2. Zapata Hardware Configuration
        3. Dialplan Configuration
        4. Dialing in
      5. Configuring an FXS Channel
        1. Zaptel Hardware Configuration
        2. Zapata Hardware Configuration
        3. Dialplan Configuration
      6. Configuring SIP
        1. SIP and RTP
        2. SIP Configuration
        3. Client Configuration
        4. Dialplan Configuration
      7. Configuring Inbound IAX Connections
        1. iax.conf Configuration
        2. Dialplan Configuration
      8. Configuring Outbound IAX Connections
        1. iax.conf Configuration
        2. Dialplan Configuration
      9. Debugging
        1. Connecting to the Console
        2. Enabling Verbosity and Debugging
      10. Conclusion
    7. 5. Dialplan Basics
      1. Dialplan Syntax
        1. Contexts
        2. Extensions
        3. Priorities
        4. Applications
      2. A Simple Dialplan
        1. The s Extension
        2. The Answer(), Playback(), and Hangup() Applications
        3. Our First Dialplan
      3. Adding Logic to the Dialplan
        1. The Background() and Goto() Applications
        2. Handling Invalid Entries and Timeouts
        3. Using the Dial() Application
        4. Adding a Context for Internal Calls
        5. Using Variables
          1. Global variables
          2. Channel variables
          3. Environment variables
          4. Adding variables to our dialplan
        6. Pattern Matching
          1. Pattern-matching syntax
          2. Pattern-matching examples
          3. Using the ${EXTEN} channel variable
        7. Enabling Outbound Dialing
        8. Includes
      4. Conclusion
    8. 6. More Dialplan Concepts
      1. Expressions and Variable Manipulation
        1. Basic Expressions
        2. Operators
      2. Dialplan Functions
        1. Syntax
        2. Examples of Dialplan Functions
      3. Conditional Branching
        1. The GotoIf() Application
        2. Time-Based Conditional Branching with GotoIfTime()
      4. Voicemail
        1. Creating Mailboxes
        2. Adding Voicemail to the Dialplan
        3. Accessing Voicemail
        4. Creating a Dial-by-Name Directory
      5. Macros
        1. Defining Macros
        2. Calling Macros from the Dialplan
        3. Using Arguments in Macros
      6. Using the Asterisk Database (AstDB)
        1. Storing Data in the AstDB
        2. Retrieving Data from the AstDB
        3. Deleting Data from the AstDB
        4. Using the AstDB in the Dialplan
      7. Handy Asterisk Features
        1. Zapateller()
        2. Call Parking
        3. Conferencing with MeetMe()
      8. Conclusion
    9. 7. Understanding Telephony
      1. Analog Telephony
        1. Parts of an Analog Telephone
          1. Ringer
          2. Dial pad
          3. Hybrid (or network)
            1. Hook switch (or switch hook)
            2. Handset
        2. Tip and Ring
      2. Digital Telephony
        1. Pulse-Code Modulation
          1. Digitally encoding an analog waveform
          2. Increasing the sampling resolution and rate
          3. Nyquist’s Theorem
          4. Logarithmic companding
          5. Aliasing
      3. The Digital Circuit-Switched Telephone Network
        1. Circuit Types
          1. The humble DS-0, the foundation of it all
          2. T-carrier circuits
          3. SONET and OC circuits
        2. Digital Signaling Protocols
          1. Channel Associated Signaling (CAS)
          2. ISDN
            1. ISDN-BRI/BRA
            2. ISDN-PRI/PRA
          3. Signaling System 7
      4. Packet-Switched Networks
      5. Conclusion
    10. 8. Protocols for VoIP
      1. The Need for VoIP Protocols
      2. VoIP Protocols
        1. IAX (The “Inter-Asterisk eXchange” Protocol)
          1. History
          2. Future
          3. Security considerations
          4. IAX and NAT
        2. SIP
          1. History
          2. Future
          3. Security considerations
          4. SIP and NAT
        3. H.323
          1. History
          2. Future
          3. Security considerations
          4. H.323 and NAT
        4. MGCP
        5. Proprietary Protocols
          1. Skinny/SCCP
          2. UNISTIM
      3. Codecs
          1. G.711
          2. G.726
          3. G.723.1
          4. G.729A
          5. GSM
          6. iLBC
          7. Speex
          8. MP3
      4. Quality of Service
        1. TCP, UDP, and SCTP
          1. Transmission Control Protocol
          2. User Datagram Protocol
          3. Stream Control Transmission Protocol
        2. Differentiated Service
        3. Guaranteed Service
          1. MPLS
          2. RSVP
        4. Best Effort
      5. Echo
        1. Why Echo Occurs
        2. Managing Echo
      6. Asterisk and VoIP
        1. Users and Peers and Friends—Oh My!
          1. Users
          2. Peers
          3. Friends
        2. register Statements
      7. Conclusion
    11. 9. The Asterisk Gateway Interface (AGI)
      1. Fundamentals of AGI Communication
        1. What Are STDIN, STDOUT, and STDERR?
        2. The Standard Pattern of AGI Communication
        3. Calling an AGI Script from the Dialplan
      2. Writing AGI Scripts in Perl
        1. The Perl AGI Library
      3. Creating AGI Scripts in PHP
        1. The PHP AGI Library
      4. Writing AGI Scripts in Python
        1. The Python AGI Library
      5. Debugging in AGI
        1. Debugging from the Operating System
        2. Using Asterisk’s agi debug Command
      6. Conclusion
    12. 10. Asterisk for the Über-Geek
      1. Festival
        1. Getting Festival Set Up and Ready for Asterisk
        2. Configuring Asterisk for Festival
        3. Starting the Festival Server
        4. Calling Festival from the Dialplan
      2. Call Detail Recording
        1. CDR Challenges
      3. Customizing System Prompts
      4. Manager
        1. Manager Commands
        2. The Flash Operator Panel
      5. Call Files
      6. DUNDi
        1. How Does DUNDi Work?
        2. Configuring Asterisk for Use with DUNDi
          1. The General Peering Agreement
          2. General configuration
          3. Creating mapping contexts
          4. Defining DUNDi peers
          5. Allowing remote connections
          6. Configuring the dialplan
      7. Conclusion
    13. 11. Asterisk: The Future of Telephony
      1. The Problems with Traditional Telephony
        1. Closed Thinking
        2. Limited Standards Compliancy
        3. Slow Release Cycles
        4. Refusing to Let Go of the Past and Embrace the Future
      2. Paradigm Shift
      3. The Promise of Open Source Telephony
        1. The Itch That Asterisk Scratches
        2. Open Architecture
        3. Standards Compliance
        4. Lightning-Fast Response to New Technologies
        5. Passionate Community
        6. Some Things That Are Now Possible
          1. Legacy PBX migration gateway
          2. Low-barrier IVR
          3. Conference rooms
          4. Home automation
      4. The Future of Asterisk
        1. Speech Processing
          1. Festival
          2. Sphinx
        2. High-Fidelity Voice
        3. Video
          1. The challenge of video-conferencing
          2. Why we love video-conferencing
          3. Why video-conferencing may never totally replace voice
        4. Wireless
          1. Wi-Fi
          2. Wi-MAX
        5. Unified Messaging
        6. Peering
          1. E.164
          2. ENUM
          3. e164.org
          4. DUNDi
        7. Challenges
          1. Too much change, too few standards
          2. VoIP spam
          3. Fear, uncertainty, and doubt
          4. Bottleneck engineering
          5. Regulatory wars
          6. Quality of Service
          7. Complexity
        8. Opportunities
          1. Tailor-made private telecommunications networks
          2. Low barrier to entry
          3. Hosted solutions of similar complexity to corporate web sites
          4. Proper integration of communications technologies
    14. A. VoIP Channels
      1. IAX
        1. General IAX Settings
        2. register Statements
        3. IAX Channel Definitions
          1. Channel-specific parameters
      2. SIP
        1. General SIP Parameters
        2. SIP Channel Definitions
    15. B. Application Reference
      1. AbsoluteTimeout()
      2. AddQueueMember()
      3. ADSIProg()
      4. AgentCallbackLogin()
      5. AgentLogin()
      6. AgentMonitorOutgoing()
      7. AGI()
      8. AlarmReceiver()
      9. Answer()
      10. AppendCDRUserField()
      11. Authenticate()
      12. Background()
      13. BackgroundDetect()
      14. Busy()
      15. CallingPres()
      16. ChangeMonitor()
      17. ChanIsAvail()
      18. CheckGroup()
      19. Congestion()
      20. ControlPlayback()
      21. Curl()
      22. Cut()
      23. DateTime()
      24. DBdel()
      25. DBdeltree()
      26. DBget()
      27. DBput()
      28. DeadAGI()
      29. Dial()
      30. DigitTimeout()
      31. Directory()
      32. DISA()
      33. DumpChan()
      34. DUNDiLookup()
      35. EAGI()
      36. Echo()
      37. EndWhile()
      38. ENUMLookup()
      39. Eval()
      40. Exec()
      41. ExecIf()
      42. FastAGI()
      43. Festival()
      44. Flash()
      45. ForkCDR()
      46. GetCPEID()
      47. GetGroupCount()
      48. GetGroupMatchCount()
      49. Goto()
      50. GotoIf()
      51. GotoIfTime()
      52. Hangup()
      53. HasNewVoicemail()
      54. HasVoicemail()
      55. IAX2Provision()
      56. ImportVar()
      57. LookupBlacklist()
      58. LookupCIDName()
      59. Macro()
      60. MailboxExists()
      61. Math()
      62. MeetMe()
      63. MeetMeAdmin()
      64. MeetMeCount()
      65. Milliwatt()
      66. Monitor()
      67. MP3Player()
      68. MusicOnHold()
      69. NBScat()
      70. NoCDR()
      71. NoOp()
      72. Park()
      73. ParkAndAnnounce()
      74. ParkedCall()
      75. PauseQueueMember()
      76. Playback()
      77. Playtones()
      78. Prefix()
      79. PrivacyManager()
      80. Progress()
      81. Queue()
      82. Random()
      83. Read()
      84. RealTime
      85. RealTimeUpdate()
      86. Record()
      87. RemoveQueueMember()
      88. ResetCDR()
      89. ResponseTimeout()
      90. RetryDial()
      91. Ringing()
      92. SayAlpha()
      93. SayDigits()
      94. SayNumber()
      95. SayPhonetic()
      96. SayUnixTime()
      97. SendDTMF()
      98. SendImage()
      99. SendText()
      100. SendURL()
      101. Set()
      102. SetAccount()
      103. SetAMAFlags()
      104. SetCallerID()
      105. SetCallerPres()
      106. SetCDRUserField()
      107. SetCIDName()
      108. SetCIDNum()
      109. SetGlobalVar()
      110. SetGroup()
      111. SetLanguage()
      112. SetMusicOnHold()
      113. SetRDNIS()
      114. SetVar()
      115. SIPAddHeader()
      116. SIPDtmfMode()
      117. SIPGetHeader()
      118. SoftHangup()
      119. StopMonitor()
      120. StopPlaytones()
      121. StripLSD()
      122. StripMSD()
      123. SubString()
      124. Suffix()
      125. System()
      126. Transfer()
      127. TrySystem()
      128. TXTCIDName()
      129. UnpauseQueueMember()
      130. UserEvent()
      131. Verbose()
      132. VMAuthenticate()
      133. VoiceMail()
      134. VoiceMailMain()
      135. Wait()
      136. WaitExten()
      137. WaitForRing()
      138. WaitForSilence()
      139. WaitMusicOnHold()
      140. While()
      141. Zapateller()
      142. ZapBarge()
      143. ZapRAS()
      144. ZapScan()
    16. C. AGI Reference
      1. ANSWER
      2. CHANNEL STATUS
      3. DATABASE DEL
      4. DATABASE DELTREE
      5. DATABASE GET
      6. DATABASE PUT
      7. EXEC
      8. GET DATA
      9. GET FULL VARIABLE
      10. GET OPTION
      11. GET VARIABLE
      12. HANGUP
      13. NOOP
      14. RECEIVE CHAR
      15. RECORD FILE
      16. SAY ALPHA
      17. SAY DATE
      18. SAY DATETIME
      19. SAY DIGITS
      20. SAY NUMBER
      21. SAY PHONETIC
      22. SAY TIME
      23. SEND IMAGE
      24. SEND TEXT
      25. SET AUTOHANGUP
      26. SET CALLERID
      27. SET CONTEXT
      28. SET EXTENSION
      29. SET MUSIC ON
      30. SET PRIORITY
      31. SET VARIABLE
      32. STREAM FILE
      33. TDD MODE
      34. VERBOSE
      35. WAIT FOR DIGIT
    17. D. Configuration Files
      1. modules.conf
        1. Resources
        2. Applications
        3. Database-Stored Call Detail Records
        4. Channels
        5. Codecs
        6. Formats
        7. PBX Core Modules
        8. Standalone Functions
      2. adsi.conf
      3. adtranvofr.conf
      4. agents.conf
      5. alarmreceiver.conf
      6. alsa.conf
      7. asterisk.conf
      8. cdr.conf
      9. cdr_manager.conf
      10. cdr_odbc.conf
      11. cdr_pgsql.conf
      12. cdr_tds.conf
      13. codecs.conf
      14. dnsmgr.conf
      15. dundi.conf
      16. enum.conf
      17. extconfig.conf
      18. extensions.conf
      19. features.conf
      20. festival.conf
      21. iax.conf
      22. iaxprov.conf
      23. indications.conf
      24. logger.conf
          1. [general]
          2. [logfiles]
      25. manager.conf
      26. meetme.conf
      27. mgcp.conf
      28. modem.conf
      29. musiconhold.conf
      30. osp.conf
      31. oss.conf
      32. phone.conf
      33. privacy.conf
      34. queues.conf
      35. res_odbc.conf
      36. rpt.conf
      37. rtp.conf
      38. sip.conf
      39. sip_notify.conf
      40. skinny.conf
      41. voicemail.conf
        1. General Voicemail Settings
        2. Voicemail Zones
        3. Defining Voicemail Contexts and Mailboxes
      42. vpb.conf
      43. zapata.conf
      44. zaptel.conf
    18. E. Asterisk Command-Line Interface Reference
      1. !
        1. !
      2. abort halt
        1. abort halt
      3. add
        1. add extension
        2. add ignorepat
        3. add queue member
      4. agi
        1. agi debug
        2. agi no debug
        3. answer
      5. database
        1. database del
        2. database deltree
        3. database get
        4. database put
        5. database show
        6. debug channel
        7. dial
        8. dont include
        9. dump agihtml
        10. exit
        11. extensions reload
        12. hangup
        13. help
      6. iax2
        1. iax2 debug
        2. iax2 no debug
        3. iax2 provision
        4. iax2 show cache
        5. iax2 show channels
        6. iax2 show firmware
        7. iax2 show peer
        8. iax2 show peers
        9. iax2 show provisioning
        10. iax2 show registry
        11. iax2 show stats
        12. iax2 show users
        13. iax2 trunk debug
        14. include context
      7. indication
        1. indication add
        2. indication remove
        3. init keys
        4. load
        5. local show channels
      8. logger
        1. logger reload
        2. logger rotate
      9. meetme
        1. meetme kick
        2. meetme list
        3. meetme lock
        4. meetme mute
        5. meetme unlock
        6. meetme unmute
      10. pri
        1. pri debug
        2. pri intense debug span
        3. pri no debug
        4. pri show debug
        5. pri show span
        6. quit
        7. reload
      11. remove
        1. remove extension
        2. remove ignorepat
        3. remove queue member
      12. restart
        1. restart gracefully
        2. restart now
        3. restart when convenient
        4. save dialplan
      13. set
        1. set debug
        2. set verbose
      14. show
        1. show agents
        2. show agi
        3. show application
        4. show applications
        5. show channel
        6. show channels
        7. show dialplan
        8. show indications
        9. show keys
        10. show manager command
        11. show manager commands
        12. show manager connected
        13. show modules
        14. show parkedcalls
        15. show queue
        16. show queues
        17. show translation
        18. show uptime
        19. show version
        20. show voicemail users
        21. show voicemail zones
      15. sip
        1. sip debug
        2. sip debug ip
        3. sip debug peer
        4. sip history
        5. sip no debug
        6. sip reload
        7. sip show channel
        8. sip show channels
        9. sip show history
        10. sip show peer
        11. sip show peers
        12. sip show registry
        13. sip show user
        14. sip show users
        15. soft hangup
      16. stop
        1. stop gracefully
        2. stop now
        3. stop when convenient
        4. unload
      17. zap
        1. zap destroy channel
        2. zap show cadences
        3. zap show channel
        4. zap show channels
    19. Index
    20. Colophon

Product information

  • Title: Asterisk: The Future of Telephony
  • Author(s): Jim Van Meggelen, Jared Smith, Leif Madsen
  • Release date: September 2005
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596009625