You are previewing Building Telephony Systems with OpenSER.
O'Reilly logo
Building Telephony Systems with OpenSER

Book Description

A step-by-step guide to building a high performance Telephony System

  • Install, configure, and troubleshoot OpenSER

  • Use OpenSER to build next generation VOIP networks from scratch

  • Learn and understand SIP Protocol and its functionality

  • Integrate MySQL with OpenSER

  • Integrate OpenSER & Asterisk

  • In Detail

    OpenSER is a flexible, free open-source VoIP server based on the Session Initiation Protocol (SIP), an application-layer control (or signaling) protocol for creating, modifying, and terminating sessions with one or more participants, including internet telephone calls, multimedia distribution, and multimedia conferences.

    Engineered to power IP telephony infrastructures up to large scale, OpenSER is written in pure C for Linux/Unix-like systems with architecture-specific optimizations to offer high performance; it is able to handle 4 million users on a single processor server. The server keeps track of users, sets up VoIP sessions, relays instant messages, and creates space for new plug-in applications.

    It can be used on systems with limited resources as well as on carrier-grade servers, scaling up to thousands of call setups per second. It is customizable, being able to feature as fast load balancer; SIP server flavors: registrar, location server, proxy server, redirect server; gateway to SMS/XMPP; or advanced VoIP application server.

    This book teaches how to develop a fast and flexible Session Initiation Protocol (SIP) server using OpenSER and shows how OpenSER can be used to implement features not available in Asterisk PBX.

    Table of Contents

    1. Building Telephony Systems with OpenSER
      1. Table of Contents
      2. Building Telephony Systems with OpenSER
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. Preface
        1. What This Book Covers
        2. What You Need for This Book
        3. Who This Book Is For
        4. Conventions
        5. Reader Feedback
          1. Customer Support
          2. Downloading the Example Code for the Book
          3. Errata
          4. Questions
      7. 1. Introduction to SIP
        1. SIP Basics
          1. SIP Proxy in the Context of a VOIP Provider
          2. SIP Operation Theory
          3. SIP Registration Process
        2. Server Operating as a SIP Proxy
        3. Server Operating as a SIP Redirect
        4. Basic Messages
          1. SIP Dialog Flow
        5. SIP Transactions and Dialogs
          1. The RTP Protocol
            1. Codecs
            2. DTMF-Relay
            3. Real Time Control Protocol (RTCP)
          2. Session Description Protocol (SDP)
        6. The SIP Protocol and the OSI Model
        7. The VoIP Provider "Big Picture"
          1. SIP Proxy
          2. User, Administration, and Provisioning Portal
          3. PSTN Gateway
          4. Media Server
          5. Media Proxy or RTP Proxy for Nat Traversal
          6. RADIUS Accounting
          7. CDRTool Rating
          8. Monitoring Tools
        8. Where You Can Find More Information
        9. Summary
      8. 2. The SIP Express Router
        1. Where Are We?
        2. What is the SIP Express Router?
        3. What Software to Use, SER or OpenSER?
        4. Usage Scenarios
        5. OpenSER Architecture
          1. Core and Modules
          2. Sections of the File openser.cfg
          3. Sessions, Dialogs, and Transactions
          4. openser.cfg Message Processing
        6. SIP Proxy—Expected Behavior
        7. Stateful Operation
        8. Differences between Strict Routing and Loose Routing
        9. Understanding SIP and RTP
          1. Summary
      9. 3. OpenSER Installation
        1. Hardware Requirements
        2. Software Requirements
        3. Lab—Installing Linux for OpenSER
        4. Downloading and Installing OpenSER v1.2
        5. Lab—Running OpenSER at the Linux Boot
        6. OpenSER v1.2 Directory Structure
          1. Configuration Files (etc/openser)
          2. Modules (/lib/openser/modules)
          3. Binaries (/sbin)
        7. Log Files
        8. Startup Options
        9. Summary
      10. 4. OpenSER Standard Configuration
        1. Where Are We?
        2. Analyzing the Standard Configuration
        3. Using the Standard Configuration
        4. Routing Basics
          1. Transactions and Dialogs
          2. Initial and Sequential Requests
          3. Routing in a Context of a Transaction
          4. Routing in the Context of a Dialog
          5. Lab—Tracking a Complete Dialog
          6. Lab—Running Stateless
          7. Lab—Disabling record-route
        5. Summary
      11. 5. Adding Authentication with MySQL
        1. Where Are We?
        2. The AUTH_DB Module
        3. The REGISTER Authentication Sequence
          1. Register Sequence (Packets Captured by ngrep)
          2. Register Sequence Code Snippet
          3. The INVITE Authentication Sequence
            1. INVITE Sequence Packet Capture
          4. Digest Authentication
            1. WWW-Authenticate Response Header
            2. The Authorization Request Header
            3. QOP—Quality of Protection
          5. Installing MySQL Support
          6. openser.cfg File Analysis
        4. The Openserctl Shell Script
          1. Openserctl Resource File
            1. Openserctlrc File
          2. Using OpenSER with Authentication
          3. Enhancing the Script
            1. Managing Multiple Domains
            2. Alternative Routes
              1. Register Requests (route[2])
              2. Non-Register Requests (route[3])
                1. Managing Calls Coming from Our Domain
                2. Inbound-to-Inbound—route[10]
                3. Inbound-to-Outbound—route[11]
                4. Outbound-to-Inbound—route[12]
                5. Outbound-to-Outbound—route[13]
        5. The Functions check_to() and check_from()
        6. Using Aliases
        7. Handling CANCEL requests and retransmissions
        8. Full Script with All the Resources Above
        9. Lab—Enhancing the Security
        10. Lab—Using Aliases
        11. Summary
      12. 6. Building the User Portal with SerMyAdmin
        1. SerMyAdmin
          1. Lab—Installing SerMyAdmin
        2. Basic Tasks
          1. Registering a New User
          2. Approving a New User
          3. User Management
          4. Domain Management
          5. Interface Customization
        3. Summary
      13. 7. Connectivity to the PSTN
        1. Where Are We?
          1. Requests Sent to the Gateway
          2. Requests Coming From the Gateway
          3. openser.cfg Inspection
        2. Lab—Using Asterisk as a PSTN Gateway
          1. Asterisk Gateway (sip.conf)
          2. Cisco 2601 Gateway
        3. Using LCR (Least Cost Routes)
          1. The LCR Module
            1. Configuration Diagram
          2. VoIP Provider Dial Plan
          3. The LCR Table
          4. The Gateways Table
            1. The Gateway Groups Table
          5. Adding, Removing, and Showing LCR and Gateways
          6. Openserctl LCR-Related Commands.
            1. Notes:
            2. Examples:
          7. Lab—Using the LCR Feature
            1. lcr Gateway Groups
            2. lcr Gateways
            3. lcr Routes
        4. Securing re-INVITES
        5. Blacklists and "473/Filtered Destination" messages
        6. Summary
      14. 8. Call Forward and Voice Mail
        1. Call Forwarding
          1. Pseudo-Variables
          2. AVP (Attribute-Value Pair) Overview
            1. AVPOPS Module Loading and Parameters
          3. Implementing Blind Call Forwarding
            1. Lab—Implementing Blind Call Forwarding
        2. Implementing Call Forward on Busy or nanswered
        3. Inspecting the Configuration File
        4. Lab—Testing the Call Forward Feature
          1. Summary
      15. 9. SIP NAT Traversal
        1. NAT Types
          1. Full Cone
          2. Restricted Cone
          3. Port Restricted Cone
          4. Symmetric
          5. NAT Firewall Table
        2. Solving the SIP NAT Traversal Challenge
          1. Implementing a Far-End NAT Solution
            1. RFC3581 and the force_rport() Function
            2. Solving the Traversal of RTP Packets
        3. Handling REGISTER Requests behind NAT
          1. Determining if the Client is behind NAT
        4. Handling INVITE Messages behind NAT
        5. Handling the Responses
        6. MediaProxy Installation and Configuration
          1. Installing MediaProxy
        7. openser.cfg Analysis
          1. Modules Loading
          2. Modules' Parameters
          3. Register Message Processing
          4. Invite Message Processing
          5. BYE and CANCEL Message Processing
          6. RE-INVITE Message Handling
          7. Reply Message Handling
          8. Routing Script
        8. Invite Diagram
          1. Packet Sequence
        9. Lab Using MediaProxy for NAT Traversal
          1. Implementing a Near-End NAT Solution
            1. Why STUN Does Not Work with Symmetric NAT Devices
            2. Comparing STUN with TURN (Media Relay Server)
            3. ALG—Application Layer Gateways
            4. ICE (Interactive Connection Establishment)
          2. Summary
      16. 10. OpenSER Accounting and Billing
        1. Objectives
        2. Where Are We?
          1. VoIP Provider Architecture
          2. Accounting Configuration
          3. LAB—Accounting using MySQL
          4. openser.cfg Analysis
          5. Accounting using RADIUS
        3. Installation of FreeRADIUS and CDRTool
          1. Packages and Dependencies
          2. Create and Configure the Database for the Radius server
          3. Configuration of the FreeRADIUS Server
          4. Configure the RADIUS Client (radiusclient-ng)
          5. Configure OpenSER
          6. Test the Configuration after Making a Call
        4. Using CDRTool for Rating
          1. LAB—CDRTool Installation
          2. LAB—Using CDRTool
        5. CDRTool Architecture
        6. How CDRTool Rates a Call
          1. Lab—Creating and Applying a Rating Plan
        7. Summary
      17. 11. Troubleshooting Tools
        1. Objectives
          1. Where Are We?
        2. Built-in Tools
        3. Packet Capture and Trace Tools
          1. TShark, Wireshark
          2. SipTrace
          3. Stress Testing Tools
            1. Sipsak
            2. SIPp
            3. Installing SIPp
            4. Stress Test—The SIP Signaling
            5. Stress Test—The RTP Signaling
            6. Testing MediaProxy
          4. Monitoring Tools
        4. Summary
      18. 12. After Words
        1. What's New in Version 1.2.3
          1. Cancel Handling
          2. Blacklist is Disabled by Default
          3. Method Filtering
          4. Alias_DB
          5. Branch_route
        2. Migration from 1.2.2 to 1.2.3 and 1.3.1
        3. Migrating the Script from Chapter 10 to openser 1.3.1
        4. RTPProxy
          1. Lab—Installing RTPProxy
        5. Areas for Further Investigation
          1. Carrier Route
          2. Dialog
          3. SIP Session Timers
        6. SIP Peering
        7. TLS Transport Layer Security
        8. Development
          1. PERL
          2. WeSIP
        9. Common Mistakes
          1. Daemon Does Not Start
          2. Client Unable to Register
          3. Sending a Call to a Provider with Authentication
          4. Typos in the Configuration File
          5. The Last Tip
        10. Forum and Training
        11. Summary
      19. Index