Reference: https://github.com/OPENAIRINTERFACE/openair-epc-fed/blob/master/docs/DEPLOY_PRE_REQUESITES.md

 

###########

OpenAirInterface Core Network Docker Deployment : Pre-Requisites

#############################

Install apps

-------------------------

 

sudo apt-get install docker docker-compose docker.io -y
python3 --version

Python 3.6.9

User permissions

-------------------------

$ sudo usermod -aG docker ${USER}

Add your user to the docker group.

You would need to log out and log back in so that your group membership is re-evaluated or  type the following command:

su -s ${USER}

 

Check docker running for user

------------------------

 

docker info

 

Docker Login

First log with your Docker Hub credentials.

docker login

Username: 

Password:

WARNING! Your password will be stored unencrypted in /home/ubuntu/.docker/config.json.

Configure a credential helper to remove this warning. See

https://docs.docker.com/engine/reference/commandline/login/#credentials-store



Login Succeeded

Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.

If you get errors

***** Message: 08:54:43.579: Remote error from secret service: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.secrets was not provided by any .service files

*****Error saving credentials: error storing credentials - err: exit status 1, out: `The name org.freedesktop.secrets was not provided by any .service files`

Run this command:

sudo apt install gnupg2 pass -y

 

Base images:

-------------------------

Then pull base images.

 

On a Ubuntu18.04 host:

 

docker pull ubuntu:bionic
docker pull cassandra:2.1

Network Configuration

Change the networking to support packet forwarding to containers.

$ cat /etc/sysctl.conf | grep net.ipv4.ip_forward

$ sudo sysctl net.ipv4.conf.all.forwarding=1

Reboot system.

 

After Reboot

$ sudo iptables -P FORWARD ACCEPT

 

 

 

#############################

Download latest docker fed code

from https://github.com/OPENAIRINTERFACE/openair-epc-fed/tree/master-documentation

#############################

 

git clone https://github.com/OPENAIRINTERFACE/openair-epc-fed.git
cd openair-epc-fed
git checkout master
git pull origin master
./scripts/syncComponents.sh --mme-branch samsumg-s10-5g-g977u-merged


---------------------------------------------------------

OAI-HSS    component branch : develop

OAI-MME    component branch : samsumg-s10-5g-g977u-merged

OAI-SPGW-C component branch : develop

OAI-SPGW-U component branch : develop

---------------------------------------------------------

 

 

 

########################################

##########Build HSS Image###############

########################################

 

docker build --target oai-hss --tag oai-hss:production \
--file component/oai-hss/ci-scripts/Dockerfile.ubuntu18.04  .
docker image prune --force

docker image ls

oai-hss                 production             f478bafd7a06        1 minute ago          341MB...

 

########################################

##########Build MME Image###############

########################################

 

docker build --target oai-mme --tag oai-mme:production \
--file component/oai-mme/ci-scripts/Dockerfile.ubuntu18.04 .
docker image prune --force
docker image ls

oai-mme                 prodution              4133e75b6fc4        1 minute ago          406MB

...

########################################

##########Build SPGW-C Image############

########################################

 

docker build --target oai-spgwc --tag oai-spgwc:production \
--file component/oai-spgwc/ci-scripts/Dockerfile.ubuntu18.04 .
docker image prune --force


docker image ls
oai-spgwu-tiny          production             588e14481f2b        1 minute ago          220MB

########################################

##########Build SPGW-U Image############

########################################

 

docker build --target oai-spgwu-tiny --tag oai-spgwu-tiny:production \
--file component/oai-spgwu-tiny/ci-scripts/Dockerfile.ubuntu18.04 .
docker image prune --force
docker image ls

oai-spgwu-tiny          production             588e14481f2b        1 minute ago          220MB

...

 

########################################

#####Create a Docker Bridged Network####

########################################

docker network create --attachable --subnet 10.154.61.0/26 --ip-range 10.154.61.0/26 prod-oai-public-net

#############################

Scripts to Launch OAI FED containers.

 #############################

Launch OAI FED Containers.  

iristest@enb:~$ cat launch_all_oai_containers.sh
#!/bin/bash

######################################
###Stop running OAI containers
######################################
echo "###########Stop running OAI containers###############"
docker stop prod-oai-spgwu-tiny
docker stop prod-oai-spgwc
docker stop prod-oai-mme
docker stop prod-oai-hss
docker stop prod-cassandra
######################################
###Delete Existing OAI Containers
######################################
echo "###########Delete Existing OAI Containers###############"
docker rm prod-oai-spgwu-tiny
docker rm prod-oai-spgwc
docker rm prod-oai-mme
docker rm prod-oai-hss
docker rm prod-cassandra


