owned this note
owned this note
Published
Linked with GitHub
# LAB3
---
# Single Machine ? Mutiple Machine ?
- In general, we can deploy eNodeB and EPC in different machine. But we can also depoly eNodeB and EPC in single machine (All in one). You can check the following pictures to know the different architecture.
- OAI eNodeB and OAI EPC in single machine

- OAI eNodeB and OAI EPC in different machine

---
# Build EPC & eNodeB in Single Machine
This tutorial using a Single Machine EPC-eNodeB Scenario and other Single Machine to be the UE. Also, this tutorial will guide you to build your own Experiment Profile from scratch.
### 1. Create Experiment Profile
After you created an account, you can go to your dashboard and start an Experiment.

### 2. Give Name and Create Topology
You can give the name whatever you want, but try to use the simple one. Then click "Create Topology" button to design a new Topology

### 3. Creating the Topology
Drag the Bare Metal PC node to your workspace

- Give a name for the node, and select raw-pc for the Node Type.
- For the Hardware Type, you should choose **nuc5300**, because this is the only Hardware Type that have USRP B210 (Radio Frequency Device) attached to it.
- For the Disk Image, you should choose Ubuntu 14.04 LTS 64-Bit, because this is the stable Ubuntu OS for running the OAI.

#### Select OS Disk Image

Drag one more Bare Metal PC node to your workspace, so we can operate it as UE. We should choose the same specification as the previous node.

FYI, we can change the icon so it will be looked different.

### 4. Write Description and Instructions
You can describe what the purpose of this profile, what Hardware Specification, OS, and Kernel that you used in each nodes, and so on. Moreover, you can write the instructions, so other people who want to instantiate your Profile can follow the same step as you do. But it doesn't matter if you want to update it later.
#### Select who can instantiate our Profile, then Click Instantiate
You can choose if you want to set your Profile to private (only for your project member), or if you want to let it public (open for everyone). Then you can click "Create"

### 5. Name the Experiments
After you give a name for your experiment, you should wait it until it's ready



After it ready, you can open the terminal using POWDER Shell and insert the documented commands

### 6. Update system utility
#### sudo apt-get update

### 7. Configure the hostname & hosts file
#### hostname
Check the hostname and copy it into the hostname & hosts file
#### sudo nano /etc/hostname


#### sudo nano /etc/hosts
Put a line below the last line. Use this format:
127.0.1.1 ==(tab)== ==(tab)== ==(your hostname)== openair4G.eur ==(space)== ==(your hostname)==

### 8. Install the latest version of Git
#### sudo apt-get install git -y

### 9. Clone the eNodeB Source Code
#### git clone https://gitlab.eurecom.fr/oai/openairinterface5g.git
### 10. Clone the EPC Source Code
#### git clone https://gitlab.eurecom.fr/oai/openair-cn.git

### 11. Choose the Source Code Branch you want to use
#### cd openair-cn/
#### git checkout v0.3.2

### 12. Install Low Latency Kernel
#### sudo apt-get install linux-lowlatency-lts-vivid -y


### 13. Set CPU Scalling
Use this to maximize the CPU usage
#### sudo apt-get install cpufrequtils


```
```
#### sudo nano /etc/default/cpufrequtils
add GOVERNOR="performance" line in the file


```
```
#### sudo nano /etc/default/grub
Find the line and modify it to this line GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_pstate=disable processor.max_cstate=1 intel_idle.max_cstate=0 idle=poll"

```
```
#### sudo update-rc.d ondemand disable

### 14. Show the list of installed Kernel
#### dpkg --get-selections | grep linux-image
### 15. Remove the unused Kernels
Remove all Kernel except those Low Latency Kernels
#### sudo apt-get purge linux-image-3.13.0-143-generic linux-image-extra-3.13.0-143-generic linux-image-generic

### 16. Set the Low Latency to be Default Kernel
#### sudo update-grub2
### 17. Reboot PC
#### sudo reboot

### 18. Install the package those are needed by the HSS
#### sudo update-grubcd openair-cn/SCRIPTS/
#### sudo ./build_hss -i

##### set password to "linux"


##### select apache

##### select "Yes"

##### set password to "linux"



### 19. Install the package those are needed by the HSS (including MME & SPGW)
#### sudo ./build_epc -i




### 20. Install the package those are needed from eNB, (including UHD driver)
#### cd ~/openairinterface5g/cmake_targets/
#### sudo ./build_oai -I --eNB -x --install-system-files -w USRP


### 21. Configure the eNB configruation file
You should copy the file to your home directory to make it easier for you when configuring it
#### cd ~/openairinterface5g/targets/PROJECTS/GENERIC-LTE-EPC/CONF/
#### cp enb.band7.tm1.50PRB.usrpb210.conf ~/
#### cd
#### sudo nano enb.band7.tm1.50PRB.usrpb210.conf
Edit the MME Parameters and Network Interfaces part to exactly same as this tutorial figure



```
```
### 22. Take a look at your Network Configuration
#### ifconfig
Take a note of your eth0 IP (inet addr). We will need it later

### 23. Configure your EPC configuration file
#### cd openair-cn/BUILD/EPC/
#### sudo nano epc.conf.in

Change the REALM to "openair4G.eur"

Edit the S6A_CONF directory to /usr/lib/
Edit the HSS_HOSTNAME from "oai-pc" into your long hostname in the step number 7a

Change the MNC and TAC, follow the figure

Change the LOGGING OUTPUT to "CONSOLE"

Edit the P-GW interface for SGI with your previously noted IP (from ifconfig)

Change the DNS, follow the figure

```
```
### 24. Build the EPC and HSS
#### cd ~/openair-cn/SCRIPTS/
#### sudo ./build_epc -i

