FreeSWITCH uses OpenSIPS for load balancing

Transfer from   https://blog.51cto.com/908405/2235934

There are many articles on load balancing of FreeSWITCH through OpenSIPS, but they are all based on the old version of OpenSIPS. The latest OpenSIPS LTS version is 2.4. If you use the old version of the configuration file, OpenSIPS will not run (of course, after some modifications) It can still be up and running). After some tossing, the author successfully realized the load balancing of OpenSIPS 2.4 to FreeSWITCH. Here I will write down the tossing attention items and the final configuration, so as not to toss again when I really need to use it next time. The author is not very familiar with OpenSIPS, and there may be some flaws. Netizens are welcome to correct me.

 

1. Environmental introduction:

OpenSIPS OS : debian 8

OpenSIPS Version:2.4 LTS

OpenSIPS IP:172.16.100.30/31

OpenSIPS HA:keepalived

OpenSIPS VIP:172.16.100.32

OpenSIPS domain:sofia.superpipi.cn

FreeSWITCH OS:debian 8

FreeSWITCH Version:1.81

FreeSWITCH IP:172.16.100.10/11

DB:Mysql 5.7

Note: The high availability of OpenSIPS is realized by using keepalived for VIP switching. At present, the availability detection script of OpenSIPS is not added, and it is only used for VIP switching.

 

2. Network introduction:

This experiment uses the following network structure. Two nodes OpenSIPS uses keepalived for VIP switching, and two nodes FreeSWITCH implements load sharing. Both OpenSIPS and FreeSWITCH are connected to MySQL ( Note: FreeSWITCH is connected to the MySQL database. Change the field length to smaller, and then manually create the channels table ). On the router ( the router used by the author has Dnsmasq function ), the domain name sofia.superpipi.cn is resolved to OpenSIPS VIP (172.16.100.32) , and the SIP extension is registered through the domain name sofia.superpipi.cn. As for why it is necessary to register through a domain name, this is because the default domain name of FreeSWITCH is its local IP. If the registered domain is not the FreeSWITCH local IP, it may not be registered and the call cannot be made. This can be achieved by modifying the FreeSWITCH domain name. If you modify the FreeSWITCH domain name to OpenSIPS VIP, then there is only one VIP, FreeSWITCH can only have one domain, and there can be multiple domain names pointing to OpenSIPS VIP, so that FreeSWITCH multi-domain can be realized. As for why FreeSWITCH needs multiple domains, it is mainly to facilitate authority management and control, which is of great significance in actual production.

 

image.png

 

3. Installation and basic configuration:

 

3.1, install and configure keepalived

 

3.1.1, install keepalived

Keepalived installation can be installed directly through apt

apt-get install keepalived

 

3.1.2, modify the keepalived configuration:

Edit /etc/keepalived/keepalived.conf and modify the two nodes respectively according to the following configuration.

 

  • 01 node keepalived configuration:

! Configuration File for keepalived
global_defs {
   notification_email {
     acassen
   }
   notification_email_from [email protected]
   smtp_server 172.16.100.251
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}
vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    garp_master_delay 10
    smtp_alert
    virtual_router_id 53
    priority 200
    nopreempt
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 915119
    }
    virtual_ipaddress {
        172.16.100.32/24
        172.16.100.32/24 label eth0:1
    }
}

 

  • 02 node keepalived configuration:

! Configuration File for keepalived
global_defs {
   notification_email {
     acassen
   }
   notification_email_from [email protected]
   smtp_server 172.16.100.251
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}
vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    garp_master_delay 10
    smtp_alert
    virtual_router_id 53
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 915119
    }
    virtual_ipaddress {
        172.16.100.32/24
        172.16.100.32/24 label eth0:1
    }
}

 

3.2. Install and configure OpenSIPS

 

3.2.1, install OpenSIPS

The author installed OpenSIPS directly through the official deb package, and the execution steps are as follows:

  • Add source:

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 049AD65B
echo "deb http://apt.opensips.org jessie 2.4-releases" >/etc/apt/sources.list.d/opensips.list
  • Update source and install OpenSIPS

apt-get update && apt-get install opensips

3.2.2, configure OpenSIPS

  • Create database

Edit /etc/opensips/opensipsctlrc to comment out the following items and modify according to the actual situation, or directly append to /etc/opensips/opensipsctlrc via echo

 

