FreeSWITCH 1.8

Book description

Build a robust, high-performance telephony system with FreeSWITCH

About This Book

  • Learn how to install and configure a complete telephony system of your own, from scratch, using FreeSWITCH 1.6
  • Get in-depth discussions of important concepts such as dialplan, user directory, NAT handling, and the powerful FreeSWITCH event socket
  • Discover expert tips from the FreeSWITCH experts, including the creator of FreeSWITCH—Anthony Minessale

Who This Book Is For

This book is for beginner-level IT professionals and enthusiasts who are interested in quickly getting a powerful telephony system up and running using FreeSWITCH. It would be good if you have some telephony experience, but it’s not a must.

What You Will Learn

  • Build a complete WebRTC/SIP VoIP platform able to interconnect and process audio and video in real time
  • Use advanced PBX features to create powerful dialplans
  • Understand the inner workings and architecture of FreeSWITCH
  • Real time configuration from database and webserver with mod_xml_curl
  • Integrate browser clients into your telephony service
  • Use scripting to go beyond the dialplan with the power and flexibility of a programming language
  • Secure your FreeSWITCH connections with the help of effective techniques
  • Deploy all FreeSWITCH features using best practices and expert tips
  • Overcome frustrating NAT issues
  • Control FreeSWITCH remotely with the all-powerful event socket
  • Trace packets, check debug logging, ask for community and commercial help

In Detail

FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice and chat-driven products, scaling from a soft-phone to a PBX and even up to an enterprise-class soft-switch. This book introduces FreeSWITCH to IT professionals who want to build their own telephony system.

This book starts with a brief introduction to the latest version of FreeSWITCH. We then move on to the fundamentals and the new features added in version 1.6, showing you how to set up a basic system so you can make and receive phone calls, make calls between extensions, and utilize basic PBX functionality.

Once you have a basic system in place, we’ll show you how to add more and more functionalities to it. You’ll learn to deploy the features on the system using unique techniques and tips to make it work better.

Also, there are changes in the security-related components, which will affect the content in the book, so we will make that intact with the latest version. There are new support libraries introduced, such as SQLite, OpenSS, and more, which will make FreeSWITCH more efficient and add more functions to it. We’ll cover these in the new edition to make it more appealing for you.

Style and approach

This easy-to-follow guide helps you understand every topic easily using real-world examples of FreeSWITCH tasks. This book is full of practical code so you get a gradual learning curve.

