You are previewing Building Telephony Systems with OpenSIPS - Second Edition.
O'Reilly logo
Building Telephony Systems with OpenSIPS - Second Edition

Book Description

Build high-speed and highly scalable telephony systems using OpenSIPS

About This Book

  • Install and configure OpenSIPS to authenticate, route, bill, and monitor VoIP calls

  • Gain a competitive edge using the most scalable VoIP technology

  • Discover the latest features of OpenSIPS with practical examples and case studies

  • Who This Book Is For

    If you want to understand how to build a SIP provider from scratch using OpenSIPS, then this book is ideal for you. It is beneficial for VoIP providers, large enterprises, and universities. This book will also help readers who were using OpenSER but are now confused with the new OpenSIPS.

    Telephony and Linux experience will be helpful to get the most out of this book but is not essential. Prior knowledge of OpenSIPS is not assumed.

    What You Will Learn

  • Learn to prepare and configure a Linux system for OpenSIPS

  • Familiarise yourself with the installation and configuration of OpenSIPS

  • Understand how to set a domain and create users/extensions

  • Configure SIP endpoints and make calls between them

  • Make calls to and from the PSTN and create access control lists to authorize calls

  • Install a graphical user interface to simplify the task of provisioning user and system information

  • Implement an effective billing system with OpenSIPS

  • Monitor and troubleshoot OpenSIPS to keep it running smoothly

  • In Detail

    OpenSIPS is a multifunctional, multipurpose signalling SIP server. SIP (Session Initiation Protocol) is nowadays the most important VoIP protocol and OpenSIPS is the open source leader in VoIP platforms based on SIP. OpenSIPS is used to set up SIP Proxy servers. The purpose of these servers is to receive, examine, and classify SIP requests. The whole telecommunication industry is changing to an IP environment, and telephony as we know it today will completely change 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.

    Starting with an introduction to SIP and OpenSIPS, you will begin by installing and configuring OpenSIPS. You will be introduced to OpenSIPS Scripting language and OpenSIPS Routing concepts, followed by comprehensive coverage of Subscriber Management. Next, you will learn to install, configure, and customize the OpenSIPS control panel and explore dialplans and routing. You will discover how to manage the dialog module, accounting, NATTraversal, and other new SIP services. The final chapters of the book are dedicated to troubleshooting tools, SIP security, and advanced scenarios including TCP/TLS support, load balancing, asynchronous processing, and more.

    A fictional VoIP provider is used to explain OpenSIPS and by the end of the book, you will have a simple but complete system to run a VoIP provider.

    Style and approach

    This book is a step-by-step guide based on the example of a VoIP provider. You will start with OpenSIPS installation and gradually, your knowledge depth will increase.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. Building Telephony Systems with OpenSIPS Second Edition
      1. Table of Contents
      2. Building Telephony Systems with OpenSIPS Second Edition
      3. Credits
      4. About the Authors
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. 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. Errata
          2. Piracy
          3. Questions
      8. 1. Introduction to SIP
        1. Understanding the SIP architecture
        2. The SIP registration process
        3. Types of SIP servers
          1. The proxy server
          2. The redirect server
          3. The B2BUA server
        4. SIP request messages
        5. The SIP dialog flow
        6. SIP transactions and dialogs
        7. Locating the SIP servers
        8. SIP services
        9. The SIP identity
        10. The RTP protocol
          1. Codecs
          2. DTMF-relay
        11. Session Description Protocol
        12. The SIP protocol and OSI model
        13. The VoIP provider's big picture
          1. The SIP proxy
          2. The user administration and provisioning portal
          3. The PSTN gateway
          4. The media server
          5. The media proxy or RTP proxy for NAT traversal
          6. Accounting and CDR generation
          7. Monitoring tools
        14. Additional references
        15. Summary
      9. 2. Introducing OpenSIPS
        1. Understanding OpenSIPS
        2. OpenSIPS capabilities
          1. An overview of the OpenSIPS project
          2. OpenSIPS knowledge transfer and support
        3. Usage scenarios for OpenSIPS
          1. The ingress side
          2. The core side
          3. The egress side
        4. Who's using OpenSIPS?
        5. The OpenSIPS design
          1. The OpenSIPS core
          2. The OpenSIPS modules
        6. Summary
      10. 3. Installing OpenSIPS
        1. Hardware and software requirements
          1. Installing Linux for OpenSIPS
          2. Downloading and installing OpenSIPS v2.1.x
        2. Generating OpenSIPS scripts
          1. Running OpenSIPS at the Linux boot time
          2. The OpenSIPS v2.1.x directory structure
            1. The configuration files
            2. Modules
        3. Working with the log files
        4. Startup options
        5. Summary
      11. 4. OpenSIPS Language and Routing Concepts
        1. An overview of OpenSIPS scripting
        2. The OpenSIPS configuration file
          1. Global parameters
          2. The modules section
          3. Scripting routes
            1. The request route
            2. The branch route
            3. The failure route
            4. The reply route
            5. The local route
            6. The start up route
            7. The timer route
            8. The event route
            9. The error route
        3. Scripting capabilities
          1. The scripting functions
          2. The scripting variables
            1. The reference variables
            2. The AVP variables
            3. The script variables
          3. Scripting transformations
          4. Scripting flags
          5. Scripting operators
          6. Script statements
        4. SIP routing in OpenSIPS
          1. Mapping SIP traffic over the routing script
          2. Stateless and stateful routing
          3. In-dialog SIP routing
        5. Summary
      12. 5. Subscriber Management
        1. Modules
        2. The AUTH_DB module
        3. The REGISTER authentication sequence
          1. The REGISTER sequence
        4. The INVITE authentication sequence
          1. The INVITE sequence packet capture
          2. The INVITE code snippet
        5. Digest authentication
          1. The authorization request header
          2. Quality of protection
        6. Plaintext or prehashed passwords
        7. Installing MySQL support
        8. Analysis of the opensips.cfg file
          1. The REGISTER requests
          2. The non-REGISTER requests
        9. The opensipsctl shell script
          1. Configuring the opensipsctl utility
          2. Using OpenSIPS with authentication
          3. The registration process
          4. Enhancing the opensips.cfg routing script
            1. Managing multiple domains
        10. Using aliases
        11. Handling the CANCEL requests and retransmissions
        12. Lab – multidomain support
        13. Lab – using aliases
        14. IP authentication
        15. Summary
      13. 6. OpenSIPS Control Panel
        1. The OpenSIPS control panel
        2. Installation of OpenSIPS-CP
          1. Configuring the OpenSIPS-CP
          2. Installing Monit
        3. Configuring administrators
        4. Adding and removing domains
        5. Manage the access control lists or groups
        6. Managing aliases
        7. Managing subscribers
          1. Verifying the subscriber registration
        8. Managing permissions and IP authentication
        9. Sending commands to the management interface
        10. A generic table viewer
        11. Summary
      14. 7. Dialplan and Routing
        1. The dialplan module
        2. PSTN routing
          1. Receiving calls from PSTN
            1. Gateway authentication
              1. The permissions module
            2. Caller identification
          2. Sending calls to PSTN
            1. Identifying PSTN calls
            2. Authorizing PSTN calls
              1. The group module
              2. Access Control Lists
            3. Caller ID in PSTN calls
            4. Routing to PSTN GWs
              1. The dynamic routing module
                1. Routing entities
                2. The selection algorithm
                3. Probing and disabling gateways
                4. Advanced features
          3. Script samples
        3. Summary
      15. 8. Managing Dialogs
        1. Enabling the dialog module
        2. Creating a dialog
        3. Dialog matching
        4. Dialog states
        5. Dialog timeout and call disconnection
        6. Dialog variables and flags
          1. Setting and reading the dialog variables
          2. Setting and reading the dialog flags
        7. Profiling a dialog
          1. Counting calls from the MI interface
        8. Disconnecting calls
          1. Disconnecting a call using the MI interface
        9. Topology hiding
          1. Initial request before topology hiding
          2. Initial request after topology hiding
          3. Sequential request before topology hiding
          4. Sequential request after topology hiding
          5. Topology hiding limitations
        10. Validating a dialog and fixing broken dialogs
        11. Displaying the dialog statistics
          1. Description of the statistics
        12. SIP session timers
          1. How the SIP session timer works
        13. Summary
      16. 9. Accounting
        1. Progress check
        2. Selecting a backend
          1. The accounting configuration
          2. Automatic accounting
          3. Manual accounting
          4. Extra accounting
          5. Multi-leg accounting
          6. Lab - accounting using MySQL
          7. Using the dialog module to obtain the duration
          8. Call end reason
          9. Generating CDRs
          10. Lab – generating CDRs
          11. CDRviewer and extra accounting
        3. Accounting using RADIUS
        4. Lab – accounting using a FreeRADIUS server
          1. Package and dependencies
          2. FreeRADIUS client and server configuration
          3. Configuring the OpenSIPS server
        5. Missing BYEs and CDRs
        6. Summary
      17. 10. SIP NAT Traversal
        1. Port address translation
        2. Where does NAT break SIP?
        3. Types of NAT
          1. Full cone
          2. Restricted cone
          3. Port-restricted cone
          4. Symmetric
          5. The NAT firewall table
        4. Solving the SIP NAT traversal challenge
          1. A solution proposed for the NAT issue
          2. The solution's topology
        5. Building the solution
          1. Installing STUN
            1. Why STUN does not work with symmetric NAT devices
          2. Solving SIP signaling
            1. Implementing NAT detection
            2. Solving the Via header using rport
            3. Fixing the Contact header for requests and replies
            4. Handling the REGISTER requests and pings
            5. Handling the responses
            6. Handling sequential requests
          3. Using a media relay server
            1. Solving the traversal of the RTP packets
        6. Understanding the solution flow
          1. (1) First INVITE
          2. (2) INVITE relayed by the server
          3. (3) Reply 200 OK with SDP
          4. Acknowledgements (ACK packets)
        7. Summary
      18. 11. Implementing SIP Services
        1. Where to implement SIP services
        2. Explaining RFC 5359 with SIP service examples
        3. Playing announcements
          1. Playing demo-thanks
        4. Call forwarding
          1. Implementing blind call forwarding
            1. Loading the AVPops module and its parameters
            2. Lab – implementing blind call forwarding
        5. Implementing call forward on busy or unanswered
        6. Debugging the routing script
        7. Lab – testing the call forwarding feature
          1. Implementing an integrated voicemail
          2. User integration
          3. Integrating Asterisk Realtime with OpenSIPS
        8. Call transfer
          1. An unattended transfer
          2. Tips for call transfer
        9. Summary
      19. 12. Monitoring Tools
        1. Built-in tools
        2. Trace tools
          1. SIPTRACE
            1. Configuring SIPTRACE
          2. Script trace
        3. Troubleshooting routing scripts
          1. A system crash
          2. Benchmarking segments of code
          3. Stress testing tools
            1. The sipsak tool
            2. SIPp
            3. Installing SIPp
            4. Stress testing
          4. Packet capturing tools
            1. Ngrep
            2. Sipgrep
            3. Wireshark
        4. Summary
      20. 13. OpenSIPS Security
        1. Configuring a firewall for OpenSIPS
          1. Blocking multiple unsuccessful authentication attempts
          2. Preventing DOS using the PIKE module
            1. PIKE in manual mode
            2. PIKE in automatic mode
        2. Preventing DNS and registration poisoning
        3. Enabling Transport Layer Security
          1. Generating a script for TLS
          2. Creating the root certificate authority
          3. Creating the server certificate
          4. Installing the root certificate authority in your softphone
        4. Enabling Secure Real-time Protocol
          1. SRTP-SDES
          2. DTLS-SRTP
          3. ZRTP
          4. Enabling SRTP
        5. Enabling the anti-fraud module
          1. Event generation
          2. Script integration
        6. Summary
      21. 14. Advanced Topics with OpenSIPS 2.1
        1. Asynchronous operations
        2. Asynchronous support in the OpenSIPS script
          1. Available asynchronous functions
        3. Binary replication
          1. Dialog replication
          2. The usrloc replication
        4. TCP handling
          1. Enabling TCP
        5. Summary
      22. Index