11 - OAI vEPC搭建 - 研一

第零章 Network

此版本OAI epc 已支持多MME、多eNB、X2切换等功能,配置方式变化较大。

环境:
物理机(运行eNB):Ubuntu 18.04 LTS,core i7 8xxxU 3.4GHz x4,16G,128G SSD,USRP B210
虚拟机(运行vEPC):Ubuntu16.04 LTS,内核4.9.x(受SPGW的限制),分配硬盘40G

  • 0.1 虚拟机中network
sudo vim upens.sh
#!/bin/bash

# MME
# ens33 192.168.176.128  ----S1---- virbr0 (vmnet8) 192.168.176.1
# ens33:9 ----S6A---- HSS ens33:12
sudo ifconfig ens33:9 172.66.1.111/16 up

sudo ifconfig ens39:10 192.168.2.111 up

sudo ifconfig ens33:11 192.168.100.111 up

# HSS
sudo ifconfig ens33:12 172.66.1.113/16 up

# SPGW  
# ens33:15 192.168.28.227 ----S1U---- virbr2 (vmnet1) 192.168.28.1

sudo ifconfig ens39:14 192.168.2.114 up

网络拓扑:
1.offical configuration:

11 - OAI vEPC搭建 - 研一_第1张图片
2. my configuration:
11 - OAI vEPC搭建 - 研一_第2张图片

  • 0.2 code
git clone https://github.com/OPENAIRINTERFACE/openair-cn.git
cd openair-cn
git checkout develop
  • 0.3 安装Cassandra
cd ~/openair-cn/scripts
./build_cassandra --check-installed-software --force

验证Cassandra是否已安装并正在运行

nodetool status

11 - OAI vEPC搭建 - 研一_第3张图片
在修改配置之前,停止Cassandra并清理日志文件