echo "SIP_DOMAIN=sofia.superpipi.cn" >> /etc/opensips/opensipsctlrc
echo "DBENGINE=MYSQL" >> /etc/opensips/opensipsctlrc
echo "DBPORT=3306" >> /etc/opensips/opensipsctlrc
echo "DBHOST=172.16.100.15" >> /etc/opensips/opensipsctlrc
echo "DBNAME=opensips" >> /etc/opensips/opensipsctlrc
echo "DBRWUSER=opensips" >> /etc/opensips/opensipsctlrc
echo "DBRWPW="ligen119"" >> /etc/opensips/opensipsctlrc

Execute the database creation tool ( Note: If the database is not on this machine, you need to authorize the root user to remotely access it )

/usr/sbin/opensipsdbctl create

After running the above command, you will be prompted to enter the root password. After entering the root password, you will be prompted to enter the database character set ( utf8 cannot be selected for Tucao ), enter gbk (you may need to store Chinese later), and then follow the wizard to create the database.

  • Configure startup parameters

It is not necessary to edit the startup parameters. If it is recommended for production applications, the memory parameters should be expanded accordingly.

Edit /etc/default/opensips to comment out the following items and modify according to the actual situation, or directly append to /etc/default/opensips through echo 

 

echo "RUN_OPENSIPS=yes" >>/etc/default/opensips
echo "USER=opensips" >>/etc/default/opensips 
echo "GROUP=opensips" >>/etc/default/opensips 
echo "S_MEMORY=512" >>/etc/default/opensips 
echo "P_MEMORY=32" >>/etc/default/opensips 
echo "DUMP_CORE=yes" >>/etc/default/opensips

 

  • Configuration file

Edit /etc/opensips/opensips.cfg, clear the original configuration file, and insert the following content into the configuration file. ( This configuration file basically refers to the configuration file of freeswitch official wiki )

log_level=1  #老版本日志级别参数为debug,级别范围1-4,建议生产上设置为1,为3或者4时将产生大量日志,磁盘空间很快就不够了
sip_warning=0
log_stderror=no
log_facility=LOG_LOCAL0
log_name="opensips"
debug_mode=no
children=4
dns_try_ipv6=no
auto_aliases=no
listen=udp:172.16.100.30:5062  #另外一个节点设置为udp:172.16.100.31:5062,取本地IP,不添加该监听项则备用节点无法与负载节点握手,导致备用节点将调度列表的负载节点设置为不可用
listen=udp:172.16.100.32:5060
mpath="/usr/lib/x86_64-linux-gnu/opensips/modules/"
 
loadmodule "db_mysql.so"
loadmodule "signaling.so"
loadmodule "sl.so"
loadmodule "tm.so"
loadmodule "rr.so"
loadmodule "uri.so"
loadmodule "dialog.so"
loadmodule "maxfwd.so"
loadmodule "textops.so"
loadmodule "mi_fifo.so"
loadmodule "dispatcher.so"
loadmodule "load_balancer.so"
loadmodule "sipmsgops.so"
loadmodule "proto_udp.so"
modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
modparam("dialog", "db_mode", 1)
modparam("dialog", "db_url", "mysql://opensips:[email protected]/opensips") 
modparam("rr", "enable_double_rr", 1)
modparam("rr", "append_fromtag", 1)
modparam("tm", "fr_timer", 2)
modparam("dispatcher", "db_url", "mysql://opensips:[email protected]/opensips")
modparam("dispatcher", "ds_ping_method", "OPTIONS")
modparam("dispatcher", "ds_ping_interval", 5)
modparam("dispatcher", "ds_probing_threshhold", 2)
modparam("dispatcher", "ds_probing_mode", 1)
modparam("load_balancer", "db_url", "mysql://opensips:[email protected]/opensips")
modparam("load_balancer", "probing_method", "OPTIONS")
modparam("load_balancer", "probing_interval", 5)
route{
 
        if (!mf_process_maxfwd_header("10")) {
                sl_send_reply("483","Too Many Hops");
                exit;
        }
 
        if (!has_totag()) {
                record_route();
        }
        else {
                loose_route();
                t_relay();
                exit;
        }
        if (is_method("CANCEL")) {
                if ( t_check_trans() )
                        t_relay();
                exit;
        }
        if (is_method("INVITE")) {
                if (!load_balance("1","pstn","1")) {
                        send_reply("503","Service Unavailable");
                        exit;
                }
        }
        else if (is_method("REGISTER")) {
                if (!ds_select_dst("1", "4")) {
                        send_reply("503","Service Unavailable");
                        exit;
                }
        }
        else {
                send_reply("405","Method Not Allowed");
                exit;
        }
        if (!t_relay()) {
                sl_reply_error();
        }
}

 

 

  • Add load node

     

