Moved from nextepc to open5gs

This commit is contained in:
Supreeth Herle
2020-02-10 13:46:55 +01:00
parent e20a9c55a0
commit 61b0c6befa
21 changed files with 734 additions and 588 deletions

View File

@@ -1,52 +1,68 @@
# docker_nextepc
Docker files to build and run NextEPC in a docker
# docker_open5gs
Docker files to build and run open5gs in a docker
## Build Instructions
## Build and Execution Instructions
* Mandatory requirements:
* docker-ce - https://docs.docker.com/install/linux/docker-ce/ubuntu/
* [docker-ce](https://docs.docker.com/install/linux/docker-ce)
* [docker-compose](https://docs.docker.com/compose)
Download and build docker image of NextEPC:
```
cd ~ && git clone https://github.com/herlesupreeth/docker_nextepc
cd docker_nextepc/nextepc
docker build --force-rm -t nextepc:v0.1 .
Clone repository and build docker image of open5gs:
```
cd ~ && git clone https://github.com/herlesupreeth/docker_open5gs
## Execution Instructions
# Compile open5gs base image
cd docker_open5gs/base
docker build --force-rm -t open5gs:v0.1 .
```
cd ~/docker_nextepc/nextepc
docker run --rm -it --cap-add=NET_ADMIN --env-file=docker_env --name epc --net=host --device /dev/net/tun --sysctl net.ipv4.ip_forward=1 nextepc:v0.1
```
# Create EPC Network
docker network create --subnet=172.18.0.0/16 epc_net
###### Notes
- --net=host is required in order to allow binding of ports in the container
- The container requires NET_ADMIN permission in order to create a tun interface
# HSS
cd ../hss
docker build --force-rm -t hss:v0.1 .
docker run -dit -v "$(pwd)":/mnt/hss -p 3000:3000 -e MME_IP='172.18.0.3' --net epc_net --ip 172.18.0.2 --name hss hss:v0.1
# PCRF
cd ../pcrf
docker build --force-rm -t pcrf:v0.1 .
docker run -dit -v "$(pwd)":/mnt/pcrf -e PGW_IP='172.18.0.5' -e HSS_IP='172.18.0.2' --net epc_net --ip 172.18.0.6 --name pcrf pcrf:v0.1
# SGW
cd ../sgw
docker build --force-rm -t sgw:v0.1 .
docker run -dit -v "$(pwd)":/mnt/sgw -p 2152:2152/udp --net epc_net --ip 172.18.0.4 --name sgw sgw:v0.1
# PGW
cd ../pgw
docker build --force-rm -t pgw:v0.1 .
docker run -dit -v "$(pwd)":/mnt/pgw --cap-add=NET_ADMIN --device /dev/net/tun -e PCRF_IP='172.18.0.6' --sysctl net.ipv4.ip_forward=1 --net epc_net --ip 172.18.0.5 --name pgw pgw:v0.1
# MME
cd ../mme
docker build --force-rm -t mme:v0.1 .
docker run -dit -v "$(pwd)":/mnt/mme -p 36412:36412/sctp -e HSS_IP='172.18.0.2' -e SGW_IP='172.18.0.4' -e PGW_IP='172.18.0.5' --net epc_net --ip 172.18.0.3 --name mme mme:v0.1
```
## Configuration
The following parameters can be modified in 'docker_env' file before running 'docker run' command to suit your Core Network deployment
* MCC - Mobile Country Code
* MNC - Mobile Network Code
* TAC1 - Tracking Area Code
* EPC_IF - Network Interface name to bind SGW and MME
The configuration files for each of the Core Network component can be found under their respective folder. Edit the .yaml files of the components before deploying each of the container
## Register a UE information
Open (http://localhost:3000) in a web browser on the machine/VM running the NextEPC docker image. Login with following credentials
Open (http://<DOCKER_HOST_IP>:3000) in a web browser, where <DOCKER_HOST_IP> is the IP of the machine/VM running the open5gs containers. Login with following credentials
```
Username : admin
Password : 1423
```
Using Web UI, you can add a subscriber as follows.
```
- Go to Subscriber Menu
- Click `+` Button to add a new subscriber
- Fill the IMSI, security context(K, OPc, AMF), and APN of the subscriber
- Click `SAVE` Button
```
This addition is applied immediately without restarting any NextEPC daemon
Using Web UI, add a subscriber
## eNB settings
On the eNB, make sure to have the static route to SGW container (since internal IP of the SGW container is advertised in S1AP messages and UE wont find the core in Uplink)
$ ip r add <SGW_CONTAINER_IP> via <DOCKER_HOST_IP>
## Not supported
- IPv6 usage in Docker

49
base/Dockerfile Normal file
View File

@@ -0,0 +1,49 @@
# BSD 2-Clause License
# Copyright (c) 2019, Supreeth Herle
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
FROM ubuntu:bionic
# Install updates and dependencies
RUN apt-get update && \
apt-get -y install python3-pip python3-setuptools python3-wheel ninja-build \
build-essential flex bison git libsctp-dev libgnutls28-dev \
libgcrypt-dev libssl-dev libidn11-dev libmongoc-dev libbson-dev \
libyaml-dev meson vim ifupdown mongodb curl gnupg gdb iptables net-tools \
iputils-ping
RUN pip3 install click
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - && apt-get install -y nodejs && \
apt-get autoremove -y && apt-get clean
# Get open5gs code and install
RUN git clone --recursive https://github.com/open5gs/open5gs && cd open5gs && \
git checkout tags/v1.2.1 && meson build --prefix=`pwd`/install && \
ninja -C build && cd build && ninja install
# Set the working directory to open5gs
WORKDIR open5gs
# Building WebUI of open5gs
RUN cd webui && npm install

45
hss/Dockerfile Normal file
View File

@@ -0,0 +1,45 @@
# BSD 2-Clause License
# Copyright (c) 2019, Supreeth Herle
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
FROM open5gs:v0.1
# Expose port 3868 for Diameter queries
EXPOSE 3868/udp
EXPOSE 3868/tcp
EXPOSE 3868/sctp
EXPOSE 5868/udp
EXPOSE 5868/tcp
EXPOSE 5868/sctp
# Expose port 3000 Web UI of HSS
EXPOSE 3000/tcp
# Expose port 27017 for Mongodb queries
EXPOSE 27017/udp
EXPOSE 27017/tcp
CMD /mnt/hss/hss_init.sh && \
cd install/bin && sleep 20 && ./open5gs-hssd

29
hss/hss.yaml Normal file
View File

@@ -0,0 +1,29 @@
db_uri: mongodb://localhost/open5gs
logger:
file: /open5gs/install/var/log/open5gs/hss.log
parameter:
no_ipv6: true
prefer_ipv4: true
hss:
freeDiameter:
identity: hss.epc.mnc001.mcc001.3gppnetwork.org
realm: epc.mnc001.mcc001.3gppnetwork.org
port: 3868
sec_port: 5868
listen_on: HSS_IP
load_extension:
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dbg_msg_dumps.fdx
conf: 0x8888
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_rfc5777.fdx
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_mip6i.fdx
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_nasreq.fdx
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_nas_mipv6.fdx
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_dcca.fdx
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_dcca_3gpp.fdx
connect:
- identity: mme.epc.mnc001.mcc001.3gppnetwork.org
addr: MME_IP
port: 3868

37
hss/hss_init.sh Executable file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
# BSD 2-Clause License
# Copyright (c) 2019, Supreeth Herle
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mongod --smallfiles --dbpath /var/lib/mongodb --logpath /var/log/mongodb/mongodb.log --bind_ip 0.0.0.0 &
cd webui && npm run dev &
export IP_ADDR=$(awk 'END{print $1}' /etc/hosts)
cp /mnt/hss/hss.yaml install/etc/open5gs
sed -i 's|HSS_IP|'$IP_ADDR'|g' install/etc/open5gs/hss.yaml
sed -i 's|MME_IP|'$MME_IP'|g' install/etc/open5gs/hss.yaml

41
mme/Dockerfile Normal file
View File

@@ -0,0 +1,41 @@
# BSD 2-Clause License
# Copyright (c) 2019, Supreeth Herle
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
FROM open5gs:v0.1
# Expose port 3868 for Diameter queries
EXPOSE 3868/udp
EXPOSE 3868/tcp
EXPOSE 3868/sctp
EXPOSE 5868/udp
EXPOSE 5868/tcp
EXPOSE 5868/sctp
# Expose port 36412
EXPOSE 36412/sctp
CMD /mnt/mme/mme_init.sh && \
cd install/bin && ./open5gs-mmed

55
mme/mme.yaml Normal file
View File

@@ -0,0 +1,55 @@
logger:
file: /open5gs/install/var/log/open5gs/mme.log
parameter:
no_ipv6: true
prefer_ipv4: true
mme:
freeDiameter:
identity: mme.epc.mnc001.mcc001.3gppnetwork.org
realm: epc.mnc001.mcc001.3gppnetwork.org
port: 3868
sec_port: 5868
listen_on: MME_IP
load_extension:
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dbg_msg_dumps.fdx
conf: 0x8888
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_rfc5777.fdx
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_mip6i.fdx
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_nasreq.fdx
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_nas_mipv6.fdx
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_dcca.fdx
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_dcca_3gpp.fdx
connect:
- identity: hss.epc.mnc001.mcc001.3gppnetwork.org
addr: HSS_IP
port: 3868
s1ap:
dev: MME_IF
gtpc:
dev: MME_IF
gummei:
plmn_id:
mcc: 001
mnc: 01
mme_gid: 2
mme_code: 1
tai:
plmn_id:
mcc: 001
mnc: 01
tac: 1
security:
integrity_order : [ EIA1, EIA2, EIA0 ]
ciphering_order : [ EEA0, EEA1, EEA2 ]
network_name:
full: Open5GS
sgw:
gtpc:
addr: SGW_IP
pgw:
gtpc:
addr: PGW_IP

38
mme/mme_init.sh Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/bash
# BSD 2-Clause License
# Copyright (c) 2019, Supreeth Herle
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
export IP_ADDR=$(awk 'END{print $1}' /etc/hosts)
export IF_NAME=$(ip r | awk '/default/ { print $5 }')
cp /mnt/mme/mme.yaml install/etc/open5gs
sed -i 's|MME_IP|'$IP_ADDR'|g' install/etc/open5gs/mme.yaml
sed -i 's|MME_IF|'$IF_NAME'|g' install/etc/open5gs/mme.yaml
sed -i 's|HSS_IP|'$HSS_IP'|g' install/etc/open5gs/mme.yaml
sed -i 's|SGW_IP|'$SGW_IP'|g' install/etc/open5gs/mme.yaml
sed -i 's|PGW_IP|'$PGW_IP'|g' install/etc/open5gs/mme.yaml

View File

@@ -1,75 +0,0 @@
# BSD 2-Clause License
# Copyright (c) 2019, Supreeth Herle
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
FROM ubuntu:bionic
# Install updates and dependencies
RUN apt-get -y update && apt-get upgrade -y && \
apt-get -y install autoconf libtool gcc pkg-config git flex bison libsctp-dev \
libgnutls28-dev libgcrypt-dev libssl-dev libidn11-dev libmongoc-dev \
libbson-dev libyaml-dev vim ifupdown mongodb curl gnupg gdb iptables
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - && apt-get install -y nodejs && \
apt-get autoremove -y && apt-get clean
# Get NextEPC code and install
RUN git clone --recursive https://github.com/open5gs/nextepc && cd nextepc && \
git checkout tags/v0.4.4 && autoreconf -iv && \
./configure --prefix=`pwd`/install && make -j `nproc` && make install
# Set appropriate configuration file changes
# Set the working directory to nextepc
WORKDIR nextepc
# Building WebUI of NextEPC
RUN cd webui && npm install
# Copy the sample configuration file and script to modify conf file
COPY nextepc.conf mod_conf.sh install/etc/nextepc/
# Set the basic parameters of the EPC. In order to change these parameters at runtime,
# alter these parameters in file 'docker_env'
ENV MCC=001 \
MNC=01 \
TAC1=1 \
EPC_IF=enp0s3
# Create tun interface and assign IP address range of UEs
# Run mongodb server
# Run WebUI
# Set iptables for routing internet traffic out of docker
# Sleep for 20 sec (Wait for mongodb to be ready) and Run NextEPC all-in-one configuration
CMD cd install/etc/nextepc && ./mod_conf.sh && \
mongod --smallfiles --dbpath /var/lib/mongodb --logpath /var/log/mongodb/mongodb.log & \
cd webui && npm run dev & \
if ! iptables-save | grep -- "-A INPUT -i pgwtun -j ACCEPT" ; then iptables -A INPUT -i pgwtun -j ACCEPT; fi && \
if ! iptables-save | grep -- "-A POSTROUTING -s 45.45.0.0/16 ! -o pgwtun -j MASQUERADE" ; then iptables -t nat -A POSTROUTING -s 45.45.0.0/16 ! -o pgwtun -j MASQUERADE; fi && \
if ls /sys/class/net | grep "pgwtun" ; then ip link delete pgwtun; fi && \
ip tuntap add name pgwtun mode tun && ip addr add 45.45.0.1/16 dev pgwtun && \
ip link set dev pgwtun mtu 1400 && \
ip addr add cafe::1/64 dev pgwtun && ip link set pgwtun up && \
sleep 20 && ./nextepc-epcd

View File

@@ -1,4 +0,0 @@
MCC=262
MNC=96
TAC1=1
EPC_IF=enp0s3

View File

@@ -1,472 +0,0 @@
db_uri: mongodb://localhost/nextepc
logger:
file: /nextepc/install/var/log/nextepc/nextepc.log
#
# o Set OGS_LOG_INFO to all domain level
# - If `level` is omitted, the default level is OGS_LOG_INFO)
# - If `domain` is omitted, the all domain level is set from 'level'
# (Nothing is needed)
#
# o Set OGS_LOG_ERROR to all domain level
# - `level` can be set with none, fatal, error, warn, info, debug, trace
# level: error
#
# o Set OGS_LOG_DEBUG to mme/emm domain level
# level: debug
# domain: mme,emm
#
# o Set OGS_LOG_TRACE to all domain level
# level: trace
# domain: core,s1ap,nas,fd,gtp,mme,emm,esm,sgw,pgw,hss,pcrf,event,tlv,mem,sock
#
#
# parameter:
#
# o Number of output streams per SCTP associations.
# sctp_streams: 30
#
# o Disable use of IPv4 addresses (only IPv6)
# no_ipv4: true
#
# o Disable use of IPv6 addresses (only IPv4)
# no_ipv6: true
#
# o Prefer IPv4 instead of IPv6 for estabishing new GTP connections.
# prefer_ipv4: true
#
# o Enable Multicast traffic to the UE
# multicast: true
#
# o Disable Stateless Address Autoconfiguration for IPv6
# no_slaac: true
#
#
parameter:
no_ipv6: true
#
# sctp:
#
# o heartbit_interval : 5000 (5secs)
# o rto_initial : 3000 (3secs)
# o rto_min : 1000 (1sec)
# o rto_max : 5000 (5secs)
# o max_num_of_ostreams : 30
# o max_num_of_istreams : 65535
# o max_attempts : 4
# o max_initial_timeout : 8000(8secs)
# o usrsctp_udp_port : 9899
sctp:
#
# max:
#
# o Maximum Number of SGW per MME
# sgw: 32
# o Maximum Number of PGW per MME
# pgw: 32
# o Maximum Number of VLR per MME
# vlr: 32
# o Maximum Number of eNodeB per MME
# enb: 32
# o Maximum Number of UE per eNodeB
# ue: 128
#
# o Memory of Packet Buffering in SGW
# - Maximum Number of packet(SDU size = 8Kbytes) pool in SGW
# - SGW Memory Usage : 65536 * 8Kbytes = 512Mbytes
# packet:
# pool: 65536
max:
mme:
freeDiameter: mme.conf
#
# <S1AP Server>>
#
# o S1AP Server(all address avaiable)
# s1ap:
#
# o S1AP Server(0.0.0.0:36412)
# s1ap:
# addr: 0.0.0.0
#
# o S1AP Server(127.0.0.1:36412, [::1]:36412)
# s1ap:
# - addr: 127.0.0.1
# - addr: ::1
# o S1AP Server(different port)
# s1ap:
# - addr: 127.0.0.1
# port: 36413
#
# o S1AP Server(address avaiable in `eth0` interface)
# s1ap:
# dev: eth0
#
s1ap:
dev: EPC_IF
#
# <GTP-C Server>>
#
# o GTP-C Server(all address avaiable)
# gtpc:
#
# o GTP-C Server(127.0.0.1:2123, [::1]:2123)
# gtpc:
# - addr: 127.0.0.1
# - addr: ::1
#
gtpc:
dev: EPC_IF
#
# <sgsap>
#
# o Single MSC/VLR(127.0.0.2:29119)
# sgsap:
# addr: 127.0.0.2
# port: 29119
# plmn_id:
# mcc: 001
# mnc: 01
# tac: 4130
# lac: 43690
#
# o Multiple MSC/VLR
# sgsap:
# - addr: 127.0.0.2
# plmn_id:
# mcc: 001
# mnc: 01
# tac: 4131
# lac: 43692
# - addr
# - 127.0.0.3
# - fe80::2%lo0
# plmn_id:
# mcc: 001
# mnc: 01
# tac: 4132
# lac: 43692
# - name: msc.open5gs.org
# plmn_id:
# mcc: 001
# mnc: 01
# tac: 4133
# lac: 43693
#
sgsap:
#
# <GUMMEI>
#
# o Multiple GUMMEI
# gummei:
# - plmn_id:
# mcc: 001
# mnc: 01
# mme_gid: 2
# mme_code: 1
# - plmn_id:
# - mcc: 002
# mnc: 02
# - mcc: 003
# mnc: 03
# mme_gid: [3, 4]
# mme_code:
# - 2
# - 3
#
gummei:
plmn_id:
mcc: MCC
mnc: MNC
mme_gid: 2
mme_code: 1
#
# <TAI>
#
# o Multiple TAI
# tai:
# - plmn_id:
# mcc: 001
# mnc: 01
# tac: [1, 2, 3]
# tai:
# - plmn_id:
# mcc: 002
# mnc: 02
# tac: 4
# - plmn_id:
# mcc: 003
# mnc: 03
# tac: 5
# tai:
# - plmn_id:
# mcc: 004
# mnc: 04
# tac: [6, 7]
# - plmn_id:
# mcc: 005
# mnc: 05
# tac: 8
# - plmn_id:
# mcc: 006
# mnc: 06
# tac: [9, 10]
#
tai:
plmn_id:
mcc: MCC
mnc: MNC
tac: TAC1
security:
integrity_order : [ EIA1, EIA2, EIA0 ]
ciphering_order : [ EEA0, EEA1, EEA2 ]
#
# <Network Name>
# network_name:
# full: NextEPC
# short: Next
#
network_name:
full: NextEPC
hss:
freeDiameter: hss.conf
sgw:
#
# ------------------------ MME --------------------------
#
# o Specify SGW addresses the GTP-C must connect to
#
# o One SGW is defined. If prefer_ipv4 is not true, [fe80::2%@LO_DEV@] is selected.
# gtpc:
# addr:
# - 127.0.0.2
# - fe80::2%@LO_DEV@
#
# o Two SGW are defined. MME selects SGW with round-robin manner per UE
# gtpc:
# - addr: 127.0.0.2
# - addr: fe80::2%@LO_DEV@
#
# o Three SGW are defined. MME selects SGW with round-robin manner per UE
# gtpc:
# - addr
# - 127.0.0.2
# - fe80::2%@LO_DEV@
# - addr
# - 127.0.0.12
# - fe80::12%@LO_DEV@
# - name: sgw3.nextepc.org
#
# ------------------------ SGW --------------------------
#
# o GTP-C Server(127.0.0.2:2123, [fe80::2%@LO_DEV@]:2123)
# gtpc:
# addr:
# - 127.0.0.2
# - fe80::2%@LO_DEV@
#
# o On SGW, Same Configuration(127.0.0.2:2123, [fe80::2%@LO_DEV@]:2123) as below.
# gtpc:
# - addr: 127.0.0.2
# - addr: fe80::2%@LO_DEV@
#
gtpc:
addr: 127.0.0.2
#
# <SGW Selection Mode>
#
# o Round-Robin
# (If `selection_mode` is omitted, the default mode is Round-Robin)
#
# selection_mode: rr
# gtpc:
# addr: 127.0.0.2
# addr: 127.0.2.2
# addr: 127.0.4.2
#
# o SGW selection by eNodeB TAC
#
# selection_mode: tac
# gtpc:
# - addr: 127.0.0.2
# tac: 26000
# - addr: 127.0.2.2
# tac: [25000, 27000, 28000]
#
#
# <GTP-U Server>
#
# o GTP-U Server(all address avaiable)
# gtpu:
#
gtpu:
dev: EPC_IF
pgw:
freeDiameter: pgw.conf
#
# ------------------------ MME --------------------------
#
# o By default, the PGW uses the first PGW node.
# - To use a different APN for each PGW, specify gtpc.apn as the APN name.
# - If the HSS uses WebUI to set the PGW IP for eacho UE,
# you can use a specific PGW node for each UE.
#
# o Two PGW are defined. 127.0.0.3:2123 is used.
# [fe80::3%@LO_DEV@]:2123 is ignored.
# gtpc:
# - addr: 127.0.0.3
# - addr: fe80::3%@LO_DEV@
#
# o One PGW is defined. if prefer_ipv4 is not true,
# [fe80::3%@LO_DEV@] is selected.
# gtpc:
# - addr:
# - 127.0.0.3
# - fe80::3%@LO_DEV@
#
# o Two PGW are defined with a different APN.
# - Note that if PGW IP for UE is configured in HSS,
# the following configurion for this UE is ignored.
# gtpc:
# - addr: 127.0.0.3
# apn: internet
# - addr: 127.0.0.5
# apn: volte
#
# o If APN is omitted, the default APN uses the first PGW node.
# gtpc:
# - addr: 127.0.0.3
# - addr: 127.0.0.5
# apn: volte
# ------------------------ PGW --------------------------
#
# o GTP-C Server(127.0.0.3:2123, [fe80::3%@LO_DEV@]:2123)
# gtpc:
# addr:
# - 127.0.0.3
# - fe80::3%@LO_DEV@
#
# o On PGW, Same configuration(127.0.0.3:2123, [fe80::3%@LO_DEV@]:2123).
# gtpc:
# - addr: 127.0.0.3
# - addr: fe80::3%@LO_DEV@
#
gtpc:
addr:
- 127.0.0.3
- ::1
#
# <GTP-U Server>>
#
# o GTP-U Server(127.0.0.3:2152, [::1]:2152)
# gtpu:
# - addr: 127.0.0.3
# - addr: ::1
#
# o Same configuration(127.0.0.3:2152, [::1]:2152) as below.
# gtpu:
# name: localhost
#
gtpu:
- addr: 127.0.0.3
- addr: ::1
#
# <UE Pool>
#
# o IPv4 Pool
# $ sudo ip addr add 45.45.0.1/16 dev pgwtun
#
# ue_pool:
# addr: 45.45.0.1/16
#
# o IPv4/IPv6 Pool
# $ sudo ip addr add 45.45.0.1/16 dev pgwtun
# $ sudo ip addr add cafe:1::1/64 dev pgwtun
#
# ue_pool:
# - addr: 45.45.0.1/16
# - addr: cafe:1::1/64
#
#
# o Specific APN(e.g 'volte') uses 45.46.0.1/16, cafe:2::1/64
# All other APNs use 45.45.0.1/16, cafe:1::1/64
# $ sudo ip addr add 45.45.0.1/16 dev pgwtun
# $ sudo ip addr add 45.46.0.1/16 dev pgwtun
# $ sudo ip addr add cafe:1::1/64 dev pgwtun
# $ sudo ip addr add cafe:2::1/64 dev pgwtun
#
# ue_pool:
# - addr: 45.45.0.1/16
# - addr: cafe:1::1/64
# - addr: 45.46.0.1/16
# apn: volte
# - addr: cafe:2::1/64
# apn: volte
#
# o Multiple Devices (default: pgwtun)
# $ sudo ip addr add 45.45.0.1/16 dev pgwtun
# $ sudo ip addr add cafe:1::1/64 dev pgwtun2
# $ sudo ip addr add 45.46.0.1/16 dev pgwtun3
# $ sudo ip addr add cafe:2::1/64 dev pgwtun3
#
# ue_pool:
# - addr: 45.45.0.1/16
# - addr: cafe:1::1/64
# dev: pgwtun2
# - addr: 45.46.0.1/16
# apn: volte
# dev: pgwtun3
# - addr: cafe:2::1/64
# apn: volte
# dev: pgwtun3
#
ue_pool:
- addr: 45.45.0.1/16
- addr: cafe::1/64
#
# <Domain Name Server>
#
# o Primary/Secondary can be configured. Others are ignored.
#
dns:
- 8.8.8.8
- 8.8.4.4
- 2001:4860:4860::8888
- 2001:4860:4860::8844
#
# <P-CSCF>
#
# o Proxy Call Session Control Function
#
# p-cscf:
# - 127.0.0.1
# - ::1
#
pcrf:
freeDiameter: pcrf.conf

38
pcrf/Dockerfile Normal file
View File

@@ -0,0 +1,38 @@
# BSD 2-Clause License
# Copyright (c) 2019, Supreeth Herle
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
FROM open5gs:v0.1
# Expose port 3868 for Diameter queries
EXPOSE 3868/udp
EXPOSE 3868/tcp
EXPOSE 3868/sctp
EXPOSE 5868/udp
EXPOSE 5868/tcp
EXPOSE 5868/sctp
CMD /mnt/pcrf/pcrf_init.sh && \
cd install/bin && ./open5gs-pcrfd

32
pcrf/pcrf.yaml Normal file
View File

@@ -0,0 +1,32 @@
db_uri: mongodb://localhost/open5gs
logger:
file: /open5gs/install/var/log/open5gs/pcrf.log
parameter:
no_ipv6: true
prefer_ipv4: true
pcrf:
freeDiameter:
identity: pcrf.epc.mnc001.mcc001.3gppnetwork.org
realm: epc.mnc001.mcc001.3gppnetwork.org
port: 3868
sec_port: 5868
listen_on: PCRF_IP
load_extension:
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dbg_msg_dumps.fdx
conf: 0x8888
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_rfc5777.fdx
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_mip6i.fdx
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_nasreq.fdx
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_nas_mipv6.fdx
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_dcca.fdx
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_dcca_3gpp.fdx
connect:
- identity: pgw.epc.mnc001.mcc001.3gppnetwork.org
addr: PGW_IP
port: 3868
- identity: pcscf.ims.mnc001.mcc001.3gppnetwork.org
addr: 10.4.128.21
port: 3871

36
pcrf/pcrf_init.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/bin/bash
# BSD 2-Clause License
# Copyright (c) 2019, Supreeth Herle
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
export IP_ADDR=$(awk 'END{print $1}' /etc/hosts)
cp /mnt/pcrf/pcrf.yaml install/etc/open5gs
sed -i 's|mongodb://localhost/|mongodb://'$HSS_IP'/|g' install/etc/open5gs/pcrf.yaml
sed -i 's|NAME|'$NAME'|g' install/etc/open5gs/pcrf.yaml
sed -i 's|REALM|'$REALM'|g' install/etc/open5gs/pcrf.yaml
sed -i 's|PCRF_IP|'$IP_ADDR'|g' install/etc/open5gs/pcrf.yaml
sed -i 's|PGW_IP|'$PGW_IP'|g' install/etc/open5gs/pcrf.yaml

44
pgw/Dockerfile Normal file
View File

@@ -0,0 +1,44 @@
# BSD 2-Clause License
# Copyright (c) 2019, Supreeth Herle
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
FROM open5gs:v0.1
# Expose port 3868 for Diameter queries
EXPOSE 3868/udp
EXPOSE 3868/tcp
EXPOSE 3868/sctp
EXPOSE 5868/udp
EXPOSE 5868/tcp
EXPOSE 5868/sctp
# Expose port 2152
EXPOSE 2152/udp
# Expose port 2123
EXPOSE 2123/udp
CMD /mnt/pgw/pgw_init.sh && \
cd install/bin && ./open5gs-pgwd

50
pgw/pgw.yaml Normal file
View File

@@ -0,0 +1,50 @@
logger:
file: /open5gs/install/var/log/open5gs/pgw.log
parameter:
no_ipv6: true
prefer_ipv4: true
pgw:
freeDiameter:
identity: pgw.epc.mnc001.mcc001.3gppnetwork.org
realm: epc.mnc001.mcc001.3gppnetwork.org
port: 3868
sec_port: 5868
listen_on: PGW_IP
load_extension:
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dbg_msg_dumps.fdx
conf: 0x8888
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_rfc5777.fdx
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_mip6i.fdx
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_nasreq.fdx
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_nas_mipv6.fdx
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_dcca.fdx
- module: /open5gs/install/lib/x86_64-linux-gnu/freeDiameter/dict_dcca_3gpp.fdx
connect:
- identity: pcrf.epc.mnc001.mcc001.3gppnetwork.org
addr: PCRF_IP
port: 3868
gtpc:
dev: PGW_IF
gtpu:
dev: PGW_IF
ue_pool:
- addr: 192.168.100.1/24
dev: ogstun
- addr: fd84:6aea:c36e:2b69::/64
dev: ogstun
apn: internet
- addr: 192.168.101.1/24
apn: ims
dev: ogstun2
- addr: fd1f:76f3:da9b:0101::/64
apn: ims
dev: ogstun2
dns:
- 8.8.8.8
- 8.8.4.4
- 2001:4860:4860::8888
- 2001:4860:4860::8844
p-cscf:
- 10.4.128.21

42
pgw/pgw_init.sh Executable file
View File

@@ -0,0 +1,42 @@
#!/bin/bash
# BSD 2-Clause License
# Copyright (c) 2019, Supreeth Herle
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export IP_ADDR=$(awk 'END{print $1}' /etc/hosts)
export IF_NAME=$(ip r | awk '/default/ { print $5 }')
python3 /mnt/pgw/tun_if.py --tun_ifname ogstun --ipv4_range 192.168.100.0/24 --ipv6_range fd84:6aea:c36e:2b69::/64
python3 /mnt/pgw/tun_if.py --tun_ifname ogstun2 --ipv4_range 192.168.101.0/24 --ipv6_range fd1f:76f3:da9b:0101::/64
cp /mnt/pgw/pgw.yaml install/etc/open5gs
sed -i 's|PGW_IP|'$IP_ADDR'|g' install/etc/open5gs/pgw.yaml
sed -i 's|PGW_IF|'$IF_NAME'|g' install/etc/open5gs/pgw.yaml
sed -i 's|PCRF_IP|'$PCRF_IP'|g' install/etc/open5gs/pgw.yaml

96
pgw/tun_if.py Normal file
View File

@@ -0,0 +1,96 @@
# BSD 2-Clause License
# Copyright (c) 2019, Supreeth Herle
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import click
import subprocess
import ipaddress
"""
Usage in command line:
e.g:
$ python3 tun_if.py --tun_ifname ogstun --ipv4_range 192.168.100.0/24 --ipv6_range fd84:6aea:c36e:2b69::/64
"""
def validate_ip_net(ctx, param, value):
try:
ip_net = ipaddress.ip_network(value)
return ip_net
except ValueError:
raise click.BadParameter('Value does not represent a valid IPv4/IPv6 range')
@click.command()
@click.option('--tun_ifname',
required=True,
help='TUN interface name e.g. ogstun')
@click.option('--ipv4_range',
required=True,
callback=validate_ip_net,
help='UE IPv4 Address range in CIDR format e.g. 192.168.100.0/24')
@click.option('--ipv6_range',
required=True,
callback=validate_ip_net,
help='UE IPv6 Address range in CIDR format e.g. fd84:6aea:c36e:2b69::/64')
def start(tun_ifname,
ipv4_range,
ipv6_range):
# Get the first IP address in the IP range and netmask prefix length
first_ipv4_addr = next(ipv4_range.hosts(), None)
if not first_ipv4_addr:
raise ValueError('Invalid UE IPv4 range. Only one IP given')
else:
first_ipv4_addr = first_ipv4_addr.exploded
first_ipv6_addr = next(ipv6_range.hosts(), None)
if not first_ipv6_addr:
raise ValueError('Invalid UE IPv6 range. Only one IP given')
else:
first_ipv6_addr = first_ipv6_addr.exploded
ipv4_netmask_prefix = ipv4_range.prefixlen
ipv6_netmask_prefix = ipv6_range.prefixlen
# Setup the TUN interface, set IP address and setup IPtables
# if ls /sys/class/net | grep "ogstun" ; then ip link delete ogstun; fi
execute_bash_cmd('ip tuntap add name ' + tun_ifname + ' mode tun')
execute_bash_cmd('ip addr add ' + first_ipv4_addr + '/' + str(ipv4_netmask_prefix) + ' dev ' + tun_ifname)
execute_bash_cmd('ip addr add ' + first_ipv6_addr + '/' + str(ipv6_netmask_prefix) + ' dev ' + tun_ifname)
execute_bash_cmd('ip link set ' + tun_ifname + ' mtu 1400')
execute_bash_cmd('ip link set ' + tun_ifname + ' up')
execute_bash_cmd('if ! iptables-save | grep -- \"-A POSTROUTING -s ' + ipv4_range.with_prefixlen + ' ! -o ' + tun_ifname + ' -j MASQUERADE\" ; then ' +
'iptables -t nat -A POSTROUTING -s ' + ipv4_range.with_prefixlen + ' ! -o ' + tun_ifname + ' -j MASQUERADE; fi')
execute_bash_cmd('if ! ip6tables-save | grep -- \"-A POSTROUTING -s ' + ipv6_range.with_prefixlen + ' ! -o ' + tun_ifname + ' -j MASQUERADE\" ; then ' +
'ip6tables -t nat -A POSTROUTING -s ' + ipv6_range.with_prefixlen + ' ! -o ' + tun_ifname + ' -j MASQUERADE; fi')
execute_bash_cmd('if ! iptables-save | grep -- \"-A INPUT -i ' + tun_ifname + ' -j ACCEPT\" ; then ' +
'iptables -A INPUT -i ' + tun_ifname + ' -j ACCEPT; fi')
execute_bash_cmd('if ! ip6tables-save | grep -- \"-A INPUT -i ' + tun_ifname + ' -j ACCEPT\" ; then ' +
'ip6tables -A INPUT -i ' + tun_ifname + ' -j ACCEPT; fi')
def execute_bash_cmd(bash_cmd):
#print("Executing: /bin/bash -c " + bash_cmd)
return subprocess.run(bash_cmd, stdout=subprocess.PIPE, shell=True)
if __name__ == '__main__':
start()

36
sgw/Dockerfile Normal file
View File

@@ -0,0 +1,36 @@
# BSD 2-Clause License
# Copyright (c) 2019, Supreeth Herle
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
FROM open5gs:v0.1
# Expose port 2152
EXPOSE 2152/udp
# Expose port 2123
EXPOSE 2123/udp
CMD /mnt/sgw/sgw_init.sh && \
cd install/bin && ./open5gs-sgwd

11
sgw/sgw.yaml Normal file
View File

@@ -0,0 +1,11 @@
logger:
file: /open5gs/install/var/log/open5gs/sgw.log
parameter:
no_ipv6: true
sgw:
gtpc:
dev: SGW_IF
gtpu:
dev: SGW_IF

View File

@@ -26,7 +26,9 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
sed -i 's|EPC_IF|'$EPC_IF'|g' /nextepc/install/etc/nextepc/nextepc.conf
sed -i 's|MCC|'$MCC'|g' /nextepc/install/etc/nextepc/nextepc.conf
sed -i 's|MNC|'$MNC'|g' /nextepc/install/etc/nextepc/nextepc.conf
sed -i 's|TAC1|'$TAC1'|g' /nextepc/install/etc/nextepc/nextepc.conf
export IF_NAME=$(ip r | awk '/default/ { print $5 }')
cp /mnt/sgw/sgw.yaml install/etc/open5gs
sed -i 's|SGW_IF|'$IF_NAME'|g' install/etc/open5gs/sgw.yaml