Table of contents

  1. Preface
    1. What this book covers
    2. What you need for this book
    3. Who this book is for
    4. Conventions
    5. Reader feedback
    6. Customer support
      1. Downloading the example code
      2. Downloading the color images of this book
      3. Errata
      4. Piracy
      5. Questions
  2. Architecture of FreeSWITCH
    1. Real-time communication without mysteries
    2. The FreeSWITCH design - modular, scalable, and stable
    3. Important modules - Endpoint and Dialplan
    4. Complex applications made simple
      1. Voicemail
      2. Multi-party audio/video conferencing
      3. FreeSWITCH API commands (FSAPI)
      4. The XML registry
      5. Scripting language modules
      6. The demo configuration
    5. Summary
  3. Building and Installation
    1. Where to Install FreeSWITCH
      1. Choice of Operating System
        1. Linux
        2. Windows
        3. OS X (Mac)
        4. *BSD
      2. Packages or Source?
    2. Installing FreeSWITCH
      1. Debian 8 Jessie
        1. From Packages
        2. From Source
      2. Windows
    3. Summary
  4. Test Driving the Example Configuration
    1. Important concepts to understand
      1. XML Configuration
      2. Regular Expressions
      3. Call Legs
      4. IVRs, Interactive Voice Response (Systems)
      5. Extensions, Contexts and Profiles
      6. Variables
        1. Caller profile Variables
        2. "Normal" Variables
        3. "Preprocessor" Variables
    2. FS_CLI and Console, Controlling FreeSWITCH
      1. Exiting from Console kills FreeSWITCH
      2. Some useful CLI commands
    3. Configure SIP and make the first calls in demo dialplan
      1. Change demo example password
      2. Configure Linphone on a Desktop
      3. Configure a SNOM SIP "real" phone
      4. Configure Linphone on Android
      5. And now... Fun, fun, fun with the Demo Dialplan
        1. 9386, Funny Prompts
        2. 1000...1019, Phone to Phone Local Call
        3. 5000, Calling the Demo Example IVR
        4. 3000, Conference Call
      6. Example Dialplan quick reference
    4. Summary
  5. User Directory, SIP, and Verto
    1. User Directory concepts
    2. AAA: Authentication, Authorization, Accounting
    3. Exploring and Using the Demo Example User Directory
      1. Domains and groups
      2. Users
      3. Adding a user to the demo example directory and dialplan
        1. Adding a new user to the directory
        2. Modifying the dialplan for the new user
      4. Call to a Group
      5. Voicemail
    4. Communicate with the World via SIP Gateways and DIDs
      1. SIP Gateway from Us to the ITSP to the World
      2. SIP DID from World to the ITSP to Us
      3. SIP and Verto Profiles, Dialplan Contexts, ITSPs
        1. SIP Profiles
        2. Dialplan Contexts
        3. Verto Profiles and Dialplan Contexts
        4. ITSPs
    5. Summary
  6. WebRTC, SIP, and Verto
    1. WebRTC concepts
    2. Encryption Everywhere
    3. WebRTC in FreeSWITCH
      1. WebRTC Signaling in FS: SIP and Verto
        1. Why SIP and why Verto?
      2. WebRTC Media Streaming in FS: SRTP
    4. Installing and Configuring WebRTC in FS
      1. Certificates
      2. Installing and Configuring Apache or NginX for HTTPS serving
        1. Apache
        2. NginX
      3. Configuring VERTO
      4. Configuring SIP on WebRTC (WSS)
    5. Writing WebRTC Clients
      1. SIP and JavaScript
      2. Verto and JavaScript
        1. Verto Communicator, an Advanced WebRTC Client
    6. WebRTC Rooms, both SIP and Verto Clients
      1. Conference chat in WebRTC Rooms
      2. FreeSWITCH Conferences
      3. mod_sms and chatplan
      4. Dialplan "chat_proto" extension
      5. HTML
      6. JavaScript
      7. TODO
    7. Summary
  7. XML Dialplan
    1. Forget all you know
    2. Contexts
      1. Default context
      2. Public context
        1. Features
    3. Extensions
    4. Conditions (and "patterns")
    5. Call legs (channels)
    6. Channel Variables
    7. Regular Expressions
    8. Actions and anti-actions
    9. How dialplan processing works
    10. Important dialplan applications
      1. answer
      2. bridge
      3. hangup
      4. ivr
      5. play_and_get_digits
      6. playback
      7. set
      8. sleep
      9. transfer
    11. Dialstring formats
      1. SIP (sofia)
      2. VERTO
      3. Other dialstring formats
      4. Originate Command
    12. Summary
  8. Phrase Macros and XML IVRs
    1. Phrase Macros and Voice Prompts
      1. Voice Prompts history
      2. Sound files in FreeSWITCH
        1. Sound files locations, sampling rate and fallbacks
      3. Phrase Macros: Concatenating Sound files
        1. macro name (pause)
        2. input pattern
        3. match - nomatch
        4. action
      4. Phrase Macros: Invocation, Patterns and Registers
        1. Phrase Macro Invocation
        2. Input Pattern and Registers
    2. XML IVRs
      1. IVR in demo config
      2. XML voice menu fields
        1. name
        2. greet-long
        3. greet-short
        4. invalid-sound
        5. exit-sound
        6. timeout
        7. inter-digit-timeout
        8. max-failures
        9. max-timeouts
        10. digit-len
        11. tts-engine
        12. tts-voice
        13. confirm-key
      3. XML voice menu entries and actions
        1. menu-exec-app
        2. menu-play-sound
        3. menu-sub
        4. menu-back
        5. menu-top
        6. menu-exit
      4. Nesting XML IVRs
    3. Summary
  9. Lua FreeSWITCH Scripting
    1. Many scripting languages
      1. Why Lua?
    2. Basic Lua syntax
    3. Lua and FreeSWITCH
      1. freeswitch
      2. freeswitch.Session and session
      3. freeswitch.API
      4. freeswitch.Dbh
      5. freeswitch.Event
      6. freeswitch.EventConsumer
      7. freeswitch.IVRMenu
    4. Lua scripting IVR Applications
      1. playAndGetDigits
        1. Syntax
        2. Arguments
        3. Behavior
      2. XML demo IVR in Lua
      3. Always checking session:ready()
    5. Summary
  10. Dialplan in Deep
    1. Where are the previous Dialplan seasons?
    2. XML Dialplan Recap
    3. More about conditions
      1. regex operator (multiple variables and/or expressions)
      2. nested conditions
    4. Pitfalls to avoid
    5. Variables
      1. Global variables
      2. Time of Day, Day of Week, Holidays
      3. Channel Variables
      4. Channel Variables and Field shortcuts
      5. Channel Variables and Caller Profile fields
      6. Channel Variables and call setup
        1. setting channel variables in dialstrings
        2. setting channel variables on B-legs: export and nolocal
        3. exporting variables to SIP custom (X-) Headers
    6. API commands from Dialplan
    7. FreeSWITCH string interpreter functions
      1. cond, C-like "expr ? truevalue : falsevalue"
      2. variables' substrings
      3. db and hash: simple key/value stores
    8. "Hotkeys", Listening, Barging
      1. bind_meta_*, DTMFs to actions outside menus
      2. eavesdrop (call barge)
        1. eavesdrop DTMF commands
    9. Dialplan Cookbook
      1. Match by IP address and call a number
      2. Match an IP address and Caller ID
      3. Match a number and strip digits
      4. Match a number, strip digits, and add a prefix
      5. Call a registered device
      6. Try party A, then party B
      7. Route DIDs to extensions
      8. Alternate outbound gateways
      9. Multiple endpoints with enterprise originate
    10. Summary
  11. Dialplan, Directory, and ALL via XML_CURL and Scripts
    1. mod_xml_curl rationale
    2. mod_xml_curl configuration
    3. mod_xml_curl: Caveats and Pitfalls
    4. php/mysql setup for mod_xml_curl
      1. Create and populate the Database
      2. Setup NGINX and xmlhandler.php
      3. mod_xml_curl configuration
      4. Testing php/mysql setup for mod_xml_curl
    5. Lua XML handler
      1. lua xmlhandler script
      2. lua.conf.xml
      3. Lua xml_handler.lua testing
    6. Summary
  12. ESL - FreeSWITCH Controlled by Events
    1. Event System Fundamentals
    2. Event format - Headers and Body
    3. Event Handling modules
      1. mod_event_socket
        1. mod_event_socket configuration
        2. Reading and sending events via telnet
        3. fs_cli
    4. Event System Commands
      1. api
      2. bgapi
      3. event
      4. filter
      5. filter delete
      6. sendevent
      7. exit
      8. auth
      9. log
      10. nolog
      11. nixevent
      12. noevents
      13. sendmsg
        1. call-command
          1. execute
          2. hangup
    5. Outbound Socket - call connects to you
    6. ESL - Event Socket Library
      1. ESL supported languages
    7. ESL Reference
      1. eslSetLogLevel
      2. ESLevent Object
        1. new
        2. serialize
        3. setPriority
        4. getHeader
        5. getBody
        6. getType
        7. addBody
        8. addHeader
        9. delHeader
        10. firstHeader
        11. nextHeader
      3. ESLconnection Object
        1. new
        2. socketDescriptor
        3. connected
        4. getInfo
        5. send
        6. sendRecv
        7. api
        8. bgapi
        9. sendEvent
        10. recvEvent
        11. recvEventTimed
        12. filter
        13. events
        14. execute
        15. executeAsync
        16. setAsyncExecute
        17. setEventLock
        18. disconnect
    8. ESL installation
    9. ESL: Examples in Perl
      1. Display Filtered Events
      2. Use "api" and "bgapi"
      3. Use "sendEvent"
    10. Summary
  13. HTTAPI - FreeSWITCH Asks Webserver Next Action
    1. HTTAPI Rationale
    2. HTTAPI dialplan
      1. data
        1. httapi_profile
        2. url
        3. method
    3. HTTAPI document syntax
      1. Work actions
        1. playback
        2. record
        3. pause
        4. speak
        5. say
        6. execute
        7. sms
        8. dial
        9. recordCall
        10. conference
        11. hangup
        12. break
        13. log
        14. continue
        15. getVar
        16. voicemail
        17. vmname
      2. exiting (param)
      3. storing data across successive requests
    4. mod_httapi configuration file
      1. params
        1. gateway-url
        2. method
      2. permissions
        1. set-params
        2. set-vars
        3. get-vars
        4. extended-data
          1. extended-data longer than max CGI length
        5. execute-apps
        6. expand-vars
        7. dial
          1. dial-set-dialplan
          2. dial-set-context
          3. dial-set-cid-name
          4. dial-set-cid-number
          5. dial-full-originate
        8. conference
          1. conference-set-profile
    5. HTTPAPI libraries for PHP and Python
    6. The demo-ivr in PHP-HTTAPI
    7. Summary
  14. Conferencing and WebRTC Video-Conferencing
    1. Conferencing Concepts
    2. Conferencing Support in FreeSWITCH
      1. Audio conferencing
      2. Video conferencing
    3. Audio Conferencing setup in FreeSWITCH
      1. profiles
        1. rate
        2. caller-controls
        3. auto-record
        4. interval
        5. energy-level
        6. member-flags
        7. conference-flags
        8. tts-engine
        9. tts-voice
        10. pin
        11. max-members
        12. caller-id-name
        13. caller-id-number
        14. comfort-noise
        15. announce-count
        16. suppress-events
        17. sound-prefix
        18. sounds
      2. caller-controls
      3. advertise
    4. Video-WebRTC conferencing setup in FreeSWITCH
      1. profiles additional video parameters
        1. video-mode
        2. video-layout-name
        3. video-canvas-size
        4. video-no-video-avatar
        5. video-mute-banner
      2. caller-controls additional video actions
      3. member-flags additional video options
      4. conference-flags additional video options
      5. screen estate layouts
      6. layout groups
    5. FreeSWITCH conferencing operation
      1. Conference Application (dialplan)
      2. Controlling active conferences
      3. Calling outbound into the conference
    6. Verto Communicator and Video-WebRTC Conferencing
      1. settings
      2. participants list
      3. participant GUI commands and chat
      4. moderator GUI commands
      5. screen sharing
    7. Summary
  15. Handling NAT
    1. A brief introduction to NAT
      1. Understanding the evolution of NAT
    2. The four pitfalls of NAT
    3. Demystifying NAT settings in FreeSWITCH
    4. Making media flow
    5. Advanced options and settings
    6. FreeSWITCH behind NAT
      1. FreeSWITCH speaks to the router
      2. FreeSWITCH behind NAT, leaving the router alone
      3. Additional ways to set the external addresses
    7. Other creative uses of FreeSWITCH in a NAT situation
    8. NAT and WebRTC (SOLVED)
    9. Conclusion
    10. Summary
  16. VoIP Security
    1. Network level protection
      1. Separating interfaces and restricting traffic
        1. Sample setup - simple
        2. Sample setup - complex
      2. VLANs
    2. Intrusion detection
      1. Registration and call attempts monitoring
        1. Fail2Ban
          1. Filter configurations
          2. Jail configurations
          3. Do not lock the good guys out!
    3. Encryption in non-WebRTC SIP: Signaling and Media
      1. Choosing between encryption options
        1. Disabling SSLv3 and SSLv2
      2. Certificates
        1. "Real" certificates, from "real" CAs
      3. Protecting signaling
        1. Encryption with TLS
      4. Protecting media
        1. Encryption with SRTP
          1. Enabling SRTP
          2. Debugging SRTP
        2. Encryption with ZRTP
          1. Enabling ZRTP
        3. Testing media SIP encryption
    4. Protecting WebRTC SIP and VERTO Signaling and Media
    5. Protecting passwords
      1. Registration passwords as hashes
      2. Voicemail passwords
    6. Summary
  17. Troubleshooting, Asking for Help, and Reporting Bugs
    1. Troubleshooting FreeSWITCH
      1. firewall rules and network issues
      2. checking FreeSWITCH configuration and operation
      3. fsctl loglevel 7
      4. sofia global siptrace on
      5. verto debug=10
      6. sngrep: SIP dialogs visualization
      7. tcpdump for saving net traffic in pcap files
    2. Asking for Help
      1. Read the documentation first!
        1. confluence
        2. books
        3. mailing list archives
        4. google
      2. How to ask for Community Help
        1. IRC
        2. HipChat
        3. mailing lists
      3. Official Commercial Support and Consulting
    3. Reporting Problems
      1. don't report a bug on mailing list !
      2. how to file a bug on Jira
    4. ClueCon
    5. Summary

Product information

  • Title: FreeSWITCH 1.8
  • Author(s): Anthony Minessale II, Giovanni Maruzzelli
  • Release date: July 2017
  • Publisher(s): Packt Publishing
  • ISBN: 9781785889134