######################################
###Start OAI EPC containers
######################################
echo "###########Launch OAI EPC containers###############"
docker run --name prod-cassandra -d -e CASSANDRA_CLUSTER_NAME="OAI HSS Cluster" \
-e CASSANDRA_ENDPOINT_SNITCH=GossipingPropertyFileSnitch cassandra:2.1
sleep 2
docker run --privileged --name prod-oai-hss -d oai-hss:production /bin/bash -c "sleep infinity"
sleep 2
docker network connect prod-oai-public-net prod-oai-hss
sleep 2
docker run --privileged --name prod-oai-mme --network prod-oai-public-net \
-d oai-mme:production /bin/bash -c "sleep infinity"
sleep 2
docker run --privileged --name prod-oai-spgwc --network prod-oai-public-net \
-d oai-spgwc:production /bin/bash -c "sleep infinity"
sleep 2
docker run --privileged --name prod-oai-spgwu-tiny --network prod-oai-public-net \
-d oai-spgwu-tiny:production /bin/bash -c "sleep infinity"
sleep 2

######################################
###Cassandra
######################################
echo "###########Launch Cassandra###############"
cd openair-epc-fed/
docker cp component/oai-hss/src/hss_rel14/db/oai_db.cql prod-cassandra:/home
sleep 2
docker exec -it prod-cassandra /bin/bash -c "nodetool status"
sleep 2
Cassandra_IP=`docker inspect --format="{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" prod-cassandra`
docker exec -it prod-cassandra /bin/bash -c "cqlsh --file /home/oai_db.cql ${Cassandra_IP}"

######################################
##HSS
######################################
echo "###########Launch HSS###############"
sleep 2
HSS_IP=`docker exec -it prod-oai-hss /bin/bash -c "ifconfig eth1 | grep inet" | sed -f ./ci-scripts/convertIpAddrFromIfconfig.sed`
sleep 2
python3 component/oai-hss/ci-scripts/generateConfigFiles.py --kind=HSS --cassandra=${Cassandra_IP} \
--hss_s6a=${HSS_IP} --apn1=apn1.carrier.com \
--users=200 --imsi=320230100000001 \
--ltek=0c0a34601d4f07677303652c0462535b --op=63bfa50ee6523365ff14c1f45f88737d \
--nb_mmes=1 --from_docker_file
sleep 2
docker cp ./hss-cfg.sh prod-oai-hss:/openair-hss/scripts
sleep 2
docker exec -it prod-oai-hss /bin/bash -c "cd /openair-hss/scripts && chmod 777 hss-cfg.sh && ./hss-cfg.sh"

######################################
###MME
######################################
echo "###########Launch MME###############"
sleep 2
MME_IP=`docker inspect --format="{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" prod-oai-mme`
sleep 2
SPGW0_IP=`docker inspect --format="{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" prod-oai-spgwc`
sleep 2
python3 component/oai-mme/ci-scripts/generateConfigFiles.py --kind=MME \
--hss_s6a=${HSS_IP} --mme_s6a=${MME_IP} \
--mme_s1c_IP=${MME_IP} --mme_s1c_name=eth0 \
--mme_s10_IP=${MME_IP} --mme_s10_name=eth0 \
--mme_s11_IP=${MME_IP} --mme_s11_name=eth0 --spgwc0_s11_IP=${SPGW0_IP} \
--mcc=320 --mnc=230 --tac_list="5 6 7" --from_docker_file
sleep 2
docker cp ./mme-cfg.sh prod-oai-mme:/openair-mme/scripts
sleep 2
docker exec -it prod-oai-mme /bin/bash -c "cd /openair-mme/scripts && chmod 777 mme-cfg.sh && ./mme-cfg.sh"

######################################
##SPGW-C
######################################
echo "###########Launch SPGW-C###############"
sleep 2
python3 component/oai-spgwc/ci-scripts/generateConfigFiles.py --kind=SPGW-C \
--s11c=eth0 --sxc=eth0 --apn=apn1.carrier.com \
--dns1_ip=134.226.56.13 --dns2_ip=134.226.32.57 --from_docker_file
sleep 2
docker cp ./spgwc-cfg.sh prod-oai-spgwc:/openair-spgwc
sleep 2
docker exec -it prod-oai-spgwc /bin/bash -c "cd /openair-spgwc && chmod 777 spgwc-cfg.sh && ./spgwc-cfg.sh"

