Kamailio 3.0.x and FreeSWITCH 1.0.6+ for Media Services

Overview

The scope of this tutorial is to show how you can use Kamailio (former OpenSER) and FreeSWITCH to build a complete SIP/VoIP platform for large number of subscribers.

Kamailio is an open source SIP server, forked from SIP Express Router (SER) in 2005 under the name OpenSER. In July 2008, OpenSER was renamed to Kamailio because of trademark issues. Starting with November 2008, Kamailio and SER teams restarted development collaboration, resulting in version 3.0.0 being the first that allow to run Kamailio and SER modules (extensions) in same SIP server instance - practically it is the same source code, the differences are the database structure used to store SIP user profiles and default enabled modules.

One of outstanding features of Kamailio is ability of hosting large number of active users in a single instance (depending of hardware it can be 100 000+). Long development life ensures the stability required in real-time tele-comunications and a broad set of features in handling SIP signaling.

FreeSWITCH is an open source multi-protocol softswitch, supporting SIP as well. It is a very attractive project from features and extensibility point of view. Its media processing capabilities makes FreeSWITCH a perfect fit for providing media services to Kamailio based platforms.

Any Kamailio version 3.0.x can be used (right now last released is 3.0.1). For FreeSWITCH I used the development version from GIT after release 1.0.6, but before any other official release (no 1.0.7 or what is going to be next).

Following services are handled in the scenario built within document:

kamailio

user authentication

user registration

user location

call routing

instant messaging and presence

freeswitch

voicemail

conference

other media services (announcement, ivr, a.s.o)

Local users have 3 digit IDs (we will use users 101 102, and 103 for testing). Voice box ID is the same as user ID. Extensions for media services start with 4.

Kamailio and FreeSWITCH are installed on the same physical server (ip 192.168.178.23), using different ports:

Kamailio Configuration

Installation

It is no special tunning needed for this tutorial, just install it as usual. You can use MySQL or your preferred database server, has no relevance here. But if you choose another database type, be sure you update the Kamailio config file, the one provided here uses MySQL.

We try to keep FreeSWITCH and Kamailio installations as much as possible independent one from the other.

Config File

Kamailio has one config file by default, named kamailio.cfg. Starting with 3.0.0, you can split it in several files and use include_file to merge the pieces in main config file.

Another important features brought by 3.0.x are 'define' directives, making easy to enable/disable features. This concept is used here as well, therefore you can see the changes done for FreeSWITCH integration by following define WITH_FREESWITCH (i.e., config parts in between #!ifdef WITH_FREESWITCH … #!endif).

First extension is to leave a voice message to callee. Second is to listen to caller's voice messages.

User Directory

You have to create some file that hold the user profiles to provide voicemail services. Here we put the XML files on the local file system.

However, with freeswitch is easy to get them dynamically, i.e., via HTTP (invoking PHP, CGI, etc.) or calling an application (written in Lua for example) that goes to database (can be Kamailio's database) and return the user profiles - I let that for a future article: Kamailio and FreeSWITCH realtime integration.