Add two load node information to the database

INSERT INTO `opensips`.`load_balancer` (`id`, `group_id`, `dst_uri`, `resources`, `probe_mode`, `description`) VALUES ('1', '1', 'sip:172.16.100.10', 'vm=100;conf=100;transc=100;pstn=500', '1', 'FS1');
INSERT INTO `opensips`.`load_balancer` (`id`, `group_id`, `dst_uri`, `resources`, `probe_mode`, `description`) VALUES ('2', '1', 'sip:172.16.100.11', 'vm=100;conf=100;transc=100;pstn=500', '1', 'FS2');
  • Allow binding non-native IP

Execute the following command to enable OpenSIPS to monitor the local IP, and the OpenSIPS service can be used when the VIP floats over

echo 'net.ipv4.ip_nonlocal_bind=1' >> /etc/sysctl.conf
  • Output log to specified file

Add keepalived and OpenSIPS log output configuration in /etc/rsyslog.conf. ( Note: log_stderror and debug_mode in the OpenSIPS configuration file must be set to no, otherwise separate logs may not be output )

echo "local0.*                        /var/log/opensips.log" >>/etc/rsyslog.conf
echo "local1.*                        /var/log/keepalived.log" >>/etc/rsyslog.conf

3.2.3, start OpenSIPS

  • Restart rsyslog, keepalived, OpenSIPS

service rsyslog restart
service keepalived restart
service opensips restart
  • Add FreeSWITCH to the schedule list

Execute the following command to add the two nodes to the scheduling list ( the command to add the scheduler here is different from version 1.7 )

 

opensipsctl dispatcher addgw 1 sip:172.16.100.10 5060 0 50 'FS1' '节点1'
opensipsctl dispatcher addgw 1 sip:172.16.100.11 5060 0 50 'FS2' '节点2'

After successfully adding the schedule list, under the control of the two FreeSWITCHs, use the sofia profile sofia.superpipi.cn siptrace on command to turn on the sip message tracking, and you can see that the two OpenSIPS nodes are constantly shaking hands with FreeSWITCH through the "OPTIONS" message, as follows:

 

   ------------------------------------------------------------------------
recv 349 bytes from udp/[172.16.100.31]:5062 at 21:41:43.502417:
   ------------------------------------------------------------------------
   OPTIONS sip:172.16.100.10 SIP/2.0
   Via: SIP/2.0/UDP 172.16.100.31:5062;branch=z9hG4bK2fe7.7ea62cf7.0
   To: sip:172.16.100.10
   From: <sip:dispatcher@localhost>;tag=5f8cfd923bd21a2d7f298654cd327b22-8a62
   CSeq: 14 OPTIONS
   Call-ID: [email protected]
   Max-Forwards: 70
   Content-Length: 0
   User-Agent: OpenSIPS (2.4.2 (x86_64/linux))
   
   ------------------------------------------------------------------------
send 735 bytes to udp/[172.16.100.31]:5062 at 21:41:43.503285:
   ------------------------------------------------------------------------
   SIP/2.0 200 OK
   Via: SIP/2.0/UDP 172.16.100.31:5062;branch=z9hG4bK2fe7.7ea62cf7.0
   From: <sip:dispatcher@localhost>;tag=5f8cfd923bd21a2d7f298654cd327b22-8a62
   To: <sip:172.16.100.10>;tag=t2y6pUXm66tQH
   Call-ID: [email protected]
   CSeq: 14 OPTIONS
   Contact: <sip:172.16.100.10>
   User-Agent: FreeSWITCH-mod_sofia/1.8.1+git~20180724×××60524Z~b33bc925c5~64bit
   Accept: application/sdp
   Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
   Supported: timer, path, replaces
   Allow-Events: talk, hold, conference, presence, as-feature-event, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer
   Content-Length: 0
   
   ------------------------------------------------------------------------
