OAI-LTE核心网搭建
此次操作主要依托于如下博客:
https://is-cloud.blog.csdn.net/article/details/103390611
操作环境
Linux 4.15.0-126-generic #129~16.04.1-Ubuntu SMP Tue Nov 24 11:22:40 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
安装了16.04.1版本Ubuntu一台,建议刷一台Ubuntu系统的电脑使用,虚拟机性能有可能达不到要求(我还没试过)。
操作流程
配置各种文件
HSS
- Initialize the HSS:
sudo oai-cn.hss-init
- Get the configuration file:
sudo oai-cn.hss-conf-get
- In
hss_fd.conf
, changeIdentity
to match<hostname>.openair4G.eur
(e.g. hostname asoai
)
vi /var/snap/oai-cn/32/hss_fd.conf
Identity = "oaitest001-ThinkCentre-M920t-N000.openair4G.eur";
root@oaitest001-ThinkCentre-M920t-N000:~# uname -a
Linux oaitest001-ThinkCentre-M920t-N000 4.15.0-126-generic #129~16.04.1-Ubuntu SMP Tue Nov 24 11:22:40 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
- 配置hss.conf,随后会对应配置数据库
vi /var/snap/oai-cn/current/hss.conf
HSS :
{
## MySQL mandatory options
MYSQL_server = "127.0.0.1"; # HSS S6a bind address
MYSQL_user = "root"; # Database server login
MYSQL_pass = "123"; # Database server password
MYSQL_db = "oai_db"; # Your database name
## HSS options
OPERATOR_key = "11111111111111111111111111111111"; # OP key matching your database
RANDOM = "true"; # True random or only pseudo random (for subscriber vector generation)
## Freediameter options
FD_conf = "/var/snap/oai-cn/current/hss_fd.conf";
};
- 安装mysql环境
# 安装 MySQL,账户设置为 root
sudo apt-get install mysql-server mysql-client
# 安装 apache2
sudo apt-get install apache2
# 安装 PHP
apt-get install php7.0
apt-get install libapache2-mod-php7.0
# 安装 phpmyadmin
sudo apt-get install phpmyadmin
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin
sudo /etc/init.d/apache2 reload
sudo service apache2 restart
Create certificates: sudo oai-cn.hss-init(会生成 oai_db 数据库,所以执行之前要安装好 MySQL)
Run HSS: sudo oai-cn.hss
The last line should read Initializing S6a layer: DONE
MME
- Initialize the MME:
sudo oai-cn.mme-init
- Locate configuration files in directory:
sudo oai-cn.mme-conf-get
- In
mme_fd.conf: Identity
needs to match hostname
vi /var/snap/oai-cn/current/mme_fd.conf
ConnectPeer= "oaitest001-ThinkCentre-M920t-N000.openair4G.eur" { ConnectTo = "10.96.100.88"; No_SCTP ; No_IPv6; Prefer_TCP; No_TLS; port = 3868; realm = "openair4G.eur";};
- 配置mme.conf,存储了ip、MNC、MCC等信息,配置出错会导致ENB无法连接
vi /var/snap/oai-cn/current/mme.conf
S6A :
{
S6A_CONF = "/var/snap/oai-cn/current/mme_fd.conf"; # YOUR MME freeDiameter config file path
HSS_HOSTNAME = "oaitest001-ThinkCentre-M920t-N000"; # THE HSS HOSTNAME
};
...
# ------- MME served GUMMEIs
# MME code DEFAULT size = 8 bits
# MME GROUP ID size = 16 bits
GUMMEI_LIST = (
{MCC="460" ; MNC="00"; MME_GID="4" ; MME_CODE="1"; } # YOUR GUMMEI CONFIG HERE
);
# ------- MME served TAIs
# TA (mcc.mnc:tracking area code) DEFAULT = 208.34:1
# max values = 999.999:65535
# maximum of 16 TAIs, comma separated
# !!! Actually use only one PLMN
TAI_LIST = (
{MCC="460" ; MNC="00"; TAC = "1"; } # YOUR TAI 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 = "eno1"; # YOUR NETWORK CONFIG HERE
MME_IPV4_ADDRESS_FOR_S1_MME = "10.96.100.88/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
};
MME_IPV4_ADDRESS_FOR_S1_MME的ip要与本机ip相一致,因为承载enb的电脑与承载EPC电脑的通信是通过ip进行的
- Start the MME:
sudo oai-cn.mme
- Last line:
Peer <hostname>.openair4G.eur is now connected...
SPGW
- Initialize the SPGW:
sudo oai-cn.spgw-init
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"; # 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 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 = "lo"; # STRING, interface name, YOUR NETWORK CONFIG HERE, USE "lo" if S-GW run on eNB host
SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP = "127.0.1.10/24"; # STRING, CIDR, YOUR NETWORK CONFIG HERE
SGW_IPV4_PORT_FOR_S1U_S12_S4_UP = 2152; # INTEGER, port number, 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"; # STRING, interface name, 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)
# external controller for managing context of UE and its user plane
SGW_REMOTE_CONTROLLER_ENABLED = "no";
SGW_REMOTE_CONTROLLER_IPV4_ADDRESS = "127.0.0.1";
SGW_REMOTE_CONTROLLER_PORT = 9999;
};
...
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"; # STRING, interface name, DO NOT CHANGE (NOT IMPLEMENTED YET)
# P-GW binded interface for SGI (egress/ingress internet traffic)
PGW_INTERFACE_NAME_FOR_SGI = "eno1"; # 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".
UE_TCP_MSS_CLAMPING = "no"; # STRING, {"yes", "no"}.
};
- Start the SPGW:
sudo oai-cn.spgw
- Last line:
Initializing SPGW-APP task interface: DONE
核心网启动
执行三个命令
oai-cn.hss
oai-cn.mme
oai-cn.spgw
为便于操作,用脚本统一执行:
#! /bin/bash
gnome-terminal --window -e 'bash -c "oai-cn.hss;exec bash"' \
--tab -e 'bash -c "oai-cn.mme;exec bash"' \
--tab -e 'bash -c "oai-cn.spgw;exec bash"' \
#--window -e './navicat15-premium-cs.AppImage'
效果图如下:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Uk2lAjPB-1607498691060)(https://s3-us-west-2.amazonaws.com/secure.notion-static.com/f8bb8d57-9101-4d02-9353-5a506eb879ad/hss.jpg)]
hss
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-JISGDAFL-1607498691062)(https://s3-us-west-2.amazonaws.com/secure.notion-static.com/4b877c8a-1af6-4905-aa10-9efda5ec0155/mme.jpg)]
mme
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-4YLX0ys6-1607498691063)(https://s3-us-west-2.amazonaws.com/secure.notion-static.com/6ee70b81-f48c-4a2b-81f8-49a1fe0db0bb/spgw.jpg)]
spgw
工具
wireshark
–拿来抓信令
navicat
–查看数据库信息
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-PwoMwMWw-1607498605868)(OAI-LTE%E6%A0%B8%E5%BF%83%E7%BD%91%E6%90%AD%E5%BB%BA%203165fb15f03f4596a32fefd6269194b2/mme.jpg)]
mme
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-yVTK5xxl-1607498605869)(OAI-LTE%E6%A0%B8%E5%BF%83%E7%BD%91%E6%90%AD%E5%BB%BA%203165fb15f03f4596a32fefd6269194b2/spgw.jpg)]
spgw
打开hss、mme、spgw配置文件,和工具软件脚本
#!/bin/bash
PS3="Please select an option:"
select i in "wireshark" "navicat" "oai-cnf"
do
case $i in
wireshark)
echo "your select is wireshark"
gnome-terminal --window -e 'bash -c "wireshark;exec bash"'
;;
navicat)
echo "your select is navicat"
gnome-terminal --window -e 'bash -c "./navicat15-premium-cs.AppImage"'
;;
oai-cnf)
echo "select a config to oepn:"
select j in "hss" "mme" "spgw"
do
case $j in
hss)
echo "open the hss..."
gnome-terminal --window -e 'vi /var/snap/oai-cn/current/hss.conf'
;;
mme)
echo "open the mme..."
gnome-terminal --window -e 'vi /var/snap/oai-cn/current/mme_fd.conf'
gnome-terminal --window -e 'vi /var/snap/oai-cn/current/mme.conf'
;;
spgw)
echo "open the spgw..."
gnome-terminal --window -e 'vi /var/snap/oai-cn/32/spgw.conf'
;;
*)
exit
;;
esac
done
;;
*)
break
;;
esac
done
小结
核心网的配置操作相对简单,耗时主要实在ip的配置,以及白卡信息的添加(imsi、key、OPc),其中key与OPc代码默认是varbinary
16位格式,而给到的白卡是32位16进制
的,直接用软件navicat无法进行修改,最终使用的命令
update users set `key`=0x00112233445566778899AABBCCDDEEFF where imsi='20834123456789';