- IP PBX
- FreeSWITCH
- Class 4 switch
- Class 5 switch
- freeswitch-setup-as-hosted-ip-pbx
- Freeswitch as B2BUA
This article talks about setting up an in-house hosted Enterprise PBX system for sure and private communication within enterprise communication.
IP PBX
A PBX acts as the central switching system for phone calls within a business.
- Cloud Hosted IP PBX Systems
- On-premise IP PBX
An IP PBX is a PBX system with IP connectivity and may provide additional audio, video, or instant messaging communication utilizing the TCP/IP protocol stack.
Wikipedia
Essentially an IP PBX is a telecommunication device( on IP Interface) that provides voice connectivity to IP phones within an organization/internal office network.

Enterprise applications, media servers, presence servers, and the VoIP/SIP PBX are interconnected through a company intranet.SIP clients can be SIP hard-phones or soft-phones on PCs, PDAs etc. A PSTN gateway links the enterprise SIP PBX to the public PSTN.
A soft switch (SIP PBX) can be a combination of several SIP entities, such as SIP registrar, proxy server, redirect server, forking server, Back-To-Back User Agent (B2BUA) etc.
FreeSWITCH is free and open source communications software licensed under Mozilla Public License. It if often the core of voice core to provider call routing and media control . Its core library, libfreeswitch, is capable of being embedded into other projects, as well as being used as a stand-alone application. Read more about FreeSwitch SIP and Media Server.
Just a network-switch is hardware that controls network traffic by receiving and forwarding data to the destination device, a soft-switch is a software that controls traffic and call routing in a voIP communication network.
Class 4 switch | Class 5 switch |
Class 4 switches route calls between communication providers such as – between telco and enterprise PBX | Class 5 switches connect communication provider with real clients (or end users) caller and callee. – can provide platform + user agent such as diallers |
Freeswitch setup as hosted IP PBX

Fetching source code
apt-get install git
git clone https://stash.freeswitch.org/scm/fs/freeswitch.git
Verify installation by checking version
freeswitch -version
FreeSWITCH version: 1.9.0-742-8f1b7e0~64bit (-742-8f1b7e0 64bit)
Steps post installation
optional arguments you can pass to freeswitch:
-nf -- no forking -reincarnate -- restart the switch on an uncontrolled exit -reincarnate-reexec -- run execv on a restart (helpful for upgrades) -u [user] -- specify user to switch to -g [group] -- specify group to switch to -core -- dump cores -help -- this message -version -- print the version and exit -rp -- enable high(realtime) priority settings -lp -- enable low priority settings -np -- enable normal priority settings -vg -- run under valgrind -nosql -- disable internal sql scoreboard -heavy-timer -- Heavy Timer, possibly more accurate but at a cost -nonat -- disable auto nat detection -nonatmap -- disable auto nat port mapping -nocal -- disable clock calibration -nort -- disable clock clock_realtime -stop -- stop freeswitch -nc -- do not output to a console and background -ncwait -- do not output to a console and background but wait until the system is ready before exiting (implies -nc) -c -- output to a console and stay in the foreground
Options to control locations of files:
-base [basedir] -- alternate prefix directory -cfgname [filename] -- alternate filename for FreeSWITCH main configuration file -conf [confdir] -- alternate directory for FreeSWITCH configuration files -log [logdir] -- alternate directory for logfiles -run [rundir] -- alternate directory for runtime files -db [dbdir] -- alternate directory for the internal database -mod [moddir] -- alternate directory for modules -htdocs [htdocsdir] -- alternate directory for htdocs -scripts [scriptsdir] -- alternate directory for scripts -temp [directory] -- alternate directory for temporary files -grammar [directory] -- alternate directory for grammar files -certs [directory] -- alternate directory for certificates -recordings [directory] -- alternate directory for recordings -storage [directory] -- alternate directory for voicemail storage -cache [directory] -- alternate directory for cache files -sounds [directory] -- alternate directory for sound files
Freeswitch as B2BUA
Tracing SIP messages and Freeswitch processing for call from external user to internal user.

