Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slightly improve N5 Route, adding IBCF Prototype #404

Open
wants to merge 14 commits into
base: exp_5g_ims_pyhss
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ SRS_GNB_IP=172.22.0.37
# GRAFANA
GRAFANA_IP=172.22.0.39

# IBCF
IBCF_IP=172.22.0.140

# UE IPv4 Subnet Range for APN=internet
UE_IPV4_INTERNET=192.168.100.0/24

Expand Down
5 changes: 4 additions & 1 deletion dns/e164.arpa
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ $TTL 1h

; Wildcard to match any tel:+xxxx and change to sip:xxxx@IMS_DOMAIN
* IN NAPTR 10 100 "u" "E2U+sip" "!(^.*$)!sip:\\1@IMS_DOMAIN!" .
NUCLEAR-WAR marked this conversation as resolved.
Show resolved Hide resolved
* IN NAPTR 20 100 "u" "E2U+sip" "!(^.*$)!sip:+\\1@IMS_DOMAIN!" .
; Record to route calls starting with DE +49 to IBCF :
*.9.4 IN NAPTR 20 100 "u" "E2U+sip" "!(^.*$)!sip:\\[email protected]_DOMAIN!" .
; add more country codes to route over IBCF using the same format as above, you may need also to adjust the dialplan in Asterisk, e.g. for UK +44:
; *.4.4 IN NAPTR 20 100 "u" "E2U+sip" "!(^.*$)!sip:\\[email protected]_DOMAIN!" .
8 changes: 8 additions & 0 deletions dns/ims_zone
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@ hss 1D IN A PYHSS_IP
smsc 1D IN A SMSC_IP
_sip._udp.smsc 1D SRV 0 0 7090 smsc
_sip._tcp.smsc 1D SRV 0 0 7090 smsc

ibcf 1D IN A IBCF_IP
_sip._udp.ibcf 1D SRV 0 0 5090 ibcf
_sip._tcp.ibcf 1D SRV 0 0 5090 ibcf

voicemail 1D IN A IBCF_IP
_sip._udp.voicemail 1D SRV 0 0 5090 voicemail
_sip._tcp.voicemail 1D SRV 0 0 5090 voicemail
68 changes: 68 additions & 0 deletions ibcf/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# syntax=docker/dockerfile:1

FROM debian:bullseye
# Install required packages
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y \
lsb-release \
ca-certificates \
git \
vim \
wget \
curl \
openssh-server \
net-tools \
&& apt-get clean
RUN apt --no-install-recommends --assume-yes install unzip autoconf automake build-essential pkg-config libedit-dev libjansson-dev libsqlite3-dev uuid-dev libxslt1-dev xmlstarlet \
&& apt clean

# Download Asterisk source :
WORKDIR /usr/src
RUN git clone -b releases/22 https://github.com/asterisk/asterisk.git
# Adding EVS and AMR support
# First EVS
WORKDIR /usr/src/asterisk
# install additional DEBs required by Asterisk
RUN sh contrib/scripts/install_prereq install
RUN sh contrib/scripts/get_mp3_source.sh
RUN git clone https://github.com/NUCLEAR-WAR/asterisk-evs.git
RUN cp --verbose --recursive ./asterisk-evs*/* ./
RUN patch -p0 <./codec_evs.patch
RUN wget www.etsi.org/deliver/etsi_ts/126400_126499/126443/16.01.00_60/ts_126443v160100p0.zip
RUN unzip -qq ts_126443v*.zip
RUN unzip -qq 26443-*-ANSI-C_source_code.zip
WORKDIR /usr/src/asterisk/c-code
RUN chmod +r ./lib_*/*.h
RUN mkdir /usr/include/3gpp-evs
RUN cp --verbose --target-directory=/usr/include/3gpp-evs ./lib_*/*.h
RUN DEBUG=0 RELEASE=1 CFLAGS='-DNDEBUG -fPIC' make
WORKDIR /usr/src/asterisk/c-code/build
RUN rm ./decoder.o
RUN cc -shared -o lib3gpp-evs.so *.o
RUN cp ./lib3gpp-evs.so /usr/lib/
WORKDIR /usr/src/asterisk
RUN patch -p0 <./build_evs.patch
RUN patch -p0 <./force_limitations.patch

# Now AMR
RUN apt --assume-yes install libopencore-amrnb-dev libopencore-amrwb-dev libvo-amrwbenc-dev
RUN wget github.com/traud/asterisk-amr/archive/master.zip
RUN unzip -qq master.zip
RUN rm master.zip
RUN cp --verbose --recursive ./asterisk-amr*/* ./
RUN patch -p0 <./codec_amr.patch
RUN patch -p0 <./build_tools.patch

