SIP Stress Testing -Part 3 (SIPp)

.

Introduction

This is Part 3 of “SIP Stress Testing” topic. In Part 1, I have talked about the definition of the stress, opensipsctl (command line tool), and OpenSIPS-CP (web tool) and how they are used in testing. In Part 2 i have talked about SIPSAK (command line tool) which is used as SIP traffic generator. In this part i will talk about SIPp which is an emulation tool which generates SIP traffic and gives some statistics. The current version (3.4) have these features:

  • Establishes and releases multiple calls with the INVITE and BYE methods.
  • Read custom XML scenarios files which described simple to complex call flows.
  • Dynamic display of statistics.
  • Support of IPv6, TLS, SCTP.
  • Support of SIPauthentication, conditional scenarios, UDP retransmissions, error robustness.
  • Call specific variable.
  • Posix regular expression to extract and re-inject any protocol fields.
  • Custom actions (log, system command exec, call stop).
  • Emulate live users using external CV file .
  • Send RTP traffic (audio/video).

SIPp Installation

Pre-requisites to compile SIPp on Fedora Red Hat:

  • Install C++ compiler: # yum install gcc-c++
  • Install ncurses-devel: # yum install  ncurses-devel
  • For TLS support,  install OpenSSL (version > 0.9.8): #yum install openssl-devel
  • For pcap play support, install libpcap and libnet : #yum install  libnet libnet-devel  libpcap libpcap-devel
  • For SCTP support, install lksctp: #yum install lksctp-tools lksctp-tools-devel
  • For distributed pauses, Install GNU Scientific Libraries (gsl): #yum install gsl gsl-devel

Please check your system for the corresponding libraries names.

Download the source code of SIPp:

To compile SIPp, we have four options:

  • Without TLS, SCTP, or PCAP support.
  • With TLS support.
  • With PCAP support
  • With SCTP support

I will combine these options to compile SIPp which supports TLS, SCTP, and PCAP:

  • # tar -xvzf sipp-3.3.990.tar.gz
  • # cd sipp-3.3.990/
  • # ./configure –with-sctp –with-pcap –with-openssl
  • # make
  • # make install

Controlling SIPp Interactively

You can control SIPp through the keyboard. For example pressing on ‘1’, will display the scenario screen, and pressing ‘2’ will display the statistics screen and so on.

SIPp can alse be controlled via a UDP socket. The default base port is 8888 for the first instance and it will increase by 1 for each following SIPp instance (8889, 8890,…). Use the option -cp to change the base port. For example to put SIPp in pause state, we execute this shell command: # echo p > /dev/udp/x.y.z.t/8888 where x.y.z.t is the IP address of the SIPp instance.

Check SIPs Network State

