> For the complete documentation index, see [llms.txt](https://zzcabbage.gitbook.io/great-oai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zzcabbage.gitbook.io/great-oai/ref/oai-all-in-one-pei-zhi-wen-dang.md).

# OAI All in One 配置文档

## 安装Ubuntu 16.04

{% hint style="info" %}
现有OAI平台不支持Ubuntu 18.x
{% endhint %}

Ubuntu系统安装完成后执行以下命令

```
sudo apt update
sudo apt upgrade
sudo apt install git
```

## 安装USRP驱动

```
sudo apt-get install libboost-all-dev libusb-1.0-0-dev python-mako doxygen python-docutils python-requests cmake build-essential

git clone git://github.com/EttusResearch/uhd.git
cd uhd
mkdir host/build
cd host/build
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
make -j4
sudo make install
sudo ldconfig
sudo /usr/lib/uhd/utils/uhd_images_downloader.py
```

测试安装是否成功：

```
//查找设备
sudo uhd_find_devices 

//查看设备信息
sudo uhd_usrp_probe
```

{% hint style="info" %}
&#x20;安装流程也可参考[网页](https://blog.csdn.net/zh915648053/article/details/87867824)
{% endhint %}

## 下载&编译 eNB on 16.04

```
//下载是否能成功与网速有关，网速太慢可能很难成功。可以将之前下载的打包备用，以后不用每次下载
git clone https://gitlab.eurecom.fr/oai/openairinterface5g.git

cd openairinterface5g
git checkout develop
git reset --hard 7580d021d
git log

//检查版本号 7580d021d387cc63fcf6ecbb97a87b816676a06f

//设置环境
source oaienv

// 安装第三方软件包，直到出现下面界面表示安装完成
./cmake_targets/build_oai -I

// compile eNB
./cmake_targets/build_oai  -w USRP --eNB
```

## 下载编译EPC

```
git clone https://gitlab.eurecom.fr/oai/openair-cn.git
cd openair-cn
git checkout develop
git reset --hard 67180ca07c
git log

//检查版本号 67180ca07c3f543fb6efde13bfdd88ec153185c7
```

## 为 EPC 安装第三方软件包

```
cd openair-cn
source oaienv
cd scripts
./build_hss -i
```

{% hint style="info" %}
安装过程中会提示一些软件是否需要安装，如果没有选择yes，安装过的可选no跳过
{% endhint %}

> Do you want to install freeDiameter 1.2.0 ?: **yes**
>
> set your MySQL password and remember it! password
>
> phpmyadmin:
>
> choose light or apache as you prefer
>
> Configure database for phpmyadmin with dbconfig-common: **yes**
>
> password: same as MySQL for simplicity password
>
> We don't use phpmyadmin later in this procedure, nevertheless we tested successfully also with it

## 修改添加hosts

```
cat /etc/hostname

oai-01



sudo gedit /etc/hosts

127.0.0.1    localhost

127.0.1.1    oai-01.openair4G.eur   oai-01

127.0.1.1    hss.openair4G.eur    hss

sudo reboot
```

{% hint style="danger" %}
上面代码中三个oai-01的命名要一致
{% endhint %}

## 配置eNB

```
sudo gedit openairinterface5g/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.conf
```

> racking\_area\_code = "1";
>
> mobile\_country\_code = "208";
>
> mobile\_network\_code = "92";
>
> ////////// MME parameters:
>
> &#x20;mme\_ip\_address = ( { ipv4 = "**127.0.1.10**";
>
> &#x20;ipv6 = "192:168:30::17";
>
> &#x20;active = "yes";
>
> &#x20;preference = "ipv4";
>
> &#x20;}
>
> &#x20;);
>
> &#x20;NETWORK\_INTERFACES :
>
> &#x20;{
>
> &#x20;ENB\_INTERFACE\_NAME\_FOR\_S1\_MME = "lo";
>
> &#x20;ENB\_IPV4\_ADDRESS\_FOR\_S1\_MME = "127.0.1.2/8";
>
> &#x20;ENB\_INTERFACE\_NAME\_FOR\_S1U = "lo";
>
> &#x20;ENB\_IPV4\_ADDRESS\_FOR\_S1U = "**127.0.6.2/8"**;
>
> &#x20;ENB\_PORT\_FOR\_S1U = **2142**; # Spec 2152
>
> &#x20;};

## 配置epc

```
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
```

{% hint style="info" %}
把附件里的epc配置相关文件分别放&#x5165;**/usr/local/etc/oai/**&#x4EE5;&#x53CA;**/usr/local/etc/oai/freeDiameter/**&#x4E2D;，替换相应文件
{% endhint %}

## Running eNB, EPC and HSS

Install certificates:

```
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/ oai-01.openair4G.eur
```

Compile & Run HSS (ALWAYS RUN HSS FIRST):

```
cd ~/openair-cn
cd scripts
./build_hss -c

//只有第一次跑一次
./run_hss -i ~/openair-cn/src/oai_hss/db/oai_db.sql 

//Run this for all subsequent runs
./run_hss  
```

Compile & Run MME:

```
cd ~/openair-cn/scripts
./build_mme -c
./run_mme
```

Compile & Run SP-GW:

```
cd ~/openair-cn
cd scripts
./build_spgw -c
./run_spgw
```

Compile & Run eNB:

```
cd ~/openairinterface5g
source oaienv
./cmake_targets/build_oai -w USRP -x -c --eNB
cd cmake_targets/lte_build_oai/build
sudo -E ./lte-softmodem -O $OPENAIR_DIR/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.conf -d

//to see help options
sudo -E ./lte-softmodem -h 
```
