---
# System prepended metadata

title: '[Technology Background] Installation and Testing 5G ORAN (Free5GC & OAI)'
tags: [Fundamental, Integration]

---

### :school: TEEP 2024_RT LAB_ORAN DPDK

#### :book: Technology Background

:::success
List the essential information of this chapter.
1. Study of ORAN
2. The Installation of 5G ORAN (Free5GC & OAI)
3. The Testing of 5G ORAN (Free5GC & OAI)
:::
---
## 1. Study of ORAN
#### 1.1 Who is ORAN ?
O-RAN ALLIANCE has been founded in February 2018 by AT&T, China Mobile, Deutsche Telekom, NTT DOCOMO and Orange. It has been established as a German entity in August 2018.
‍
Since then, O-RAN ALLIANCE has become a world-wide community of mobile network operators, vendors, and research & academic institutions operating in the Radio Access Network (RAN) industry.
‍
The O-RAN ALLIANCE’s mission is to re-shape the RAN industry towards more intelligent, open, virtualized, and interoperable networks. To achieve its mission, it embarks on three main streams of work:
1. Specification effort
2. O-RAN Software Community
3. Testing and Integration

As part of the Testing and Integration stream, Open Testing and Integration Centres (OTICs) and the O-RAN Certification and Badging program are key pillars that support the ecosystem in achieving the mission of O-RAN. This white paper provides an overview of these two key pillars, what they are, how they operate, and their key objectives.

O-RAN ALLIANCE operates in compliance with WTO principles for the development of international standards, guides and recommendations: transparency, openness, impartiality and consensus, effectiveness and relevance, coherence, and addressing the concerns of developing countries. 

**Open Testing and Integration Centre (OTIC)**

The O-RAN ALLIANCE qualified Open Testing and Integration Centre (OTIC) provides a collaborative, open, vendor-independent, and impartial working environment to any potential client/customer that is interested in testing its products and solutions.

Any O-RAN Member and/or Contributor that exhibit vendor neutrality can apply to host an OTIC, and each OTIC may be hosted by one or more hosts. The host(s) coordinates and is fully responsible for all the activities in an OTIC.

Each OTIC may focus on different activities and services such as:

* Awarding O-RAN certificates and/or badges
* Hosting O-RAN PlugFests to accelerate the maturity of products and solutions based on O-RAN specifications
* Conformance, interoperability and/or end-to-end testing of O-RAN products and solutions
* Reference setups and testbed
* Supporting wide adoption of O-RAN specifications and promote the openness of the O-RAN ecosystem via demos, community events (e.g., speaker sessions, workshops, tutorials), lab and field trials, etc.
* Fostering and developing technical skills of the O-RAN community via workshops, tutorials, etc.
* Providing feedback to the O-RAN community about the experiences with O-RAN specifications acquired during the testing, to encourage and enable implementation-driven specifications

![image](https://hackmd.io/_uploads/ry4aa5Pja.png)

#### 1.2 What ORAN do ?
O-RAN ALLIANCE mission is to transform the Radio Access Network industry towards truly open, intelligent, virtualized and fully interoperable RAN.

According to their website, they have 4 jobs

1. Specification Effort
   * O-RAN specifications define individual parts of the O-RAN Architecture. Anyone can use them to create innovative and competitive open RAN solutions.
   * O-RAN ALLIANCE's white papers describe in deeper detail its purpose, objectives and plans to achieve them.
2. Open Software for the RAN
   * The O-RAN Software Community is a collaboration between the O-RAN ALLIANCE and Linux Foundation aiming to support the creation of open software for the RAN.
   * The O-RAN Software initiatives are focused on aligning a software reference implementation with the O-RAN Architecture and specifications. The aim is to achieve a solution that can be utilized to unify and accelerate the evolution and deployment in the RAN.
3. Testing & Integration of O-RAN Implementations
   * O-RAN ALLIANCE supports its Members and Contributors in testing and integration of their O-RAN implementations
   * Open Testing and Integration Centres (OTIC) provide a collaborative, open, and impartial
testing environment.
4. O-RAN Demonstrations
   * O-RAN Virtual Exhibition allows companies to demonstrate their O-RAN based implementations.
   
#### 1.3 ORAN Working Group
The O-RAN specification work has been divided into technical Work Groups (WG), all of them under the supervision of the Technical Steering Committee. Each of the WGs covers a part of the O-RAN Architecture. All WGs are open to all Members and Contributors.

![image](https://hackmd.io/_uploads/SymdyiDja.png)

**WG1: Use Cases and Overall Architecture Work Group**
It has overall responsibility for the O-RAN Architecture and Use Cases.  WG 1 identifies tasks to be completed within the scope of the Architecture and Use Cases and assigns Task Group leads to drive these tasks to completion while working across other O-RAN Work Groups.

**WG2: The Non-Real-Time RAN Intelligent**
Controller and A1 Interface Work Group
The primary goal of Non-RT RIC is to support Non-Real-Time intelligent radio resource management, higher layer procedure optimization, policy optimization in RAN, and providing AI/ML models to Near-RT RIC.

**WG3: The Near-Real-Time RIC**
and E2 Interface Work Group
The focus of this WG is to define an architecture based on Near-Real-Time Radio Intelligent Controller (Near-RT RIC), which enables near-real-time control and optimization of RAN elements and resources via fine-grained data collection and actions over E2 interface.

**WG4: The Open Fronthaul Interfaces Work Group**
The objective of this WG is to deliver truly open fronthaul interfaces, in which multi-vendor DU-RRU interoperability can be realized.

**WG5: The Open F1/W1/E1/X2/Xn Interface Work Group**
The objective of this WG is to provide fully operable multi-vendor profile specifications (which shall be compliant with 3GPP specification) for F1/W1/E1/X2/Xn interfaces and in some cases will propose 3GPP specification enhancements.

**WG6: The Cloudification and Orchestration Work Group**
The cloudification and orchestration WG seeks to drive the decoupling of RAN software from the underlying hardware platforms and to produce technology and reference designs that would allow commodity hardware platforms to be leveraged for all parts of a RAN deployment including the CU and the DU.

**WG7: The White-box Hardware Work Group**
The promotion of open reference design hardware is a potential way to reduce the cost of 5G deployment that will benefit both the operators and vendors. The objective of this Work Group is to specify and release a complete reference design to foster a decoupled software and hardware platform.

**WG8: Stack Reference Design Work Group**
The aim of this WG is to develop the software architecture, design, and release plan for the O-RAN Central Unit (O-CU) and O-RAN Distributed Unit (O-DU) based on O-RAN and 3GPP specifications for the NR protocol stack.

**WG9: Open X-haul Transport Work Group**
This WG focuses on the transport domain, consisting of transport equipment, physical media and control/management protocols associated with the transport network.

**WG10: OAM Work Group**
This WG is responsible for the OAM requirements, OAM architecture and the O1 interface.

**WG11: Security Work Group**
This WG focuses on security aspects of the open RAN ecosystem.


---

## 2. The Installation of 5G ORAN
#### 2.1 Free5GC
![image](https://hackmd.io/_uploads/ByGgzPuip.png)

:::warning
We choose to use K8s to deploy free5GC.
Actually, you can also follow offical website to setup free5GC without K8s.
:::
##### 2.1.1 Prerequisites
```
sudo apt-get install -y docker.io curl git
## update package repository
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"
## install kubeadm, kubectl and kubelet in specific version
sudo apt-get install -y kubelet=1.19.0-00 kubeadm=1.19.0-00 kubectl=1.19.0-00
## mark these packages not need to be updated
sudo apt-mark hold kubelet kubectl kubeadm
## add kubectl auto-completion
echo "source <(kubectl completion bash)" >> ~/.bashrc
## This command is optional
## If you want to use docker without sudo
sudo usermod -aG docker <username>
```

##### 2.1.2 Write configuration (in cluster-config.yaml)
```
apiVersion: kubeadm.k8s.io/v1beta2
kind: ClusterConfiguration
kubernetesVersion: v1.19.0
apiServer:
  extraArgs:
    feature-gates: "SCTPSupport=true"
```

##### 2.1.3 Configure the swap to disable
```
## Disable swap in order for the kubelet to work properly
sudo swapoff -a
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
```

##### 2.1.4 Deploy K8s Cluster
```
sudo kubeadm init --config cluster-config.yaml
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl taint nodes --all node-role.kubernetes.io/master-
```
Install Calico as CNI of this cluster
```
kubectl apply -f https://docs.projectcalico.org/v3.11/manifests/calico.yaml
```

##### 2.1.5 Install Network File System (NFS) Server

```
sudo apt install -y nfs-kernel-server
sudo mkdir -p /var/share/free5gc
echo "/var/share/free5gc *(rw,sync,no_root_squash)" | sudo tee -a /etc/exports
sudo exportfs -r
## check if directory is exported correctly
sudo showmount -e
```
note: NFS serves as backend store for MongoDB
##### 2.1.6 Install gtp5g Kernel Module
```
sudo apt install -y build-essential
## for free5gc v3.3.0
git clone -b v0.8.5 https://github.com/free5gc/gtp5g.git
cd gtp5g
make
sudo make install
## check if gtp5g is loaded
lsmod | grep gtp5g
```
##### 2.1.7 Deploy pods in cluster
```
cd ~/free5GC-stage3-on-k8s
## for free5gc v3.3.0
sudo docker build -t free5gc-build:v3.3.0 .
## order: mongo -> webui -> NRF -> NFs other than SMF -> SMF
cd free5gc-nf-yml/
kubectl apply -f mongo
kubectl apply -f webui
kubectl apply -f nrf
kubectl apply -f pcf
kubectl apply -f udm
kubectl apply -f udr
kubectl apply -f upf
kubectl apply -f amf
kubectl apply -f ausf
kubectl apply -f nssf
kubectl apply -f smf
## check if all pods are running
kubectl get pod -o wide
```
![image](https://hackmd.io/_uploads/HkFPLe73p.png)

##### 2.1.8 Webconsole & Create subscriber (UE)
Go to localhost:30300, username is admin and password is free5gc

![image](https://hackmd.io/_uploads/HJIktl72p.png)

Add new subscriber (default)

![image](https://hackmd.io/_uploads/r1JGtg7h6.png)

#### 2.2 Open Air Interface (OAI)

![image](https://hackmd.io/_uploads/HkJqteQh6.png)

##### 2.2.1 Clone Openairinterface5g

```
sudo apt install git cmake build-essentials
# Fetch the OpenAirInterface source code
git clone https://gitlab.eurecom.fr/oai/openairinterface5g.git
```
##### 2.2.2 Build the source code from what you clone
```
cd openairinterface5g
# Initialize the necessary environment variables
source oaienv
cd cmake_targets/ 
./build_oai -I --gNB --nrUE -w SIMU
```

##### 2.2.3 Check the compiled binary
```
# Make sure the binaries are exist at ran_build
ls ran_build/build/
```
![image](https://hackmd.io/_uploads/H14Tj9jO6.png)

i use branch 2023.w43
```=
git branch
```
![image](https://hackmd.io/_uploads/S1Os60-nT.png)

## 3. Setup configuration file for gNB and UE
#### 3.1 gNB-CU Configuration
```
// Tracking area code, 0x0000 and 0xfffe are reserved values
    tracking_area_code  =  1;
    plmn_list = ({
			 mcc = 208;
			 mnc = 93;
			 mnc_length = 2;
			 snssaiList = (
			 {
				sst = 1;
				sd  = 0x010203; // 0 false, else true
			 },
			 {
				 sst = 1;
				 sd  = 0x112233; // 0 false, else true
			 }
			);
		});
    
    nr_cellid = 12345678L
    
    tr_s_preference = "f1";
    
    local_s_if_name = "lo";
    local_s_address = "127.0.0.1";
    remote_s_address = "127.0.0.2";
    local_s_portc   = 600;
    local_s_portd   = 2152;
    remote_s_portc  = 601;
    remote_s_portd  = 2152;
...
////////// AMF parameters:
    amf_ip_address      = ( { ipv4       = "192.168.2.2"; // AMF IP address
                              ipv6       = "192:168:30::17"; // not important
                              active     = "yes";
                              preference = "ipv4";
                            }
                          );


    NETWORK_INTERFACES :
    {
        GNB_INTERFACE_NAME_FOR_NG_AMF            = "enp0s3"; // any interface accessible to AMF
        GNB_IPV4_ADDRESS_FOR_NG_AMF              = "10.0.2.15/24"; // IP of above interface
        GNB_INTERFACE_NAME_FOR_NGU               = "enp0s3"; // any interface accessible to UPF
        GNB_IPV4_ADDRESS_FOR_NGU                 = "10.0.2.15/24"; // IP of above interface
        GNB_PORT_FOR_S1U                         = 2152; # Spec 2152
    };
```
#### 3.2 gNB-DU Configuration
```
// Tracking area code, 0x0000 and 0xfffe are reserved values
    tracking_area_code  =  1;
    plmn_list = ({
			 mcc = 208;
			 mnc = 93;
			 mnc_length = 2;
			 snssaiList = (
			 {
				sst = 1;
				sd  = 0x010203; // 0 false, else true
			 },
			 {
				sst = 1;
				sd  = 0x112233; // 0 false, else true
			 }
			);
		});
...
////////// Physical parameters:

    ssb_SubcarrierOffset  = 0;
    pdsch_AntennaPorts    = 1;
    pusch_AntennaPorts    = 1;
    min_rxtxtime          = 6;
    sib1_tda              = 1;
...
MACRLCs = (
  {
    num_cc           = 1;
    tr_s_preference  = "local_L1";
    tr_n_preference  = "f1";
    local_n_if_name = "lo";
    local_n_address = "127.0.0.2";
    remote_n_address = "127.0.0.1";
    local_n_portc   = 601;
    local_n_portd   = 2152;
    remote_n_portc  = 600;
    remote_n_portd  = 2152;

  }
...
# If you add this setting, you don't need to add RFSIMULATOR parameter during running CU
rfsimulator: {
    serveraddr = "server";
    serverport = "4043";
    options = (); #("saviq"); or/and "chanmod"
    modelname = "AWGN";
    IQfile = "/tmp/rfsimulator.iqs"
}
```
#### 3.3UE Configuration
```
uicc0 = {
imsi = "208930000000003";
key = "8baf473f2f8fd09487cccbd7097c6862";
opc= "8e27b6af0e692e750f32667a3b14605d";
dnn= "internet";
nssai_sst=1;
nssai_sd=0x010203;
}
```

## Running The Env
### Running gNB-CU
```
cd openairinterface5g/cmake_targets/ran_build/build
## If you have set rfsimulator in DU configuration
sudo ./nr-softmodem --rfsim --sa -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf
## Else
sudo RFSIMULATOR=server ./nr-softmodem --rfsim --sa -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf
```
### Running gNB-DU
```
cd openairinterface5g/cmake_targets/ran_build/build
## If you have set rfsimulator in DU configuration
sudo ./nr-softmodem --rfsim --sa -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf
## Else
sudo RFSIMULATOR=server ./nr-softmodem --rfsim --sa -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf
```
### Running UE
```
cd openairinterface5g/cmake_targets/ran_build/build
sudo RFSIMULATOR=127.0.0.1 ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --sa --nokrnmod -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/ue.conf
```
## Testing The Env
### Ping the network
```
ping -I oaitun_ue1 8.8.8.8
```
![image](https://hackmd.io/_uploads/By0P1-X2T.png)
