O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building Telephony Systems with OpenSIPS 1.6

Book Description

Build scalable and robust telephony systems using SIP

  • Build a VoIP Provider based on the SIP Protocol

  • Cater to scores of subscribers efficiently with a robust telephony system based in pure SIP

  • Gain a competitive edge using the most scalable VoIP technology

  • Learn how to avoid pitfalls using precise billing

  • Packed with rich practical examples and case studies on the latest OpenSIPS version 1.6

  • In Detail

    SIP is the most important VoIP protocol and OpenSIPS is clearly the open source leader in VoIP platforms based on pure SIP. The whole telecommunication industry is changing to an IP environment, and telephony in the way we know today will disappear in less than ten years. SIP is the protocol leading this disruptive revolution and it is one of the main protocols on next-generation networks. While a VoIP provider is not the only kind of SIP infrastructure created using OpenSIPS, it is certainly one of the most difficult to implement.

    This book will give you a competitive edge by helping you to create a SIP infrastructure capable of handling tens of thousands of subscribers. You can extend the examples given in this book easily to other applications such as a SIP router, load balancing, IP PBX, and Hosted PBX as well. This book is an update of the title Building Telephony Systems with OpenSER.

    The book starts with the simplest configuration and evolves chapter by chapter teaching you how to add new features and modules. It will first teach you the basic concepts of SIP and SIP routing. Then, you will start applying the theory by installing OpenSIPS and creating the configuration file. You will learn about features such as authentication, PSTN connectivity, user portals, media server integration, billing, NAT traversal, and monitoring. The book uses a fictional VoIP provider to explain OpenSIPS. The idea is to have a simple but complete running VoIP provider by the end of the book.

    Table of Contents

    1. Building Telephony Systems with OpenSIPS 1.6
      1. Table of Contents
      2. Building Telephony Systems with OpenSIPS 1.6
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. Preface
        1. What this book covers
        2. Who this book is for
        3. Conventions
        4. Reader feedback
        5. Customer support
          1. Errata
          2. Piracy
          3. Questions
      7. 1. Introduction to SIP
        1. SIP basics
        2. SIP operation theory
        3. SIP registering process
        4. Server operating as a SIP proxy
        5. Server operating as a SIP redirect
        6. Basic messages
        7. SIP dialog flow
        8. SIP transactions and dialogs
        9. The RTP protocol
          1. Codecs
          2. DTMF relay
          3. Real Time Control Protocol (RTCP)
        10. Session Description Protocol (SDP)
        11. The SIP protocol and the OSI model
        12. VoIP provider, the 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. Accounting and CDR generation
          7. Monitoring tools
        13. Where you can find more information
        14. Summary
      8. 2. Introduction to OpenSIPS
        1. Where we are
        2. What is OpenSIPS?
        3. OpenSIPS history
        4. Main characteristics
          1. Speed
          2. Flexibility
          3. OpenSIPS is extendable
          4. Portability
          5. Small footprint
          6. Usage scenarios
        5. OpenSIPS configuration file
          1. Core and modules
          2. Sections of the opensips.cfg file
          3. Sessions, dialogs, and transactions
          4. Message processing in the opensips.cfg
        6. SIP proxy—expected behavior
        7. Stateful operation
        8. Summary
      9. 3. OpenSIPS Installation
        1. Hardware requirements
        2. Software requirements
        3. Lab—installing Linux for OpenSIPS
        4. Downloading and installing OpenSIPS v1.6.x
        5. OpenSIPS console
        6. Lab—running OpenSIPS at the Linux boot
        7. OpenSIPS v1.6.x directory structure
          1. Configuration files (etc/opensips)
          2. Modules (/lib/opensips/modules)
          3. Binaries (/sbin)
        8. Log files
        9. Redirecting OpenSIPS log files
        10. Startup options
        11. Summary
      10. 4. Script and Routing Basics
        1. Where we are
        2. Scripting OpenSIPS
          1. Global parameters
            1. Listen interfaces
            2. Logging
            3. Number of processes
            4. Daemon options
            5. SIP identity
            6. Miscellaneous
            7. Standard script for global parameters
        3. Modules and their parameters
          1. Standard configuration for modules and parameters
        4. Scripting basics
          1. Core functions
          2. Core values
          3. Core keywords
          4. Pseudo-variables
          5. Script variables
          6. Attribute-Value Pair (AVP) overview
        5. Flags
          1. The module GFLAGS
        6. Statements
          1. if-else
          2. Switch
          3. Subroutes
        7. Routing basics
          1. Routing requests and replies
          2. Initial and sequential requests
          3. Sample route script
        8. Using the standard configuration
          1. Common issues
            1. Daemon does not start
            2. Client unable to register
            3. Too many connections
        9. Summary
      11. 5. Adding Authentication with MySQL
        1. Where we are
        2. The AUTH_DB module
        3. The REGISTER authentication sequence
          1. Register sequence
          2. Register sequence code snippet
        4. The INVITE authentication sequence
          1. INVITE sequence packet capture
          2. INVITE code snippet
        5. Digest authentication
          1. WWW-Authenticate response header
          2. The Authorization request header
          3. QOP—Quality Of Protection
        6. Plaintext or hashed passwords
        7. Installing MySQL support
        8. Analysis of the opensips.cfg file
          1. Register requests
          2. Non-Register requests
        9. The opensipsctl shell script
          1. The resource file—opensipsctlrc
            1. The opensipsctlrc file
          2. Using OpenSIPS with authentication
          3. Enhancing the script
            1. Managing multiple domains
        10. Using aliases
        11. Handling CANCEL request and retransmissions
        12. Full script with all the resources above
        13. Lab—multi-domain support
        14. Lab—using aliases
        15. Summary
      12. 6. Graphical User Interfaces for OpenSIPS
        1. OpenSIPS Control Panel
        2. Installation of opensips-cp
          1. Installing Monit
          2. Configuring OpenSIPS Control Panel
        3. SerMyAdmin
          1. Lab—installing SerMyAdmin
            1. SerMyAdmin configuration
        4. Basic tasks
          1. Registering a new user
          2. Approving a new user
          3. User management
          4. Domain management
          5. Interface customization
        5. Comparing OpenSIPS-CP and SerMyAdmin
        6. Summary
      13. 7. Connectivity to the PSTN
        1. The big picture
          1. Requests sent to the gateway
        2. The group module
          1. Requests coming from the gateways
        3. The module permissions
        4. Example
          1. Inspection of the opensips.cfg file
        5. Using Asterisk as a PSTN gateway
          1. Asterisk gateway (sip.conf)
          2. Cisco 2601 gateway
        6. Dynamic routing
          1. Most relevant parameters
            1. Sort order
            2. Blacklist
            3. Force_dns
          2. Drouting tables
          3. Case study for dynamic routing
        7. DIALPLAN transformations
          1. DIALPLAN example
            1. Inspection of the file opensips.cfg
        8. Blacklists and "473/Filtered Destination" messages
        9. Summary
      14. 8. Media Services Integration
        1. Playing announcements
          1. Example: playing demo-thanks
          2. Voicemail
          3. How to integrate Asterisk Real Time with OpenSIPS
        2. Call forwarding
          1. Implementing blind call forwarding
            1. AVPOPS module loading and parameters
            2. Lab—implementing blind call forwarding
        3. Implementing call forward on busy or unanswered
        4. Inspecting the configuration file
        5. Lab—testing the call forward feature
        6. Summary
      15. 9. SIP NAT Traversal
        1. Why NAT breaks SIP
        2. Where NAT breaks SIP
        3. NAT types
          1. Full cone
          2. Restricted cone
          3. Port restricted cone
          4. Symmetric
          5. Why symmetric NAT is hard to traverse
          6. NAT firewall table
        4. Solving the SIP NAT traversal challenge
          1. Implementing a near-end NAT solution
            1. Why STUN does not work with symmetric NAT devices
          2. Implementing a far-end NAT solution
            1. The RFC3581 and the force_rport() function
            2. Solving the traversal of the RTP packets
        5. RTP Proxy installation and configuration
        6. Analysis of the file opensips.cfg
          1. Modules loading
          2. Modules parameters
        7. Determining if the client is behind NAT
        8. Handling REGISTER requests behind NAT
        9. Handling INVITE messages behind NAT
        10. Handling the responses
          1. Handling RE-INVITE messages
          2. Routing script
        11. Invite diagram
          1. Packet sequence
        12. Lab—using the RTP Proxy for NAT traversal
          1. Comparing STUN with TURN (MRS)
          2. Application layer gateways (ALGs)
          3. Interactive Connectivity Establishment (ICE)
        13. Summary
      16. 10. OpenSIPS Accounting and Billing
        1. Objectives
        2. Where we are
          1. VoIP provider architecture
          2. Accounting configuration
          3. Automatic accounting
          4. Multi-leg accounting
          5. Lab—accounting using MySQL
          6. Analysis of the opensips.cfg file
          7. Generating the CDRs
          8. Lab—generating Call Detail Records
          9. Accounting using RADIUS
        3. Lab—accounting using a FreeRADIUS server
          1. Package and dependencies
          2. FreeRADIUS client and server configuration
          3. Configure OpenSIPS server
        4. Solving the problem with missing BYEs
          1. Account in the gateway instead of the proxy
          2. Use SIP session timers
          3. Use RTP proxy timeout
          4. Use Media Proxy timeout
        5. Prepaid and postpaid billing
        6. Summary
      17. 11. Monitoring Tools
        1. Where we are
        2. Built-in tools
        3. Trace tools
          1. SIPTRACE
            1. Configuring the SIPTRACE
          2. Stress testing tools
            1. SIPSAK
            2. SIPp
            3. Installing SIPp
            4. Stress test—the SIP signaling
            5. Stress test—the RTP signaling
          3. Wireshark
          4. Monitoring tools
        4. Summary
      18. Index