Skip to content
Snippets Groups Projects
README.md 17.6 KiB
Newer Older
## Installation and deployment of 5G Core (5GC) of Open Air Interface (OAI)
## Objectives
- Install and configure the 5GC of OAI in a virtual machine Ubuntu 20.04 LTS (Focal Fossa)
- Deploy 5GC Core
- Inspec 5G Core Docker containers by means of command line instructions 
- Install and configure Portainer tool
- Inspec 5G Core Docker containers by means of Portainer browser

**Minimum hardware requirements for OAI UE, according to doc/NR_SA_Tutorial_COTS_UE.md · develop · oai / openairinterface5G · GitLab (eurecom.fr):**
- Ubuntu 20.04.5 LTS;
- CPU: 4 cores x86_64;
- 8 GB RAM.

**Minimum hardware requirements for OAI 5GC and OAI gNB, according to doc/NR_SA_Tutorial_COTS_UE.md · develop · oai / openairinterface5G · GitLab (eurecom.fr):**
- Ubuntu 20.04.5 LTS;
- CPU: 8 cores x86_64 3.5 GHz;
- 32 GB RAM.

**However, if you do not have such hardware specifications, you may use the one below for both devices (tested for us, you may face some lags, but it works):**
- Ubuntu 20.04.5 LTS;
- CPU: 4 cores x86_64;
- 4 GB RAM.

## 5GC Installation

![ALT](/openairinterface5g/openairinterface-conf/fig/core_slice5g.png)  

In a Linux Terminal, follow the steps below:

**Step 0:** Setup your VM or Baremetal Machine, after install Useful Software:

> sudo apt update -y 
> sudo apt upgrade -y
> sudo apt install -y python3-pip git curl cmake tree golang vim net-tools build-essential nfs-common openssh-server
**Step 1:** Install dependencies
> sudo apt-get install ca-certificates 
> 
> sudo apt-get install curl 
> 
> sudo apt-get install gnupg 
> 
> sudo apt-get install lsb-release 
**Step 2:** Enable packet forwarding
> sudo sysctl net.ipv4.conf.all.forwarding=1
> 
> sudo iptables -P FORWARD ACCEPT
**Step 3:** Install docker and docker-compose
> sudo rm /etc/apt/sources.list.d/docker.list*
> 
> sudo mkdir -p /etc/apt/keyrings 
> 
> curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
> 
> sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
> 
> sudo chmod a+r /etc/apt/keyrings/docker.gpg
> 
> sudo apt-get update
> 
> sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
> 
> sudo curl -L https://github.com/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
> 
> sudo chmod +x /usr/local/bin/docker-compose
**Step 4:** Clone OpenAirInterface 5G Core repository
> git clone https://gitlab.eurecom.fr/oai/cn5g/oai-cn5g-fed.git
> 
> cd oai-cn5g-fed
> 
> git checkout slicing-spring-of-code

## OAI 5G RAN, RIC (FlexRIC) and OAI UE Installations
![ALT](/openairinterface5g/openairinterface-conf/fig/ran_ric.png)  
## Objectives
- Install the OAI 5G RAN (gNB) 
- Install the FlexRIC 
- Install OAI UE
To install OAI RAN 5G and OAI UE, go back for ~/ and follow this tutorial.
**Step 0:** go back to ~/. In a Linux Terminal, type:
> cd ~/
**Step 1:** Install dependencies
> sudo add-apt-repository ppa:ettusresearch/uhd
> 
> sudo apt-get install libuhd-dev uhd-host -y
> 
> sudo apt-get install libuhd4.6.0 -y
> 
> sudo apt-get install ccache -y
> 
> sudo apt-get install net-tools


**Step 2:** Fix problem in the libuhd. When you run the commands below, if you get the error "cannot access archive", you can continue to the next step.
sudo dpkg -i --force-overwrite /var/cache/apt/archives/libuhd4.6.0_4.6.0.0-0ubuntu1~focal1_amd64.deb