If we have SIPp instance running on the machine (UAS instance :# sipp -sn uas -i 10.0.0.9) and we want to check the network state of that instance, we execute “netstat” command as following:

# netstat -lpn  |grep sipp

The output will be like this

udp        0      0 0.0.0.0:8888            0.0.0.0:*                           14144/sipp
udp        0      0 10.0.0.9:5067           0.0.0.0:*                           14144/sipp
udp        0      0 10.0.0.9:6000           0.0.0.0:*                           14144/sipp
udp        0      0 10.0.0.9:6002           0.0.0.0:*                           14144/sipp

Where:

  • 8888 is the port for SIPp control. Use the option -cp in the command line to change the base number.
  • 5067 is the port for SIP signaling. Use the option -p in the command line to change it.
  • 6000 is  the default local RTP echo port.Use the option -mp in the command line to change it. RTP/UDP packets received on this port are echoed to their sender
  • 6002 is the RTP echo port +2. RTP/UDP packets coming on this port are also echoed to their sender.

SIP User Agent Definition

  • User Agent Client (UAC): It is a logical entity that creates a new SIP request. This role (the role of being UAC) lasts only for the duration of the transaction (SIP transaction).
  • User Agent Server (UAS): It is a logical entity that generates a response to a SIP request. This role (the role of being UAS) lasts  only for the duration of the transaction (SIP transaction).

UACUAS Example

SIP traffic between two SIP user agents on the same host (IP: 10.0.0.9). The traffic is passed directly from the user agent client (UAC) to the user agent server (UAS) without passing a SIP proxy.

Scenario Definition

We want to generate SIP traffic with this specification:

  • Number of calls per second (call rate) = 100 cps. This can be specified as a parameter in the “sipp” command line after the option -r. This rate can be changed interactively (i.e. during the test) by pressing keys on the keyboard. For example pressing ‘+’ will increase the rate by 1 (‘-‘ decrease by 1, ‘*’ increase by 10, ‘/’ decrease by 10).
  • Rate Period in milliseconds for the call rate=10000 ms. This can be specified in the “sipp” command line after the option -rp.

To have n calls every m milliseconds, we mix the previous command line parameters together. So it will be like this –r n -rp m. Here in this scenario, i want to generate 100 calls per 10 seconds so the parameters will be -r 100 -rp 10000.

  • The UAC and UAS are on the same machine. For UAC, i will choose the port 5061 for SIP signaling. For UAS, i will choose the port 5067 for SIp signaling.
  • I will use IPv4 addresses.
  • Call Flow between UAC and UAS: The default behaviour of the UAC (what UAC sends and what it expects as response for each request it sends) is defined in the scenario file (uac.xml). As it is the default scenario so i don’t need to pass the name of the xml file as a parameter in the command line “sipp”. This is the default call flow of the UAC and UAS :

scenarios

In the default scenario, authentication is not used and there is no record routing.

Here is the XML scenario file of the UAS  uas.xml.You can create your own custom XML scenarios as i will do in the next article. In this case you have to pass the names of the XML files which describes the call flows as parameters to “sipp” command (after the option -sf).

Run the UAC and UAS

SIPp will generate SIP traffic according to scenario defined above. SIPp has an embedded SIP user agent client (UAC) which will generate this traffic. Open one terminal and execute this command “# sipp -sn uac 10.0.0.9:5067  -r 100 -rp 10000  -i 10.0.0.9 -p 5061” to run the SIP client (uac). According to this, the UAC (10.0.0.9:5061) will send 100 calls per 10 seconds to the UAS (10.0.0.9:5067).

SIPp has an embedded user agent server (UAS). Open another terminal on the same host and execute this command “# sipp -sn uas -i 10.0.0.9 -p 5067“. This will run the UAS on 10.0.0.9:5067.

Be sure that the ports you want to use are free (not used by another application). This article is like a tutorial so run your UAC and UAS on different machine. Note that we are using the same command “sipp” to run the UAC and UAS. Remember SIPp is an emulation tool for testing the SIP protocol.

Scenario Screenshots

The scenario screen display the call flow as well as some information. This is the scenario screen of the UAC:

Here is the scenario screen of the UAS:

Several screens are available to monitor SIP traffic. You can change the screen by pressing 1 to 9 keys on the keyboard. For example click key ‘2’ to display the statistics screen. Here is the statistics screen of the UAC:

Here is the statistics screen of the UAS:

As you can see the number of successful calls is 150 and the number of failed calls is 0.

UACSIP ProxyUAS Example

SIP traffic between two SIP user agents. The traffic is passing the proxy from the user agent client (UAC) to the user agent server (UAS).  We will take the same previous scenario but with proxy. The UAC, UAS, and the proxy are all on the same machine. The proxy will be OpenSIPS. The routing script of the proxy must work properly with UAC and UAS.

SIPp-Example2

Register and Run the UAS

Assume OpenSIPS is running on 10.0.0.9:5060. We will send packets continuously to the UAS through the proxy. So we need UAS to stay registered during the test (OpenSIPs always knows UAS IP address). So we will register UAS manually by adding a static mapping in the OpenSIPS ‘s “Location” table and this entry will be permanent (available at any time).  

Do as following:

  • Go to OpenSIPS’s sbin directory: # cd /usr/local/opensips_1_11/sbin/
  • Add UAS with the user name = 1234Test: # opensipsctl ul add 1234Test@10.0.0.9 sip:1234Test@10.0.0.9:5067. This will add an entry for this user in the location table.

opensipsctl

We have 10.0.0.9 added in OpenSIPS “Domain table” (# opensipsctl domain add 10.0.0.9).

  • Run the UAS:  sippsn uas -rsa 10.0.0.9:5060  -i 10.0.0.9 -p 5067. The address which comes after the option -rsa  is the remote sending address (Here it is the OpenSIPS proxy).

Now the UAS is ready. You can check its status by executing “# ./opensipsctl ul show”. The output will be as this:

Domain:: location table=512 records=1
AOR:: 1234Test
Contact:: sip:1234Test@10.0.0.9:5067 Q=1
Expires:: permanent
Callid:: dfjrewr12386fd6-343@opensips.mi
Cseq:: 1
User-agent:: OpenSIPS MI Server
State:: CS_SYNC
Flags:: 0
Cflags::
Methods:: 4294967295

As you can see this is a static entry and it is permanent (No need for refreshment). The OpenSIPS now always can route all requests destined to UAS (Request-URI=1234Test@10.0.0.9:5060 (OpenSIPS URI)).

Avoid Authentication of SIP Requests and Loose Routing for Sequential Requests:

Here i am taking the default routing script of OpenSIPS which is generated for residential service. Do the following changes:

  • Avoid loose routing of SIPp packets by skipping the loose routing section where the client is sipp ($fU is “sipp”):

 if (has_totag()  && ($fU!=“sipp”)) {

// Do the loose routing

}

  • Avoid Authentication for SIPp packets: Comment these lines in your routing script:

  # if (!proxy_authorize(“”, “subscriber”)) {
#                   proxy_challenge(“”, “0”);
#                   exit;
# }
# if (!db_check_from()) {
#                sl_send_reply(“403″,”Forbidden auth ID”);
#               exit;
# }

# consume_credentials();
# caller authenticated

  • Restart OpenSIPS (# systemctl restart opensips.service)

Run The UAC

Run this command : #sipp  -sn uac 10.0.0.9:5060 -s 1234Test -i 10.0.0.9 -p 5061 -d 20000 -r 100 -rp 10000

The option ‘-s’ sets the username part of the request URI. The option -d controls the length of calls (duration of pause).

Screenshots

The following is the scenario screens of UAS:

Server-Scenario-Ex2and the statistics screen of the UAS:

Server-Stat-Ex2

Troubleshooting

If you got some errors, enable logging by setting the option -trace_err in command line. For example enable logging at UAC side:

#sipp -trace_err -sn uac 10.0.0.9:5060 -s 1234Test -i 10.0.0.9 -p 5061

Press the key ‘q’ to quit and check the log file. The scenarios of the UAC and UAS and the routing script of the proxy, should be compatible with each other regarding what have been received and what should be sent otherwise you will get unexpected messages.

What does play a role in the results of this test ?

  • The operating system (CPU, Memory, Scheduler,….etc): Fedora Red Hat
  • The Proxy (internal design, routing script, Private and shared memory) : OpenSIPS
  • The traffic generator Performance (internal design): SIPp
  • The network design: UAS, Proxy, and UAS are on the same machine (This article is like a tutorial).

Now you can do what is called tuning (change the parameters that affect the performance). Best is using tools that help you to do the tuning and give you some statistics.


The Part 4 of “SIP Stress Testing” topic will also be about SIPp.  It will be writing custom scenario for the example UAC-SIP Proxy-UAS above.


More Information


Advertisements

SIPTRACE OpenSIPS Tracing Tool

.

What is SIPTRACE ?

siptraceIt is a tracing tool tied to OpenSIPS. With this tool, you can trace all calls or a specific user calls in real time (i.e. You can see the SIP messages related to a specific user and passed the OpenSIPS in real time).  As this tool logs the signalling messages in the database, this affects the the performance when enabled. To enable this tool, the module “siptrace” must be loaded and configured in the configuration file of the OpenSIPS (routing script).

Steps To Trace Specific User’s  SIP Messages

  • Load “siptrace” module. Add this line in the configuration file:

loadmodule “siptrace.so”

  • Set db_url module parameter (database URL).

modparam(“siptrace”, “db_url“, “mysql://user:passwd@host/dbname”)

  • Set trace_flag parameter (Which flag is used to mark messages to trace):

modparam(“siptrace”, “trace_flag“, “22”)    # Here the trace_flag will 22.

  • The module parametertraced_user_avp” specifies the AVP which stores the SIP URI of the traced user. The name of the user will be shown in the “traced_user” field in the “sip_trace” table. Setting the “traced_user_avp” will automatically enable tracing. You can store multiple values in the AVP if you want to trace more than one user.

modparam(“siptrace”, “traced_user_avp“, “$avp(traced_user)”)

  • Set trace_on parameter (1(on) or 0(off)): Default value is 0.

modparam(“siptrace”, “trace_on”, 1)

If this parameter is not set (remained 0) in the configuration file, the tracing can be enabled by setting the module parameter “traced_user_avp” or using opensipsctl tool:

# opensipsctl fifo sip_trace on

  • Before writing the code responsible for actual tracing of sip messages, You should be familiar with what is called Attribute Value Pair (AVP) variables. This is found here. Add this block to load and configure the “avpops” module which is needed for managing AVPs (Add/Remove/Update/Delete) in the database.

loadmodule “avpops.so”
modparam(“avpops”,”db_url”,“mysql://user:passwd@host/dbname”) # Customize This
modparam(“avpops”, “avp_table”, “New_usr_preferences”) # Customize this If you are using another table.

  • To trace the current SIP message, we need to call the function (sip_trace). To trace all messages related to the current SIP meesage (i.e. messages related to the transaction created by that request), we need to set  the tracing flag (setflag(22)). Remember this flag is defined as trace_flag (modparam(“siptrace”, “trace_flag“, “22“)).

Write the following code in the main request routing block of the routing script.

if(avp_db_load(“$fu”,”$avp(trace)”)) {
$avp(traced_user)=$fu;
setflag(22);
sip_trace();
xlog(“L_INFO”,”User $fu being traced”);
}

The $fu is a reference to URI of “From” header. The function avp_db_load(“$fu”,”$avp(trace)”) loads the AVP which belongs to $fu and has the name “trace”. This AVP must be added in the “usr_preferences” table.  Use “opensipsctl” tool to add it. # opensipsctl avp add –T usr_preferences test@youripaddress trace 1 1. This add AVP which has the name “trace”, type 1 (string,integer), and the value =1 (e.g. <=> true). This correspond to $(AVP(trace)) in the routing script. This AVP when loaded by avp_db_load function, its value will be 1 (<=> True ). The function returns true if it loaded a value in $(AVP(trace)) and this means the message/transaction belongs to that user will be traced.

Note: In the request route, you get only requests (no replies can be traced there). setting the tracing flag will solve the problem.

  • Restart OpenSIPS

# systemctl restart opensips.service

  • Use opensipsctl tool to start tracing

# opensipsctl fifo sip_trace on

OpenSIPS-CP view of “sip_trace” Table

To see the traced messages, you can look directly in the “sip_trace” table or in the OpenSIPS Control Panel. OpenSIPS-CP ‘s siptrace should also be configured. Open the local configuration of the siptrace tool in your OpenSIPS-CP folder :”opensips-cp/config/tools/system/siptrace/local.inc.php” and update the proxy list addresses and the name of OpenSIPS ‘s  sip_trace table.

$config->table_trace = “sip_trace”; # Table Name

$proxy_list=array(“udp:Your_Server_IP_Address:Port”,”tcp:Your_Server_IP_Address:5060″);

To see the traced messages, open the web page “System –> SIP Trace”. You will get something like these figures.

trace

trace1

trace2

You can also disable or enable tracing through the web (the red/green button on the right of the page “System –> SIP Trace”).

trace3SIPTRACE as a SIP Capturing Agent

SIPTRACE module can send the captured packets to an external HEP server (e.g. Homer) instead of storing them in the local database. The following is the configuration:

modparam(“siptrace”, “duplicate_uri”, “sip:10.0.0.1:9060″) # The capturing server address to send a duplicate of traced message to.

modparam(“siptrace”, “duplicate_with_hep”, 1)  # Enable HEP

modparam(“siptrace”, “trace_to_database”, 0) # Disable tracing to the local database

 Here you can find an example to make OpenSIPS (SIPTRACE module) operate as a SIP capturing agent.


More Information


Attribute Value Pair (AVP) Variables in OpenSIPS

.

Here i want to talk about AVPs from routing script’s point of view and the database’s point of view.

AVPs IN The Routing Script

These variables are used in the routing script. They are allocated at the beginning of the transaction and unallocated when the transaction is completed. So they are called transaction-persistent variables (if stateful processing is used). If stateless processing is used, theses variables will be attached to a singular message. When the message is received or the transaction is created, it will initially have an empty list of AVPs. The AVPs will be created directly in the routing script or through functions called from the script. They will automatically attached to the message/transaction.

The AVPs are visible in the routes where the message will be processed (i.e. branch_route , failure_route, onreply_route). If we want the AVPs to be visible in the onreply_route, we need to enable the TM parameter “onreply_avp_mode”.

OpenSIPS ‘s AVPs are Read-Write variables (You can read data from AVP or write data to AVP). AVP can also deleted. When we assign a value to an AVP, the new value is appended to the AVP. So the AVP may contain multiple values. New assignment (write operation) will add a new value to the AVP. The AVP is like a stack (Last in First out).

AVP’s Synatx: The name starts with $ sign. It looks like $avp(name) or $(avp(name)[N]). The index “N”  referes to a specific value. If no index is used, the last added value will be returned. See the figure below

The assignment can be done directly in the script or by calling a function which brings values from database and add them to the AVP. To delete a specific AVP’s value, we do this  $(avp(test)[N])=NULL. To remove the last value, we do this $(avp(test))=NULL. If no values remained, the AVP will be deleted. You can also delete the AVP by avp_delete(“$avp(test)/g”).


AVPs In The Database

The AVPs in the routing script can be loaded by values taken from the database. The default table to store the AVPs is “usr_preferences”. This table is used by the “avpops” module. Each user which uniquely identified by Unique User ID (UUID) or (username and domain), may have several preferences formed in (attribute, value) pairs and stored in the usr_preferences table.  The AVP is defined by this tuple (Attribute, Type , Value). The Attribute is the name of the AVP(The name can be string or number). The type is number (0 (str:str), 1 (str:int), 2 (int:str), 3 (int:int)). For example $avp(123)=2 <=> Type = 3 (integer name and integer value). The value (as a field) is a string.

The figure below explains the structure of the usr_preferences table.

The table “usr_preferences” is the default but you can change it by adding this line in the opensips configuration file with your table’s name:

modparam(“avpops”, “avp_table”, “usr_preferences”)

When a SIP message is received or new SIP transaction is created, the user’s preferences should be taken into account otherwise it will not called preferences, right?.

The function avp_db_load(“$fu”,”$avp(test-name)”) loads the AVP which belongs to $fu and has the name “test_name”.  This function exists in the “avpops” module. So the module must be loaded when using this function or any other AVP ‘s functions. The second parameter of this function can be empty – which means all AVPs identified by the source(first parameter).

Opensipsctl and AVPs

You can use opensipsctl tool to manage AVPs (add, remove, or configure) in the database. To get help info, type #./opensipsctl avp help

For example to add AVP which has the name “trace”, type 1 (string,integer), and the value =1 (e.g. <=> true):

opensipsctl avp add  -T usr_preferences test@youripaddress trace 1 1

This correspond to $(AVP(trace)) in the routing script. The value will be 1.

Note: You can use your favourite database editor to manage  the AVPs  in the database directly (in “usr_preferences” table). For example “phpMyAdmin” (Mysql Administration on the web).


More Information


SIP Stress Testing -Part 1 (Opensipsctl & OpenSIPS-CP)

.

What is Stress Testing ?

It is the process of putting so great load on the system and measuring its response. It helps to determine the maximum operating capacity of the system. The behaviour of the system will be predictable under high/peak loads.

I will mention some tools which help you in the testing of OpenSIPS SIP server under stress.

.

Using SIP traffic generator , we can highly load the SIP server and read the statistics. For example under certain high load, the number of dropped packets became unacceptable or the number of SIP transactions that are in use in memory is so large.

Opensipsctl Tool

It is shell script and it is used as management and monitoring tool. It has some options to generate some statistics. This script communicates with OpenSIPS server through either FIFO pipe or unix socket (The control engine is either fifo or unixsocket). The script is present in OpenSIPS sbin directory. Its configuration file opensipsctlrc is stored in OpenSIPS etc directory. Check the name of your fifo file in the configuration file. To display the available commands, type: #./opensipsctl fifo which

Here is a list of commands available in OpenSIPS 1.11.

get_statistics, reset_statistics, uptime, version, pwd, arg, which, ps, kill, debug, cache_store, cache_fetch, cache_remove, event_subscribe, events_list, subscribers_list, list_tcp_conns, help, list_blacklists, t_uac_dlg, t_uac_cancel, t_hash, t_reply, ul_rm, ul_rm_contact, ul_dump, ul_flush, ul_add, ul_show_contact, ul_sync, dlg_list, dlg_list_ctx, dlg_end_dlg, dlg_db_sync, dlg_restore_db, profile_get_size, profile_list_dlgs, profile_get_values, list_all_profiles.

  • For example to execute the command “ps”, type: #./opensipsctl fifo ps. This command display all  processes running by OpenSIPS. The output looks like:

Process::  ID=0 PID=9739 Type=attendant
Process::  ID=1 PID=9747 Type=MI FIFO
Process::  ID=2 PID=9749 Type=SIP receiver udp:10.0.0.9:5060
Process::  ID=3 PID=9751 Type=SIP receiver udp:10.0.0.9:5060
Process::  ID=4 PID=9753 Type=SIP receiver udp:10.0.0.9:5060
Process::  ID=5 PID=9755 Type=SIP receiver udp:10.0.0.9:5060
Process::  ID=6 PID=9756 Type=time_keeper
Process::  ID=7 PID=9757 Type=timer: tm-utimer
Process::  ID=8 PID=9760 Type=TCP receiver
Process::  ID=9 PID=9762 Type=TCP receiver
Process::  ID=10 PID=9764 Type=TCP receiver
Process::  ID=11 PID=9765 Type=TCP receiver
Process::  ID=12 PID=9768 Type=TCP main

  • To get the number of simultaneous calls (=dialogs in case no presence), type: #./opensipsctl fifo get_statistics dialog. Both SIP INVITE message (Establishing a Call) and SUBSCRIBE message (subscription to presence service) creates dialog. If the SIP server provides call management + presence,  the number of active dialogs will not be equal to the number of calls. The length of the call affects the memory of the SIP server not the processing because the dialog remains in the memory till one of the end parties (caller or calle) ends the dialog by sending SIP BYE message.
  • To take information about specific command, use “help” command with the name of the command as an argument. For example if you want to take information about  the command “ps”, type: #./opensipsctl fifo help ps. The output looks like:

Help:: lists all processes used by OpenSIPS
Exported by:: core

Note: Current opensipsctl does not support NoSQL databases.

OpenSIPS Control Panel (OpenSIPS-CP)

You can also use OpenSIPS control panel (OpenSIPS-CP) to do the same things. Open the web interface. Click on “System” –> “MI Commands”. Choose a command from the command list and press “Enter”. Dont forget the parameters.

OpenSIPS-CP Statistics Monitor Page

  • There are two tables needed for statistics monitoring in OpenSIPS-CP. Do the following to download the structures of monitored_stats and monitoring_stats tables in mysql opensips database:

#cd /var/www/opensips-cp/

#mysql -Dopensips -p < config/tools/system/smonitor/tables.mysql

  • On the web interface, click on “System” –> “Statistics Monitor”. You will get the following:

omslag1

For example you can get some real time statistics about transaction module (TM)  by clicking on the corresponding item in the list “Module:tm”. The “inuse_transaction” sub-item gives the number of transactions in use in memory. The transactions should be released quickly and the average value of this number should be stable (transactions created and released quickly). The number of  transactions per second defines the performance of SIP proxy.

Also you can get statistics on the number of TCP/UDP packets which waiting to be processed. By clicking on “Module:net” item, you can see “waiting_udp” and “waiting_tcp” sub-items.

  • Edit the cron_job/get_opensips_stats.php file and check the value of the variable $path_to_smonitor if it is correct according to your opensips-cp.
  • Add a cron job that collects data from the opensips:

# crontab -e

Append the following entry:

* * * * *   root   php /var/www/opensips-cp/cron_job/get_opensips_stats.php > /dev/null

Note

The MI exported functions can be called only if the corresponded modules are loaded.  Otherwise you will get an error message (command not available). For example enabling tracing by calling sip_trace (# ./opensipsctl fifo sip_trace on) will not work if the module “siptrace.so” is not loaded (i.e. configured to be loaded in the configuration file). You will get this error message “500 command ‘sip_trace’ not available”.

Module Not loaded –> No Exported Functions –> Error upon calling “not exist” Function


Next

The Next Part will be about SIPSAK command line tool which is used as a SIP traffic generator to test the performance and the security of the SIP servers or user agents.


OpenSIPS Provisioning for a simple SIP Call

It is very easy to configure and manage OpenSIPS through OpenSIPS-CP.

Add the domains that OpenSIPS is responsible for

Lets add any domain (like 10.0.0.4 just for test). click on System menu –> Domains

snapshot8

Add the users

Now we can add users to that domain. click on “Users” –> “User Management” snapshot9

User1: (username:test1, password:1234, domain:10.0.0.4), User2: (username: test2, password:1234, domain:10.0.0.4).

Jitsi2

Register the users and make the call (user2 –> user1)

Now we have two users: user1 and user2 and we want test2 to call test1.  Users must be registered first from SIP clients installed by the users.  Here you can find a list of open source and free SIP clients: List of Free and Open-Source SIP Software.  I recommend Jitsi,  Linphone, and CSipSimple.

Now i am using Jitsi for test1 on my laptop and i have entered the following account information in Jitsi interface:

( SIP id: test1@10.0.0.4, password: 1234, Proxy: 10.0.0.4, Proxy Port: 5060)

And now Click på “Sign in” and the user test1 is now “online”.

Jitsi

I will make test2 register itself from my mobile where i have downloaded CSipSimple SIP client on it. My mobile phone and my laptop are in the same LAN. The laptop has the OpenSIPS and local SIP client (Jitsi). The laptop is protected by firewall.

Firewall rules

Everything is OK but test2 (on mobile phone) can not register itself. WHY because the firewall prevents this access. So i have to let the firewall allows SIP traffic to come to the OpenSIPS. We need to open the ports that the OpenSIPS is listening on. In my case the UDP ports 5060-5061.  To do this use dynamic firewall with Firewalld  or static firewall (system-config-firewall) with iptables.  Using static firewall means disabling and stopping of dynamic firewall.

For Firewalld you can either use the graphical configuration tool firewall-config or the command line client firewall-cmd. More information is here Firewalld

More information about editing iptables rules is here: Iptables

Note: Be aware of these “enable”, “disable”, “start”,  “stop” when using “systemctl” command.

“opensipsctl” Tool to see the Registered Users

To take information about the regitered users.

# cd /usr/local/opensips_1_11/sbin/

# ./opensipsctl fifo ul_dump
And this is the output:

AOR:: test2
Contact:: sip:test2@10.0.0.3:56347;ob Q=
Expires:: 894
Callid:: Vd8CYS9wJO7ffGoNAembj-bnC5Rte-k3
Cseq:: 55430
User-agent:: CSipSimple_MT15i-10/r2330
State:: CS_SYNC
Flags:: 0
Cflags::
Socket:: udp:10.0.0.4:5060
Methods:: 8063
AOR:: test1
Contact:: sip:test1@10.0.0.4:53577;transport=udp;registering_acc=10_0_0_4 Q=
Expires:: 521
Callid:: 3586ed724fb54b2e7505f24627e93ff6@0:0:0:0:0:0:0:0
Cseq:: 36
User-agent:: Jitsi2.2.4603.9615Linux
State:: CS_SYNC
Flags:: 0
Cflags::
Socket:: udp:10.0.0.4:5060
Methods:: 4294967295

You can also do this (# ./opensipsctl ul show). Now test1 is calling test2 :

Jitsi36- Get the Dialog Information from the OpenSIPS-CP Web Interface

During the call establishment, click on “System” menu –> “Dialog”. See the figures below of dialog early state and confirmed state.

dialog1

dialog2

What will be different if we want to deploy such a system ?

The answer is the existence of NAT.  I will explain this problem and how to solve it later.