Skip to content
Snippets Groups Projects
Commit 44507d0d authored by Sagar Arora's avatar Sagar Arora :bicyclist_tone1:
Browse files

Demo-configuration

- edited core-network bash script
parent af5aff36
No related branches found
No related tags found
No related merge requests found
......@@ -26,32 +26,32 @@ if [[ -z $N11_PORT_STATUS ]]; then
echo "Healthcheck error: N11/SBI TCP/HTTP port $AMF_PORT_FOR_N11_HTTP is not listening"
fi
host="${MYSQL_SERVER}"
user="${MYSQL_USER:-root}"
export MYSQL_PWD="${MYSQL_PASS}"
args=(
-h"$host"
-u"$user"
--silent
)
if ! command -v mysql &> /dev/null; then
echo "Installing mysql command"
apt update
apt-get -y install mysql-client
else
if select="$(echo 'SELECT 1' | mysql "${args[@]}")" && [ "$select" = '1' ]; then
database_check=$(mysql -h$host -u$user -D oai_db --silent -e "SELECT * FROM users;")
if [[ -z $database_check ]]; then
echo "Healthcheck error: oai_db not populated"
STATUS=1
fi
STATUS=0
else
echo "Healthcheck error: Mysql port inactive"
STATUS=1
fi
fi
exit $STATUS
\ No newline at end of file
#host="${MYSQL_SERVER}"
#user="${MYSQL_USER:-root}"
#export MYSQL_PWD="${MYSQL_PASS}"
#args=(
# -h"$host"
# -u"$user"
# --silent
#)
#if ! command -v mysql &> /dev/null; then
# echo "Installing mysql command"
# apt update
# apt-get -y install mysql-client
#else
# if select="$(echo 'SELECT 1' | mysql "${args[@]}")" && [ "$select" = '1' ]; then
# database_check=$(mysql -h$host -u$user -D oai_db --silent -e "SELECT * FROM users;")
# if [[ -z $database_check ]]; then
# echo "Healthcheck error: oai_db not populated"
# STATUS=1
# fi
# STATUS=0
# else
# echo "Healthcheck error: Mysql port inactive"
# STATUS=1
# fi
#fi
exit $STATUS
......@@ -13,51 +13,84 @@ RED='\033[0;31m'
NC='\033[0m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
STATUS=0 #STATUS 0 exit safe STATUS 1 exit with an error
if [[ $1 == 'start' ]]; then
start_time=$(date +%s%N | cut -b1-13)
echo -e "${BLUE}Starting 5gcn components in the order mysql, nrf, amf, smf, spgwu${NC}..."
docker-compose -f docker-compose.yaml -p 5gcn up -d
if [[ $2 == 'nrf' ]]; then
echo -e "${BLUE}Starting 5gcn components in the order nrf, mysql, amf, smf, spgwu${NC}..."
docker-compose -f docker-compose.yaml -p 5gcn up -d
else
echo -e "${BLUE}Starting 5gcn components in the order mysql, amf, smf, spgwu${NC}..."
docker-compose -f docker-compose-no-nrf.yaml -p 5gcn up -d
fi
echo -e "${GREEN}Checking the health status of the containers${NC}..."
while true; do
for loop in $(seq 1 25); do
mysql_health=$(docker inspect --format='{{json .State.Health.Status}}' mysql)
nrf_health=$(docker inspect --format='{{json .State.Health.Status}}' oai-nrf)
if [[ $2 == 'nrf' ]]; then
nrf_health=$(docker inspect --format='{{json .State.Health.Status}}' oai-nrf)
fi
amf_health=$(docker inspect --format='{{json .State.Health.Status}}' oai-amf)
smf_health=$(docker inspect --format='{{json .State.Health.Status}}' oai-smf)
spgwu_health=$(docker inspect --format='{{json .State.Health.Status}}' oai-spgwu)
if [[ ${mysql_health} == '"healthy"' && ${nrf_health} == '"healthy"' && ${amf_health} == '"healthy"' && ${smf_health} == '"healthy"' && ${spgwu_health} == '"healthy"' ]]; then
echo -e "${GREEN}All components are healthy${NC}..."
if [[ ${mysql_health} == '"healthy"' && ${amf_health} == '"healthy"' && ${smf_health} == '"healthy"' && ${spgwu_health} == '"healthy"' && $2 != 'nrf' ]]; then
echo -e "\n${GREEN}All components are healthy${NC}..."
STATUS=0
break
elif [[ ${mysql_health} == '"healthy"' && ${amf_health} == '"healthy"' && ${smf_health} == '"healthy"' && ${spgwu_health} == '"healthy"' && ${nrf_health} == '"healthy"' && $2 == 'nrf' ]]; then
echo -e "\n${GREEN}All components are healthy${NC}..."
STATUS=0
break
elif [[ $2 != 'nrf' ]]; then
echo -ne "mysql : $mysql_health, oai-amf : $amf_health, oai-smf : $smf_health, oai-spgwu : $spgwu_health\033[0K\r"
STATUS=1
sleep 2
else
echo -e "${RED}Component Status\nmysql : $mysql_health\noai_nrf : $nrf_health\noai_amf : $amf_health\noai_smf : $smf_health\noai_spgwu : $spgwu_health${NC}"
echo -ne "oai-nrf : $nrf_health, mysql : $mysql_health, oai-amf : $amf_health, oai-smf : $smf_health, oai-spgwu : $spgwu_health\033[0K\r"
STATUS=1
sleep 2
fi
done
echo "Checking if core network is configured properly.."
smf_registration_nrf=$(curl -s -X GET http://192.168.66.44/nnrf-nfm/v1/nf-instances?nf-type="SMF" | grep -o '192.168.66.43')
upf_registration_nrf=$(curl -s -X GET http://192.168.66.44/nnrf-nfm/v1/nf-instances?nf-type="UPF" | grep -o '192.168.66.45')
sample_registration=$(curl -s -X GET http://192.168.66.44/nnrf-nfm/v1/nf-instances?nf-type="SMF")
echo -e "${BLUE}For example: oai-smf Registration with oai-nrf can be checked on this url /nnrf-nfm/v1/nf-instances?nf-type='SMF' $sample_registration${NC}"
if [[ -z $smf_registration_nrf && -z $upf_registration_nrf ]]; then
echo -e "${RED}Registration problem with NRF, check the reason manually${NC}..."
else
echo -e "${GREEN}SMF and UPF are registered to NRF${NC}..."
fi
upf_logs=$(docker logs oai-spgwu | grep 'Received SX HEARTBEAT RESPONSE')
if [[ -z $upf_logs ]]; then
echo -e "${RED}UPF not receiving heartbeats from SMF${NC}..."
if [[ $2 == 'nrf' && $STATUS == 0 ]]; then
echo -e "\nChecking if SMF and UPF registered with nrf core network"
smf_registration_nrf=$(curl -s -X GET http://192.168.70.130/nnrf-nfm/v1/nf-instances?nf-type="SMF" | grep -o '192.168.70.133')
upf_registration_nrf=$(curl -s -X GET http://192.168.70.130/nnrf-nfm/v1/nf-instances?nf-type="UPF" | grep -o '192.168.66.134')
sample_registration=$(curl -s -X GET http://192.168.70.130/nnrf-nfm/v1/nf-instances?nf-type="SMF")
echo -e "\n${BLUE}For example: oai-smf Registration with oai-nrf can be checked on this url /nnrf-nfm/v1/nf-instances?nf-type='SMF' $sample_registration${NC}"
if [[ -z $smf_registration_nrf && -z $upf_registration_nrf ]]; then
echo -e "${RED}Registration problem with NRF, check the reason manually${NC}..."
STATUS=1
else
echo -e "${GREEN}SMF and UPF are registered to NRF${NC}..."
fi
else
echo -e "${GREEN}UPF receiving heathbeats from SMF${NC}..."
echo -e "${BLUE}Checking if SMF is able to connect with UPF${NC}"
upf_logs=$(docker logs oai-spgwu | grep 'Received SX HEARTBEAT RESPONSE')
if [[ -z $upf_logs && $STATUS == 0 ]]; then
echo -e "\n${RED}UPF not receiving heartbeats from SMF${NC}..."
STATUS=1
else
echo -e "\n${GREEN}UPF receiving heathbeats from SMF${NC}..."
fi
fi
end_time=$(date +%s%N | cut -b1-13)
final_time=$(expr $(expr $end_time - $start_time))
echo -e "${GREEN}Core network is running properly, total time taken $final_time milli seconds${NC}"
if [[ $STATUS == 0 ]]; then
echo -e "\n${GREEN}Core network is configured and healthy, total time taken $final_time milli seconds${NC}"
exit $STATUS
else
echo -e "\n${RED}Core network is un-healthy, total time taken $final_time milli seconds\ndebug using docker inspect command...${NC}"
exit $STATUS
fi
elif [[ $1 == 'stop' ]]; then
echo -e "${BLUE}Stopping the core network${NC}..."
docker-compose -f docker-compose.yaml -p 5gcn down
if [[ $2 == 'nrf' ]]; then
docker-compose -f docker-compose.yaml -p 5gcn down
else
docker-compose -f docker-compose-no-nrf.yaml -p 5gcn down
fi
echo -e "${GREEN}Core network stopped${NC}"
else
echo -e "Please define either to ${RED}start${NC} or ${RED}stop${NC} the core network"
echo -e "Only use the following options\n\n${RED}start${NC}: start the 5gCN\n${RED}stop${NC}: stops the 5gCN\n${RED}nrf${NC}: nrf should be used\n${RED}no-nrf${NC}: nrf should not be used\nExample: ./core-network.sh start nrf"
fi
......@@ -3,8 +3,6 @@ services:
mysql:
container_name: "mysql"
image: mysql:5.7
ports:
- 3306/tcp
volumes:
- ./oai_db.sql:/docker-entrypoint-initdb.d/oai_db.sql
- ./mysql-healthcheck.sh:/tmp/mysql-healthcheck.sh
......@@ -20,16 +18,13 @@ services:
timeout: 5s
retries: 5
networks:
5gcore:
ipv4_address: 192.168.70.6
public_net:
ipv4_address: 192.168.70.131
oai-amf:
container_name: "oai-amf"
image: oai-amf:develop
ports:
- 38412/sctp
- 80/tcp
image: oai-amf:multi-pdu
environment:
- TZ=Europe/Paris
- TZ=Europe/paris
- INSTANCE=0
- PID_DIRECTORY=/var/run
- MCC=208
......@@ -54,19 +49,17 @@ services:
- AMF_INTERFACE_NAME_FOR_NGAP=eth0
- AMF_INTERFACE_NAME_FOR_N11=eth0
- SMF_INSTANCE_ID_0=1
- SMF_IPV4_ADDR_0=192.168.70.3
- SMF_IPV4_ADDR_0=192.168.70.133
- SMF_HTTP_VERSION_0=v1
- SELECTED_0=true
- SMF_INSTANCE_ID_1=2
- SMF_IPV4_ADDR_1=192.168.70.3
- SMF_IPV4_ADDR_1=0.0.0.0
- SMF_HTTP_VERSION_1=v1
- SELECTED_1=false
- MYSQL_SERVER=192.168.70.6
- MYSQL_SERVER=192.168.70.131
- MYSQL_USER=root
- MYSQL_PASS=linux
- MYSQL_DB=oai_db
- OPERATOR_KEY=63bfa50ee6523365ff14c1f45f88737d
- NRF_IPV4_ADDRESS=192.168.70.4
- NRF_IPV4_ADDRESS=0.0.0.0
- NRF_PORT=80
- NF_REGISTRATION=no
- SMF_SELECTION=no
......@@ -84,14 +77,11 @@ services:
timeout: 15s
retries: 5
networks:
5gcore:
ipv4_address: 192.168.70.2
public_net:
ipv4_address: 192.168.70.132
oai-smf:
container_name: "oai-smf"
image: oai-smf:develop
ports:
- 80/tcp
- 9090/tcp
environment:
- TZ=Europe/Paris
- INSTANCE=0
......@@ -103,14 +93,14 @@ services:
- SMF_API_VERSION=v1
- DEFAULT_DNS_IPV4_ADDRESS=192.168.18.129
- DEFAULT_DNS_SEC_IPV4_ADDRESS=8.8.8.8
- AMF_IPV4_ADDRESS=192.168.70.2
- AMF_IPV4_ADDRESS=192.168.70.132
- AMF_PORT=80
- AMF_API_VERSION=v1
- UDM_IPV4_ADDRESS=127.0.0.1
- UDM_PORT=80
- UDM_API_VERSION=v1
- UPF_IPV4_ADDRESS=192.168.70.5
- NRF_IPV4_ADDRESS=192.168.70.4
- UPF_IPV4_ADDRESS=192.168.70.134
- NRF_IPV4_ADDRESS=0.0.0.0
- NRF_PORT=80
- NRF_API_VERSION=v1
- REGISTER_NRF=no
......@@ -125,14 +115,11 @@ services:
timeout: 5s
retries: 5
networks:
5gcore:
ipv4_address: 192.168.70.3
public_net:
ipv4_address: 192.168.70.133
oai-spgwu:
container_name: "oai-spgwu"
image: oai-spgwu:develop
ports:
- 2152/udp
- 8805/udp
image: oai-spgwu:gtp-ext-header
environment:
- TZ=Europe/Paris
- PID_DIRECTORY=/var/run
......@@ -140,8 +127,8 @@ services:
- SGW_INTERFACE_NAME_FOR_SX=eth0
- PGW_INTERFACE_NAME_FOR_SGI=eth0
- NETWORK_UE_IP=12.1.1.0/24
- SPGWC0_IP_ADDRESS=192.168.70.3
- NRF_IPV4_ADDRESS=192.168.70.4
- SPGWC0_IP_ADDRESS=192.168.70.133
- NRF_IPV4_ADDRESS=0.0.0.0
- NRF_PORT=80
- NRF_API_VERSION=v1
- REGISTER_NRF=no
......@@ -161,25 +148,28 @@ services:
timeout: 5s
retries: 5
networks:
5gcore:
ipv4_address: 192.168.70.5
oai-external-dn:
public_net:
ipv4_address: 192.168.70.134
oai-ext-dn:
image: ubuntu:bionic
privileged: true
container_name: oai-external-dn
container_name: oai-ext-dn
entrypoint: /bin/bash -c \
"apt update; apt install -y iptables iproute2 iputils-ping;"\
"iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;"\
"ip route add 12.1.1.0/24 via 192.168.70.5 dev eth0; sleep infinity"
"ip route add 12.1.1.0/24 via 192.168.70.134 dev eth0; sleep infinity"
command: ["/bin/bash", "-c", "trap : TERM INT; sleep infinity & wait"]
depends_on:
- oai-spgwu
networks:
5gcore:
ipv4_address: 192.168.70.7
public_net:
ipv4_address: 192.168.70.135
networks:
5gcore:
public_net:
driver: bridge
name: demo-oai-public-net
ipam:
config:
- subnet: 192.168.70.0/24
- subnet: 192.168.70.128/26
driver_opts:
com.docker.network.bridge.name: "demo-oai"
version: '3.8'
services:
oai-nrf:
container_name: "oai-nrf"
image: oai-nrf:develop
environment:
- NRF_INTERFACE_NAME_FOR_SBI=eth0
- NRF_INTERFACE_PORT_FOR_SBI=80
- NRF_INTERFACE_HTTP2_PORT_FOR_SBI=9090
- NRF_API_VERSION=v1
- INSTANCE=0
- PID_DIRECTORY=/var/run
networks:
public_net:
ipv4_address: 192.168.70.130
volumes:
- ./nrf-healthcheck.sh:/openair-nrf/bin/nrf-healthcheck.sh
healthcheck:
test: /bin/bash -c "/openair-nrf/bin/nrf-healthcheck.sh"
interval: 10s
timeout: 5s
retries: 5
mysql:
container_name: "mysql"
image: mysql:5.7
ports:
- 3306/tcp
volumes:
- ./oai_db.sql:/docker-entrypoint-initdb.d/oai_db.sql
- ./mysql-healthcheck.sh:/tmp/mysql-healthcheck.sh
......@@ -20,16 +38,13 @@ services:
timeout: 5s
retries: 5
networks:
5gcore:
ipv4_address: 192.168.70.6
public_net:
ipv4_address: 192.168.70.131
oai-amf:
container_name: "oai-amf"
image: oai-amf:develop
ports:
- 38412/sctp
- 80/tcp
image: oai-amf:multi-pdu
environment:
- TZ=Europe/Paris
- TZ=Europe/paris
- INSTANCE=0
- PID_DIRECTORY=/var/run
- MCC=208
......@@ -54,21 +69,19 @@ services:
- AMF_INTERFACE_NAME_FOR_NGAP=eth0
- AMF_INTERFACE_NAME_FOR_N11=eth0
- SMF_INSTANCE_ID_0=1
- SMF_IPV4_ADDR_0=192.168.70.3
- SMF_IPV4_ADDR_0=0.0.0.0
- SMF_HTTP_VERSION_0=v1
- SELECTED_0=true
- SMF_INSTANCE_ID_1=2
- SMF_IPV4_ADDR_1=192.168.70.3
- SMF_IPV4_ADDR_1=0.0.0.0
- SMF_HTTP_VERSION_1=v1
- SELECTED_1=false
- MYSQL_SERVER=192.168.70.6
- MYSQL_SERVER=192.168.70.131
- MYSQL_USER=root
- MYSQL_PASS=linux
- MYSQL_DB=oai_db
- OPERATOR_KEY=63bfa50ee6523365ff14c1f45f88737d
- NRF_IPV4_ADDRESS=192.168.70.4
- NRF_IPV4_ADDRESS=192.168.70.130
- NRF_PORT=80
- NF_REGISTRATION=yes
- NF_REGISTRATION=no
- SMF_SELECTION=yes
- NRF_API_VERSION=v1
- AUSF_IPV4_ADDRESS=127.0.0.1
......@@ -76,7 +89,6 @@ services:
- AUSF_API_VERSION=v1
depends_on:
- mysql
- oai-nrf
volumes:
- ./amf-healthcheck.sh:/openair-amf/bin/amf-healthcheck.sh
healthcheck:
......@@ -85,14 +97,11 @@ services:
timeout: 15s
retries: 5
networks:
5gcore:
ipv4_address: 192.168.70.2
public_net:
ipv4_address: 192.168.70.132
oai-smf:
container_name: "oai-smf"
image: oai-smf:develop
ports:
- 80/tcp
- 9090/tcp
environment:
- TZ=Europe/Paris
- INSTANCE=0
......@@ -104,22 +113,20 @@ services:
- SMF_API_VERSION=v1
- DEFAULT_DNS_IPV4_ADDRESS=192.168.18.129
- DEFAULT_DNS_SEC_IPV4_ADDRESS=8.8.8.8
- AMF_IPV4_ADDRESS=192.168.70.2
- AMF_IPV4_ADDRESS=0.0.0.0
- AMF_PORT=80
- AMF_API_VERSION=v1
- UDM_IPV4_ADDRESS=127.0.0.1
- UDM_PORT=80
- UDM_API_VERSION=v1
- UPF_IPV4_ADDRESS=192.168.70.5
- NRF_IPV4_ADDRESS=192.168.70.4
- UPF_IPV4_ADDRESS=192.168.70.134
- NRF_IPV4_ADDRESS=192.168.70.130
- NRF_PORT=80
- NRF_API_VERSION=v1
- REGISTER_NRF=yes
- DISCOVER_UPF=yes
depends_on:
- oai-nrf
- oai-amf
- oai-spgwu
volumes:
- ./smf-healthcheck.sh:/openair-smf/bin/smf-healthcheck.sh
healthcheck:
......@@ -128,38 +135,11 @@ services:
timeout: 5s
retries: 5
networks:
5gcore:
ipv4_address: 192.168.70.3
oai-nrf:
container_name: "oai-nrf"
image: oai-nrf:develop
ports:
- 80/tcp
- 9090/tcp
environment:
- TZ=Europe/Paris
- NRF_INTERFACE_NAME_FOR_SBI=eth0
- NRF_INTERFACE_PORT_FOR_SBI=80
- NRF_INTERFACE_HTTP2_PORT_FOR_SBI=9090
- NRF_API_VERSION=v1
- INSTANCE=0
- PID_DIRECTORY=/var/run
networks:
5gcore:
ipv4_address: 192.168.70.4
volumes:
- ./nrf-healthcheck.sh:/openair-nrf/bin/nrf-healthcheck.sh
healthcheck:
test: /bin/bash -c "/openair-nrf/bin/nrf-healthcheck.sh"
interval: 10s
timeout: 5s
retries: 5
public_net:
ipv4_address: 192.168.70.133
oai-spgwu:
container_name: "oai-spgwu"
image: oai-spgwu:develop
ports:
- 2152/udp
- 8805/udp
image: oai-spgwu:gtp-ext-header
environment:
- TZ=Europe/Paris
- PID_DIRECTORY=/var/run
......@@ -167,8 +147,8 @@ services:
- SGW_INTERFACE_NAME_FOR_SX=eth0
- PGW_INTERFACE_NAME_FOR_SGI=eth0
- NETWORK_UE_IP=12.1.1.0/24
- SPGWC0_IP_ADDRESS=192.168.70.3
- NRF_IPV4_ADDRESS=192.168.70.4
- SPGWC0_IP_ADDRESS=192.168.70.133
- NRF_IPV4_ADDRESS=192.168.70.130
- NRF_PORT=80
- NRF_API_VERSION=v1
- REGISTER_NRF=yes
......@@ -188,25 +168,29 @@ services:
timeout: 5s
retries: 5
networks:
5gcore:
ipv4_address: 192.168.70.5
oai-external-dn:
public_net:
ipv4_address: 192.168.70.134
oai-ext-dn:
image: ubuntu:bionic
privileged: true
container_name: oai-external-dn
container_name: oai-ext-dn
entrypoint: /bin/bash -c \
"apt update; apt install -y iptables iproute2 iputils-ping;"\
"iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;"\
"ip route add 12.1.1.0/24 via 192.168.70.5 dev eth0; sleep infinity"
"ip route add 12.1.1.0/24 via 192.168.70.134 dev eth0; sleep infinity"
command: ["/bin/bash", "-c", "trap : TERM INT; sleep infinity & wait"]
depends_on:
- oai-spgwu
networks:
5gcore:
ipv4_address: 192.168.70.7
public_net:
ipv4_address: 192.168.70.135
networks:
5gcore:
driver: bridge
ipam:
config:
- subnet: 192.168.70.0/24
public_net:
external:
name: demo-oai-public-net
# Incase the user wants docker-compose to create a bridge rather than creating the bridge manually then uncomment the below lines
# ipam:
# config:
# - subnet: 192.168.70.128/26
# driver_opts:
# com.docker.network.bridge.name: "demo-oai"
FROM ubuntu:bionic
RUN apt update
RUN apt install -y iptables iproute2 iputils-ping
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment