# (A3) NS-3 Simulation
###### tags:`NS-3` `ORAN`
## :notebook_with_decorative_cover: Personal Information
:::info
- Name: Saffana Zyan Dini
- ID : M11102815
:::
## :book: Part I :A3 NS-3 Simulator
### A. Weekly Plan
| Study | 04/10 | 07/10 | 09/10 | 11/10 | 14/10 | 15/10 |
|:-----------------------------------------:|:----------:| ----- |:------:|:-------:|:-------:|:-------:|
|[Study paper](https://arxiv.org/pdf/2209.14171.pdf) |X| X | | | | |
|Install [sim-e2](https://github.com/o-ran-sc/sim-e2-interface.git) | X|X||| | |
|ns-3 configuration | |X|X| | | |
|ns-3 testing | |X| X| | | |
|ns-3 Simulation | |X|X|X| X| X |
|Study Note | | | | |X | X |
|Presentation Video | | | | | | x |
***
### B. Study Reference
:bookmark:**Paper information:**

:bookmark:**Title:** [Programmable and Customized Intelligence for
Traffic Steering in 5G Networks Using
Open RAN Architectures](https://arxiv.org/pdf/2209.14171.pdf)
:bookmark:**Author:** Andrea Lacava, Student Member, IEEE, Michele Polese, Member, IEEE,
Rajarajan Sivaraj, Senior Member, IEEE, Rahul Soundrarajan, Bhawani Shanker Bhati, Tarunjeet Singh,
Tommaso Zugno, Francesca Cuomo, Senior Member, IEEE and Tommaso Melodia Fellow, IEEE
:bookmark: **Problem**
The problem addressed in this paper is the lack of fine-grained control and optimization of network functionalities customized to individual users in the current cellular architecture [6a]. The document focuses on the development and evaluation of an intelligent traffic steering solution in the context of Open RAN architectures [1]. Specifically, the paper formulates the optimization problem for traffic steering and discusses the algorithm design to determine the optimal target cells for handover of User Equipments (UEs) [6b]. It proposes a data-driven UE-based traffic steering/handover optimization technique based on Conservative Q-learning, which is the first of its kind [6c]. The document highlights the challenges associated with designing and testing intelligent RAN control solutions, including the need for large-scale data collection and isolated environments for training and testing [2].
:bookmark: **Challenge and importance of the problem**
The challenge addressed in the document is the lack of fine-grained control and optimization of network functionalities customized to individual users in the current cellular architecture [2a]. This limitation hinders the efficient management of handovers and mobility for different use cases [2b]. The importance of addressing this challenge lies in the need for advanced network control and optimization in 5G networks to meet diverse requirements, such as high-quality video streaming and ultra-reliable low-latency communication for autonomous vehicles [2b]. The document emphasizes the importance of developing intelligent RAN control solutions to embed into xApps, enabling the optimization of handover decisions tailored to the quality of service requirements of each user [6]. This problem is crucial for realizing the full potential of Open RAN architectures, which aim to provide programmable and customized intelligence for traffic steering [1].
:bookmark: **Assumptions**
It assumes the use of Open RAN paradigm and its specifications for closed-loop control and intelligent optimization of the Radio Access Network (RAN) at the user-level. The document also assumes the use of a software framework called ns-O-RAN that integrates a real-world, near-real-time RAN Intelligent Controller (near-RT RIC) with a simulated environment on ns-3 for the development, testing, and evaluation of custom RAN control applications (xApps) and Deep Reinforcement Learning (DRL) driven control policies.
:bookmark: **Performance metrics**
The performance metrics considered for the evaluation of the proposed traffic steering solution in the document include throughput, channel quality, spectral efficiency, and mobility overhead [10a]. For throughput, the average user throughput at the Packet Data Convergence Protocol (PDCP) layer is reported, which includes both LTE and NR split bearers [11a]. The document also discusses the 10th and 95th percentiles of user throughput, showing improvements for both the worst and best users compared to baseline heuristics [11b].
Channel quality is represented by the Signal-to-Interference-plus-Noise Ratio (SINR), and its Cumulative Distribution Function (CDF) is analyzed to show the performance gains of the proposed solution [11a]. Spectral efficiency is evaluated by analyzing the average spectral efficiency per user and per cell, as well as the percentage of Physical Resource Blocks (PRBs) used for downlink traffic [11c] [11d].
The mobility overhead is evaluated as the number of handovers per unit time weighted by a throughput factor [10b]. The document shows that the proposed solution avoids adding more handovers compared to baseline strategies while delivering better throughput [11e].
Overall, these performance metrics provide a comprehensive evaluation of the proposed traffic steering solution's effectiveness in improving network performance in terms of throughput, channel quality, spectral efficiency, and mobility overhead.
:bookmark: **Basic concepts**
The document provides an overview of programmable and customized intelligence for traffic steering in 5G networks using Open RAN architectures. It discusses the limitations of the current cellular architecture in terms of fine-grained control and optimization of network functionalities for individual users. To address this gap, the document proposes the use of the Open RAN paradigm and its specifications, which introduce an "open" architecture with abstractions that enable closed-loop control and intelligent optimization of the Radio Access Network (RAN) at the user-level.
One of the key components in this proposed architecture is a software framework called ns-O-RAN, which integrates a real-world, near-real-time RAN Intelligent Controller (near-RT RIC) with a simulated environment on ns-3. This framework allows for the development of custom RAN control applications (xApps) and facilitates large-scale data collection and testing of Deep Reinforcement Learning (DRL)-driven control policies.
The document also proposes a user-specific O-RAN Traffic Steering (TS) intelligent handover framework, which optimally assigns a serving base station to each user in the network using a combination of algorithms. The performance evaluation of this framework shows improvements in throughput and spectral efficiency compared to traditional handover heuristics.
Overall, the document highlights the challenges associated with designing and testing intelligent RAN control solutions and emphasizes the need for large-scale data collection and isolated environments for training and testing. It provides insights into the development and evaluation of an intelligent traffic steering solution within the context of Open RAN architectures.
:bookmark: **Results**
In the document, the results of the performance evaluation of the proposed framework for traffic steering in 5G networks using Open RAN architectures are discussed. The evaluation compared the performance of the RAN Intelligent Controller (RIC) using reinforcement learning (RL) agent to baseline handover control policies. The results showed improvements in average user throughput, spectral efficiency, and other key performance metrics [12a][12b][12c][12d][11a][11b]. The RL agent demonstrated adaptability across different frequency bands and showed significant gains for different types of traffic, such as video streaming, web browsing, and instant messages [12a][12b][12d]. The results also highlighted the customization of handover management for individual users and scalability of the approach [11b][11c]. Furthermore, the RL agent improved the spectral efficiency and throughput while keeping the mobility overhead similar to or lower than the baselines [11a][12e]. Thus, the results demonstrate the effectiveness of the proposed intelligent traffic steering solution in optimizing network performance in Open RAN architectures.
### C. Simulation
#### :bookmark: Install ns3-o-ran-e2
This ns-3 module enables the support for running multiple terminations of an O-RAN-compliant E2 interface inside the simulation process. It has been developed as part of a collaborative effort between the Institute for the Wireless Internet of Things (WIoT) at Northeastern University, Mavenir, and the University of Padova.
1. **System Requirements:**
- A Linux-based operating system (e.g., Ubuntu, Fedora, Debian). NS-3 is not officially supported on Windows, but you can use Windows Subsystem for Linux (WSL) or a virtual machine with Linux.
- Python 2.7 or later (Python 3 is recommended).
- Some optional modules might require additional software, such as GCC and other development tools.
**2. Prerequisites:**
**Note**: Cmake version >= 12.00
**a. Install Docker 19.03**
* Install dependency Packeges
```bash![]
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
```
* Add Docker GPG key
```bash![]
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt - key add - sudo apt - key fingerprint 0EBFCD88
```
* Add Docker Packege Library
```bash![]
sudo add-apt-repository "deb [arch=amd64] https :// download . docker . com / linux / ubuntu $(lsb_release -cs) stable"
```
* Install NVIDIA Cantainer Toolkit
```bash![]
sudo apt-get update
sudo apt-get install nvidia-container-toolkit
```
* Install NVIDIA Cantainer Toolkit
```bash![]
sudo apt-get update
sudo apt-get install nvidia-container-toolkit
```
* Restart docker
```bash![]
sudo systemctl restart docker
```
* Execute docker without sudo (optimal)
```bash![]
sudo groupadd docker
sudo gpasswd -a ${USER} docker
sudo service docker restart
```
**b. Install cmake, g++, python**
The installation are needed by ns-O-RAN Setup
```bash![]
sudo apt-get update
# Requirements for e2sim
sudo apt-get install -y build-essential git cmake libsctp-dev autoconf automake libtool bison flex libboost-all-dev
# Requirements for ns-3
sudo apt-get install g++ python3
```
**3. Near-RT RIC Setup**
* Cloning the Colosseum's near-RT RIC
```bash![]
sudo git clone -b ns-o-ran https://github.com/wineslab/colosseum-near-rt-ric
cd colosseum-near-rt-ric/setup-scripts
```
* import all the images we need in Docker, tag them properly and we build and launch them
```bash![]
sudo ./import-wines-images.sh # import and tag
sudo ./setup-ric-bronze.sh # setup and launch
```
Result:


**Note:**
we can open **two terminal** for the RIC, one for logging the values on the E2Term and check the E2AP messages exchange, the other for the xApp.it is will build and run a Docker container for the x-app and will also create a shell inside the container, and log you inside the container.
#### Terminal 1
logs the E2Term, this will help to show only when a gnb is interacting
```bash![]
sudo docker logs e2term -f --since=1s 2>&1 | grep gnb:
```
#### Terminal 2
builds and run the x-app container.
```bash![]
cd colosseum-near-rt-ric/setup-scripts
sudo ./start-xapp-ns-o-ran.sh
```
Result:

we can move to the /home/sample-xapp directory inside the Docker container, and run the xApp logic:
```bash!
cd /home/sample-xapp
./run_xapp.sh
```
result:
**4. ns-O-RAN Setup**
* Then we can clone and install the e2Sim software. To see the E2 ASN messages on the e2sim, we build it with LOG_LEVEL equal to 3 (DEBUG). This is useful to debug the exchange of the messages between the ns-3 and the RIC, but we also provide different debug levels that can be setup. These levels are summarized in the table below.
```bash!
sudo git clone https://github.com/wineslab/ns-o-ran-e2-sim oran-e2sim # this will create a folder called oran-e2sim
cd oran-e2sim/e2sim/
sudo mkdir build
sudo ./build_e2sim.sh 3
```
* clone and install the ns3-mmWave project:
```bash!
cd ns-3-mmwave-oran/contrib
sudo git clone -b master https://github.com/o-ran-sc/sim-ns3-o-ran-e2 oran-interface
cd .. # go back to the ns-3-mmwave-oran folder
```
* build ns-3
```bash!
sudo ./waf configure --enable-examples --enable-tests
sudo ./waf build
```
Result:

**d. RUN the Scenario**
we can run an example ns-3 scenario called “Scenario Zero”. This scenario features a Non Stand Alone (NSA) 5G setup in which we have one LTE eNB positioned in the center of the scenario and four gNBs around it with an inter site distance of 1000 between the eNB and each gNB. We can run the scenario with the command:
```bash!
sudo ./waf --run scratch/scenario-zero.cc
```

### C. Presentation Video
[Presentation Video](https://youtu.be/wCoV9qfqGWs)
## :book: Part II :Demo Video
Demo video: [ns3 ORAN Demo Video](https://youtu.be/tS9wNUrJAZ0)
### Reference
[Install Docker in Ubuntu](https://roychou121.github.io/2020/07/13/ubuntu-install-docker/)
[Tutorial ns3 ORAN](https://openrangym.com/tutorials/ns-o-ran)