recv 349 bytes from udp/[172.16.100.30]:5062 at 21:41:45.769168:
   ------------------------------------------------------------------------
   OPTIONS sip:172.16.100.10 SIP/2.0
   Via: SIP/2.0/UDP 172.16.100.30:5062;branch=z9hG4bKbace.ec1b06f.0
   To: sip:172.16.100.10
   From: <sip:dispatcher@localhost>;tag=45af385df62c8fa46b1bdd54b7adb556-4f80
   CSeq: 14 OPTIONS
   Call-ID: [email protected]
   Max-Forwards: 70
   Content-Length: 0
   User-Agent: OpenSIPS (2.4.2 (x86_64/linux))
   
   ------------------------------------------------------------------------
send 735 bytes to udp/[172.16.100.30]:5062 at 21:41:45.770861:
   ------------------------------------------------------------------------
   SIP/2.0 200 OK
   Via: SIP/2.0/UDP 172.16.100.30:5062;branch=z9hG4bKbace.ec1b06f.0
   From: <sip:dispatcher@localhost>;tag=45af385df62c8fa46b1bdd54b7adb556-4f80
   To: <sip:172.16.100.10>;tag=UBrZrper3FHaD
   Call-ID: [email protected]
   CSeq: 14 OPTIONS
   Contact: <sip:172.16.100.10>
   User-Agent: FreeSWITCH-mod_sofia/1.8.1+git~20180724×××60524Z~b33bc925c5~64bit
   Accept: application/sdp
   Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
   Supported: timer, path, replaces
   Allow-Events: talk, hold, conference, presence, as-feature-event, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer
   Content-Length: 0
   
   ------------------------------------------------------------------------


 

Four, FreeSWITCH configuration and verification

 

4.1. Domain name modification

Since the phone is registered through the domain name when registering, it is necessary to modify the FreeSWITCH domain to the registered domain name.

