Compiling and Installing of RTPEngine on Debian Systems

Please follow the below steps to create *.deb packages of rtpengine
$ apt-get install aptitude dpkg-dev lsb-release markdown nfs-common netcat netcat-openbsd
$ cd /usr/local/src
$ git clone --single-branch --branch mr8.1.1 https://github.com/sipwise/rtpengine.git
If you want to transcode g729 then use the link to install libbcg729-dev package from the instruction given in RTPEngine documentation otherwise disable G729 with the following command
$ export DEB_BUILD_PROFILES="pkg.ngcp-rtpengine.nobcg729"
Now try the build deb package by going to main directory of rtpengine
$ cd rtpengine
$ dpkg-buildpackage
$ dpkg-checkbuilddeps
$ aptitude install debhelper default-libmysqlclient-dev gperf iptables-dev libavcodec-dev libavfilter-dev libavformat-dev libavutil-dev libbencode-perl libcrypt-openssl-rsa-perl libcrypt-rijndael-perl libcurl4-openssl-dev libcurl4-gnutls-dev libdigest-crc-perl libdigest-hmac-perl libevent-dev libglib2.0-dev libhiredis-dev libio-multiplex-perl libio-socket-inet6-perl libiptc-dev libjson-glib-dev libnet-interface-perl libpcap0.8-dev libpcre3-dev libsocket6-perl libspandsp-dev libssl-dev libswresample-dev libsystemd-dev libxmlrpc-core-c3-dev
$ dpkg-buildpackage
Now go to the parent directory and you will the *.deb packages of debain
$ cd ..
$ ls -lhtr
total 2.8M
drwxr-xr-x 16 root root 4.0K Dec 30 02:18 rtpengine
-rw-r--r--  1 root root 391K Dec 30 02:57 ngcp-rtpengine_8.1.1.2+0~mr8.1.1.2.tar.xz
-rw-r--r--  1 root root 1.9K Dec 30 02:57 ngcp-rtpengine_8.1.1.2+0~mr8.1.1.2.dsc
-rw-r--r--  1 root root 246K Dec 30 03:02 ngcp-rtpengine-daemon_8.1.1.2+0~mr8.1.1.2_amd64.deb
-rw-r--r--  1 root root 1.3M Dec 30 03:02 ngcp-rtpengine-daemon-dbgsym_8.1.1.2+0~mr8.1.1.2_amd64.deb
-rw-r--r--  1 root root  85K Dec 30 03:02 ngcp-rtpengine-recording-daemon_8.1.1.2+0~mr8.1.1.2_amd64.deb
-rw-r--r--  1 root root 369K Dec 30 03:02 ngcp-rtpengine-recording-daemon-dbgsym_8.1.1.2+0~mr8.1.1.2_amd64.deb
-rw-r--r--  1 root root  40K Dec 30 03:02 ngcp-rtpengine-iptables_8.1.1.2+0~mr8.1.1.2_amd64.deb
-rw-r--r--  1 root root 2.3K Dec 30 03:02 ngcp-rtpengine-iptables-dbgsym_8.1.1.2+0~mr8.1.1.2_amd64.deb
-rw-r--r--  1 root root  84K Dec 30 03:02 ngcp-rtpengine_8.1.1.2+0~mr8.1.1.2_all.deb
-rw-r--r--  1 root root  92K Dec 30 03:02 ngcp-rtpengine-kernel-source_8.1.1.2+0~mr8.1.1.2_all.deb
-rw-r--r--  1 root root  59K Dec 30 03:02 ngcp-rtpengine-kernel-dkms_8.1.1.2+0~mr8.1.1.2_all.deb
-rw-r--r--  1 root root  58K Dec 30 03:02 ngcp-rtpengine-utils_8.1.1.2+0~mr8.1.1.2_all.deb
-rw-r--r--  1 root root  15K Dec 30 03:02 ngcp-rtpengine_8.1.1.2+0~mr8.1.1.2_amd64.buildinfo
-rw-r--r--  1 root root 5.8K Dec 30 03:02 ngcp-rtpengine_8.1.1.2+0~mr8.1.1.2_amd64.changes
Now install rtpengine
$ dpkg -i ngcp-rtpengine-daemon_8.1.1.2+0~mr8.1.1.2_amd64.deb
$ dpkg -i ngcp-rtpengine-iptables_8.1.1.2+0~mr8.1.1.2_amd64.deb
$ dpkg -i ngcp-rtpengine-kernel-dkms_8.1.1.2+0~mr8.1.1.2_all.deb
$ dpkg -i  ngcp-rtpengine-recording-daemon_8.1.1.2+0~mr8.1.1.2_amd64.deb
$ dpkg -i  ngcp-rtpengine-recording-daemon_8.1.1.2+0~mr8.1.1.2_amd64.deb
$ dpkg -i ngcp-rtpengine_8.1.1.2+0~mr8.1.1.2_all.deb
Enjoy ;)
For distros other than Debian use to the following link

RESET MYSQL ROOT PASSWORD

