OAI搭建教程

OAI搭建教程

一 系统解析

OAI开源代码分为两部分:核心网EPC(openair-cn)+基站eNB(openairinterface5g)。EPC中包括MME/HSS/SPGW等核心网的功能模块;eNB中实现了基站处理的逻辑模块,基站的射频发射模块由usrpB210完成。

二 系统环境

基站eNB(openairinterface5g)都搭建在Ubuntu 14.04.2TLS上, 核心网EPC(openair-cn)搭建在Ubuntu 16.04.2上。其中,搭建EPC的系统需要将内核换成4.7,由于eNB对系统的性能要求较高,所以搭建eNB的系统需要将内核换成低延时内核,具体操作见下。

三 安装步骤

3.1openair-cn搭建过程

3.1.1 准备工作

安装Ubuntu16.04.2TLS系统,注意主机的命名,因为oai中大多使用的是nano,建议主机和用户名都设置为nano。

通过sudo gedit /etc/apt/sources.list进入源文件,替换源。推荐使用阿里源(国内速度较快,也可根据实际情更换其他源)。

更改hosts, 百度laod host,根据博客更改系统的hosts文件,用来,实际使用效果还不错。

 (hosts 链接,https://laod.cn/hosts, 换完测试谷歌,看能不能连上来)

 

安装git (从oai官网下载内核以及所需的源代码): 

 sudo apt-get update

sudoapt-get install git 

下载并安装内核(以下是安装官网 pre-compile内核版本步骤):

git clone https://gitlab.eurecom.fr/oai/linux-4.7.x.git

cd linux-4.7.x

sudo dpkg -i linux-headers-4.7.7-oaiepc_4.7.7-oaiepc-10.00.Custom_amd64.deblinux-image-4.7.7-oaiepc_4.7.7-oaiepc-10.00.Custom_amd64.deb

内核安装完成重启电脑,uname-a查看当前的内核版本。(出现4.7.7-oaiepc,方可进行下一步操作)。为了方便安装,也可以使用我们附件中的linux-4.7.x进行内核代替相对快一些(从官网Git的,源码都是一样的)。

3.1.3 下载源码

git clone https://gitlab.eurecom.fr/oai/openair-cn.git

如果出现http缓存不够的情况,执行以下命令设置缓存空间:

git config --global http.postBuffer 524288000

也可以使用我们附件中的源码,跳过Git clone阶段。(ps:官网上有很多的openair-cn的版本,我们在安装时测试了master版本,出现了一些小问题,随后换成了develop版本,编译过程正常,无任何报错)。

3.1.4 修改主机名

a)       执行hostname查看主机名

b)       执行sudo gedit /etc/hosts 修改源host文件。在文件开头添加以下信息:

127.0.0.1   localhost

127.0.1.1    主机名.openair4G.eur   主机名(如按照设置,此处为nano)

127.0.1.1   hss.openair4G.eur    hss

3.1.5 编译源码

cd openair-cn

cd scripts

./build_mme -i      #系统自动安装apache2php phpMyadmin mysql等,将mysql数据库root用户的密码设置为linux(也可以设置为其他,要记住密码)

./build_hss -i

./build_spgw -i、


3.1.6 配置EPC(红色为要修改或要注意的地方,其他地方基本不变)

a)       将配置文件放在 /usr/local/etc文件夹下(设置运行时的参数,目前主要改的是网卡名称和IP地址,需要注意,文件目录名的大小写,不同版本路径大小写不一样)。

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

 

b)       用ifcongfig 查看自己的网卡和ip地址

终端显示的网卡名称,以及网卡对应的本机IP地址(非常重要,如果配置错误,运行会报错)

c)       执行 sudo gedit /usr/local/etc/oai/mme.conf 配置MME


  # MME binded interface for S1-C or S1-MME  communication (S1AP), can be ethernetinterface, virtual ethernet interface, we don't advise wireless interfaces

        MME_INTERFACE_NAME_FOR_S1_MME         = “”;                         # YOUR NETWORK CONFIGHERE(上一步查到的网卡名称写这里)

        MME_IPV4_ADDRESS_FOR_S1_MME           = "";                            # YOUR NETWORK CONFIG HERE(上一步查到的ip地址写这里)

        # MME binded interface for S11communication (GTPV2-C)

        MME_INTERFACE_NAME_FOR_S11_MME        = "lo";                           # YOUR NETWORKCONFIG HERE

        MME_IPV4_ADDRESS_FOR_S11_MME          = "127.0.11.1/8";                 # YOUR NETWORK CONFIG HERE

        MME_PORT_FOR_S11_MME                  = 2123;                           # YOUR NETWORKCONFIG HERE}

 

