VoLTE Setup With Kamailio IMS and Open5GS - Open5GS
VoLTE Setup With Kamailio IMS and Open5GS - Open5GS
VoLTE Setup With Kamailio IMS and Open5GS - Open5GS
OpenStack is not required for VoLTE setup. If you are using one machine without OpenStack, you can start from step 3.
This removes all existing cloud users and allows only root user and sets a password
$ mkdir -p /usr/local/src/
$ cd /usr/local/src/
$ git clone https://github.com/herlesupreeth/kamailio
$ cd kamailio
$ git checkout -b 5.3 origin/5.3
$ cd /usr/local/src/kamailio
$ export RADCLI=1
$ make Q=0 all | tee make_all.txt
$ make install | tee make_install.txt
$ ldconfig
To be able to use the binaries from command line, make sure that /usr/local/sbin is set in PATH environment variable. You can check
that with echo $PATH. If not and you are using bash, open /root/.bash_profile and at the end add:
PATH=$PATH:/usr/local/sbin
export PATH
In case you set the PREFIX variable in make cfg command, then replace /usr/local in all paths above with the value of PREFIX in order to
locate the files installed.
https://open5gs.org/open5gs/docs/tutorial/02-VoLTE-setup/ 2/19
12/21/2020 VoLTE Setup with Kamailio IMS and Open5GS | Open5GS
Set the SIP_DOMAIN to your SIP service domain (or IP address if you don’t have a DNS hostname associated with your SIP service). Set
the DBENGINE to be MYSQL and adjust other setting as you want. Finally, uncomment both SIP_DOMAIN and DBENGINE.
In example above, the following values are set for SIP_DOMAIN and DBENGINE
SIP_DOMAIN=ims.mnc001.mcc001.3gppnetwork.org
DBENGINE=MYSQL
You can change other values in kamctlrc file. Once you are done updating kamctlrc file, run the script to create the database used by
Kamailio:
$ kamdbctl create
When prompted for mysql root user password enter the root password if its is set or else leave it blank i.e. Press Enter
$ mysql
<mysql> show databases;
<mysql> use kamailio;
<mysql> show tables;
<mysql> select * from subscriber;
- kamailio - (with default password 'kamailiorw') - user which has full access rights to 'kamailio' database
- kamailioro - (with default password 'kamailioro') - user which has read-only access rights to 'kamailio' database
here, -l <PUBLIC_IP>
Then run,
10. Edit configuration file to fit your requirements for the VoIP platform:
Follow the instruction in the comments to enable usage of MySQL. Basically you have to add several lines at the top of config file, like:
https://open5gs.org/open5gs/docs/tutorial/02-VoLTE-setup/ 3/19
12/21/2020 VoLTE Setup with Kamailio IMS and Open5GS | Open5GS
#!define WITH_MYSQL
#!define WITH_AUTH
#!define WITH_USRLOCDB
#!define WITH_NAT
(uncomment this line and enter the DNS domain created above)
alias="ims.mnc001.mcc001.3gppnetwork.org"
(uncomment this line, 10.4.128.21 is the internal IP and 172.24.15.30 is the Public/Floating IP)
listen=udp:10.4.128.21:5060 advertise 172.24.15.30:5060
listen=tcp:10.4.128.21:5060 advertise 172.24.15.30:5060
(Further down, we will need to modify the rtpproxy_sock value to match the CONTROL_SOCK option we set for RTPProxy in
/etc/default/rtpproxy)
modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7722")
If you changed the password for the ‘kamailio’ user of MySQL, you have to update the value for ‘DBURL’ parameters.
/usr/local/src/kamailio/pkg/kamailio/deb/debian/kamailio.init
Just copy the init file into the /etc/init.d/kamailio. Then change the permissions:
$ cp /usr/local/src/kamailio/pkg/kamailio/deb/bionic/kamailio.init /etc/init.d/kamailio
$ chmod 755 /etc/init.d/kamailio
Then edit the /etc/init.d/kamailio file updating the $DAEMON and $CFGFILE values:
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
DAEMON=/usr/local/sbin/kamailio
CFGFILE=/usr/local/etc/kamailio/kamailio.cfg
You need to setup a configuration file in the /etc/default/ directory. This file can be found at:
/usr/local/src/kamailio/pkg/kamailio/deb/bionic/kamailio.default
You need to rename the /etc/default/kamailio file to ‘kamailio’ after you’ve copied it. Then edit this file and set RUN_KAMAILIO=yes. Edit
the other options as per your setup.
$ cp /usr/local/src/kamailio/pkg/kamailio/deb/bionic/kamailio.default /etc/default/kamailio
$ systemctl daemon-reload
$ mkdir -p /var/run/kamailio
Default setting is to run Kamailio as user kamailio and group kamailio. For that you need to create the user and set ownership
https://open5gs.org/open5gs/docs/tutorial/02-VoLTE-setup/ 4/19
12/21/2020 VoLTE Setup with Kamailio IMS and Open5GS | Open5GS
12. A quick check for the basic working of SIP server can be done as follows:
Create new subscriber accounts. A new account can be added using kamctl tool via kamctl add <username> <password> (When asked for
entering MySQL password for user kamailio@localhost: type kamailiorw, as provided in kamailio.cfg)
Connect to a network through which SIP server is reachable (either Wi-Fi or LTE)
Goto phone dialer and select the Settings in the menu on top right corner
Then select Call settings
Configure SIP accounts in phones as added above using kamctl:
In Phone 1:
Username: test
Password: testpasswd
Server: ims.mnc001.mcc001.3gppnetwork.org (Created DNS Domain Name or IP to which IMS components are bound to, visible
interface IP address)
Optional Settings:
Authentication username: test
Outbound proxy address: 172.24.15.30 (Floating IP of VM in case of OpenStack or else no need to fill in case of
physical machine)
Transport type: UDP
In Phone 2:
Username: test2
Password: testpasswd
Server: ims.mnc001.mcc001.3gppnetwork.org (Created DNS Domain Name or IP to which IMS components are bound to, visible
interface IP address)
Optional Settings:
Authentication username: test2
Outbound proxy address: 172.24.15.30 (Floating IP of VM in case of OpenStack or else no need to fill in case of
physical machine)
Transport type: UDP
In Phone 1:
In Phone 2:
Upon completion of this test, set “Receive incoming calls” option to disabled state and set “Use SIP calling” to “Only for SIP calls”
13. Create new mysql database for pcscf, scscf and icscf, populate databases and grant
permissions to respective users identified by a password
$ mysql
<mysql> CREATE DATABASE `pcscf`;
<mysl> CREATE DATABASE `scscf`;
<mysl> CREATE DATABASE `icscf`;
In all of the below steps, when prompted for mysql root user password, leave it blank i.e. Press Enter
$ cd /usr/local/src/kamailio/utils/kamctl/mysql
$ mysql -u root -p pcscf < standard-create.sql
$ mysql -u root -p pcscf < presence-create.sql
$ mysql -u root -p pcscf < ims_usrloc_pcscf-create.sql
$ mysql -u root -p pcscf < ims_dialog-create.sql
$ cd /usr/local/src/kamailio/misc/examples/ims/icscf
$ mysql -u root -p icscf < icscf.sql
Verify that following tables are present in respective databases by logging into mysql
https://open5gs.org/open5gs/docs/tutorial/02-VoLTE-setup/ 6/19
12/21/2020 VoLTE Setup with Kamailio IMS and Open5GS | Open5GS
+-----------------+
| Tables_in_pcscf |
+-----------------+
| active_watchers |
| dialog_in |
| dialog_out |
| dialog_vars |
| location |
| presentity |
| pua |
| version |
| watchers |
| xcap |
+-----------------+
+-----------------+
| Tables_in_scscf |
+-----------------+
| active_watchers |
| contact |
| dialog_in |
| dialog_out |
| dialog_vars |
| impu |
| impu_contact |
| impu_subscriber |
| presentity |
| pua |
| ro_session |
| subscriber |
| version |
| watchers |
| xcap |
+-----------------+
+---------------------+
| Tables_in_icscf |
+---------------------+
| nds_trusted_domains |
| s_cscf |
| s_cscf_capabilities |
+---------------------+
Then,
$ mysql
<mysql> use icscf;
<mysql> INSERT INTO `nds_trusted_domains` VALUES (1,'ims.mnc001.mcc001.3gppnetwork.org');
<mysql> INSERT INTO `s_cscf` VALUES (1,'First and only S-CSCF','sip:scscf.ims.mnc001.mcc001.3gppnetwork.org:6060');
<mysql> INSERT INTO `s_cscf_capabilities` VALUES (1,1,0),(2,1,1);
14. Copy pcscf, icscf and scscf configuration files to /etc folder and edit accordingly
https://open5gs.org/open5gs/docs/tutorial/02-VoLTE-setup/ 7/19
12/21/2020 VoLTE Setup with Kamailio IMS and Open5GS | Open5GS
15. Setup the DNS for resolving IMS and EPC components names
$ apt install -y bind9
Use the below example DNS Zone file to create a DNS Zone file into the bind folder and edit /etc/bind/named.conf.local and
/etc/bind/named.conf.options accordingly:
$ cd /etc/bind
In the below example: Kamailio IMS & DNS server running at 10.4.128.21/172.24.15.30 (Floating IP) and PCRF also at
10.4.128.21/172.24.15.30 (Floating IP)
$ cat ims.mnc001.mcc001.3gppnetwork.org
$ORIGIN ims.mnc001.mcc001.3gppnetwork.org.
$TTL 1W
@ 1D IN SOA localhost. root.localhost. (
1 ; serial
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
1D IN NS ns
ns 1D IN A 10.4.128.21
pcscf 1D IN A 10.4.128.21
_sip._udp.pcscf 1D SRV 0 0 5060 pcscf
_sip._tcp.pcscf 1D SRV 0 0 5060 pcscf
icscf 1D IN A 10.4.128.21
_sip._udp 1D SRV 0 0 4060 icscf
_sip._tcp 1D SRV 0 0 4060 icscf
scscf 1D IN A 10.4.128.21
_sip._udp.scscf 1D SRV 0 0 6060 scscf
_sip._tcp.scscf 1D SRV 0 0 6060 scscf
hss 1D IN A 10.4.128.21
$ cat epc.mnc001.mcc001.3gppnetwork.org
$ORIGIN epc.mnc001.mcc001.3gppnetwork.org.
$TTL 1W
@ 1D IN SOA localhost. root.localhost. (
1 ; serial
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
1D IN NS epcns
epcns 1D IN A 10.4.128.21
pcrf 1D IN A 127.0.0.5
https://open5gs.org/open5gs/docs/tutorial/02-VoLTE-setup/ 8/19
12/21/2020 VoLTE Setup with Kamailio IMS and Open5GS | Open5GS
//
// Do any local configuration here
//
// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";
zone "ims.mnc001.mcc001.3gppnetwork.org" {
type master;
file "/etc/bind/ims.mnc001.mcc001.3gppnetwork.org";
};
zone "epc.mnc001.mcc001.3gppnetwork.org" {
type master;
file "/etc/bind/epc.mnc001.mcc001.3gppnetwork.org";
};
options {
directory "/var/cache/bind";
//forwarders {
// Put here the IP address of other DNS server which could be used if name cannot be resolved with DNS
server running in this machine (Optional)
//10.4.128.2;
//};
//========================================================================
// If BIND logs error messages about the root key being expired,
// you will need to update your keys. See https://www.isc.org/bind-keys
//========================================================================
dnssec-validation no;
allow-query { any; };
Then, test DNS resolution by adding following entries on top of all other entries in /etc/resolv.conf (make sure it persist across reboots)
search ims.mnc001.mcc001.3gppnetwork.org
nameserver 10.4.128.21
$ ping pcscf
PING pcscf.ims.mnc001.mcc001.3gppnetwork.org (10.4.128.21) 56(84) bytes of data.
64 bytes from localhost (10.4.128.21): icmp_seq=1 ttl=64 time=0.017 ms
64 bytes from localhost (10.4.128.21): icmp_seq=2 ttl=64 time=0.041 ms
To make changes in /etc/resolv.conf be persistent across reboot edit the /etc/netplan/50-cloud-init.yaml file as follows:
https://open5gs.org/open5gs/docs/tutorial/02-VoLTE-setup/ 9/19
12/21/2020 VoLTE Setup with Kamailio IMS and Open5GS | Open5GS
$ netplan apply
$ ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
$ systemctl restart systemd-resolved.service
$ export DEB_BUILD_PROFILES="pkg.ngcp-rtpengine.nobcg729"
$ apt install dpkg-dev
$ git clone https://github.com/sipwise/rtpengine
$ cd rtpengine && git checkout mr7.4.1
$ dpkg-checkbuilddeps
The above command checks for dependencies and give you a list of dependencies which are missing in the system. The below list is the
result of this command
After installing dependencies run the below command again and verify that no dependencies are left out
$ dpkg-checkbuilddeps
This should just return back to shell with no output if all depedencies are met
interface = 10.4.128.21
Port on which rtpengine binds i.e. listen_ng parameter is udp port 2223. This should be updated in kamailio_pcscf.cfg file at
modparam(rtpengine …)
https://open5gs.org/open5gs/docs/tutorial/02-VoLTE-setup/ 10/19
12/21/2020 VoLTE Setup with Kamailio IMS and Open5GS | Open5GS
RUN_RTPENGINE=yes
RUN_RTPENGINE_RECORDING=yes
$ cp /etc/rtpengine/rtpengine-recording.sample.conf /etc/rtpengine/rtpengine-recording.conf
$ mkdir /var/spool/rtpengine
$ systemctl restart ngcp-rtpengine-daemon.service ngcp-rtpengine-recording-daemon.service ngcp-rtpengine-recording-nfs-
mount.service
$ systemctl enable ngcp-rtpengine-daemon.service ngcp-rtpengine-recording-daemon.service ngcp-rtpengine-recording-nfs-
mount.service
$ mkdir -p /var/run/kamailio_pcscf
$ kamailio -f /etc/kamailio_pcscf/kamailio_pcscf.cfg -P /kamailio_pcscf.pid -DD -E -e
$ mkdir -p /var/run/kamailio_scscf
$ kamailio -f /etc/kamailio_scscf/kamailio_scscf.cfg -P /kamailio_scscf.pid -DD -E -e
$ mkdir -p /var/run/kamailio_icscf
$ kamailio -f /etc/kamailio_icscf/kamailio_icscf.cfg -P /kamailio_icscf.pid -DD -E -e
18. Install Open5GS in the same machine as Kamailio IMS - Install Open5GS from source
Please refer to instructions at https://open5gs.org/open5gs/docs/guide/02-building-open5gs-from-sources/
If you are using OpenStack, installing Open5GS and Kamailio IMS on the same machine is very important because the Framed-IP-Address in the
AAR request via Rx interface takes received IP address and port in ims_qos module, hence, if the Open5GS is on a separate VM/machine, the IP and
port received in received_ip and received_port values seen by Kamailio IMS will be the NATed IP of the Open5GS machine resulting in failing of
AAR request.
Modify below mentioned parts of configuration files in addition to Configure Open5GS section. For reference, look at the configuration files at
https://github.com/herlesupreeth/Open5gs_Config. These configuration only holds for open5gs tag v1.3.0, please tweak configuration files based
on the open5gs tag you use.
#!/bin/bash
APN Configuration:
---------------------------------------------------------------------------------------------------------------------
| APN | Type | QCI | ARP | Capability | Vulnerablility | MBR DL/UL(Kbps) | GBR DL/UL(Kbps) | PGW IP |
---------------------------------------------------------------------------------------------------------------------
| internet | IPv4 | 9 | 8 | Disabled | Disabled | unlimited/unlimited | | |
---------------------------------------------------------------------------------------------------------------------
| ims | IPv4 | 5 | 1 | Disabled | Disabled | 3850/1530 | | |
| | | 1 | 2 | Enabled | Enabled | 128/128 | 128/128 | |
---------------------------------------------------------------------------------------------------------------------
https://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html
$ mkdir -p /usr/lib/jvm/
$ tar -zxf jdk-7u79-linux-x64.tar.gz -C /usr/lib/jvm/
$ update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_79/bin/java 100
$ update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_79/bin/javac 100
https://open5gs.org/open5gs/docs/tutorial/02-VoLTE-setup/ 12/19
12/21/2020 VoLTE Setup with Kamailio IMS and Open5GS | Open5GS
$ java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
Install Ant
$ cd ~
$ wget http://archive.apache.org/dist/ant/binaries/apache-ant-1.9.14-bin.tar.gz
$ tar xvfvz apache-ant-1.9.14-bin.tar.gz
$ mv apache-ant-1.9.14 /usr/local/
$ sh -c 'echo ANT_HOME=/usr/local/ >> /etc/environment'
$ ln -s /usr/local/apache-ant-1.9.14/bin/ant /usr/bin/ant
$ ant -version
Apache Ant(TM) version 1.9.14 compiled on March 12 2019
$ mkdir /opt/OpenIMSCore
$ cd /opt/OpenIMSCore
Download:
Compile:
$ cd FHoSS
$ export JAVA_HOME="/usr/lib/jvm/jdk1.7.0_79"
$ export CLASSPATH="/usr/lib/jvm/jdk1.7.0_79/jre/lib/"
$ ant compile deploy | tee ant_compile_deploy.txt
Create configurator.sh using below script to change domain names and IP address in all configuration files
$ cd deploy
$ vim configurator.sh
https://open5gs.org/open5gs/docs/tutorial/02-VoLTE-setup/ 13/19
12/21/2020 VoLTE Setup with Kamailio IMS and Open5GS | Open5GS
#!/bin/bash
# Interaction
printf "Domain Name:"
read domainname
printf "IP Adress:"
read ip_address
if [ $# != 0 ]
then
printf "changing: "
for j in $*
do
sed -i -e "s/$DDOMAIN/$domainname/g" $j
sed -i -e "s/$DSDOMAIN/$slasheddomain/g" $j
sed -i -e "s/$DEFAULTIP/$ip_address/g" $j
printf "$j "
done
echo
else
printf "File to change [\"all\" for everything, \"exit\" to quit]:"
# loop
while read filename ;
do
if [ "$filename" = "exit" ]
then
printf "exitting...\n"
break ;
elif [ -w $filename ]
then
printf "changing $filename \n"
sed -i -e "s/$DDOMAIN/$domainname/g" $filename
sed -i -e "s/$DSDOMAIN/$slasheddomain/g" $filename
sed -i -e "s/$DEFAULTIP/$ip_address/g" $filename
else
printf "cannot access file $filename. skipping... \n"
fi
printf "File to Change:"
done
fi
https://open5gs.org/open5gs/docs/tutorial/02-VoLTE-setup/ 14/19
12/21/2020 VoLTE Setup with Kamailio IMS and Open5GS | Open5GS
$ chmod +x configurator.sh
$ ./configurator.sh
Domain Name:ims.mnc001.mcc001.3gppnetwork.org
IP Adress:10.4.128.21
$ grep -r "open-ims"
(Change realm name in the below file from open-ims.test to ims.mnc001.mcc001.3gppnetwork.org)
$ vim webapps/hss.web.console/WEB-INF/web.xml
$ vim hibernate.properties
hibernate.connection.url=jdbc:mysql://127.0.0.1:3306/hss_db
$ cp configurator.sh ../scripts/
$ cd ../scripts
$ grep -r "open-ims"
$ ./configurator.sh
Domain Name:ims.mnc001.mcc001.3gppnetwork.org
IP Adress:10.4.128.21
$ cp configurator.sh ../config/
$ cd ../config
$ ./configurator.sh
Domain Name:ims.mnc001.mcc001.3gppnetwork.org
IP Adress:10.4.128.21
$ cd ../src-web
$ vim WEB-INF/web.xml
$ mysql
<mysql> drop database hss_db;
<mysql> create database hss_db;
<mysql> quit
$ cd /opt/OpenIMSCore
$ mysql -u root -p hss_db < FHoSS/scripts/hss_db.sql
$ mysql -u root -p hss_db < FHoSS/scripts/userdata.sql
$ mysql
# See last line in hss_db.sql:
<mysql> grant delete,insert,select,update on hss_db.* to hss@localhost identified by 'hss';
<mysql> grant delete,insert,select,update on hss_db.* to hss@'%' identified by 'hss';
Check database if domain names are o.k. in various entries and privileges
$ mysql -u hss -p
<mysql> show databases;
<mysql> use hss_db;
<mysql> select * from impu;
$ cp /opt/OpenIMSCore/FHoSS/deploy/startup.sh /root/hss.sh
https://open5gs.org/open5gs/docs/tutorial/02-VoLTE-setup/ 15/19
12/21/2020 VoLTE Setup with Kamailio IMS and Open5GS | Open5GS
cd /opt/OpenIMSCore/FHoSS/deploy
JAVA_HOME="/usr/lib/jvm/jdk1.7.0_79"
CLASSPATH="/usr/lib/jvm/jdk1.7.0_79/jre/lib/"
$ ./hss.sh
user: hssAdmin
password: hss
20. Add IMS subscription use in FoHSS as follows from the Web GUI
Assuming IMSI of the user as 001010123456791 and MSISDN is 0198765432100
https://open5gs.org/open5gs/docs/tutorial/02-VoLTE-setup/ 16/19
12/21/2020 VoLTE Setup with Kamailio IMS and Open5GS | Open5GS
Now, goto Public User Identity and create further IMPUs as following
1. tel:0198765432100
2. sip:0198765432100
https://open5gs.org/open5gs/docs/tutorial/02-VoLTE-setup/ 17/19
12/21/2020 VoLTE Setup with Kamailio IMS and Open5GS | Open5GS
Click Add
And, finally add these IMPUs as implicit set of IMSI derived IMPU in HSS i.e
sip:001011234567891@ims.mnc001.mcc001.3gppnetwork.org as follows:
First create internet APN, APN name: internet, APN type: default –> Save APN
Then, create ims APN, APN name: ims, APN type: ims –> Save APN
On the eNB machine have the following static routes (since internal IP of the VM is advertised in S1AP messages and UE wont find the
core in Uplink)
24. Start IMS components and FoHSS followed by Open5GS and eNB, then try
connecting the phones
Also,
https://open5gs.org/open5gs/docs/tutorial/02-VoLTE-setup/ 18/19
12/21/2020 VoLTE Setup with Kamailio IMS and Open5GS | Open5GS
Debugging Diameter messages between PCRF and P-CSCF in Wireshark if the TCP/SCTP port other than 3868
Open Wireshark –> Preferences –> Protocols –> Diameter –> Change to whatever ports are being used
Appendix
Open5GS
Sukchan Lee open5gs
acetcom@gmail.com
Open5GS is a C-language implementation of 5G Core and EPC, i.e. the core network of NR/LTE network (Release-16)
https://open5gs.org/open5gs/docs/tutorial/02-VoLTE-setup/ 19/19