To reset MySQL root password, you need to stop MySQL services.
$ systemctl stop mysqld
$ systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
$ systemctl start mysqld
$ mysql -u root
mysql> update user set authentication_string=PASSWORD("MyR00tPass") where User='root';
mysql> flush privileges;
mysql> exit
or for MySQL Version 8 
$ sudo mysqld_safe --skip-grant-tables --skip-networking &
$ mysql -u root -p 
mysql> update user set authentication_string=NULL where User='root';
mysql> exit
$ kill -9 mysqld
$ mysql -u root -p
Enter password: [ENTER]
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'MyR00tPass';
mysql> flush privileges;
mysql> exit
$ systemctl restart mysqld
$ mysql -u root -p 
Enter password: [PASSWORD]
mysql>
The root password has been updated. Please try to connect with an updated password
$ mysql -u root -p
mysql> create user 'bss'@'%' identified by 'passw0rd';
mysql> grant all on opensips.* to 'bss'@'%';
mysql> flush privileges;
mysql> exit
enjoy ;)

MySQL 8.0 installation on CentOS 7

MYSQL Server Installation step by step

$ yum remove `rpm -qa | grep mariadb`
$ yum install net-tools libxml2-devel.x86_64 libaio.x86_64 libaio-devel.x86_64 openssl.x86_64 openssl-devel.x86_64
$ wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-community-client-8.0.17-1.el7.x86_64.rpm
$ wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-community-server-8.0.17-1.el7.x86_64.rpm
$ wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-community-devel-8.0.17-1.el7.x86_64.rpm
$ wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-community-common-8.0.17-1.el7.x86_64.rpm
$ wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-community-libs-8.0.17-1.el7.x86_64.rpm
$ rpm -i mysql-community-common-8.0.17-1.el7.x86_64.rpm
$ rpm -i mysql-community-libs-8.0.17-1.el7.x86_64.rpm
$ rpm -i mysql-community-client-8.0.17-1.el7.x86_64.rpm
$ rpm -i mysql-community-server-8.0.17-1.el7.x86_64.rpm
$ systemctl start mysqld
$ grep 'temporary password' /var/log/mysqld.log
2018-08-27T21:52:41.002744Z 1 [Note] A temporary password is generated for root@localhost: GyD?Srgeq0IC
$ mysql_secure_installation
$ mysqladmin -u root -p version

For Debian follow this link and for MySQL5.7 you can follow this link

Enjoy ;)

Configure B2BUA Server using OpenSIPs

I used the topology hiding method in B2BUA Server.