Edit ../conf/vars.xml and set the domain to sofia.superpipi.cn. (Note: If FreeSWITCH uses multiple domains, please refer to the multi-domain method to modify, refer to: https://www.cnblogs.com/lzpong/p/8573372.html)

<X-PRE-PROCESS cmd="set" data="domain=sofia.superpipi.cn"/>

After modification, FreeSWITCH needs to be restarted to take effect

4.2, registration verification

I used eyeBeam, Linphone, eSpace SoftPhone three soft phones and a Fanvil X5 hard phone to test the registration, and the registration was successful.

Execute fs_cli -x "sofia status profile sofia.superpipi.cn reg" on the server where freeswitch is located

The results are as follows:

 

root@debian:~# fs_cli -x "sofia status profile sofia.superpipi.cn reg"
Registrations:
=================================================================================================
Call-ID:        [email protected]
User:           [email protected]
Contact:        "1004" <sip:[email protected]:6060>
Agent:          Fanvil X5 1.3.256.1566
Status:         Registered(UDP)(unknown) EXP(2018-09-23 22:14:29) EXPSECS(2228)
Ping-Status:    Reachable
Ping-Time:      0.00
Host:           debian
IP:             172.16.100.32
Port:           5060
Auth-User:      1004
Auth-Realm:     sofia.superpipi.cn
MWI-Account:    [email protected]
Call-ID:        YTFjZjBmZDZjNWEyZGQwNTgxMTEzZDcwMTAwNDdiZDQ.
User:           [email protected]
Contact:        "1000" <sip:[email protected]:51540;rinstance=f8dca36459b0bdec>
Agent:          eyeBeam release 1011d stamp 40820
Status:         Registered(UDP)(unknown) EXP(2018-09-23 22:35:27) EXPSECS(3486)
Ping-Status:    Reachable
Ping-Time:      0.00
Host:           debian
IP:             172.16.100.32
Port:           5060
Auth-User:      1000
Auth-Realm:     sofia.superpipi.cn
MWI-Account:    [email protected]
Call-ID:        SdnqWECcxy
User:           [email protected]
Contact:        "" <sip:[email protected]:64242;transport=udp>
Agent:          Linphone Desktop/4.1.1 (belle-sip/1.6.3)
Status:         Registered(UDP)(unknown) EXP(2018-09-23 21:47:38) EXPSECS(617)
Ping-Status:    Reachable
Ping-Time:      0.00
Host:           debian
IP:             172.16.100.32
Port:           5060
Auth-User:      1002
Auth-Realm:     sofia.superpipi.cn
MWI-Account:    [email protected]
Call-ID:        NzBhNzg3NTY2NWExZmE0M2ZiODdlZGIwYmY1NGVmY2Y.
User:           [email protected]
Contact:        "" <sip:[email protected]:5060;rinstance=b0fff9289f8fbf0c>
Agent:          HUAWEI OpenEye v3.1
Status:         Registered(UDP)(unknown) EXP(2018-09-23 21:42:52) EXPSECS(331)
Ping-Status:    Reachable
Ping-Time:      0.00
Host:           debian
IP:             172.16.100.32
Port:           5060
Auth-User:      1003
Auth-Realm:     sofia.superpipi.cn
MWI-Account:    [email protected]
Total items returned: 4
=================================================================================================

 

4.3, call verification

  • Use extension 1000 to dial 1003

The 172.16.100.10 (FS1) node receives the "INVITE" message from extension 1000 and initiates an "INVITE" message to extension 1003. The message tracking is as follows (Note: SDP is deleted and some messages are omitted):

 

recv 1431 bytes from udp/[172.16.100.32]:5060 at 21:48:29.481716:
   ------------------------------------------------------------------------
   INVITE sip:[email protected] SIP/2.0
   Record-Route: <sip:172.16.100.32;lr;ftag=f104f441;did=83f.44ccd293>
   Via: SIP/2.0/UDP 172.16.100.32:5060;branch=z9hG4bKc6fd.c55828d7.0
   Via: SIP/2.0/UDP 172.16.100.251:51540;received=172.16.100.251;branch=z9hG4bK-d87543-8651904ed85c056f-1--d87543-;rport=51540
   Max-Forwards: 69
   Contact: <sip:[email protected]:51540>
   To: "1003"<sip:[email protected]>
   From: "1000"<sip:[email protected]>;tag=f104f441
   Call-ID: NDkyOTM1YWI4YzhiMGY4MWI0ZDMwYmQzNThjYjE2NzQ.
   CSeq: 2 INVITE
   Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO
   Content-Type: application/sdp
   Proxy-Authorization: Digest username="1000",realm="sofia.superpipi.cn",nonce="e9c8201d-3c8a-461b-a86c-4719edc9cae3",uri="sip:[email protected]",response="07eca040fed8f8ecfb7392671af7cc20",cnonce="44bb05f0c983e2e22b491a7bc82f0ab6",nc=00000001,qop=auth,algorithm=MD5
   User-Agent: eyeBeam release 1011d stamp 40820
   Content-Length: 442

   ------------------------------------------------------------------------
send 354 bytes to udp/[172.16.100.32]:5060 at 21:48:29.502215:
   ------------------------------------------------------------------------
   SIP/2.0 100 Trying
   Via: SIP/2.0/UDP 172.16.100.32:5060;branch=z9hG4bKc6fd.c55828d7.0
   From: "1000"<sip:[email protected]>;tag=f104f441
   To: "1003"<sip:[email protected]>
   Call-ID: NDkyOTM1YWI4YzhiMGY4MWI0ZDMwYmQzNThjYjE2NzQ.
   CSeq: 2 INVITE
   User-Agent: FreeSWITCH-mod_sofia/1.8.1+git~20180724×××60524Z~b33bc925c5~64bit
   Content-Length: 0
   
   ------------------------------------------------------------------------
send 1272 bytes to udp/[172.16.100.251]:5060 at 21:48:30.575115:
   ------------------------------------------------------------------------
   INVITE sip:[email protected]:5060;rinstance=b0fff9289f8fbf0c SIP/2.0
   Via: SIP/2.0/UDP 172.16.100.10;rport;branch=z9hG4bKg7X53ye14956r
   Max-Forwards: 68
   From: "Extension 1000" <sip:[email protected]>;tag=9e7rDt1XcyNZc
   To: <sip:[email protected]:5060;rinstance=b0fff9289f8fbf0c>
   Call-ID: 326006cf-39da-1237-4983-000c2953a0b0
   CSeq: 128519191 INVITE
   Contact: <sip:[email protected]:5060>
   User-Agent: FreeSWITCH-mod_sofia/1.8.1+git~20180724×××60524Z~b33bc925c5~64bit
   Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
   Supported: timer, path, replaces
   Allow-Events: talk, hold, conference, presence, as-feature-event, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer
   Content-Type: application/sdp
   Content-Disposition: session
   Content-Length: 246
   X-FS-Support: update_display,send_info
   Remote-Party-ID: "Extension 1000" <sip:[email protected]>;party=calling;screen=yes;privacy=off
   
   ------------------------------------------------------------------------
recv 318 bytes from udp/[172.16.100.251]:5060 at 21:48:30.634089:
   ------------------------------------------------------------------------
   SIP/2.0 100 Trying
   Via: SIP/2.0/UDP 172.16.100.10;rport=5060;branch=z9hG4bKg7X53ye14956r
   To: <sip:[email protected]:5060;rinstance=b0fff9289f8fbf0c>
   From: "Extension 1000" <sip:[email protected]>;tag=9e7rDt1XcyNZc
   Call-ID: 326006cf-39da-1237-4983-000c2953a0b0
   CSeq: 128519191 INVITE
   Content-Length: 0
   
   ------------------------------------------------------------------------
recv 399 bytes from udp/[172.16.100.251]:5060 at 21:48:30.634221:
   ------------------------------------------------------------------------
   SIP/2.0 180 Ringing
   Via: SIP/2.0/UDP 172.16.100.10;rport=5060;branch=z9hG4bKg7X53ye14956r
   Contact: <sip:[email protected]:5060;rinstance=b0fff9289f8fbf0c>
   To: <sip:[email protected]:5060;rinstance=b0fff9289f8fbf0c>;tag=77eb678a
   From: "Extension 1000"<sip:[email protected]>;tag=9e7rDt1XcyNZc
   Call-ID: 326006cf-39da-1237-4983-000c2953a0b0
   CSeq: 128519191 INVITE
   Content-Length: 0
   ------------------------------------------------------------------------
  • Use extension 1002 to dial 1004

In the call state between 1000 and 1003, use extension 1002 to dial 1004, 172.16.100.11 (FS2) node receives the "INVITE" message from extension 1002, and initiates an "INVITE" message to extension 1004. The message tracking is as follows (Note: Delete SDP and omit part of the message):

recv 1935 bytes from udp/[172.16.100.32]:5060 at 21:54:32.072291:
   ------------------------------------------------------------------------
   INVITE sip:[email protected] SIP/2.0
   Record-Route: <sip:172.16.100.32;lr;ftag=0HIj01pcT;did=cdf.8df222c6>
   Via: SIP/2.0/UDP 172.16.100.32:5060;branch=z9hG4bKc54a.a53a6847.0
   Via: SIP/2.0/UDP 172.16.100.251:64242;received=172.16.100.251;branch=z9hG4bK.m5Jiasf70;rport=64242
   From: <sip:[email protected]>;tag=0HIj01pcT
   To: sip:[email protected]
   CSeq: 21 INVITE
   Call-ID: LJD8EMDXo0
   Max-Forwards: 69
   Supported: replaces, outbound
   Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO, UPDATE
   Content-Type: application/sdp
   Content-Length: 898
   Contact: <sip:[email protected]:64242;transport=udp>;+sip.instance="<urn:uuid:bcb91990-4d9b-47ea-8ba8-3af172d27fce>"
   User-Agent: Linphone Desktop/4.1.1 (belle-sip/1.6.3)
   Proxy-Authorization:  Digest realm="sofia.superpipi.cn", nonce="771a93e4-504d-410e-b5ca-4b927a297b61", algorithm=MD5, username="1002",  uri="sip:[email protected]", response="ed40318d6162ef2a623f8f3049995a99", cnonce="3zQAEkGGvoZhNjcE", nc=00000001, qop=auth
   ------------------------------------------------------------------------
send 308 bytes to udp/[172.16.100.32]:5060 at 21:54:32.098044:
   ------------------------------------------------------------------------
   SIP/2.0 100 Trying
   Via: SIP/2.0/UDP 172.16.100.32:5060;branch=z9hG4bKc54a.a53a6847.0
   From: <sip:[email protected]>;tag=0HIj01pcT
   To: sip:[email protected]
   Call-ID: LJD8EMDXo0
   CSeq: 21 INVITE
   User-Agent: FreeSWITCH-mod_sofia/1.8.1+git~20180724×××60524Z~b33bc925c5~64bit
   Content-Length: 0
   
   ------------------------------------------------------------------------
send 1427 bytes to udp/[172.16.100.110]:6060 at 21:54:33.154929:
   ------------------------------------------------------------------------
   INVITE sip:[email protected]:6060 SIP/2.0
   Via: SIP/2.0/UDP 172.16.100.11;rport;branch=z9hG4bKecU1j8vy36H9r
   Max-Forwards: 68
   From: "Extension 1002" <sip:[email protected]>;tag=v4c83jm6gtF0H
   To: <sip:[email protected]:6060>
   Call-ID: 0a7d51fd-39db-1237-2d8d-000c29916959
   CSeq: 128519372 INVITE
   Contact: <sip:[email protected]:5060>
   User-Agent: FreeSWITCH-mod_sofia/1.8.1+git~20180724×××60524Z~b33bc925c5~64bit
   Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
   Supported: timer, path, replaces
   Allow-Events: talk, hold, conference, presence, as-feature-event, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer
   Content-Type: application/sdp
   Content-Disposition: session
   Content-Length: 455
   X-FS-Support: update_display,send_info
   Remote-Party-ID: "Extension 1002" <sip:[email protected]>;party=calling;screen=yes;privacy=off
   ------------------------------------------------------------------------
recv 378 bytes from udp/[172.16.100.110]:6060 at 21:54:33.338614:
   ------------------------------------------------------------------------
   SIP/2.0 100 Trying
   Via: SIP/2.0/UDP 172.16.100.11;rport=5060;branch=z9hG4bKecU1j8vy36H9r
   From: "Extension 1002" <sip:[email protected]>;tag=v4c83jm6gtF0H
   To: <sip:[email protected]:6060>
   Call-ID: 0a7d51fd-39db-1237-2d8d-000c29916959
   CSeq: 128519372 INVITE
   Allow: INVITE, ACK, OPTIONS, BYE, CANCEL, REFER, NOTIFY, INFO, PRACK, UPDATE, MESSAGE
   Content-Length: 0
   
   ------------------------------------------------------------------------
recv 349 bytes from udp/[172.16.100.31]:5062 at 21:54:33.541289:
   ------------------------------------------------------------------------
   OPTIONS sip:172.16.100.11 SIP/2.0
   Via: SIP/2.0/UDP 172.16.100.31:5062;branch=z9hG4bKe86c.f1b595f2.0
   To: sip:172.16.100.11
   From: <sip:dispatcher@localhost>;tag=5f8cfd923bd21a2d7f298654cd327b22-a1e0
   CSeq: 14 OPTIONS
   Call-ID: [email protected]
   Max-Forwards: 70
   Content-Length: 0
   User-Agent: OpenSIPS (2.4.2 (x86_64/linux))
   
   ------------------------------------------------------------------------
send 735 bytes to udp/[172.16.100.31]:5062 at 21:54:33.542155:
   ------------------------------------------------------------------------
   SIP/2.0 200 OK
   Via: SIP/2.0/UDP 172.16.100.31:5062;branch=z9hG4bKe86c.f1b595f2.0
   From: <sip:dispatcher@localhost>;tag=5f8cfd923bd21a2d7f298654cd327b22-a1e0
   To: <sip:172.16.100.11>;tag=XD605D59D35jD
   Call-ID: [email protected]
   CSeq: 14 OPTIONS
   Contact: <sip:172.16.100.11>
   User-Agent: FreeSWITCH-mod_sofia/1.8.1+git~20180724×××60524Z~b33bc925c5~64bit
   Accept: application/sdp
   Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
   Supported: timer, path, replaces
   Allow-Events: talk, hold, conference, presence, as-feature-event, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer
   Content-Length: 0
   
   ------------------------------------------------------------------------

 

Five, postscript

OpenSIPS uses keepalived to switch between active and standby for high availability, and then the load balancing experiment on FreeSWITCH is complete, but there are still some areas that need to be improved, such as From: <sip:dispatcher@localhost> in the sip message, and official The IP addresses of the calls mentioned can only be recorded in OpenSIPS IP issues, OpenSIPS proxy media issues, and OpenSIPS availability detection scripts.

In short, in the production and application of FreeSWITCH, high-availability solutions must be considered. The previous tossing note has introduced the high availability of FreeSWITCH active/standby switching through keepalived. Here, we will toss the high-availability method of load balancing. You may ask: Why not use the official "Corosync+Pacemaker" method for high availability of active/standby switching, mainly because I am a little familiar with keepalived, and the switching efficiency of "keepalived+ detection script" is also very high.

Guess you like

Origin blog.csdn.net/gredn/article/details/88696624