SIP stands for Session Initiation Protocol. As the name says it is widely used for starting a new session. A session being an audio call, a video call, a screen share, a file share, a game of chess etc. SIP just provides a way to traverse the internet and connect endpoints. It doesn't work alone and another protocol can piggy back on it and enables different functionalities. The most common one is SDP, Session Description Protocol, it contains the info regarding this new session: what IP address, port, codec, type of media and numerous detailing attributes are found within SDP.
This information is significant here because we're going to setup SIP servers of different nature and telling them specific roles to do. Generally speaking following types of SIP servers can be found in a VoIP network:
Proxy Server: Relays SIP packets from one side to another side. It can be stateless or state full and can be powerful enough to modify the SIP packets. It can serially or parallel fork the SIP packets as well.
Redirect Server: This could be a stateless simple SIP server which based on some logic either dynamic or static just redirects the requesting party. Imagine this is a mirror and reflects the light rays to different angles based on some logic.
Registrar Server: This keeps record of active/online OR inactive/offline users. When queried about a user it returns the route-able address of a user. An analogy of a receptionist who knows where a person is sitting and either is in office or not.
Media Server: This is pretty much the value added services kind of server. It entertains a session and based on what is configured performs some action. Media Servers are SIP servers designed specially to play with the Media of the session. Different media servers give different capabilities to the VoIP network for example a Conferencing Server, or a Fax-to-Email Server, or possibly a multi-player game engine. These are also referred as Application Servers.
Media Proxy: These are just relays mostly. They receive media from one side and deliver on the other side. Generally they are not designed to modify the media streams and rather focus on capacity and efficiency. They support a big time for media to traverse the networks and reach their desired destination safely.
Lets Get Started:
The very first thing we need to have is a server (either virtual or physical) with Linux installed on it. There could be many different Operating system choices but for sake of simplicity I'm going to stick to Debian 8.4 throughout the series of this blog.
First, make sure you've Debian OS installed before beginning to follow the instructions. I have setup VirtualBox on my host machine and created 4 Debian based Virtual Machines on it. Once sure that the virtual-servers are able to connect to the internet please proceed to install any of the following SIP Servers.
Following SIP Servers are my major focus in this blog:
Asterisk and FreeSWITCH are Media Servers and they never do any SIP signalling level functions. OpenSIPS and Kamailio are both amazing SIP servers and are able to dissect a SIP packet, perform some functions, and then route it anywhere we ask them to.
I will install all 4 of them at the same time and similarly will demonstrate the same task done by all 4 of them simultaneously. This will continue for the next couple of posts until to a point where Media-Servers and SIP Proxies diverge and no longer do the same things. Please note that these are all different servers and following commands should not be mistaken to be executed all at just one server.
Note: Executing "make menuseclect" will open up a console window and requires to select or deselect different modules, applications, functions, or resources.
At this point we have our asterisk ready to be started. Follow this command to start asterisk in background
Now, asterisk provides us with a Command Line Interface (CLI) where we can do alot of things with asterisk - (all operational commands no configurations yet). To access the asterisk CLI
This is a pretty straight forward indicator that asterisk server is running.
Note: Please uncomment or comment desired modules in file modules.conf
Next start our FreeSWITCH server:
Using fs_cliconnects with freeswitch console and it should always result in the following screen (unless modified)
Include the db_mysql module in the included modules to compile.
Save and Exit the file, time to compile.
Modify the Database related parameters so Kamailio can create its database. I have a central DB so I modified the following fields according to my setup. At the very minimum the DBENGINE=MYSQL needs to be uncommented so Database could be steup on local MySQL instance.
Modify the DAEMON path to /usr/local/sbin/kamailio
Time to setup the default parameters for kamailio startup.
Here is what my default kamailio file looks like.
Next we will create directory for kamailio to save its PID and create user for kamailio to use, and finally need to setup the Startup script for kamailio:
Here is a sample kamailio.service file which is really important for systemctl to start or stop kamailio as service.
Time to reload systemctl-daemon and start kamailio as service.
Once service started, we can check if it is running by using command ps -ef | grep kamailio
Thats pretty much it, our Kamailio Server is ready and running.
When executing "make menuconfig" we have to navigate to select the modules required, please add desired modules by navigating as following:
Press Arrow keys to enter or exit a sub-menu. Enter Configure Compile Options first.
Move further into Configuring Excluded modules to add/remove the modules.
Once modules selected exit back to main menu and execute "Compile And Install OpenSIPS" this command returns back to command prompt if executed successfully else gets some error and display the menu again. In this case probably some library is missing.
Once at command prompt follow these commands:
Again, need to set some default parameters for OpenSIPS.
Next add opensips user, create PID directory and start our OpenSIPS using the following commands.
It should start like this, check using ps -ef | grep opensips
This was easy an quick, right ? Now we have our OpenSIPS server up and running - all we need to do next is configure it.
We now have all our voip servers ready and working. Its time to read some documentations about them and know them a bit more. In my next post I will show how to have some Users registered on each of these and make calls between them.
I'm busy working on my blog posts. Watch this space!