**Step 3:** Clone OpenAirInterface 5G RAN repository

> git clone https://gitlab.eurecom.fr/oai/openairinterface5g.git
> cd ~/openairinterface5g
> 
> git checkout slicing-spring-of-code
> 
> **Step 4:** Run the installation script
> 
> source oaienv
> 
> cd cmake_targets
> 
> sudo ./build_oai -I 
> 
> sudo ./build_oai -I --install-optional-packages
> 
> sudo ./build_oai -w USRP --ninja --gNB --nrUE -C --build-lib "uescope nrscope telnetsrv" 
To install RIC (FlexRIC), go back to ~/ and follow this tutorial.
**Step 0:** go back to ~/. In a Linux Terminal, type:
> cd ~/

**Step 1:** Install dependencies:

> sudo apt-get install -y autotools-dev automake g++ make libpcre2-dev byacc cmake python3-dev libsctp-dev pcre2-utils bison

**Step 2:** Install swig:

> cd ~/ 
> git clone https://github.com/swig/swig.git
> 
> cd swig
> 
> git checkout release-4.1 
> 
> ./autogen.sh
> 
> ./configure --prefix=/usr/
> 
> make -j8
> 
> sudo make install
**Step 3:** Clone FlexRIC repository:
> git clone https://gitlab.eurecom.fr/mosaic5g/flexric flexric
> 
> cd flexric/
> 
> git checkout slicing-spring-of-code
> 
> **Step 4:** Build FlexRIC:
> 
> mkdir build && cd build && cmake .. && make -j8
> 
> sudo make install
## RAN (gNB) Configuration

In a Linux Terminal, follow the steps below:

**Step 1:** Configure the PLMN and TAC values

The Public Land Mobile Network (PLMN) and Tracking Area Code (TAC) will be configured in the gNB (~/openairinterface5g/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf) configuration file. 
Figure below shows the part of the code that must be modified in the CU and DU files (lines 17 and 18). The parameters shown in figure should be modified according to the values present in the template, , specifically "plmn_support_list" session (~/oai-cn5g-fed/docker-compose/conf/slicing_base_config.yaml). 

![ALT](/openairinterface5g/openairinterface-conf/fig/gNB_config_01.png)  

Figure below shows the parameters that should be checked and passed to the monolithic configuration file: tac (referring to "tracking_area_code"), mcc (referring to "mcc"), mnc (referring to "mnc"), sst (referring to "sst") and the sd (referring to "sd").

![ALT](/openairinterface5g/openairinterface-conf/fig/slice_parameters.png)  

Open files by typing:

gedit ~/openairinterface5g/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf
gedit ~/oai-cn5g-fed/docker-compose/conf/slicing_base_config.yaml
**Step 2:**  Configure the network interfaces

This part you will configure the N2 interface in (~/openairinterface5g/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf), such as in figure below. This interface is responsible to connect the gNB and the AMF.
![ALT](/openairinterface5g/openairinterface-conf/fig/N2_parameters.png)  
You need to verify/change the IP addresses. You can find the OAI-AMF IP address inside ~/oai-cn5g-fed/docker-compose/docker-compose-slicing-basic-nrf.yaml, such as in figure below. You must get this IP address and put it in the "amf_ip_address" parameter, in the "ipv4" field (such as in previous figure).

![ALT](/openairinterface5g/openairinterface-conf/fig/amf_parameters.png)  


Check if the IP Address of gnb.sa.band78.fr1.106PRB.usrpb210.conf is the same of docker-compose-slicing-basic-nrf.yaml. To edit gnb.sa.band78.fr1.106PRB.usrpb210.conf, type:
gedit ~/openairinterface5g/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf
**Step 3:** to check a virtual interface, type:
ip -br -c a
You should find the interface and the ip address of the RAN (as shown in figure below). This interface serves to connect the gNB with OAI-AMF. 
![ALT](/openairinterface5g/openairinterface-conf/fig/demo_oai.png)  
However, if you are trying to connect to the 5G Core located on another PC, you need to configure the routes accordingly. You can use the command below.