sudo service cassandra stop
sudo rm -rf /var/lib/cassandra/data/system/*
sudo rm -rf /var/lib/cassandra/commitlog/*
sudo rm -rf /var/lib/cassandra/data/system_traces/*
sudo rm -rf /var/lib/cassandra/saved_caches/*

然后如果需要,更新Cassandra配置(默认配置设置1个 cassandra节点监听localhost)
更新/etc/cassandra/cassandra.yaml,如下所示。地址应该是HSS用于连接到Cassandra的Cassandra服务器的IP地址。“…”表示需要修改的值之间的配置行。

...
cluster_name: "HSS Cluster"
...
seed_provider:
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
- seeds: ""
...
listen_address: 
...
rpc_address: 
...
# LG: seems to be this option that is working ()
# endpoint_snitch: SimpleSnitch
endpoint_snitch: GossipingPropertyFileSnitch

启动 Cassandra

sudo service cassandra start

第一章 HSS

  • 1.1 Build HSS
sudo ./build_hss_rel14 --check-installed-software --force
sudo ./build_hss_rel14 --clean
sudo vim configcassandra.sh
#!/bin/bash

cd ~/openair-cn/scripts
Cassandra_Server_IP='127.0.0.1'
cqlsh --file ../src/hss_rel14/db/oai_db.cql $Cassandra_Server_IP
./data_provisioning_users --apn default --apn2 internet --key fec86ba6eb707ed08905757b1bb44b8f --imsi-first 001011234561000 --msisdn-first 001011234561000 --mme-identity mme.ng4T.com --no-of-users 20 --realm ng4T.com --truncate True  --verbose True --cassandra-cluster $Cassandra_Server_IP
./data_provisioning_mme --id 3 --mme-identity mme.ng4T.com --realm ng4T.com --ue-reachability 1 --truncate True  --verbose True

结果:
3

11 - OAI vEPC搭建 - 研一_第4张图片
如果有这种报错:
11 - OAI vEPC搭建 - 研一_第5张图片
则需要修改一下cassandra配置

cqlsh
describe keyspaces;

keyspaces

use vhss;
describe tables;

ALTER KEYSPACE vhss WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1 };
  • 1.2 配置 HSS
sudo vim configHSS.sh
#!/bin/bash

#sudo ifconfig ens9:0 172.66.1.113 up
PREFIX='/usr/local/etc/oai-vepc/hss14'
sudo mkdir -m 777 -p $PREFIX
sudo mkdir -m 777    $PREFIX/freeDiameter
# freeDiameter configuration files
cp ../etc/acl.conf ../etc/hss_rel14_fd.conf $PREFIX/freeDiameter
cp ../etc/hss_rel14.conf ../etc/hss_rel14.json $PREFIX

declare -A HSS_CONF
HSS_CONF[@PREFIX@]=$PREFIX
HSS_CONF[@REALM@]='ng4T.com'
HSS_CONF[@HSS_FQDN@]="hss.${HSS_CONF[@REALM@]}"
HSS_CONF[@cassandra_Server_IP@]='127.0.0.1'
HSS_CONF[@OP_KEY@]='1006020f0a478bf6b699f15c062e42b3'
HSS_CONF[@ROAMING_ALLOWED@]='true'
HSS_CONF[@cassandra_Server_IP@]='127.0.0.1'

for K in "${!HSS_CONF[@]}"; do 
  egrep -lRZ "$K" $PREFIX | xargs -0 -l sed -i -e "s|$K|${HSS_CONF[$K]}|g"
done
### freeDiameter certificate
../src/hss_rel14/bin/make_certs.sh hss ${HSS_CONF[@REALM@]} $PREFIX

取消ListenOn = “xxxxx”; 的注释并改成相应的ip地址(172.66.1.113):

sudo vim /usr/local/etc/oai-vepc/hss14/freeDiameter/hss_rel14_fd.conf
  • 1.3 Run HSS
sudo oai_hss -j /usr/local/etc/oai-vepc/hss14/hss_rel14.json

第二章 MME

  • 2.1 Build MME
sudo ./build_mme --check-installed-software --force
sudo ./build_mme --clean
  • 2.2 配置 MME
sudo vim configMME.sh
#!/bin/bash

# S6a
#sudo ifconfig ens9:11 172.66.1.111 up
#cd ~/openair-cn/scripts
INSTANCE=1
PREFIX='/usr/local/etc/oai-vepc/mme1'
sudo mkdir -m 777 -p $PREFIX
sudo mkdir -m 777    $PREFIX/freeDiameter

# freeDiameter configuration file
cp ../etc/mme_fd.sprint.conf  $PREFIX/freeDiameter/mme_fd.conf

cp ../etc/mme.conf  $PREFIX

declare -A MME_CONF

MME_CONF[@MME_S6A_IP_ADDR@]="172.66.1.111"
MME_CONF[@INSTANCE@]=$INSTANCE
MME_CONF[@PREFIX@]=$PREFIX
MME_CONF[@REALM@]='ng4T.com'
MME_CONF[@PID_DIRECTORY@]='/var/run'
MME_CONF[@MME_FQDN@]="mme.${MME_CONF[@REALM@]}"
MME_CONF[@HSS_HOSTNAME@]='hss'
MME_CONF[@HSS_FQDN@]="${MME_CONF[@HSS_HOSTNAME@]}.${MME_CONF[@REALM@]}"
MME_CONF[@HSS_IP_ADDR@]='172.66.1.113'
MME_CONF[@MCC@]='208'
MME_CONF[@MNC@]='93'
MME_CONF[@MME_GID@]='32768'
MME_CONF[@MME_CODE@]='3'
MME_CONF[@TAC_0@]='600'
MME_CONF[@TAC_1@]='601'
MME_CONF[@TAC_2@]='602'
MME_CONF[@MME_INTERFACE_NAME_FOR_S1_MME@]='ens33'
MME_CONF[@MME_IPV4_ADDRESS_FOR_S1_MME@]='192.168.176.128/24'
MME_CONF[@MME_INTERFACE_NAME_FOR_S11@]='ens39:10'
MME_CONF[@MME_IPV4_ADDRESS_FOR_S11@]='192.168.2.111/24'
MME_CONF[@MME_INTERFACE_NAME_FOR_S10@]='ens33:11'
MME_CONF[@MME_IPV4_ADDRESS_FOR_S10@]='192.168.10.111/24'
MME_CONF[@OUTPUT@]='CONSOLE'
MME_CONF[@SGW_IPV4_ADDRESS_FOR_S11_TEST_0@]='192.168.2.114/24'
MME_CONF[@SGW_IPV4_ADDRESS_FOR_S11_0@]='192.168.2.114/24'
MME_CONF[@PEER_MME_IPV4_ADDRESS_FOR_S10_0@]='0.0.0.0/24'
MME_CONF[@PEER_MME_IPV4_ADDRESS_FOR_S10_1@]='0.0.0.0/24'

#implicit MCC MNC 001 01
TAC_SGW_TEST='7'
tmph=`echo "$TAC_SGW_TEST / 256" | bc`
tmpl=`echo "$TAC_SGW_TEST % 256" | bc`
MME_CONF[@TAC-LB_SGW_TEST_0@]=`printf "%02x\n" $tmpl`
MME_CONF[@TAC-HB_SGW_TEST_0@]=`printf "%02x\n" $tmph`

MME_CONF[@MCC_SGW_0@]=${MME_CONF[@MCC@]}
MME_CONF[@MNC3_SGW_0@]=`printf "%03d\n" $(echo ${MME_CONF[@MNC@]} | sed 's/^0*//')`
TAC_SGW_0='600'
tmph=`echo "$TAC_SGW_0 / 256" | bc`
tmpl=`echo "$TAC_SGW_0 % 256" | bc`
MME_CONF[@TAC-LB_SGW_0@]=`printf "%02x\n" $tmpl`
MME_CONF[@TAC-HB_SGW_0@]=`printf "%02x\n" $tmph`