#### sudo ./build_epc -c -l

#### sudo ./build_hss -c -l

### 25. Run HSS
#### sudo ./run_hss


### 26. Run EPC
#### sudo ./run_epc -i -r


### 27. Run eNB
#### cd openairinterface5g/cmake_targets/lte_build_oai/build/
#### sudo ifconfig eth0:3 192.170.0.2 up
#### sudo ifconfig eth0:4 192.170.1.2 up
#### sudo ./lte-softmodem -E -O ~/enb.band7.tm1.50PRB.usrpb210.conf



### 28. Successully run HSS, EPC, and eNB

You should make sure that your terminal runs the Log message like this. It means the eNB is waiting the UE to be attached
---
# Build UE in single machine
---
### Implementation of OAI UE in POWDER
## Create Experiment profile
1. We get an error in the first experiment and also get a suggestion about porting OAI using nuc5300. So we try it again use another topology

2. I name it correct1

3. Click create topology,

4. drag 1 Bare metal PC to the space

5. left-click on the icon, chose hardware type : nuc5300 since this hardware is connected with USRP b210.

Choose disk image Ubuntu14-64-STD as shown in the figure below

6. Finish it by clicking accept and it directly go to the next page. Just hit create button

7. After process, it will be shown, Hit instantiate button to start the project

8. fill the name of your profile to the blank, i name my profile as correct1profile and click finish

10. wait until the process finish. You have 16 hours to finish your experiment. If you think it is not enough you can extend it 
## Start Instalation Kernel
1. Picture shown below is the shell view of our PC. You can click tab topology view if you want to see your topology

2. type sudo apt-get update

3. Go to this link : https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/uestartup
4. Setup the kernel, we choose kernel vivid

5. type : sudo apt-get install linux-lowlatency-lts-vivid -y

type sudo reboot to know the result
6. press symbol x next to UE
7. go to topology view
8. click left-click, choose shell
9. Type uname -r to check whether your kernel low latency already installed

## Increase power management
1. According to this link https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/uestartup if we want to increase the use of power we have to ensure doing this procedure :
- Install low-latency kernel
- Disable C-states from BIOS (or from GRUB)
- Disable CPU freq. scaling
2. We have finished installing low-latency kernel
3. To check CPU frequency scaling type this command watch grep \ "cpu MHz\ " /proc/cpuinfo 
press Ctrl+C to back to shell
4. we can see the picture that the CPU is used devided in some parts.
5. The next step to disable CPU frequency is install cpufrequtils using this command :
sudo apt-get install cpufrequtils

6. create cpufrequtils file
sudo vi /etc/default/cpufrequtils
7. And add the following line to it: GOVERNOR="performance"

save and exit
8. Now you need to disable ondemand daemon, otherwise after you reboot the settings will be overwritten. *sudo update-rc.d ondemand disable*

9. and type : sudo /etc/init.d/cpufrequtils restart

10. to check our setting : cpufreq-info

11. type sudo Reboot
12. you must disable p-state and c-state in linux so you need to add intel_pstate=disable to the Linux boot options, i.e GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_pstate=disable" in /etc/default/grub, then perform update-grub. You may optionally add the following as well "processor.max_cstate=1 intel_idle.max_cstate=0 idle=poll"

then perform update-grub.

13. Append "blacklist intel_powerclamp" to the end of /etc/modprobe.d/blacklist.conf, to blacklist the intel_powerclamp" module. If the file does not exist, create one, and add the line into it.

16. Install i7z utility to check the cpu *sudo apt-get install i7z* 
and *sudo i7z*

17. We have successfully increased the performance of our CPU. The next step is to implement OAI in powder
## Save our disk image
1. Before we continue to next step, we should save our work on disk image by clicking create disk image 
2. If we choose the first choice it is like only save, if we want to save as without replacing current file we can choose second choice  after choosing one of them hit continue button
3. If we want to put our file we should choose the locations like /usr/local or /opt. However it will be not saved
## Implement OAI UE
1. I go to /opt and I will download openairinterface to this folder

2. Type sudo git clone https://gitlab.eurecom.fr/oai/openairinterface5g.git

3. after success download it, go to openairinterface5g/cmake_targerts folder. run command sudo ./build_oai -I

4. Type sudo ./build_oai --UE -w USRP

### ./build_oai --UE -w USRP Problem
- run command *sudo ./build_oai --UE -w USRP* but we found failed of build

- we tried to solv it, in a real case when we got this problem we just try to make a file of build_oai as an execute file. Go to
*/opt/openairinterface5g/cmake_targets/lte_build_oai/build/CMakeFiles/*
you can use command *ls -l CMakeOutput.log* to see whether your file is readable, writeable, executeable file or not

- because CMakeOutput.log is not executable file so we run this command
chmod +x CMakeOutput.log

- after that run this command sudo apt-get install libboost-all-dev, press y to continue when you get the question. Wait until the process done

5. go to folder tools by running this command cd tools, and type sudo ./init_nas_s1 UE
6. go to folder cd /opt/openairinterface5g/targets/bin and type sudo -E ./lte-softmodem.Rel14 -U -C2660000000 -r25 --ue-scan-carrier --ue-txgain 125 --ue-rxgain 125 2>&1 | tee UE.log

7. go to openairinterface5g/cmake_targets/ and type sudo apt-get install libboost-all-dev

8. type sudo ./build_oai --UE -w USRP -x

9. we are assuming that this process is correct and we can use another new shell

---
OAI eNB and EPC installation is created by David Raditya K (davidraditya.netic@yahoo.com)
OAI UE installation is created by Asif Ali Zamzami