> sudo ip route add 192.168.70.0/24 via "IP_PC_CORE" dev "INTERFACE_CONNECTED_WITH_PC_CORE"

## UE 1 Configurations

## Objectives
- Configure the OAI UE 1

**Step 1:** Creating a namespace:

> sudo ip netns add oai-ue1

**Step 2:** Creating a pair of virtual interfaces (veth):

> sudo ip link add veth0 type veth peer name veth1

**Step 3:** Moving one interface to the created namespace:

> sudo ip link set veth1 netns oai-ue1

**Step 4:** Configuring an IP address for veth0 interface:

> sudo ip addr add 192.168.1.1/24 dev veth0

**Step 5:** Configuring an IP address for veth1 interface within the namespace:

> sudo ip netns exec oai-ue1 ip addr add 192.168.1.2/24 dev veth1

**Step 6:** Bringing up the veth0 interface:

> sudo ip link set veth0 up

**Step 7:** Bringing up the veth1 interface within the namespace:

> sudo ip netns exec oai-ue1 ip link set veth1 up

**Step 8:** Adding a route within the namespace:

> sudo ip netns exec oai-ue1 ip route add 192.168.70.0/24 via 192.168.1.1 dev veth1

**Step 9:** Enabling packet forwarding within the namespace:

> sudo ip netns exec oai-ue1 sysctl net.ipv4.conf.all.forwarding=1
>
> sudo ip netns exec ip route add default via 192.168.2.1 dev veth2

**Step 10:** Setting default policy for packet forwarding within the namespace to ACCEPT::

> sudo ip netns exec oai-ue1 iptables -P FORWARD ACCEPT
**Step 11:** Enable packet forwarding on the Host:

> echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
>
> sudo iptables -t nat -A POSTROUTING -s 192.168.1.0/24 ! -o veth0 -j MASQUERADE

**Step 12:** Configure the IMSI, Permanent Key and OPC
This part you will configure the UE parameters. The UE parameters file is ~/openairinterface5g/targets/PROJECTS/GENERIC-NR-5GC/CONF/ue.conf. The first three lines of the file are composed by the IMSI, Permanent Key and OPC, as shown in figure below. You will configure these parameters. 

![ALT](/openairinterface5g/openairinterface-conf/fig/ue_parameters.png) 

You need to check in the docker-compose file (~/oai-cn5g-fed/docker-compose/database/oai_db2.sql) which SQL file the core is using. See figure below. 

![ALT](/openairinterface5g/openairinterface-conf/fig/db_file.png)  

Verify/change the parameters in UE file (~/openairinterface5g/targets/PROJECTS/GENERIC-NR-5GC/CONF/ue.conf) according to the SQL file illustrated in figure below. The parameters are:
 - "ueid" refers to "imsi"
 - "encPermanentKey" refers to "key"
 - "encOpcKey" refers to "opc

![ALT](/openairinterface5g/openairinterface-conf/fig/UE_config_03.png) 

To open UE file, type:

gedit ~/openairinterface5g/targets/PROJECTS/GENERIC-NR-5GC/CONF/ue.conf

To open Docker Composer file, type:

gedit ~/oai-cn5g-fed/docker-compose/docker-compose-slicing-basic-nrf.yaml

To see sqlFile, type in a terninal.

gedit ~/oai-cn5g-fed/docker-compose/database/oai_db2.sql

Or use a SQLLite database visualizer like DB Browser (to install: sudo apt install sqlitebrowser -y).