S-GW : {

    # S-GW binded interface for S11communication (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

}

 

d)      执行sudo gedit  /usr/local/etc/oai/spgw.conf 配置spgw

 

 

NETWORK_INTERFACES :

    {

        # S-GW bindedinterface for S11 communication (GTPV2-C), if none selected the ITTI messageinterface is used

       SGW_INTERFACE_NAME_FOR_S11             = "lo";                        # STRING, interface name, YOUR NETWORK CONFIG HERE

        SGW_IPV4_ADDRESS_FOR_S11                ="127.0.11.2/8";               #STRING, CIDR, YOUR NETWORK CONFIG HERE

        # S-GW bindedinterface for S1-U communication (GTPV1-U) can be ethernet interface, virtualethernet interface, we don't advise wireless interfaces

       SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP   = "";                      # STRING, interface name, YOUR NETWORK CONFIG HERE, USE "lo"if S-GW run on eNB host(上步查到的网卡名称写这里)

       SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP     = "";           # STRING,CIDR, YOUR NETWORK CONFIG HERE(上步查到的ip地址写这里)

       SGW_IPV4_PORT_FOR_S1U_S12_S4_UP        = 2152;                         #INTEGER, port number, PREFER NOT CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING

        # S-GW bindedinterface for S5 or S8 communication, not implemented, so leave it to none

       SGW_INTERFACE_NAME_FOR_S5_S8_UP         = "none";                       # STRING, interfacename, DO NOT CHANGE (NOT IMPLEMENTED YET)

       SGW_IPV4_ADDRESS_FOR_S5_S8_UP          = "0.0.0.0/24";                # STRING, CIDR, DO NOT CHANGE (NOT IMPLEMENTED YET)

 NETWORK_INTERFACES :

    {

        # P-GW bindedinterface for S5 or S8 communication, not implemented, so leave it to none

       PGW_INTERFACE_NAME_FOR_S5_S8         = "none";                         # STRING, interfacename, DO NOT CHANGE (NOT IMPLEMENTED YET)

        # P-GW bindedinterface for SGI (egress/ingress internet traffic)

       PGW_INTERFACE_NAME_FOR_SGI           = "";                        # STRING, YOUR NETWORK CONFIG HERE(上步查到的网卡名写这里)

       PGW_MASQUERADE_SGI                   = "yes";                           # STRING, {"yes","no"}. YOUR NETWORK CONFIG HERE, will do NAT for you if you put"yes".(将原文件中的no改为yes

       UE_TCP_MSS_CLAMPING                  = "no";                           # STRING,{"yes", "no"}.

    };


e)       执行sudo gedit  /usr/local/etc/oai/hss.conf配置hss

 

HSS :

{

## MySQL mandatory options

MYSQL_server = "127.0.0.1";     # HSS S6a bind address

MYSQL_user   = "root";  #Database server login

MYSQL_pass   = "设置的密码";  # Database server password

MYSQL_db     ="oai_db";        # Yourdatabase name

## HSS options(OPERATOR_key换成全1)

#OPERATOR_key ="1006020f0a478bf6b699f15c062e42b3"; # OP key matching your database

OPERATOR_key ="11111111111111111111111111111111"; # OP key matching your database(选这个)

 

RANDOM = "true";                                   # True random or only pseudorandom (for subscriber vector generation)

 

## Freediameter options

FD_conf ="/usr/local/etc/oai/freeDiameter/hss_fd.conf";

};

f)      执行 sudo gedit  /usr/local/etc/oai/freeDiameter/hss_fd.conf  确保  Identity = "hss.openair4G.eur"Realm = "openair4G.eur"

i)       执行sudo gedit   /usr/local/etc/oai/freeDiameter/mme_fd.conf 确保里面信息如下:

Identity = "主机名.openair4G.eur"; #需要注意,文件里面原来是yang.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";};


3.1.6 编译和运行

a)       安装证书(重要)

 

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/ 主机名.openair4G.eur


