Building Telephony Systems with OpenSIPS 1.6

Building Telephony Systems with OpenSIPS 1.6
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters


  • 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

Book Details

Language : English
Paperback : 284 pages [ 235mm x 191mm ]
Release Date : January 2010
ISBN : 1849510741
ISBN 13 : 9781849510745
Author(s) : Flavio E. Goncalves
Topics and Technologies : All Books, Networking and Servers, Networking & Telephony, Open Source

Table of Contents

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

Flavio E. Goncalves

Flavio E.Goncalves was born in 1966 in Brazil. Having always had a strong interest in computers, he got his first personal computer in 1983 and since then it has been almost an addiction. He received his degree in Engineering in 1989 with a focus on computer-aided design and computer-aided manufacturing.

He is also the CEO of V.Office Networks in Brazil—a consulting company dedicated to the areas of Networks, Security, and Telecommunications and a training center since its foundation in 1996. Since 1993, he has participated in a series of certification programs and been certificated as Novell MCNE/MCNI, Microsoft MCSE/MCT, Cisco CCSP/CCNP/CCDP, Asterisk dCAP, and some others.

He started writing about open source software because he thinks that the way certification programs were organized in the past was very good for helping learners. Some books today are written by strictly technical people who, sometimes, do not have a clear idea of how people learn. He tried to use his 15 years of experience as an instructor to help people learn about the open source telephony software. His experience with networks, protocol analyzers, and IP telephony combined with his teaching experience give him an edge to write this book. This is the third book written by him; the first one was "Configuration Guide for Asterisk PBX“, BookSurge Publishing.

As the CEO of V.Office, Flavio E. Goncalves balances his time between family, work, and fun. He is a father of two children and lives in Florianopolis, Brazil, one of the most beautiful places in the world. He dedicates his free time to water sports such as surfing and sailing.

You can contact him at, or visit his website

Code Downloads

Download the code and support files for this book.

Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


- 5 submitted: last submission 07 Apr 2014

Errata type: Technical | Page number: 18

Last sentence: ...(that is, "487 busy here")... Should be: ...(that is, "486 busy here")...


Errata type: Code | Page number: 168

On the last line of the page: countrycode)=contrycode;$avp(s:areacode)=areacode") Should be countrycode)=countrycode;$avp(s:areacode)=areacode")


Errata type: Others | Page number: 165

"We will have two gateways " should be "We will have three gateways"


Errata type: Code | Page number: 150

Missing closing bracket in the following line:
if (!check_source_address("0"). It should be if (!check_source_address("0"))


Errata type: Technical | Page number: 207 | Errata date: 22 July 11

"It seems that force_rtp_proxy was replaced by rtpproxy_offer() and rtpproxy_answer()"


Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

Building Telephony Systems with OpenSIPS 1.6 +    Oracle Weblogic Server 11gR1 PS2: Administration Essentials =
50% Off
the second eBook
Price for both: $41.55

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book


  • Identify how SIP transactions are routed including initial and sequential requests
  • Accelerate the processing of SIP sequential requests with the help of Loose Routing
  • Install OpenSIPS in a Linux platform and integrate a media server such as Asterisk
  • Acquire authentication and persistency by enabling a MySQL back-end for OpenSIPS
  • Administer the server with the help of graphical web interfaces such as OpenSIPS control panel and serMyAdmin
  • Connect to a PSTN gateway to send and receive calls
  • Enable dynamic dial plans and routing by using the DIALPLAN module DROUTING module
  • Traverse NAT using STUN and TURN
  • Bill your costumers or simply check your expenses by generating CDRs (Call Detail Records)
  • Monitor your SIP infrastructure to keep it running smoothly

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. 

A practical guide to building an efficient SIP telephony system


This is a practical, hands-on book based around a fictitious case study VoIP Provider that you will build on a development server using OpenSIPS 1.6. The case study grows chapter by chapter, from installing your local development server, right up to the finished VoIP provider.

Who this book is for

This book is for readers who want to understand how to build a SIP provider from scratch using OpenSIPS. It is suitable for VoIP providers, large enterprises, and universities.

Telephony and Linux experience will be helpful but is not essential. Readers need not have prior knowledge of OpenSIPS. This book will also help readers who were using OpenSER but are now confused with the new OpenSIPS.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software