####### Global Parameters #########
#debug_mode=yes
log_level=3
log_stderror=no
log_facility=LOG_LOCAL0
children=8
#tcp_children=32
check_via=no
rev_dns=off
/* uncomment the following lines to enable debugging */
#debug_mode=yes
/* uncomment the next line to enable the auto temporary blacklisting of
not available destinations (default disabled) */
#disable_dns_blacklist=no
/* uncomment the next line to enable IPv6 lookup after IPv4 dns
lookup failures (default disabled) */
#dns_try_ipv6=yes
/* comment the next line to enable the auto discovery of local aliases
based on reverse DNS on IPs */
auto_aliases=no
listen=udp:127.0.0.1:5060 AS 8.8.8.8:5060 ### Customize Me
#listen=tcp:127.0.0.1:5060 AS 8.8.8.8:5060 ### Customize Me
#listen=tls:127.0.0.1:5060 AS 8.8.8.8:5060 ### Customize Me
#tcp_max_msg_time=10
#tcp_connect_timeout=350
#sip_warning=0
#tcp_connection_lifetime = 3600
#tcp_keepalive=0
####### Modules Section ########
#set module path
mpath="/usr/local/lib64/opensips/modules/"
#### SIGNALING module
loadmodule "signaling.so"
#### StateLess module
loadmodule "sl.so"
#### Transaction Module
loadmodule "tm.so"
modparam("tm", "fr_timeout", 15)
modparam("tm", "fr_inv_timeout", 48)
modparam("tm", "restart_fr_on_each_reply", 0)
modparam("tm", "onreply_avp_mode", 1)
#### Record Route Module
loadmodule "rr.so"
/* do not append from tag to the RR (no need for this script) */
modparam("rr", "append_fromtag", 0)
#### MAX ForWarD module
loadmodule "maxfwd.so"
#### SIP MSG OPerationS module
loadmodule "sipmsgops.so"
#### FIFO Management Interface
loadmodule "mi_fifo.so"
modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
modparam("mi_fifo", "fifo_mode", 0666)
#### URI module
loadmodule "uri.so"
modparam("uri", "use_uri_table", 0)
#### MYSQL module
loadmodule "db_mysql.so"
#### AVPOPS module
loadmodule "avpops.so"
#### ACCounting module
#loadmodule "acc.so"
/* what special events should be accounted ? */
#modparam("acc", "early_media", 0)
#modparam("acc", "report_cancels", 0)
/*
by default we do not adjust the direct of the sequential requests.
if you enable this parameter, be sure the enable "append_fromtag"
in "rr" module
*/
#modparam("acc", "detect_direction", 0)
#modparam("acc", "db_url",
# "mysql://opensips:opensipsrw@localhost/opensips") # CUSTOMIZE ME
#### DISPATCHER module
#loadmodule "dispatcher.so"
#modparam("dispatcher", "db_url","mysql://user:password@127.0.0.1/database") ### Customize Me
#modparam("dispatcher", "ds_ping_method", "OPTIONS")
#modparam("dispatcher", "ds_probing_mode", 0)
#modparam("dispatcher", "ds_ping_interval", 30)
#### MI_HTTP module
#loadmodule "mi_http.so"
loadmodule "proto_udp.so"
#loadmodule "proto_tcp.so"
#modparam("proto_tcp", "tcp_send_timeout", 2000)
#modparam("proto_tcp", "tcp_max_msg_chunks", 8)
#loadmodule "proto_tls.so"
#loadmodule "tls_mgm.so"
#modparam("tls_mgm","verify_cert", "1")
#modparam("tls_mgm","require_cert", "0")
#modparam("tls_mgm","tls_method", "TLSv1")
#modparam("tls_mgm","certificate", "/usr/local/etc/opensips/server.pem")
#modparam("tls_mgm","private_key", "/usr/local/etc/opensips/server.key")
#modparam("tls_mgm","ca_list", "/usr/local/etc/opensips/server.pem")
#### B2B_Entity ####
loadmodule "b2b_entities.so"
modparam("b2b_entities", "script_req_route", "b2b_request")
modparam("b2b_entities", "script_reply_route", "b2b_reply")
modparam("b2b_entities", "b2b_key_prefix", "B2B1")
modparam("b2b_entities", "db_mode", 0)
#modparam("b2b_entities", "replication_mode", 0)
#### B2B_Entity ####
loadmodule "b2b_logic.so"
modparam("b2b_logic", "init_callid_hdr", "Init-CallID")
loadmodule "uac_auth.so"
####### Routing Logic ########
# main request routing logic
route{
xlog("L_INFO","[$fU $tU $ci $rm] Request Received from $pr:$si:$sp User-Agent:$ua");
if (!mf_process_maxfwd_header("10")) {
send_reply("483","Too Many Hops");
exit;
}
if (has_totag()) {
# handle hop-by-hop ACK (no routing required)
if ( is_method("ACK") && t_check_trans() ) {
xlog("L_INFO","[$fU $tU $ci $rm] Relaying Request to $ru");
t_relay();
exit;
}
# sequential request withing a dialog should
# take the path determined by record-routing
if ( !loose_route() ) {
# we do record-routing for all our traffic, so we should not
# receive any sequential requests without Route hdr.
send_reply("404","Not here");
exit;
}
/*
if (is_method("BYE")) {
xlog("L_INFO","[$fU $tU $ci $rm] BYE ");
# do accounting even if the transaction fails
#o_accounting("db","failed");
}
*/
# route it out to whatever destination was set by loose_route()
# in $du (destination URI).
route(RELAY);
exit;
}
#### INITIAL REQUESTS
# CANCEL processing
if (is_method("CANCEL")) {
if (t_check_trans())
t_relay();
exit;
}
/*
if ($rU==NULL) {
# request with no Username in RURI
send_reply("484","Address Incomplete");
exit;
}
*/
t_check_trans();
# preloaded route checking
if (loose_route()) {
xlog("L_ERR","[$fU $tU $ci $rm] Attempt to route with preloaded Route's");
remove_hf("Route");
}
if(is_method("REGISTER")) {
$ru=$du;
} else if (is_method("INVITE")) {
$du="sip:{Remote Carrier IP}:5060";
$ru= "sip:" + $tU + "@{Remote Carrier IP}:5060" ;
xlog("L_INFO","[$fU $tU $ci $rm] Relaying Request to $ru");
xlog("L_INFO","[$fU $tU $ci $rm] Calling function b2b_init");
b2b_init_request("top hiding");
exit;
}
t_on_failure("GW_FAILOVER");
route(RELAY);
}
route[RELAY] {
if (!t_relay()) {
sl_reply_error();
}
exit;
}
failure_route[GW_FAILOVER] {
if (t_was_cancelled()) {
exit;
}
# failure detection with redirect to next available trunk
if (t_check_status("(408)|([56][0-9][0-9])")) {
xlog("Failed trunk $rd/$du detected \n");
send_reply("500","All GW are down");
}
}
route[b2b_request]
{
xlog("L_INFO","[$fU $tU $ci $rm] B2B_Request Received from $pr:$si:$sp User-Agent:$ua");
xlog("L_INFO","[$fU $tU $ci $rm] B2B_Request message $rs:$rr received \n");
}
route[b2b_reply]
{
xlog("L_INFO","[$fU $tU $ci $rm] B2B_Reply Received from $pr:$si:$sp User-Agent:$ua");
xlog("L_INFO","[$fU $tU $ci $rm] B2B_Reply message $rs:$rr received \n");
}


Hamid Raza Hashmi hamid.hashmi006@gmail.com +92 300 968 22 85

How to store IOT devices data Using QRYN

Configuring your own MQTT broker with a database offers significant cost advantages over cloud IoT platforms like AWS or Azure. You eliminat...