The last three lines of the file are composed of DNN (Data Network Name), N-SSAI SST (Network Slice Selection Assistance Information Slice/Service Type), N-SSAI SD (Network Slice Selection Assistance Information Slice/Service Type). To configure these parameters you will explore the configuration files for each slice, in this case here, we are going to configure the UE for the slice 1 (~/oai-cn5g-fed/docker-compose/conf/slicing_slice1_config.yaml), shown in figure below.
![ALT](/openairinterface5g/openairinterface-conf/fig/slice1_configuration.png)  
The UE parameters (figure below) must be equal to the slice 1 configuration file parameters in the template, as illustrated in the figure below.
![ALT](/openairinterface5g/openairinterface-conf/fig/ue_parameters_p2.png)  
**Step 12:** As the experiments were performed at UFRN. It was necessary to add the DNS of the institution's server (10.3.156.40).

![ALT](/openairinterface5g/openairinterface-conf/fig/slice1_dns.png)

## UE 2 Configurations

## Objectives
- Configure the OAI UE 2

**Step 1:** Creating a namespace:

> sudo ip netns add oai-ue2

**Step 2:** Creating a pair of virtual interfaces (veth):

> sudo ip link add veth1 type veth peer name veth2

**Step 3:** Moving one interface to the created namespace:

> sudo ip link set veth2 netns oai-ue2
**Step 4:** Configuring an IP address for veth1 interface:
> sudo ip addr add 192.168.2.1/24 dev veth1

**Step 5:** Configuring an IP address for veth1 interface within the namespace:

> sudo ip netns exec oai-ue2 ip addr add 192.168.2.2/24 dev veth2
**Step 6:** Bringing up the veth1 interface:
> sudo ip link set veth1 up

**Step 7:** Bringing up the veth1 interface within the namespace:

> sudo ip netns exec oai-ue2 ip link set veth2 up

**Step 8:** Adding a route within the namespace:

> sudo ip netns exec oai-ue2 ip route add 192.168.70.0/24 via 192.168.2.1 dev veth2

**Step 9:** Enabling packet forwarding within the namespace:

> sudo ip netns exec oai-ue2 sysctl net.ipv4.conf.all.forwarding=1
**Step 10:** Setting default policy for packet forwarding within the namespace to ACCEPT:

> sudo ip netns exec oai-ue2 iptables -P FORWARD ACCEPT
>
>
> sudo ip netns exec ip route add default via 192.168.2.1 dev veth2
**Step 11:** Enable packet forwarding on the Host:

> echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
>
> sudo iptables -t nat -A POSTROUTING -s 192.168.2.0/24 ! -o veth0 -j MASQUERADE

**Step 12:** Copy the UE file:
> cp ~/openairinterface5g/targets/PROJECTS/GENERIC-NR-5GC/CONF/ue.conf ~/openairinterface5g/targets/PROJECTS/GENERIC-NR-5GC/CONF/ue2.conf
**Step 13:** Configure the IMSI, Permanent Key and OPC
This part you will configure the UE parameters. The UE parameters file is ~/openairinterface5g/targets/PROJECTS/GENERIC-NR-5GC/CONF/ue2.conf. The first three lines of the file are composed by the IMSI, Permanent Key and OPC, as shown in figure below. You will configure these parameters. 
![ALT](/openairinterface5g/openairinterface-conf/fig/ue2_parameters.png) 
You need to check in the docker-compose file (~/oai-cn5g-fed/docker-compose/database/oai_db2.sql) which SQL file the core is using. See figure below. 
Important: The IMSI must be different between the UEs !

![ALT](/openairinterface5g/openairinterface-conf/fig/db_file.png)  

Verify/change the parameters in UE file (~/openairinterface5g/targets/PROJECTS/GENERIC-NR-5GC/CONF/ue2.conf) according to the SQL file illustrated in figure below. The parameters are:
 - "ueid" refers to "imsi"
 - "encPermanentKey" refers to "key"
 - "encOpcKey" refers to "opc

![ALT](/openairinterface5g/openairinterface-conf/fig/UE_config_03.png) 

To open UE file, type:

gedit ~/openairinterface5g/targets/PROJECTS/GENERIC-NR-5GC/CONF/ue2.conf

To open Docker Composer file, type:

gedit ~/oai-cn5g-fed/docker-compose/docker-compose-slicing-basic-nrf.yaml