######################################
##SPGW-U
######################################
echo "###########Launch SPGW-U###############"
sleep 2
python3 component/oai-spgwu-tiny/ci-scripts/generateConfigFiles.py --kind=SPGW-U \
--sxc_ip_addr=${SPGW0_IP} --sxu=eth0 --s1u=eth0 --from_docker_file
sleep 2
docker cp ./spgwu-cfg.sh prod-oai-spgwu-tiny:/openair-spgwu-tiny
sleep 2
docker exec -it prod-oai-spgwu-tiny /bin/bash -c "cd /openair-spgwu-tiny && chmod 777 spgwu-cfg.sh && ./spgwu-cfg.sh"

echo $MME_IP
######################################
###Launch OAI EPC container services
######################################
echo "###########Launch OAI EPC container services###############"
sleep 2
docker exec -d prod-oai-hss /bin/bash -c "nohup ./bin/oai_hss -j ./etc/hss_rel14.json --reloadkey true > hss_check_run.log 2>&1"
sleep 2
docker exec -d prod-oai-mme /bin/bash -c "nohup ./bin/oai_mme -c ./etc/mme.conf > mme_check_run.log 2>&1"
sleep 2
docker exec -d prod-oai-spgwc /bin/bash -c "nohup ./bin/oai_spgwc -o -c ./etc/spgw_c.conf > spgwc_check_run.log 2>&1"
sleep 2
docker exec -d prod-oai-spgwu-tiny /bin/bash -c "nohup ./bin/oai_spgwu -o -c ./etc/spgw_u.conf > spgwu_check_run.log 2>&1"

echo "#############COMPLETE####################"

Reload OAI FED EPC Services

This script will reload the OAI FED EPC services without stopping and restarting all containers. Basically, if you want to restart the enb only. Then run this also. 

iristest@enb:~$ cat reload_oai_epc.sh
#!/bin/bash

docker exec -it prod-oai-hss /bin/bash -c "killall --signal SIGINT oai_hss tshark tcpdump"
sleep 2
docker exec -it prod-oai-mme /bin/bash -c "killall --signal SIGINT oai_mme tshark tcpdump"
sleep 2
docker exec -it prod-oai-spgwc /bin/bash -c "killall --signal SIGINT oai_spgwc tshark tcpdump"
sleep 2
docker exec -it prod-oai-spgwu-tiny /bin/bash -c "killall --signal SIGINT oai_spgwu tshark tcpdump"
sleep 2
docker exec -d prod-oai-hss /bin/bash -c "nohup ./bin/oai_hss -j ./etc/hss_rel14.json --reloadkey true > hss_check_run.log 2>&1"
sleep 2
docker exec -d prod-oai-mme /bin/bash -c "nohup ./bin/oai_mme -c ./etc/mme.conf > mme_check_run.log 2>&1"
sleep 2
docker exec -d prod-oai-spgwc /bin/bash -c "nohup ./bin/oai_spgwc -o -c ./etc/spgw_c.conf > spgwc_check_run.log 2>&1"
sleep 2
docker exec -d prod-oai-spgwu-tiny /bin/bash -c "nohup ./bin/oai_spgwu -o -c ./etc/spgw_u.conf > spgwu_check_run.log 2>&1"

iristest@enb:~$ 

Stop and rm OAI Fed Containers

Stop the OAI containers and delete them.

cat stop_del_oai.sh
#!/bin/bash

################################################################################
#Stop and remove EPC containers
################################################################################
#######stop container########
docker stop prod-oai-spgwu-tiny
docker stop prod-oai-spgwc
docker stop prod-oai-mme
docker stop prod-oai-hss
docker stop prod-cassandra
########rm container #######
docker rm prod-oai-spgwu-tiny
docker rm prod-oai-spgwc
docker rm prod-oai-mme
docker rm prod-oai-hss
docker rm prod-cassandra

 

#############################

Access bash to containers

#############################

 bash into the hss container and tail the log

docker exec -it prod-oai-hss /bin/bash

tail -f hss_check_run.log

 bash into the mme container and tail the log

docker exec -it prod-oai-mme /bin/bash

tail -f mme_check_run.log

 

bash into the spgc container and tail the log

 

docker exec -it prod-oai-spgwc /bin/bash

tail -f spgwc_check_run.log

bash into the spgwu container and tail the log 

 