b)       编译运行hss(一定要先运行hss)

 

./build_hss

./run_hss

c)       编译运行mme 

./build_mme

./run_mme

d)      编译运行spgw

./build_spgw

./run_spgw

到这里EPC安装完成,需要注意的几个点:

1、在配置EPC之前,按照http://blog.csdn.net/u013429928/article/details/75110371安装mysql, apach, phpmyadmin等软件(针对Ubuntu 16.04.2系统)。

2、编译过程中,记住已经安装了的软件名称,再次安装时可以跳过该软件的安装。

3、因为网络原因,下载安装过程非常缓慢,请大家耐心等待。如果处于下载过程,网络长时间没反应,可以Ctrl+C停止进行,完了再重新运行之前的命令,之前下载的东西不会丢失,在tmp文件夹下面。 


3.2 openairinterface5G搭建过程

3.2.1 系统准备

安装Ubuntu14.04.2TLS系统,按照3.1.1的过程替换系统源文件、host文件。

3.2.2 替换内核

 

sudo apt-get update

sudo apt-get install git

sudo apt-get install linux-image-3.19.0-61-lowlatencylinux-headers-3.19.0-61-lowlatency (低延时内核直接install 就行)

 

重启电脑之后再用uname-a 查看内核版本。(有的电脑会直接在开机时让用户选择内核版本,这时,选择低延时内核即可)

3.2.3 电源设置

a)       执行sudo gedit /etc/default/grub;在打开的文件中添加下面两行:

 

GRUB_CMDLINE_LINUX_DEFAULT="quietintel_pstate=disable"

GRUB_CMDLINE_LINUX_DEFAULT="processor.max_cstate=1intel_idle.max_cstate=0 idle=poll”

 

 


b)       执行sudo gedit /etc/modprobe.d/blacklist.conf ;在打开的文件最后添加下面一行:

 

  blacklist intel_powerclam


c)       重启电脑,进入bios之后,关闭与节能或者影响CPU性能的设置,如超线程,C-state(这一步非必须,只要电脑性能够强,有的电脑bios里面没有这些设置,不必担心)

d)      执行sudo apt-get install i7z  安装i7z 同时运行i7z查看CPU运行信息。

e)       执行sudo apt-get install cpufrequtils 安装cpufrequtils,执行sudo gedit/etc/default/cpufrequtils文件(有可能为空文件),在里面加上一句:GOVERNOR="performance"

f)        执行 sudo update-rc.d ondemand disable

g)        重启

3.2.4 下载源码

执行sudo apt-getinstall git 安装源码

执行

git clone https://gitlab.eurecom.fr/oai/openairinterface5g.git

(下载之前应该设置http的缓存大小,具体的设置过程参见3.1.3 OAI搭建之EPC下载源码)

3.2.5 编译eNB

 

cd openairinterface

     sourceoaienv

 cd cmake_targets

 ./build_oai -I --eNB -x --install-system-files -wUSRP

 

 

 

 

(在编译之前,应该提前插上usrp,在编译过程中会自动下载usrp需要的驱动包之类)

 

3.2.6 配置eNB

a)       执行ifconfig 查看本机的网卡名和ip地址

b)       执行 sudo gedit/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.conf打开eNB的配置文件

c)       修改配置文件

 

 tracking_area_code  = "1";

 mobile_country_code = "208";

 mobile_network_code = "93";(和mme.conf里面一致)

 MME parameters:

mme_ip_address  = ( { ipv4    = "";这里配置安装EPC的主机的IP地址

ipv6= "192:168:30::17";

active = "yes";

preference = "ipv4";

}

);

NETWORK_INTERFACES :

{

ENB_INTERFACE_NAME_FOR_S1_MME= "";(这里配置本机网卡名)

ENB_IPV4_ADDRESS_FOR_S1_MME= "";(这里配置那本机的ip地址)

ENB_INTERFACE_NAME_FOR_S1U= "";(这里配置本机网卡名)

ENB_IPV4_ADDRESS_FOR_S1U= "";(这里配置那本机的ip地址)

ENB_PORT_FOR_S1U= 2152; # Spec 2152

};

 

3.2.7 运行eNB

执行

 

cd ~/openairinterface5g
source oaienv
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 

 

 

 

你可能感兴趣的:(eNB,EPC)