To see sqlFile, type in a terninal.

gedit ~/oai-cn5g-fed/docker-compose/database/oai_db2.sql

Or use a SQLLite database visualizer like DB Browser (to install: sudo apt install sqlitebrowser -y).

The last three lines of the file are composed of DNN (Data Network Name), N-SSAI SST (Network Slice Selection Assistance Information Slice/Service Type), N-SSAI SD (Network Slice Selection Assistance Information Slice/Service Type). To configure these parameters you will explore the configuration files for each slice, in this case here, we are going to configure the UE for the slice 2 (~/oai-cn5g-fed/docker-compose/conf/slicing_slice2_config.yaml), shown in figure below.
![ALT](/openairinterface5g/openairinterface-conf/fig/slice2_configuration.png)  
The UE parameters (figure below) must be equal to the slice 2 configuration file parameters in the template, as illustrated in the figure below.
![ALT](/openairinterface5g/openairinterface-conf/fig/ue2_parameters_p2.png)  

**Step 13:** As the experiments were performed at UFRN. It was necessary to add the DNS of the institution's server (10.3.156.40).

![ALT](/openairinterface5g/openairinterface-conf/fig/slice2_dns.png)

## Scenario deployment
![ALT](/openairinterface5g/openairinterface-conf/fig/slice_deployment.png)  

## Objectives
- Deploy 5GC, 5G RAN, FlexRIC and OAI UE
Use a separate terminal for each of the following steps.
**Step 1:** Core deployment?
> cd ~/oai-cn5g-fed/docker-compose
> docker compose -f docker-compose-slicing-basic-nrf.yaml up -d 
After running the above command, nine containers are expected to be in the "Up (healthy)" state as shown in figure below.

![ALT](/openairinterface5g/openairinterface-conf/fig/results_deploy_core.png)  

**Step 2:** FlexRIC deployment:

> cd flexric/
>
> ./build/examples/ric/nearRT-RIC 

After running the above command the expect result is shown in figure below.

![ALT](/openairinterface5g/openairinterface-conf/fig/expected_result_flexric.png)  

**Step 3:** gNB deployment:

**Attention:** You must have Core 5G up and running

**Step 3.1:** gNB deploy:
> cd ~/openairinterface5g/cmake_targets/ran_build/build/
> 
> sudo RFSIMULATOR=server ./nr-softmodem --rfsim --sa -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --gNBs.[0].min_rxtxtime 6 --continuous-tx 

**Step 3.2**: To check the connection of gNodeB to the Core, see AMF logs. Open a terminal and use the command below: 

> docker logs -f oai-amf

The expected return is shown in figure below, where gNodeB shows the connected status.

![ALT](/openairinterface5g/openairinterface-conf/fig/gNB_config_06.png)  

**Step 4:** UE 1 deployment:

> sudo ip netns exec oai-ue1 bash
> 
> cd ~/openairinterface5g/cmake_targets/ran_build/build/
> sudo RFSIMULATOR="RAN_IP" ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --sa --nokrnmod -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/ue.conf
**Important:** Verify the IP address set by 5G Core. You will use the command below 

> ip a

The command must show the interface 
**Step 5:** UE 2 deployment:

> sudo ip netns exec oai-ue2 bash
> 
> cd ~/openairinterface5g/cmake_targets/ran_build/build/
> sudo RFSIMULATOR="RAN_IP" ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --sa --nokrnmod -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/ue2.conf

**Step 6:** Slice scheduling xApp:

> cd flexric/build/examples/xApp/c/ctrl
> 
> ./xapp_rc_slice_ctrl

**Step 7:** iperf test UE 1 (Open a new terminal):

> sudo ip netns exec oai-ue1 bash
> 
> Print the oai_tun1 com IP.
>
> iperf3 -i1 -s

**Step 7:** iperf test UE 2 (Open a new terminal):

> sudo ip netns exec oai-ue2 bash
> 
> Print the oai_tun1 com IP.
>
> iperf3 -i1 -s