# Run the bootstrap script to re-generate configure files and configure patched Asterisk:
RUN ./bootstrap.sh
RUN ./configure
COPY menuselect.makedeps .
COPY menuselect.makeopts .
RUN make && make install

COPY config/* /etc/asterisk/

CMD ["/mnt/ibcf/start-asterisk.sh"]


5 changes: 5 additions & 0 deletions ibcf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This is a basic kind of IBCF based on Asterisk to handle calls from and to Docker_open5gs, I tried my best to do all the configs, but it still requires your adjustments.

Please read the Comments carefully before starting the container, specially in : pjsip.conf, acl.conf, extenteions.conf and voiemail.conf, those files must be configured otherwise the IBCF will not work properly!!

have fun Testing!
1 change: 1 addition & 0 deletions ibcf/config/acl.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[ibcf_acl]
13 changes: 13 additions & 0 deletions ibcf/config/asterisk.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[options]
; If we want to start Asterisk with a default verbosity for the verbose
; or debug logger channel types, then we use these settings (by default
; they are disabled).
;verbose = 5
;debug = 2

; User and group to run asterisk as. NOTE: This will require changes to
; directory and device permissions.
;runuser = asterisk ; The user to run as. The default is root.
;rungroup = asterisk ; The group to run as. The default is root

;defaultlanguage = es
7 changes: 7 additions & 0 deletions ibcf/config/cdr.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[general]
enable=yes

[custom]
; We log the unique ID as it can be useful for troubleshooting any issues
; that arise.
loguniqueid=yes
4 changes: 4 additions & 0 deletions ibcf/config/cdr_custom.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[mappings]
; Our CDR log will be written to /var/log/asterisk/cdr-custom/Master.csv
; with the following schema.
Master.csv => ${CSV_QUOTE(${CDR(clid)})},${CSV_QUOTE(${CDR(src)})},${CSV_QUOTE(${CDR(dst)})},${CSV_QUOTE(${CDR(dcontext)})},${CSV_QUOTE(${CDR(channel)})},${CSV_QUOTE(${CDR(dstchannel)})},${CSV_QUOTE(${CDR(lastapp)})},${CSV_QUOTE(${CDR(lastdata)})},${CSV_QUOTE(${CDR(start)})},${CSV_QUOTE(${CDR(answer)})},${CSV_QUOTE(${CDR(end)})},${CSV_QUOTE(${CDR(duration)})},${CSV_QUOTE(${CDR(billsec)})},${CSV_QUOTE(${CDR(disposition)})},${CSV_QUOTE(${CDR(amaflags)})},${CSV_QUOTE(${CDR(accountcode)})},${CSV_QUOTE(${CDR(uniqueid)})},${CSV_QUOTE(${CDR(userfield)})},${CDR(sequence)}
1 change: 1 addition & 0 deletions ibcf/config/confbridge.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; All conferences use default settings. This config must be present to load the confbridge application
176 changes: 176 additions & 0 deletions ibcf/config/extensions.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@

; extensions.conf - the Asterisk dial plan
;
; Static extension configuration file, used by
; the pbx_config module. This is where you configure all your
; inbound and outbound calls in Asterisk.
;
; This configuration file is reloaded
; - With the "dialplan reload" command in the CLI
; - With the "reload" command (that reloads everything) in the CLI

;
; The "General" category is for certain variables.
;
[general]
;
; If static is set to no, or omitted, then the pbx_config will rewrite
; this file when extensions are modified. Remember that all comments
; made in the file will be lost when that happens.
;
; XXX Not yet implemented XXX
;
static=yes
;
; if static=yes and writeprotect=no, you can save dialplan by
; CLI command "dialplan save" too
;
writeprotect=yes
;
; If autofallthrough is set, then if an extension runs out of
; things to do, it will terminate the call with BUSY, CONGESTION
; or HANGUP depending on Asterisk's best guess. This is the default.
;
; If autofallthrough is not set, then if an extension runs out of
; things to do, Asterisk will wait for a new extension to be dialed
; (this is the original behavior of Asterisk 1.0 and earlier).
;
;autofallthrough=no
;
;
;
; If extenpatternmatchnew is set (true, yes, etc), then a new algorithm that uses
; Trie
extenpatternmatchnew=no
;
; If clearglobalvars is set, global variables will be cleared
; and reparsed on a dialplan reload, or Asterisk reload.
;
; If clearglobalvars is not set, then global variables will persist
; through reloads, and even if deleted from the extensions.conf or
; one of its included files, will remain set to the previous value.
;
; NOTE: A complication sets in, if you put your global variables into
; the AEL file, instead of the extensions.conf file. With clearglobalvars
; set, a "reload" will often leave the globals vars cleared, because it
; is not unusual to have extensions.conf (which will have no globals)
; load after the extensions.ael file (where the global vars are stored).
; So, with "reload" in this particular situation, first the AEL file will
; clear and then set all the global vars, then, later, when the extensions.conf
; file is loaded, the global vars are all cleared, and then not set, because
; they are not stored in the extensions.conf file.
;
clearglobalvars=yes
;
; User context is where entries from users.conf are registered. The
; default value is 'default'
;


; Welcome to Asterisk Dialplan!! its not complicated, you will get use to it in just a "few" tries
userscontext=unspecified


; Here are some deffined variables that will be used in the dialplan, some of them must be adjusted to your need!

; I use a german Trunk so I have the +49, adjust depand on your country, this is used on incoming, as my provider sends only E164 numbers.
[globals]
INTERNAL_DIAL_OPT=,30
ENUM_PREFIX_FOR_DE=+49

; this this the head number, you need to change it to teh value provided by your providers, in consist of 10 digit, this is important as we will cut the number and normalize it before it enters the IMS Core, there is various names for Head number like : Direct dial in .. prefix numbers..etc so its basiclly the number from your SIPTrunk Provider that can be extended and add digits to it

PHONE_NR_HEAD=1234567890

; Dont change
ICP_OUT=ICP_LINK_out
ICP_IN=ims_core
; change to your provider's provided domain
SIPTRUNK_DOMAIN=PROVIDER_DOMAIN
; Dont change
IMS_CN_DOMAIN=IMS_DOMAIN
PAI_HEADER=P-Asserted-Identity
PPI_HEADER=P-Preferred-Identity
NO_FORK=Request-Disposition
P_HEADER=P-Early-Media
X_HEADER=P-MeinSipTrunk

; now the dial plan, here is an explnination so you can adjust what you need to make it able to proccess calls and send it to and from teh IMS Core
NUCLEAR-WAR marked this conversation as resolved.
Show resolved Hide resolved
; in "incoming" in my case i used an internal MSISDN for my open5GS Netwrok 0912584710 as you see this is a private self generated number.
; in normal world there is a shared Database for all operator so they know that a numer belong to a specific operator, in our case the netwrok is private and our
; numbers are unknown to teh wolrd, so I had to do a trick, this trick consist of the head numer provided from my SIPTrunk provider adding the UE MSISDN to it liek that:
; CC+HEADER_NUMER+MSSIDN = +49 228 1234567 0912584710 and then cut or add the CC+HEADER_NUMER depanding on the direction :
; to IMS Core cute CC+HEADER_NUMER, if to outside world then add CC+HEADER_NUMER
; this is using the ${EXTEN:n} "n" is where the digit that need to stay along with the digits the come after it. in my case its the 0, so the results will be 0912584710 that will
; be recognized insdie my private network, this need to be adjusted depand on the your needs like the lenth of your Head number and your MSISDN.
; after doing that we need to send the call to the ICSCF as we dont know where the user is registred, the rest will be done insdie the IMS Core+Open5GS
;
; its preconfigured here on digit 13 ( UK users please change it! not to trigger any bad luck!)


[incoming]

; +49 228 1234567 + any
exten => _${ENUM_PREFIX_FOR_DE}${PHONE_NR_HEAD}X.,1,Verbose(incoming call from ICP from ${CALLERID(num)} calling to ${EXTEN:13})
same => n,Verbose(check for exten ${EXTEN} 8 ${EXTEN:8} 9 ${EXTEN:9} 10 ${EXTEN:10} 11 ${EXTEN:11} 13 ${EXTEN:13} )
; cutting until digi 13 CUT0912584710 set some headers and send to icscf to reach the users
same => n,Dial(PJSIP/${ICP_IN}/sip:${EXTEN:13}@${IMS_CN_DOMAIN},120,b(outgoing^ims_inc^1))
same => n,Hangup()

[outgoing]

; Due to diffrent way that the devices do calls there is two way defined here eather the call will start with 0 ( in teh IMS is not possbile) or with +

; here is with 0, its not applicale, our IMS is 3gpp compitable so it has always E164
exten => _0X.,1,Verbose(outgoing conext leading null ${EXTEN} calling from IMS User ${CALLERID(num)} )
same => n,Dial(PJSIP/${ICP_OUT}/sip:${ENUM_PREFIX_FOR_DE}${EXTEN:1}@${SIPTRUNK_DOMAIN},120,b(outgoing^headers^1))
same => n,Hangup()


; here is the used one as we use E164 in IMS
exten => _${ENUM_PREFIX_FOR_DE}X.,1,Verbose(outgoing Call leading +49 calling from IMS User ${CALLERID(num)} to ${EXTEN} )
same => n,Verbose(Sending INVITE to ICP)
; we set the head number and add the MSISDN to it then set it in the "From" header
same => n,Set(CALLERID(num)=${ENUM_PREFIX_FOR_DE}${PHONE_NR_HEAD}${CALLERID(num)})
; setting some headers and sends the INVITE to the Provdier/ICP
same => n,Dial(PJSIP/${ICP_OUT}/sip:${EXTEN}@${SIPTRUNK_DOMAIN},120,b(outgoing^ims_out^1))
same => n,Hangup()

; this headers used in outgoing
exten => ims_out,1,Verbose(Setting required headers in outgoing INVITE)
; setting the P-Preferred-Identity and optionally P-Preferred-Identity ( PAI is only a Networ thing) here we do the the as we done with From:
; adding the MSISDN ot the head number before sending it out.
same => n,Set(PJSIP_HEADER(add,${PPI_HEADER})=<sip:${ENUM_PREFIX_FOR_DE}${PHONE_NR_HEAD}${CONNECTEDLINE(num)}@${SIPTRUNK_DOMAIN}>)
same => n,Set(PJSIP_HEADER(add,${PAI_HEADER})=<sip:${ENUM_PREFIX_FOR_DE}${PHONE_NR_HEAD}${CONNECTEDLINE(num)}@${SIPTRUNK_DOMAIN}>)
; Setting P-Early-Media to Supported, Asterisk know nothing about RFC5009, but its required by 3GPP, so we can only cheat here sorry!
same => n,Set(PJSIP_HEADER(add,${P_HEADER})=Supported)
same => n,Set(PJSIP_HEADER(add,Supported)=199)
same => n,Return()

; for incoming we need to set the PAI, some devices need this header
exten => ims_inc,1,Verbose(Setting required headers in incoming INVITE)
same => n,Set(PJSIP_HEADER(add,${PAI_HEADER})=<tel:${CONNECTEDLINE(num)}>)
same => n,Set(PJSIP_HEADER(add,${PAI_HEADER})=<sip:${CONNECTEDLINE(num)}@${IMS_CN_DOMAIN}>)
same => n,Set(PJSIP_HEADER(add,${P_HEADER})=Supported)
same => n,Set(PJSIP_HEADER(add,Supported)=199)
same => n,Return()

[IMS_INC]

include => outgoing

;;;;;;; Voicemail IMS, this is a WIP, need to add appreciate IFC for it, dont forget to confgure your MSISDN in the voicemail.conf!!

; configure teh start of your number instaed of "09125" eg. if your MSISDN start with 09125123456 then exten => _09125X.
exten => _09125X.,1,Verbose(1, Caller ${CALLERID(all)} has entered Voicemail for ${EXTEN} from IMS )
same => n,VoiceMail(${EXTEN})

exten => 500,1,Ringing()
exten => 500,n,Wait(2)
exten => 500,n,Answer
exten => 500,n,Wait(2)
exten => 500,n,VoiceMailMain(${CALLERID(num)})
exten => 500,n,HangUp()
exten => 500,n,PlayBack(vm-goodbye)
exten => 500,n,HangUp()

21 changes: 21 additions & 0 deletions ibcf/config/indications.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[general]
country = de

[de]
description = Germany
; Reference: http://www.itu.int/ITU-T/inr/forms/files/tones-0203.pdf
ringcadence = 1000,4000
dial = 425
busy = 425/480,0/480
ring = 425/1000,0/4000
congestion = 425/240,0/240
callwaiting = !425/200,!0/200,!425/200,!0/5000,!425/200,!0/200,!425/200,!0/5000,!425/200,!0/200,!425/200,!0/5000,!425/200,!0/200,!425/200,!0/5000,!425/200,!0/200,!425/200,0
; DIALRECALL - not specified
dialrecall = !425/100,!0/100,!425/100,!0/100,!425/100,!0/100,425
; RECORDTONE - not specified
record = 1400/80,0/15000
info = 950/330,1400/330,1800/330,0/1000
stutter = 425+400

; Additional country configurations can be found in the Asterisk source
; at /configs/samples/indications.conf.sample
9 changes: 9 additions & 0 deletions ibcf/config/logger.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[general]

[logfiles]

console = verbose,notice,warning,error

;messages = notice,warning,error
;full = verbose,notice,warning,error,debug
;security = security
Loading