docker exec -it prod-oai-spgwu-tiny /bin/bash

tail -f spgwu_check_run.log

 

#############################

Install tools in Docker containers

#############################

 The following tools can be useful to install in the in the prod-oai-spgwu-tiny. support tcpdump to gateway address. Also ping, and vi if you need it.

docker exec -it prod-oai-spgwu-tiny /bin/bash

apt-get update

apt install iputils-ping tcpdump vim -y

#############################

oPC and OP value.. 

#############################

https://chancetarver.com/oai/cn/ 

docker exec -it prod-cassandra /bin/bash

apt-get update

root@2e09b547ed4d:/# cqlsh
Connected to OAI HSS Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 2.1.21 | CQL spec 3.2.1 | Native protocol v3]
Use HELP for help.
cqlsh> USE vhss;
cqlsh:vhss> select * from users_imsi;
.....

Run:
cqlsh:vhss> UPDATE users_imsi SET OPc='db73d1afc0e296cdad60741f9b1ca535' where imsi='901700000027509';

 

#############################

DEBUG in mme

#############################

Get some extra logging in the mme, spgwu, spgwc, hss

root@1c97d9db3d9e:/openair-mme# find / -name "*mme*.conf"
/openair-mme/etc/mme.conf
/openair-mme/etc/mme_fd.conf

For example 1, modifying the config files:

 

    LOGGING :
    {
        # OUTPUT choice in { "CONSOLE", `path to file`", "`IPv4@`:`TCP port num`"}
        # `path to file` must start with '.' or '/'
        # if TCP stream choice, then you can easily dump the traffic on the remote or local host: nc -l `TCP port num` > received.txt
        OUTPUT            = "CONSOLE";
        THREAD_SAFE       = "no";                                               # THREAD_SAFE choice in { "yes", "no" }, safe to let 'no'
        COLOR             = "yes";                                              # COLOR choice in { "yes", "no" } means use of ANSI styling codes or no
        # Log level choice in { "EMERGENCY", "ALERT", "CRITICAL", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG", "TRACE"}
        SCTP_LOG_LEVEL    = "TRACE";
        S10_LOG_LEVEL     = "TRACE";
        S11_LOG_LEVEL     = "TRACE";
        # NEW LOGS FOR MCE
        SM_LOG_LEVEL      = "TRACE";
        MCE_APP_LOG_LEVEL = "TRACE";
        M2AP_LOG_LEVEL    = "TRACE";
        GTPV2C_LOG_LEVEL  = "TRACE";
        UDP_LOG_LEVEL     = "DEBUG";
        S1AP_LOG_LEVEL    = "DEBUG";
        NAS_LOG_LEVEL     = "TRACE";
        MME_APP_LOG_LEVEL = "TRACE";
        S6A_LOG_LEVEL     = "TRACE";
        UTIL_LOG_LEVEL    = "ERROR";
        MSC_LOG_LEVEL     = "ERROR";
        ITTI_LOG_LEVEL    = "ERROR";
        ASN1_VERBOSITY    = "annoying";
    };

For example 2,

 
e.g., 
Change:
        S10_LOG_LEVEL     = "TRACE";
        S11_LOG_LEVEL     = "TRACE";
to 
        S10_LOG_LEVEL     = "DEBUG";
        S11_LOG_LEVEL     = "DEBUG";

spgwu

/openair-spgwu-tiny/etc/spgw_u.conf

spgwc

/openair-spgwc/etc/spgw_c.conf

hss

root@2be848f05efa:/openair-hss# ls -ltrh /openair-hss/etc/*         
-rw-r--r-- 1 root root  839 Aug 28 09:10 /openair-hss/etc/oss.json
-rw-r--r-- 1 root root 1.1K Sep 11 08:21 /openair-hss/etc/acl.conf
-rw-r--r-- 1 root root 1.3K Sep 11 08:21 /openair-hss/etc/hss_rel14.conf
-rw-r--r-- 1 root root  973 Sep 11 08:21 /openair-hss/etc/hss_rel14.json
-rw-r--r-- 1 root root 9.2K Sep 11 08:21 /openair-hss/etc/hss_rel14_fd.conf
-rw-r--r-- 1 root root  989 Sep 11 08:21 /openair-hss/etc/cacert.pem
-rw------- 1 root root  891 Sep 11 08:21 /openair-hss/etc/hss.key.pem
-rw-r--r-- 1 root root 3.1K Sep 11 08:21 /openair-hss/etc/hss.cert.pem