Receives incoming Call INVITE from Caller
recv 823 bytes from tcp/[caller_ip]:35365 at 09:55:07.936234: ------------------------------------------------------------------------ INVITE sip:to_number@sometelco.com:5060 SIP/2.0 Via: SIP/2.0/TCP 192.168.1.23:55934;branch=z9hG4bK-524287-1---cc11593581af6519;rport Max-Forwards: 70 Contact: <sip:from_number@192.168.1.23:55934;transport=tcp> To: <sip:to_number@sometelco.com:5060> From: "from_number"<sip:from_number@sometelco.com:5060>;tag=47a61272 Call-ID: 94385YTY3ODNlNzE1YjE5MmY4NmQ3ZWUyZDAzM2E0YzBkM2I CSeq: 1 INVITE Allow: OPTIONS, SUBSCRIBE, NOTIFY, INVITE, ACK, CANCEL, BYE, REFER, INFO Content-Type: application/sdp Supported: replaces User-Agent: X-Lite release 5.4.0 stamp 94385 Content-Length: 208 v=0 o=- 1553248503383592 1 IN IP4 192.168.1.23 s=X-Lite release 5.4.0 stamp 94385 c=IN IP4 192.168.1.23 t=0 0 m=audio 49874 RTP/AVP 8 101 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-15 a=sendrecv ------------------------------------------------------------------------
checks with ACL for permission and set NAT. Isolate SDP for processing.
New Channel sofia/internal/from_number@sometelco.com:5060 [a8a2003f-5755-40fe-ab63-aab2f5264886] Running State Change CS_NEW (Cur 1 Tot 274) receiving invite from caller_ip:35365 version: 1.9.0 -742-8f1b7e0 64bit IP caller_ip Approved by acl "domains[]". Access Granted. Setting NAT mode based on nat.auto Channel sofia/internal/from_number@sometelco.com:5060 entering state [received][100] Remote SDP: v=0 o=- 1553248503383592 1 IN IP4 192.168.1.23 s=X-Lite release 5.4.0 stamp 94385 c=IN IP4 192.168.1.23 t=0 0 m=audio 49874 RTP/AVP 8 101 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-15
mainatin and Updates call-state (switch_core_state_machine ) CS_NEW -> CS_INIT -> CS_ROUTING -> RINGING and send 100 trying to caller
State Change CS_NEW -> CS_INIT State NEW Running State Change CS_INIT (Cur 1 Tot 274) State INIT SOFIA INIT Standard INIT State Change CS_INIT -> CS_ROUTING State INIT going to sleep Running State Change CS_ROUTING (Cur 1 Tot 274) Change DOWN -> RINGING State ROUTING send 413 bytes to tcp/[caller_ip]:35365 at 09:55:07.937474: ------------------------------------------------------------------------ SIP/2.0 100 Trying Via: SIP/2.0/TCP 192.168.1.23:55934;branch=z9hG4bK-524287-1---cc11593581af6519;rport=35365;received=caller_ip From: "from_number"<sip:from_number@sometelco.com:5060>;tag=47a61272 To: <sip:to_number@sometelco.com:5060> Call-ID: 94385YTY3ODNlNzE1YjE5MmY4NmQ3ZWUyZDAzM2E0YzBkM2I CSeq: 1 INVITE User-Agent: FreeSWITCH-mod_sofia/1.9.0-742-8f1b7e0~64bit Content-Length: 0 ------------------------------------------------------------------------
Checks dialplan to route incoming call. In this case action is to bridge the incoming call to internal user
mod_sofia.c:154 sofia/internal/from_number@sometelco.com:5060 SOFIA ROUTING switch_core_state_machine.c:236 sofia/internal/from_number@sometelco.com:5060 Standard ROUTING mod_dialplan_xml.c:637 Processing from_number <from_number>->to_number in context public Dialplan: sofia/internal/from_number@sometelco.com:5060 parsing [public->dialplan_cutsom] continue=false Dialplan: sofia/internal/from_number@sometelco.com:5060 Regex (PASS) [dialplan_cutsom] destination_number(to_number) =~ /^(\d+)$/ break=on-false Dialplan: sofia/internal/from_number@sometelco.com:5060 Action log(INFO ***** Forwarding calls to gateway ****** ) Dialplan: sofia/internal/from_number@sometelco.com:5060 Action bridge({sip_auth_username=user,sip_auth_password=pass,sip_route_uri=sip:to_number@ip_addr;transport=tls,sip_invite_req_uri=sip:to_number@sometelco.com;transport=tls}sofia/external/to_number@ip_addr)
update call state CS_ROUTING -> CS_EXECUTE
State Change CS_ROUTING -> CS_EXECUTE State ROUTING going to sleep Running State Change CS_EXECUTE (Cur 1 Tot 274) State EXECUTE SOFIA EXECUTE
set the crypto and codecs for the new call
switch_ivr_originate.c:2159 Parsing global variables switch_channel.c:1104 New Channel sofia/external/to_number@ip_addr [cc1ae238-9efd-4f51-93e9-05abd48bea4d] mod_sofia.c:5026 (sofia/external/to_number@ip_addr) State Change CS_NEW -> CS_INIT switch_core_state_machine.c:584 (sofia/external/to_number@ip_addr) Running State Change CS_INIT (Cur 2 Tot 275) switch_core_state_machine.c:627 (sofia/external/to_number@ip_addr) State INIT mod_sofia.c:93 sofia/external/to_number@ip_addr SOFIA INIT Set Local audio crypto Key [1 AEAD_AES_256_GCM_8 inline:ZbEHd76sP6FZSO9AYcqryybaA4HY3O5p2Uo+e1gmmfVaZCEic6cvKyArhMU] Set Local video crypto Key [1 AEAD_AES_256_GCM_8 inline:Ehr3LoDR8Ur+wtNAMqoqIDn3S7V2inE2/n++awxS6/1P2ijcqfk12+LM/Pc] Set Local text crypto Key [1 AEAD_AES_256_GCM_8 inline:NVSfjOmSS5BaP/5yqg+SOXcqvEFTHHrC8R5AYkkClXLuNOXYoaUYlrIWeW0] Set Local audio crypto Key [2 AEAD_AES_128_GCM_8 inline:ePH/F2Qw5+zi8c7tkBb6Y2AQE5uevp+jWUkjgQ] Set Local video crypto Key [2 AEAD_AES_128_GCM_8 inline:YWdfNLSx6MqG9WQ3TmsV/cSBDqjRUAbHE0rRCg] Set Local text crypto Key [2 AEAD_AES_128_GCM_8 inline:DFXOP2V2Ep6FoHNz5HIMrm0cu6Za8I5wOI/hUw] Set Local audio crypto Key [3 AES_CM_256_HMAC_SHA1_80 inline:SG5rYx3GSR2imutYQ+LzqHufG9UkG3n/SfmFHFOG/r75v2pwf2lG7Qpup+J0mw] Set Local video crypto Key [3 AES_CM_256_HMAC_SHA1_80 inline:LkU3i9MD25k2wtTfSXUvhlxo66GtMWnXkKoxSdgRZyANoeOhufYnXzbXDo+7+w] Set Local text crypto Key [3 AES_CM_256_HMAC_SHA1_80 inline:AUgUOVmFunzotvwZ6KuMDnBRR2XKk1DsX2qg465MsT6OAxHc2qKBFpeQEpxrqA] Set Local audio crypto Key [4 AES_CM_192_HMAC_SHA1_80 inline:2PVBBJEp4QcTzTf4Th8Ag/7KiVPmrYb/FCowiRb6yAuTO/kxQLc] Set Local video crypto Key [4 AES_CM_192_HMAC_SHA1_80 inline:OiFbZQ6mWuf5sHJT1pFPU6EWxEvQAO/0rcp8uGMf79k7RSR3IQA] Set Local text crypto Key [4 AES_CM_192_HMAC_SHA1_80 inline:XyednWJmzRfsWQOgdhKaMeOeE/OLmnwo6hVEZWl4OJdKdgK6TVc] Set Local audio crypto Key [5 AES_CM_128_HMAC_SHA1_80 inline:Yd4L5Qi7A/8xay5ZHWR1jKk9j5Kvy9s2Zo3NOES2] Set Local video crypto Key [5 AES_CM_128_HMAC_SHA1_80 inline:ImgbbD6cnhnH19O1knP5SSIUULsZTaNJJIUepxt0] Set Local text crypto Key [5 AES_CM_128_HMAC_SHA1_80 inline:V7+IbSZmTdQNjh/upUZ5TFDSlgarhDTVfV+AcUA+] Set Local audio crypto Key [6 AES_CM_256_HMAC_SHA1_32 inline:JI+s9uFdZ3JfZmRRfwHr0OrpyZdtUXmMC0WRIZow1EuXRB9xKFRBk6KmSWomqQ] Set Local video crypto Key [6 AES_CM_256_HMAC_SHA1_32 inline:MX6CGCrMEioUCJsIOCxRqlHOx4mUYRw4DslpY25njZQAkH6MgG/9hp7G8xr44A] Set Local text crypto Key [6 AES_CM_256_HMAC_SHA1_32 inline:ikCz2sYLGoMO+dlrZj+znlQ3djAkGSYzSLLu6Az8u2THWPgnkFJXVgXSxHOaHw] Set Local audio crypto Key [7 AES_CM_192_HMAC_SHA1_32 inline:5JzlrMywFZhHuNLWPG/HBrUi/Zcg414Q7ZfSaJQnUF5N9APy+GQ] Set Local video crypto Key [7 AES_CM_192_HMAC_SHA1_32 inline:K0dZtwH1Q7AuSMBPPUesy047c4nAF+QuFsVvGdf3fYJDOD0Uwxo] Set Local text crypto Key [7 AES_CM_192_HMAC_SHA1_32 inline:96SwyWAdV1a+BU3UbiX1PHdkRlSS4RtmwPWNPbCR3NDm1MyBh58] Set Local audio crypto Key [8 AES_CM_128_HMAC_SHA1_32 inline:/RLYPhZs07WCCBRY8tWNTJemT/IFq1VPHGHmGvnG] Set Local video crypto Key [8 AES_CM_128_HMAC_SHA1_32 inline:mQlgScFq1iMKEW8vobzwhmN9TWSmVblAv9u7c1/c] Set Local text crypto Key [8 AES_CM_128_HMAC_SHA1_32 inline:WAQveMfrQkPBcfqH2qLmuzY63VLfT+N30/YLyuqE] Set Local audio crypto Key [9 AES_CM_128_NULL_AUTH inline:f2fx2ekxPG3GTwTYARtquNJ87qO0Q5ei47KYlo9K] Set Local video crypto Key [9 AES_CM_128_NULL_AUTH inline:qpAkfc1bWnZ0Y/1ql+dNvhIGgxxWZoVltnRD5kqn] Set Local text crypto Key [9 AES_CM_128_NULL_AUTH inline:LyhSlzI3X38WKPwZ83035Ddvse4J/2KnKoydo2FD]
set proxy route and create SDP for sending invite to bridged client
sofia_glue.c:1268 sip:to_number@ip_addr;transport=tls Setting proxy route to sofia/external/to_number@ip_addr sofia_glue.c:1299 sofia/external/to_number@ip_addr sending invite version: 1.9.0 -742-8f1b7e0 64bit Local SDP: v=0 o=FreeSWITCH 1553228435 1553228436 IN IP4 via_addr s=FreeSWITCH c=IN IP4 via_addr t=0 0 m=audio 20072 RTP/SAVP 8 101 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-16 a=crypto:1 AEAD_AES_256_GCM_8 inline:ZbEHd76sP6FZSO9AYcqryybaA4HY3O5p2Uo+e1gmmfVaZCEic6cvKyArhMU a=crypto:2 AEAD_AES_128_GCM_8 inline:ePH/F2Qw5+zi8c7tkBb6Y2AQE5uevp+jWUkjgQ a=crypto:3 AES_CM_256_HMAC_SHA1_80 inline:SG5rYx3GSR2imutYQ+LzqHufG9UkG3n/SfmFHFOG/r75v2pwf2lG7Qpup+J0mw a=crypto:4 AES_CM_192_HMAC_SHA1_80 inline:2PVBBJEp4QcTzTf4Th8Ag/7KiVPmrYb/FCowiRb6yAuTO/kxQLc a=crypto:5 AES_CM_128_HMAC_SHA1_80 inline:Yd4L5Qi7A/8xay5ZHWR1jKk9j5Kvy9s2Zo3NOES2 a=crypto:6 AES_CM_256_HMAC_SHA1_32 inline:JI+s9uFdZ3JfZmRRfwHr0OrpyZdtUXmMC0WRIZow1EuXRB9xKFRBk6KmSWomqQ a=crypto:7 AES_CM_192_HMAC_SHA1_32 inline:5JzlrMywFZhHuNLWPG/HBrUi/Zcg414Q7ZfSaJQnUF5N9APy+GQ a=crypto:8 AES_CM_128_HMAC_SHA1_32 inline:/RLYPhZs07WCCBRY8tWNTJemT/IFq1VPHGHmGvnG a=crypto:9 AES_CM_128_NULL_AUTH inline:f2fx2ekxPG3GTwTYARtquNJ87qO0Q5ei47KYlo9K a=ptime:20 a=sendrecv m=audio 20072 RTP/AVP 8 101 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-16 a=ptime:20 a=sendrecv
attach the SDP to INVITE and proceed forwarding INVITE to callee
send 1988 bytes to tls/[ip_addr]:5061 at 09:55:07.939831: ------------------------------------------------------------------------ INVITE sip:to_number@sometelco.com;transport=tls SIP/2.0 Via: SIP/2.0/TLS via_addr:5080;rport;branch=z9hG4bK21Qm9U3eHX0Nc Max-Forwards: 69 From: "from_number" <sip:from_number@via_addr>;tag=8jByBXa2pF1Fj To: <sip:to_number@ip_addr> Call-ID: 6a827514-c72b-1237-8aab-02a933b32da0 CSeq: 2070461 INVITE Contact: <sip:mod_sofia@via_addr:5080> User-Agent: FreeSWITCH-mod_sofia/1.9.0-742-8f1b7e0~64bit Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY Supported: timer, path, replaces Allow-Events: talk, hold, conference, refer Content-Type: application/sdp Content-Disposition: session Content-Length: 1162 X-FS-Support: update_display,send_info Remote-Party-ID: "from_number" <sip:from_number@via_addr>;party=calling;screen=yes;privacy=off v=0 o=FreeSWITCH 1553228435 1553228436 IN IP4 via_addr s=FreeSWITCH c=IN IP4 via_addr t=0 0 m=audio 20072 RTP/SAVP 8 101 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-16 a=crypto:1 AEAD_AES_256_GCM_8 inline:ZbEHd76sP6FZSO9AYcqryybaA4HY3O5p2Uo+e1gmmfVaZCEic6cvKyArhMU a=crypto:2 AEAD_AES_128_GCM_8 inline:ePH/F2Qw5+zi8c7tkBb6Y2AQE5uevp+jWUkjgQ a=crypto:3 AES_CM_256_HMAC_SHA1_80 inline:SG5rYx3GSR2imutYQ+LzqHufG9UkG3n/SfmFHFOG/r75v2pwf2lG7Qpup+J0mw a=crypto:4 AES_CM_192_HMAC_SHA1_80 inline:2PVBBJEp4QcTzTf4Th8Ag/7KiVPmrYb/FCowiRb6yAuTO/kxQLc a=crypto:5 AES_CM_128_HMAC_SHA1_80 inline:Yd4L5Qi7A/8xay5ZHWR1jKk9j5Kvy9s2Zo3NOES2 a=crypto:6 AES_CM_256_HMAC_SHA1_32 inline:JI+s9uFdZ3JfZmRRfwHr0OrpyZdtUXmMC0WRIZow1EuXRB9xKFRBk6KmSWomqQ a=crypto:7 AES_CM_192_HMAC_SHA1_32 inline:5JzlrMywFZhHuNLWPG/HBrUi/Zcg414Q7ZfSaJQnUF5N9APy+GQ a=crypto:8 AES_CM_128_HMAC_SHA1_32 inline:/RLYPhZs07WCCBRY8tWNTJemT/IFq1VPHGHmGvnG a=crypto:9 AES_CM_128_NULL_AUTH inline:f2fx2ekxPG3GTwTYARtquNJ87qO0Q5ei47KYlo9K a=ptime:20 m=audio 20072 RTP/AVP 8 101 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-16 a=ptime:20 ------------------------------------------------------------------------
manage and update call state for this call leg too CS_INIT -> CS_ROUTING -> CS_CONSUME_MEDIA
Standard INIT State Change CS_INIT -> CS_ROUTING State INIT going to sleep Running State Change CS_ROUTING (Cur 2 Tot 275) Channel sofia/external/to_number@ip_addr entering state [calling][0] State ROUTING SOFIA ROUTING State Change CS_ROUTING -> CS_CONSUME_MEDIA State ROUTING going to sleep Running State Change CS_CONSUME_MEDIA (Cur 2 Tot 275) State CONSUME_MEDIA State CONSUME_MEDIA going to sleep recv 365 bytes from tls/[ip_addr]:5061 at 09:55:07.940977: ------------------------------------------------------------------------ SIP/2.0 100 trying -- your call is important to us Via: SIP/2.0/TLS via_addr:5080;rport=59774;branch=z9hG4bK21Qm9U3eHX0Nc;received=via_addr From: "from_number" <sip:from_number@via_addr>;tag=8jByBXa2pF1Fj To: <sip:to_number@ip_addr> Call-ID: 6a827514-c72b-1237-8aab-02a933b32da0 CSeq: 2070461 INVITE Server: XYZ Content-Length: 0 ------------------------------------------------------------------------
Callee from PBX throws auth challenge
recv 483 bytes from tls/[ip_addr]:5061 at 09:55:08.046934: ------------------------------------------------------------------------ SIP/2.0 407 Proxy Authentication Required Via: SIP/2.0/TLS via_addr:5080;received=via_addr;rport=59774;branch=z9hG4bK21Qm9U3eHX0Nc From: "from_number" <sip:from_number@via_addr>;tag=8jByBXa2pF1Fj To: <sip:to_number@ip_addr>;tag=f1cff938000510c1d9006e5a2a4e240b-5736 Call-ID: 6a827514-c72b-1237-8aab-02a933b32da0 CSeq: 2070461 INVITE Proxy-Authenticate: Digest realm="domain.com", nonce="XJSyI1yUsPf0w1bAocvH4IOCayfWt3bX", qop="auth" Content-Length: 0 ------------------------------------------------------------------------ send 387 bytes to tls/[ip_addr]:5061 at 09:55:08.047056: ------------------------------------------------------------------------ ACK sip:to_number@sometelco.com;transport=tls SIP/2.0 Via: SIP/2.0/TLS via_addr:5080;rport;branch=z9hG4bK21Qm9U3eHX0Nc Max-Forwards: 69 From: "from_number" <sip:from_number@via_addr>;tag=8jByBXa2pF1Fj To: <sip:to_number@ip_addr>;tag=f1cff938000510c1d9006e5a2a4e240b-5736 Call-ID: 6a827514-c72b-1237-8aab-02a933b32da0 CSeq: 2070461 ACK Content-Length: 0 ------------------------------------------------------------------------
Freeswitch IP PBX B2BUA acting as caller sends re-invite with auth details
Authenticating 'altanai' with 'Digest:"doamin.com":altanai:pass'. send 2273 bytes to tls/[ip_addr]:5061 at 09:55:08.047387: ------------------------------------------------------------------------ INVITE sip:to_number@sometelco.com;transport=tls SIP/2.0 Via: SIP/2.0/TLS via_addr:5080;rport;branch=z9hG4bK3aHDBQmje6p8Q Max-Forwards: 69 From: "from_number" <sip:from_number@via_addr>;tag=8jByBXa2pF1Fj To: <sip:to_number@ip_addr> Call-ID: 6a827514-c72b-1237-8aab-02a933b32da0 CSeq: 2070462 INVITE Contact: <sip:mod_sofia@via_addr:5080> User-Agent: FreeSWITCH-mod_sofia/1.9.0-742-8f1b7e0~64bit Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY Supported: timer, path, replaces Allow-Events: talk, hold, conference, refer Proxy-Authorization: Digest username="altanai", realm="domain.com", nonce="XJSyI1yUsPf0w1bAocvH4IOCayfWt3bX", cnonce="apLWcMcrEjerigKpM7MtoA", algorithm=MD5, uri="sip:to_number@sometelco.com;transport=tls", response="0044b00a4d5026252b32eed619d70f9d", qop=auth, nc=00000001 Content-Type: application/sdp Content-Disposition: session Content-Length: 1162 X-FS-Support: update_display,send_info Remote-Party-ID: "from_number" <sip:from_number@via_addr>;party=calling;screen=yes;privacy=off v=0 o=FreeSWITCH 1553228435 1553228436 IN IP4 via_addr s=FreeSWITCH c=IN IP4 via_addr t=0 0 m=audio 20072 RTP/SAVP 8 101 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-16 a=crypto:1 AEAD_AES_256_GCM_8 inline:ZbEHd76sP6FZSO9AYcqryybaA4HY3O5p2Uo+e1gmmfVaZCEic6cvKyArhMU a=crypto:2 AEAD_AES_128_GCM_8 inline:ePH/F2Qw5+zi8c7tkBb6Y2AQE5uevp+jWUkjgQ a=crypto:3 AES_CM_256_HMAC_SHA1_80 inline:SG5rYx3GSR2imutYQ+LzqHufG9UkG3n/SfmFHFOG/r75v2pwf2lG7Qpup+J0mw a=crypto:4 AES_CM_192_HMAC_SHA1_80 inline:2PVBBJEp4QcTzTf4Th8Ag/7KiVPmrYb/FCowiRb6yAuTO/kxQLc a=crypto:5 AES_CM_128_HMAC_SHA1_80 inline:Yd4L5Qi7A/8xay5ZHWR1jKk9j5Kvy9s2Zo3NOES2 a=crypto:6 AES_CM_256_HMAC_SHA1_32 inline:JI+s9uFdZ3JfZmRRfwHr0OrpyZdtUXmMC0WRIZow1EuXRB9xKFRBk6KmSWomqQ a=crypto:7 AES_CM_192_HMAC_SHA1_32 inline:5JzlrMywFZhHuNLWPG/HBrUi/Zcg414Q7ZfSaJQnUF5N9APy+GQ a=crypto:8 AES_CM_128_HMAC_SHA1_32 inline:/RLYPhZs07WCCBRY8tWNTJemT/IFq1VPHGHmGvnG a=crypto:9 AES_CM_128_NULL_AUTH inline:f2fx2ekxPG3GTwTYARtquNJ87qO0Q5ei47KYlo9K a=ptime:20 m=audio 20072 RTP/AVP 8 101 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-16 a=ptime:20 ------------------------------------------------------------------------ 2019-03-22 09:55:08.041945 [DEBUG] sofia.c:7291 Channel sofia/external/to_number@ip_addr entering state [calling][0] recv 365 bytes from tls/[ip_addr]:5061 at 09:55:08.048255: ------------------------------------------------------------------------ SIP/2.0 100 trying -- your call is important to us Via: SIP/2.0/TLS via_addr:5080;rport=59774;branch=z9hG4bK3aHDBQmje6p8Q;received=via_addr From: "from_number" <sip:from_number@via_addr>;tag=8jByBXa2pF1Fj To: <sip:to_number@ip_addr> Call-ID: 6a827514-c72b-1237-8aab-02a933b32da0 CSeq: 2070462 INVITE Server: XYZ Content-Length: 0 ------------------------------------------------------------------------
Call is accepted by callee, 200 OK is received by Freeswitch PBX
recv 1451 bytes from tls/[ip_addr]:5061 at 09:55:14.223460: ------------------------------------------------------------------------ SIP/2.0 200 OK Via: SIP/2.0/TLS via_addr:5080;received=via_addr;rport=59774;branch=z9hG4bK3aHDBQmje6p8Q Record-Route: <sip:ip_addr1:5060;lr;ftag=8jByBXa2pF1Fj> Record-Route: <sip:ip_addr2;lr;ftag=8jByBXa2pF1Fj;did=fd.0971> Record-Route: <sip:ip_addr:5060;r2=on;lr;ftag=8jByBXa2pF1Fj;nat=yes> Record-Route: <sip:ip_addr:5061;transport=tls;r2=on;lr;ftag=8jByBXa2pF1Fj;nat=yes> From: "from_number" <sip:from_number@via_addr>;tag=8jByBXa2pF1Fj To: <sip:to_number@ip_addr>;tag=D0r5K6pp80Ujm Call-ID: 6a827514-c72b-1237-8aab-02a933b32da0 CSeq: 2070462 INVITE Contact: <sip:to_number@34.201.27.78:5080;transport=udp> User-Agent: FreeSWITCH-mod_sofia/1.9.0-742-8f1b7e0~64bit Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY Supported: timer, path, replaces Allow-Events: talk, hold, conference, refer Content-Type: application/sdp Content-Disposition: session Content-Length: 380 Remote-Party-ID: "to_number" <sip:to_number@34.201.27.78>;party=calling;privacy=off;screen=no v=0 o=FreeSWITCH 1553215954 1553215955 IN IP4 <FS_IPADDR> s=FreeSWITCH c=IN IP4 <FS_IPADDR> t=0 0 m=audio 33516 RTP/SAVP 8 101 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-16 a=sendrecv a=crypto:3 AES_CM_256_HMAC_SHA1_80 inline:/itE1k5BLMoTNzo7YEv6hCyM6R6wyHem3Coc5jjYVlKR2L3tEzBG5zx1QHgVSg== a=ptime:20 m=audio 0 RTP/SAVP 19 a=rtpmap:19 ------------------------------------------------------------------------
send ACK to callee
Update Callee ID to "to_number" <to_number> Channel sofia/external/to_number@ip_addr entering state [completing][200] sofia.c:7301 Remote SDP: v=0 o=FreeSWITCH 1553215954 1553215955 IN IP4 <FS_IPADDR> s=FreeSWITCH c=IN IP4 <FS_IPADDR> t=0 0 m=audio 33516 RTP/SAVP 8 101 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-16 a=crypto:3 AES_CM_256_HMAC_SHA1_80 inline:/itE1k5BLMoTNzo7YEv6hCyM6R6wyHem3Coc5jjYVlKR2L3tEzBG5zx1QHgVSg== a=ptime:20 m=audio 0 RTP/SAVP 19 send 953 bytes to tls/[ip_addr]:5061 at 09:55:14.224320: ------------------------------------------------------------------------ ACK sip:to_number@34.201.27.78:5080;transport=udp SIP/2.0 Via: SIP/2.0/TLS via_addr:5080;rport;branch=z9hG4bK4Ka6cj5NBFDUK Route: <sip:ip_addr:5061;transport=tls;r2=on;lr;ftag=8jByBXa2pF1Fj;nat=yes> Route: <sip:ip_addr:5060;r2=on;lr;ftag=8jByBXa2pF1Fj;nat=yes> Route: <sip:ip_addr2;lr;ftag=8jByBXa2pF1Fj;did=fd.0971> Route: <sip:ip_addr3:5060;lr;ftag=8jByBXa2pF1Fj> Max-Forwards: 70 From: "from_number" <sip:from_number@via_addr>;tag=8jByBXa2pF1Fj To: <sip:to_number@ip_addr>;tag=D0r5K6pp80Ujm Call-ID: 6a827514-c72b-1237-8aab-02a933b32da0 CSeq: 2070462 ACK Contact: <sip:mod_sofia@via_addr:5080> Proxy-Authorization: Digest username="altanai", realm="domain.com", nonce="XJSyI1yUsPf0w1bAocvH4IOCayfWt3bX", cnonce="apLWcMcrEjerigKpM7MtoA", algorithm=MD5, uri="sip:to_number@sometelco.com;transport=tls", response="0044b00a4d5026252b32eed619d70f9d", qop=auth, nc=00000001 Content-Length: 0 ------------------------------------------------------------------------
set audio codecs, update call state CS_CONSUME_MEDIA -> CS_EXCHANGE_MEDIA
entering state [ready][200] looking for crypto suite [AEAD_AES_256_GCM_8] in [3 AES_CM_256_HMAC_SHA1_80 inline:/itE1k5BLMoTNzo7YEv6hCyM6R6wyHem3Coc5jjYVlKR2L3tEzBG5zx1QHgVSg==] looking for crypto suite [AEAD_AES_128_GCM_8] in [3 AES_CM_256_HMAC_SHA1_80 inline:/itE1k5BLMoTNzo7YEv6hCyM6R6wyHem3Coc5jjYVlKR2L3tEzBG5zx1QHgVSg==] looking for crypto suite [AES_CM_256_HMAC_SHA1_80] in [3 AES_CM_256_HMAC_SHA1_80 inline:/itE1k5BLMoTNzo7YEv6hCyM6R6wyHem3Coc5jjYVlKR2L3tEzBG5zx1QHgVSg==] Found suite AES_CM_256_HMAC_SHA1_80 Set Remote Key [3 AES_CM_256_HMAC_SHA1_80 inline:/itE1k5BLMoTNzo7YEv6hCyM6R6wyHem3Coc5jjYVlKR2L3tEzBG5zx1QHgVSg==] Audio Codec Compare [PCMA:8:8000:20:64000:1]/[PCMA:8:8000:20:64000:1] Audio Codec Compare [PCMA:8:8000:20:64000:1] ++++ is saved as a match Set telephone-event payload to 101@8000 Set Codec sofia/external/to_number@ip_addr PCMA/8000 20 ms 160 samples 64000 bits 1 channels sofia/external/to_number@ip_addr Original read codec set to PCMA:8 Set telephone-event payload to 101@8000 sofia/external/to_number@ip_addr Set 2833 dtmf send payload to 101 recv payload to 101 AUDIO RTP [sofia/external/to_number@ip_addr] 10.130.74.15 port 20072 -> <FS_IPADDR> port 33516 codec: 8 ms: 20 Starting timer [soft] 160 bytes per 20ms Set 2833 dtmf send payload to 101 Set 2833 dtmf receive payload to 101 Set rtp dtmf delay to 40 Activating audio Secure RTP SEND srtp:sdes:AES_CM_256_HMAC_SHA1_80 Activating audio Secure RTP RECV srtp:sdes:AES_CM_256_HMAC_SHA1_80 has been answered Callstate Change DOWN -> ACTIVE Audio Codec Compare [PCMA:8:8000:20:64000:1]/[PCMU:0:8000:20:64000:1] Audio Codec Compare [PCMA:8:8000:20:64000:1]/[PCMA:8:8000:20:64000:1] Audio Codec Compare [PCMA:8:8000:20:64000:1] ++++ is saved as a match Set telephone-event payload to 101@8000 Set Codec sofia/internal/from_number@sometelco.com:5060 PCMA/8000 20 ms 160 samples 64000 bits 1 channels sofia/internal/from_number@sometelco.com:5060 Original read codec set to PCMA:8 Set telephone-event payload to 101@8000 sofia/internal/from_number@sometelco.com:5060 Set 2833 dtmf send payload to 101 recv payload to 101
Send early media/ RTP to Callee
Pre-Answer sofia/internal/from_number@sometelco.com:5060! Callstate Change RINGING -> EARLY 2019-03-22 09:55:14.221933 [DEBUG] switch_core_media.c:8147 Audio params are unchanged for sofia/internal/from_number@sometelco.com:5060. 2019-03-22 09:55:14.221933 [DEBUG] mod_sofia.c:881 Local SDP sofia/internal/from_number@sometelco.com:5060: v=0 o=FreeSWITCH 1553219088 1553219089 IN IP4 via_addr s=FreeSWITCH c=IN IP4 via_addr t=0 0 m=audio 29426 RTP/AVP 8 101 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-16 a=ptime:20 sedn a=sendrecv
Send 200 OK to Caller
send 1254 bytes to tcp/[caller_ip]:35365 at 09:55:14.232934: ------------------------------------------------------------------------ SIP/2.0 200 OK Via: SIP/2.0/TCP 192.168.1.23:55934;branch=z9hG4bK-524287-1---cc11593581af6519;rport=35365;received=caller_ip From: "from_number"<sip:from_number@sometelco.com:5060>;tag=47a61272 To: <sip:to_number@sometelco.com:5060>;tag=NjvKFKQaHp52e Call-ID: 94385YTY3ODNlNzE1YjE5MmY4NmQ3ZWUyZDAzM2E0YzBkM2I CSeq: 1 INVITE Contact: <sip:to_number@via_addr:5060;transport=tcp> User-Agent: FreeSWITCH-mod_sofia/1.9.0-742-8f1b7e0~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 Session-Expires: 120;refresher=uas Content-Type: application/sdp Content-Disposition: session Content-Length: 220 Remote-Party-ID: "to_number" <sip:to_number@sometelco.com>;party=calling;privacy=off;screen=no v=0 o=FreeSWITCH 1553219088 1553219089 IN IP4 via_addr s=FreeSWITCH c=IN IP4 via_addr t=0 0 m=audio 29426 RTP/AVP 8 101 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-16 a=ptime:20 ------------------------------------------------------------------------ entering state [completed][200] Channel [sofia/internal/from_number@sometelco.com:5060] has been answered Callstate Change EARLY -> ACTIVE Originate Resulted in Success: [sofia/external/to_number@ip_addr] State Change CS_CONSUME_MEDIA -> CS_EXCHANGE_MEDIA Running State Change CS_EXCHANGE_MEDIA (Cur 2 Tot 275) State EXCHANGE_MEDIA SOFIA EXCHANGE_MEDIA
Receive ACK from Caller
recv 507 bytes from tcp/[caller_ip]:35365 at 09:55:14.459247: ------------------------------------------------------------------------ ACK sip:to_number@via_addr:5060;transport=tcp SIP/2.0 Via: SIP/2.0/TCP 192.168.1.23:55934;branch=z9hG4bK-524287-1---104aee5ed0b7ca66;rport Max-Forwards: 70 Contact: <sip:from_number@192.168.1.23:55934;transport=tcp> To: <sip:to_number@sometelco.com:5060>;tag=NjvKFKQaHp52e From: "from_number"<sip:from_number@sometelco.com:5060>;tag=47a61272 Call-ID: 94385YTY3ODNlNzE1YjE5MmY4NmQ3ZWUyZDAzM2E0YzBkM2I CSeq: 1 ACK User-Agent: X-Lite release 5.4.0 stamp 94385 Content-Length: 0 ------------------------------------------------------------------------
Sounds
apt-get install python-software-properties add-apt-repository ppa:freeswitch-drivers/freeswitch-nightly-drivers apt-get update apt-get install freeswitch freeswitch-lang-en freeswitch-sounds-en-us-callie-8000
User Registeration
List existing users
freeswitch@altanai-Inspiron-15-5578> list_users userid|context|domain|group|contact|callgroup|effective_caller_id_name|effective_caller_id_number 1000|default|192.168.0.121|default|error/user_not_registered|techsupport|Extension 1000|1000 1001|default|192.168.0.121|default|error/user_not_registered|techsupport|Extension 1001|1001
There are many ways to register users for call
1. Add users to be registered
Goto folder /usr/local/freeswitch/conf/directory/ and vim default.xml
<include> <!--the domain or ip (the right hand side of the @ in the addr--> <domain name="$${domain}"> ... <users> <user id="altanai"> <params> <param name="password" value="$${default_password}"/> <param name="vm-password" value="1000"/> </params> <variables> <variable name="toll_allow" value="domestic,international,local"/> <variable name="accountcode" value="987"/> <variable name="user_context" value="video-mcu-stereo"/> <variable name="effective_caller_id_name" value="altanai"/> <variable name="outbound_caller_id_name" value="altanai_outbound"/> </variables> </user> </users> .. </domain> </include>
2. Blind Registeration
Allow users to register with any username and password
Goto /usr/local/freeswitch/conf/sip_profiles/internal.xml and uncomment below snippet
<!-- this lets anything register --> <!-- comment the next line and uncomment one or both of the other 2 lines for call authentication --> <param name="accept-blind-reg" value="true"/> <!-- accept any authentication without actually checking (not a good feature for most people) --> <param name="accept-blind-auth" value="true"/>
3. Set a profile
Goto folder for freeswitch conf such as /usr/local/freeswitch/conf/directory/default
vim altanai.xml
and edit the variable
<include> <user id="altanai"> <params> <param name="password" value="$${default_password}"/> <param name="vm-password" value="6000"/> </params> <variables> <variable name="toll_allow" value="domestic,international,local"/> <variable name="accountcode" value="6000"/> <variable name="user_context" value="default"/> <variable name="effective_caller_id_name" value="Extension 6000"/> <variable name="effective_caller_id_number" value="6000"/> <variable name="outbound_caller_id_name" value="$${outbound_caller_name}"/> <variable name="outbound_caller_id_number" value="$${outbound_caller_id}"/> <variable name="callgroup" value="developer"/> </variables> </user> </include>
Rescan the profile
sofia profile internal rescan reloadxml
Log Levels
log <loglevel> and nolog are used to enable and disable logging
fs_ctl
fsctl loglevel alert
sofia level
sofia tracelevel [ console] [ alert] [ crit] [ err] [ warning] [ notice] [ info] [ debug]
References :
- [1] Freeswitch IP PBX
- [2] Asterisk IP PBX
- [3] Cisco IP PBX https://www.cisco.com/c/en/us/solutions/small-business/resource-center/collaboration/small-business-pbx.html#~ip-based-pbx
- XM User Directory Freeswitch : https://freeswitch.org/confluence/display/FREESWITCH/XML+User+Directory