MME_CONF[@MCC_MME_0@]=${MME_CONF[@MCC@]}
MME_CONF[@MNC3_MME_0@]=`printf "%03d\n" $(echo ${MME_CONF[@MNC@]} | sed 's/^0*//')`
TAC_MME_0='601'
tmph=`echo "$TAC_MME_0 / 256" | bc`
tmpl=`echo "$TAC_MME_0 % 256" | bc`
MME_CONF[@TAC-LB_MME_0@]=`printf "%02x\n" $tmpl`
MME_CONF[@TAC-HB_MME_0@]=`printf "%02x\n" $tmph`

MME_CONF[@MCC_MME_1@]=${MME_CONF[@MCC@]}
MME_CONF[@MNC3_MME_1@]=`printf "%03d\n" $(echo ${MME_CONF[@MNC@]} | sed 's/^0*//')`
TAC_MME_1='602'
tmph=`echo "$TAC_MME_1 / 256" | bc`
tmpl=`echo "$TAC_MME_1 % 256" | bc`
MME_CONF[@TAC-LB_MME_1@]=`printf "%02x\n" $tmpl`
MME_CONF[@TAC-HB_MME_1@]=`printf "%02x\n" $tmph`


for K in "${!MME_CONF[@]}"; do
  egrep -lRZ "$K" $PREFIX | xargs -0 -l sed -i -e "s|$K|${MME_CONF[$K]}|g"
  ret=$?;[[ ret -ne 0 ]] && echo "Tried to replace $K with ${MME_CONF[$K]}"
done


# freeDiameter certificate
sudo ./check_mme_s6a_certificate $PREFIX/freeDiameter mme.${MME_CONF[@REALM@]}

需要配置的地方:
MME_S6A_IP_ADDR
HSS_IP_ADDR
MCC
MNC
MME_INTERFACE_NAME_FOR_S1_MME
MME_IPV4_ADDRESS_FOR_S1_MME
MME_INTERFACE_NAME_FOR_S11
MME_IPV4_ADDRESS_FOR_S11
MME_INTERFACE_NAME_FOR_S10
MME_IPV4_ADDRESS_FOR_S10
SGW_IPV4_ADDRESS_FOR_S11_TEST_0
SGW_IPV4_ADDRESS_FOR_S11_0
SGW_IPV4_ADDRESS_FOR_S11_TEST_0
SGW_IPV4_ADDRESS_FOR_S11_0

  • 2.3 Run MME
sudo ./run_mme --config-file /usr/local/etc/oai-vepc/mme1/mme.conf --set-virt-if

11 - OAI vEPC搭建 - 研一_第6张图片

第三章 SPGW

  • 3.0 降级至4.9.x内核
sudo apt install libncurses5-dev libncursesw5-dev bc binutils gcc libssl-dev make autoconf libelf-dev
cd /usr/src
sudo wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.9.108.tar.xz
sudo tar xf linux-4.9.108.tar.xz && cd linux-4.9.108/
sudo make olddefconfig && sudo make -j`nproc`
sudo make modules_install && sudo make install
grep submenu /boot/grub/grub.cfg
例:submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-b5f9e301-3dff-4f60-a22b-b5b4717d92cb' {

