:::info
# How to connect UE with OAI gNB (USRP B210)
:::
[TOC]
## 1. Installation and Configuration of OAI gNB + EPC + HSS
:::warning
**Problem:** "openair-cn-cups" (SPGW) should build on ubuntu **18.04**.
**Solution:** Create a VM (ubuntu 18.04) by **uvtool**.
:::
### 1.1 Installation
#### (1). git clone "openairinterface5g", "openair-cn" and "openair-cn-cups"
```cpp=
# clone eNB/UE source code from EURECOM gitlab
git clone https://gitlab.eurecom.fr/oai/openairinterface5g.git
# clone MME & HSS source code from EURECOM github
git clone https://github.com/OPENAIRINTERFACE/openair-cn.git
# clone SPGW source code from EURECOM github
git clone https://github.com/OPENAIRINTERFACE/openair-cn-cups.git
```
#### (2). Specify FQDN for EPC (no need because we will build LTEbox)
In this example, the hostname is **"nano"**.
```cpp=
# confirm the hostname
nano@nano:$ cat /etc/hostname
nano
```
```cpp=
nano@nano:$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 nano.openair4G.eur nano
127.0.1.1 hss.openair4G.eur hss
nano@nano:$ hostname
nano
nano@nano:$ hostname -f
nano.openair4G.eur
```
#### (3). Run Automated Build Script (openairinterface5g)
```cpp=
cd ~/openairinterface5g
git checkout develop-nr
source oaienv
cd cmake_targets
./build_oai -I --gNB -x --install-system-files -w USRP
```
- -I: installs required packages.
- --gNB: installs gNB, i.e., nr-softmodem.
- -x: adds a software oscilloscope feature to the produced binaries.
- --install-system-files: installs OAI required files in Linux system.
- -w: adds the hardware support, which is USRP in our case.
#### (4). Run Automated script for openair-cn
```cpp=
cd openair-cn
git checkout develop
git pull
cd SCRIPTS
./build_mme -i #(Need to run only once to install missing packages)
./build_hss -i #(Need to run only once to install missing packages)
./build_spgw -i #(Need to run only once to install missing packages)
```
#### (5). Run Automated script for openair-cn-cups
```cpp=
cd openair-cn-cups
git checkout develop
git pull
cd SCRIPTS
./build_spgw -i #(Need to run only once to install missing packages)
```
### 1.2 Configuration
#### (1). gNB and EPC+HSS on Different Hosts (RECOMMENDED SETUP)
:::success
Assume the IP addresses of eNB and EPC+HSS are **192.168.12.82** and **192.168.12.62** respectively.
We also assume that the interface with which they are connected together is ethernet **(eth0)**.
:::
- Configure eNB machine (update config files)
In eNB configuration file (~/openairinterface5g/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.conf)
```cpp=
tracking_area_code = "1";
mobile_country_code = "208";
mobile_network_code = "92";
////////// MME parameters:
mme_ip_address = ( { ipv4 = "192.168.12.62";
ipv6 = "192:168:30::17";
active = "yes";
preference = "ipv4";
}
);
NETWORK_INTERFACES :
{
ENB_INTERFACE_NAME_FOR_S1_MME = "eth0";
ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.82/24";
ENB_INTERFACE_NAME_FOR_S1U = "eth0";
ENB_IPV4_ADDRESS_FOR_S1U = "192.168.12.82/24";
ENB_PORT_FOR_S1U = 2152; # Spec 2152
};
```
#### (2). Configure EPC machine (update config files)
Copy the EPC config files in /usr/local/etc/oai
```cpp=
sudo mkdir -p /usr/local/etc/oai/freeDiameter
sudo cp ~/openair-cn/ETC/mme.conf /usr/local/etc/oai
sudo cp ~/openair-cn/ETC/hss.conf /usr/local/etc/oai
sudo cp ~/openair-cn/ETC/spgw.conf /usr/local/etc/oai
sudo cp ~/openair-cn/ETC/acl.conf /usr/local/etc/oai/freeDiameter
sudo cp ~/openair-cn/ETC/mme_fd.conf /usr/local/etc/oai/freeDiameter
sudo cp ~/openair-cn/ETC/hss_fd.conf /usr/local/etc/oai/freeDiameter
```
- In MME configuration file (/usr/local/etc/oai/mme.conf)
```cpp=
REALM = "openair4G.eur";
S6A :
{
S6A_CONF = "/usr/local/etc/oai/freeDiameter/mme_fd.conf"; # YOUR MME freeDiameter config file path
HSS_HOSTNAME = "hss"; # THE HSS HOSTNAME
};
GUMMEI_LIST = (
{MCC="208" ; MNC="92"; MME_GID="4" ; MME_CODE="1"; } # YOUR GUMMEI CONFIG HERE
);
TAI_LIST = (
{MCC="208" ; MNC="92"; TAC = "1"; } # YOUR PLMN CONFIG HERE
);
NETWORK_INTERFACES :
{
# MME binded interface for S1-C or S1-MME communication (S1AP), can be ethernet interface, virtual ethernet interface, we don't advise wireless interfaces
MME_INTERFACE_NAME_FOR_S1_MME = "eth0"; # YOUR NETWORK CONFIG HERE
MME_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.62/24"; # YOUR NETWORK CONFIG HERE
# MME binded interface for S11 communication (GTPV2-C)
MME_INTERFACE_NAME_FOR_S11_MME = "lo"; # YOUR NETWORK CONFIG HERE
MME_IPV4_ADDRESS_FOR_S11_MME = "127.0.11.1/8"; # YOUR NETWORK CONFIG HERE
MME_PORT_FOR_S11_MME = 2123; # YOUR NETWORK CONFIG HERE
};
S-GW :
{
# S-GW binded interface for S11 communication (GTPV2-C), if none selected the ITTI message interface is used
SGW_IPV4_ADDRESS_FOR_S11 = "127.0.11.2/8"; # YOUR NETWORK CONFIG HERE
};
```
- In SPGW configuration file (/usr/local/etc/oai/spgw.conf):
```cpp=
S-GW :
{
NETWORK_INTERFACES :
{
# S-GW binded interface for S11 communication (GTPV2-C), if none selected the ITTI message interface is used
SGW_INTERFACE_NAME_FOR_S11 = "lo"; # YOUR NETWORK CONFIG HERE
SGW_IPV4_ADDRESS_FOR_S11 = "127.0.11.2/8"; # YOUR NETWORK CONFIG HERE
# S-GW binded interface for S1-U communication (GTPV1-U) can be ethernet interface, virtual ethernet interface, we don't advise wireless interfaces
SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP = "eth0"; # YOUR NETWORK CONFIG HERE, USE "lo" if S-GW run on eNB host
SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP = "192.168.12.62/24"; # YOUR NETWORK CONFIG HERE
SGW_IPV4_PORT_FOR_S1U_S12_S4_UP = 2152; # PREFER NOT CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING
# S-GW binded interface for S5 or S8 communication, not implemented, so leave it to none
SGW_INTERFACE_NAME_FOR_S5_S8_UP = "none"; # DO NOT CHANGE (NOT IMPLEMENTED YET)
SGW_IPV4_ADDRESS_FOR_S5_S8_UP = "0.0.0.0/24"; # DO NOT CHANGE (NOT IMPLEMENTED YET)
};
...
}
P-GW =
{
NETWORK_INTERFACES :
{
# P-GW binded interface for S5 or S8 communication, not implemented, so leave it to none
PGW_INTERFACE_NAME_FOR_S5_S8 = "none"; # DO NOT CHANGE (NOT IMPLEMENTED YET)
PGW_IPV4_ADDRESS_FOR_S5_S8 = "0.0.0.0/24"; # DO NOT CHANGE (NOT IMPLEMENTED YET)
# P-GW binded interface for SGI (egress/ingress internet traffic)
PGW_INTERFACE_NAME_FOR_SGI = "eth0"; # YOUR NETWORK CONFIG HERE
PGW_MASQUERADE_SGI = "yes"; # YOUR NETWORK CONFIG HERE
UE_TCP_MSS_CLAMPING = "no"; # STRING, {"yes", "no"}.
};
...
# DNS address communicated to UEs
DEFAULT_DNS_IPV4_ADDRESS = "192.168.106.12"; # YOUR NETWORK CONFIG HERE
DEFAULT_DNS_SEC_IPV4_ADDRESS = "192.168.12.100"; # YOUR NETWORK CONFIG HERE
...
}
```
- In HSS freediameter configuration file (/usr/local/etc/oai/freeDiameter/hss_fd.conf):
```cpp=
Identity = "hss.openair4G.eur";
Realm = "openair4G.eur";
```
- In MME freediameter configuration file (/usr/local/etc/oai/freeDiameter/mme_fd.conf):
```cpp=
Identity = "nano.openair4G.eur";
Realm = "openair4G.eur";
ConnectPeer= "hss.openair4G.eur" { ConnectTo = "127.0.0.1"; No_SCTP ; No_IPv6; Prefer_TCP; No_TLS; port = 3868; realm = "openair4G.eur";};
```
- In HSS configuration file (/usr/local/etc/oai/hss.conf):
```cpp=
MYSQL_user = "root";
MYSQL_pass = "linux"; #Put here the root password of mysql database that was provided during installation
OPERATOR_key = "1006020f0a478bf6b699f15c062e42b3"; # OP key for oai_db.sql, Must match to that of UE Sim card, OP_Key
```
### 1.3 Running gNB, EPC and HSS
#### (1). Install certificates
```cpp=
cd ~/openair-cn/SCRIPTS
./check_hss_s6a_certificate /usr/local/etc/oai/freeDiameter/ hss.openair4G.eur
./check_mme_s6a_certificate /usr/local/etc/oai/freeDiameter/ nano.openair4G.eur
```
#### (2). Compile & Run HSS
```cpp=
cd ~/openair-cn
cd SCRIPTS
./build_hss -c
./run_hss -i ~/openair-cn/SRC/OAI_HSS/db/oai_db.sql #Run only once to install database
./run_hss #Run this for all subsequent runs
```
#### (3). Compile & Run MME
```cpp=
cd ~/openair-cn/SCRIPTS
./build_mme -c
./run_mme
```
#### (4). Compile & Run SP-GW
```cpp=
cd ~/openair-cn
cd SCRIPTS
./build_spgw -c
./run_spgw
```
--> **Build fail, so it still some problem.**
#### (5). Compile & Run eNB
```cpp=
cd ~/openairinterface5g
source oaienv
./cmake_targets/build_oai -w USRP -x -c --gNB
cd cmake_targets/lte_build_oai/build
sudo -E ./nr-softmodem -O $OPENAIR_DIR/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.conf -d
sudo -E ./nr-softmodem -h #(to see help options)
```
---
## 2. UE Configuration and User Registration on HSS Database