Building Telephony Systems with OpenSER

Building Telephony Systems with OpenSER
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 40%!
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
  • 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

Book Details

Language : English
Paperback : 324 pages [ 235mm x 191mm ]
Release Date : April 2008
ISBN : 1847193730
ISBN 13 : 9781847193735
Author(s) : Flavio E. Goncalves
Topics and Technologies : All Books, Networking and Servers, Linux Servers, Networking & Telephony, Open Source

Table of Contents

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


- 3 submitted: last submission 03 Dec 2012

Errata type: Typo | Page number: 5

In the section titled "Downloading the Example Code for the Book"
the phrase "directly downlad" should read "directly download".


Errata type: Typo | Page number: 8

RVSP Should be


Errata type: Typo | Page number: 56

Step 4 under the heading "Lab—Running OpenSER at the Linux Boot"
Edit /etc/default/openser.cfg Should be
Edit /etc/default/openser


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 OpenSER +    OData Programming Cookbook for .NET Developers =
50% Off
the second eBook
Price for both: £24.65

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

What you will learn from this book

  • An introduction to SIP
  • An overview of SIP Proxies
  • Compiling and installing OpenSER
  • SIP Proxy default configuration
  • Implementing MySQL support for authentication
  • Installing the user portal (SerWEB)
  • Connecting to the PSTN using a gateway
  • Sending a call to voicemail
  • NAT traversal using mediaproxy
  • Billing with Freeradius and CDRTool
  • Troubleshooting tips and tools.

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.


This book is a well illustrated, step-by-step guide to building a SIP based network using OpenSER.

Who this book is for

This book is for readers who want to understand how to build a SIP provider from scratch using OpenSER. Telephony and Linux experience will be helpful but is not essential. Readers need not have prior knowledge of OpenSER.

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