grep gnulinux /boot/grub/grub.cfg
例:

11 - OAI vEPC搭建 - 研一_第7张图片

sudo vim /etc/default/grub
修改:submenu>gnulinux
例:
#GRUB_DEFAULT=0
GRUB_DEFAULT="gnulinux-advanced-b5f9e301-3dff-4f60-a22b-b5b4717d92cb>gnulinux-4.9.108-advanced-b5f9e301-3dff-4f60-a22b-b5b4717d92cb"
sudo update-grub
sudo reboot
  • 3.1 Build SPGW
# cd ~/openair-cn/scripts
sudo ./build_spgw --check-installed-software --force
sudo ./build_spgw --clean
  • 3.2 配置 SPGW
sudo vim configSPGW.sh
#!/bin/bash

INSTANCE=1
PREFIX='/usr/local/etc/oai-vepc/spgw1'
sudo mkdir -m 777 -p $PREFIX
cp ../etc/spgw.conf  $PREFIX

declare -A SPGW_CONF
SPGW_CONF[@PID_DIRECTORY@]='/var/run'
SPGW_CONF[@SGW_INTERFACE_NAME_FOR_S11@]="ens39:14"
SPGW_CONF[@SGW_IPV4_ADDRESS_FOR_S11@]="192.168.2.114/24"
SPGW_CONF[@SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP@]="ens38"
SPGW_CONF[@SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP@]="192.168.10.128/24"
SPGW_CONF[@SGW_UDP_PORT_FOR_S1U_S12_S4_UP@]=2152
SPGW_CONF[@OUTPUT@]="CONSOLE"
SPGW_CONF[@INSTANCE@]=$INSTANCE
SPGW_CONF[@PID_DIRECTORY@]='/var/run'
SPGW_CONF[@PGW_INTERFACE_NAME_FOR_SGI@]="ens37"
SPGW_CONF[@PGW_IPV4_ADDRESS_FOR_SGI@]="172.16.238.128/24"
SPGW_CONF[@ARP_UE@]="oai"
SPGW_CONF[@DEFAULT_DNS_IPV4_ADDRESS@]="192.168.176.1"
SPGW_CONF[@DEFAULT_DNS_SEC_IPV4_ADDRESS@]="192.168.176.1"
SPGW_CONF[@GTPV1U_REALIZATION@]="GTP_KERNEL_MODULE"

for K in "${!SPGW_CONF[@]}"; do 
  egrep -lRZ "$K" $PREFIX | xargs -0 -l sed -i -e "s|$K|${SPGW_CONF[$K]}|g"
done

需要配置的地方:
SGW_INTERFACE_NAME_FOR_S11
SGW_IPV4_ADDRESS_FOR_S11
SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP
SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP
PGW_INTERFACE_NAME_FOR_SGI
PGW_IPV4_ADDRESS_FOR_SGI
DEFAULT_DNS_IPV4_ADDRESS
DEFAULT_DNS_SEC_IPV4_ADDRESS

  • 3.3 Run SPGW
sudo ./run_spgw --config-file /usr/local/etc/oai-vepc/spgw1/spgw.conf --sgi-mac-nh 52:54:00:66:21:e2 --set-virt-if

jio本 runEPC.sh

cd ~/openair-cn/scripts
sudo oai_hss -j /usr/local/etc/oai-vepc/hss14/hss_rel14.json   &
sleep 3
sudo ./run_mme --config-file /usr/local/etc/oai-vepc/mme1/mme.conf --set-virt-if   &
sleep 3
sudo ./run_spgw --config-file /usr/local/etc/oai-vepc/spgw1/spgw.conf --sgi-mac-nh 52:54:00:66:21:e2 --set-virt-if 

第四章 eNB

  • 4.1 eNB搭建:
    https://blog.csdn.net/BUPTOctopus/article/details/81561607

  • 4.2
    配置文件里MNC MCC 改成核心网里配置的,然后TAC改成核心网中配置的,例如MCC MNC 为208 93 TAC为600或601或602。

2019.01.08 完成测试


11 - OAI vEPC搭建 - 研一_第8张图片

你可能感兴趣的:(研一)