Added files required to build and run a NextEPC docker image

This commit is contained in:
Supreeth Herle
2019-07-10 13:58:29 +02:00
parent 9d7057ccde
commit ae6e54a2da
4 changed files with 583 additions and 0 deletions

75
nextepc/Dockerfile Normal file
View File

@@ -0,0 +1,75 @@
# 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

4
nextepc/docker_env Normal file
View File

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

32
nextepc/mod_conf.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/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.
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

472
nextepc/nextepc.conf Normal file
View File

@@ -0,0 +1,472 @@
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