当前位置:   article > 正文

一文学会Open5GS和UERANSIM安装及使用

open5gs

1 环境准备

VM配置(2台)

①操作系统:Ubuntu18.04.6 server(注意server版安装需要断网安装)

②CPU: 4

③Memory: 2G

④网卡2块:一块使用NAT模式用于访问外网(同时用于WebUI访问),另一块用于VM间的通信(配置桥接网卡,使用主机上的环回适配器)

注意:配置桥接口地址不要配置网关,否则可能无法访问外网

2 安装Open5GS及WebUI(使用1台虚拟机安装)

确认该虚拟机的网络地址配置,如修改,需执行sudo netplan apply执行生效

2.1 安装Open5GS

参考链接:
https://open5gs.org/open5gs/docs/guide/01-quickstart/

参考Ubuntu安装方法,具体如下:

  1. $ sudo apt update
  2. $ sudo apt install software-properties-common
  3. $ sudo add-apt-repository ppa:open5gs/latest
  4. $ sudo apt update
  5. $ sudo apt install open5gs

2.2 安装WebUI

参考链接:
https://open5gs.org/open5gs/docs/guide/01-quickstart/

具体如下:

  1. $ sudo apt install curl
  2. $ curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
  3. $ sudo apt install nodejs
  4. $ curl -fsSL https://open5gs.org/open5gs/assets/webui/install | sudo -E bash -

WebUI需要通过http://localhost:3000访问,若localhost与想要访问的地址不一致,进行以下修改:

(1)修改文件中的hostname为ens33的IP地址172.16.190.214(OAM地址),可以使用“OAM地址+端口号”的格式访问客户端。

(2)重启webui服务

  1. systemctl stop open5gs-webui.service
  2. systemctl start open5gs-webui.service
  3. root@guoliang:/home/guoliang# systemctl status open5gs-webui.service
  4. open5gs-webui.service - Open5GS WebUI
  5. Loaded: loaded (/lib/systemd/system/open5gs-webui.service; enabled; vendor preset: enabled)
  6. Active: active (running) since Sun 2022-06-19 03:20:38 UTC; 6s ago
  7. Main PID: 6756 (node)
  8. Tasks: 11 (limit: 2287)
  9. CGroup: /system.slice/open5gs-webui.service
  10. └─6756 /usr/bin/node server/index.js
  11. Jun 19 03:20:38 guoliang systemd[1]: Started Open5GS WebUI.
  12. Jun 19 03:20:39 guoliang node[6756]: > Ready on http://172.16.190.214:3000
  13. root@guoliang:/home/guoliang#

(3)查看修改成功

(4)本地PC浏览器访问
http://172.16.190.214:3000/,默认账号密码:admin/1423

3 安装UERANSIM(使用另1台虚拟机安装)

确认该虚拟机的网络地址配置,如修改,需执行sudo netplan apply执行生效

参考链接:
https://github.com/aligungr/UERANSIM/wiki/Installation

  1. cd ~
  2. git clone https://github.com/aligungr/UERANSIM
  3. sudo apt update
  4. sudo apt upgrade
  5. sudo apt install make
  6. sudo apt install gcc
  7. sudo apt install g++
  8. sudo apt install libsctp-dev lksctp-tools
  9. sudo apt install iproute2
  10. sudo snap install cmake --classic
  11. cd ~/UERANSIM
  12. make

克隆时如需要输入账号密码,请登录github注册账号并获取token,token获取方式参考链接
https://blog.csdn.net/ddnosh/article/details/120575405

4 修改地址实现UERANSIM与Open5GS互通

VM内的网元通过默认的loopback口进行通信,VM间使用管理口地址互通

4.1 N2互通

修改UERANSIM虚机地址配置,vi
~/UERANSIM/config/open5gs-gnb.yaml

修改Open5GS虚机地址配置,vi /etc/open5gs/amf.yaml

4.2 N3互通

N3互通地址为子接口地址,跟管理口在同一网段下。

修改UERANSIM虚机GNB配置,vi
~/UERANSIM/config/open5gs-gnb.yaml

UERANSIM虚机配置子接口地址,vi
/etc/netplan/00-installer-config.yaml

修改Open5GS虚机UPF配置,vi /etc/open5gs/upf.yaml

Open5GS虚机配置子接口地址,vi
/etc/netplan/00-installer-config.yaml

待N2和N3接口地址配置完后,Open5GS执行以下命令生效配置

  1. sudo systemctl restart open5gs-amfd
  2. sudo systemctl restart open5gs-upfd

确认UERANSIM和Open5GS虚机可以互通ping通N2和N3接口地址

5 用户上下线

(1)启动5gs网元

systemctl start open5gs-upfd.service

查看网元状态

  1. ps -aux | grep open5gs
  2. root@guoliang:/home/guoliang# ps -aux | grep open5gs
  3. open5gs 3248 0.0 0.7 220552 15820 ? Ssl 03:05 0:00 /usr/bin/open5gs-nrfd -c /etc/open5gs/nrf.yaml
  4. open5gs 3339 0.0 0.7 260936 15932 ? Ssl 03:05 0:00 /usr/bin/open5gs-sgwud -c /etc/open5gs/sgwu.yaml
  5. open5gs 3549 0.0 0.8 270020 17244 ? Ssl 03:05 0:00 /usr/bin/open5gs-sgwcd -c /etc/open5gs/sgwc.yaml
  6. open5gs 3630 0.0 0.5 199712 10176 ? Ssl 03:05 0:00 /usr/bin/open5gs-bsfd -c /etc/open5gs/bsf.yaml
  7. open5gs 3798 0.0 0.4 196220 9588 ? Ssl 03:05 0:00 /usr/bin/open5gs-nssfd -c /etc/open5gs/nssf.yaml
  8. open5gs 4066 0.0 0.6 2468672 12608 ? Ssl 03:05 0:02 /usr/bin/open5gs-mmed -c /etc/open5gs/mme.yaml
  9. open5gs 4197 0.0 0.4 197004 9696 ? Ssl 03:05 0:00 /usr/bin/open5gs-ausfd -c /etc/open5gs/ausf.yaml
  10. open5gs 4295 0.0 1.8 2772456 36484 ? Ssl 03:05 0:02 /usr/bin/open5gs-smfd -c /etc/open5gs/smf.yaml
  11. open5gs 4426 0.0 0.5 197008 10936 ? Ssl 03:05 0:00 /usr/bin/open5gs-udmd -c /etc/open5gs/udm.yaml
  12. open5gs 4701 0.0 0.7 2459676 14420 ? Ssl 03:05 0:02 /usr/bin/open5gs-hssd -c /etc/open5gs/hss.yaml
  13. open5gs 4826 0.0 0.7 222900 14272 ? Ssl 03:05 0:00 /usr/bin/open5gs-udrd -c /etc/open5gs/udr.yaml
  14. open5gs 4839 0.0 0.7 2462400 14188 ? Ssl 03:05 0:02 /usr/bin/open5gs-pcrfd -c /etc/open5gs/pcrf.yaml
  15. open5gs 4939 0.0 0.7 233648 14860 ? Ssl 03:05 0:00 /usr/bin/open5gs-pcfd -c /etc/open5gs/pcf.yaml
  16. open5gs 6816 0.0 0.6 229440 12240 ? Ssl 04:04 0:00 /usr/bin/open5gs-amfd -c /etc/open5gs/amf.yaml
  17. root 7190 0.0 0.0 13144 1060 pts/0 S+ 04:04 0:00 grep --color=auto open5gs
  18. root@guoliang:/home/guoliang#
  19. systemctl list-units | grep open5gs
  20. root@guoliang:/home/guoliang# systemctl list-units | grep open5gs
  21. open5gs-amfd.service loaded active running Open5GS AMF Daemon
  22. open5gs-ausfd.service loaded active running Open5GS AUSF Daemon
  23. open5gs-bsfd.service loaded active running Open5GS BSF Daemon
  24. open5gs-hssd.service loaded active running Open5GS HSS Daemon
  25. open5gs-mmed.service loaded active running Open5GS MME Daemon
  26. open5gs-nrfd.service loaded active running Open5GS NRF Daemon
  27. open5gs-nssfd.service loaded active running Open5GS NSSF Daemon
  28. open5gs-pcfd.service loaded active running Open5GS PCF Daemon
  29. open5gs-pcrfd.service loaded active running Open5GS PCRF Daemon
  30. open5gs-sgwcd.service loaded active running Open5GS SGW-C Daemon
  31. open5gs-sgwud.service loaded active running Open5GS SGW-U Daemon
  32. open5gs-smfd.service loaded active running Open5GS SMF Daemon
  33. open5gs-udmd.service loaded active running Open5GS UDM Daemon
  34. open5gs-udrd.service loaded active running Open5GS UDR Daemon
  35. open5gs-upfd.service loaded activating auto-restart Open5GS UPF Daemon
  36. open5gs-webui.service loaded active running Open5GS WebUI
  37. root@guoliang:/home/guoliang#

ps:修改网元配置后要重启网元服务生效

  1. sudo systemctl restart open5gs-amfd
  2. sudo systemctl restart open5gs-upfd

(2)启动基站

root@ueran:~/UERANSIM/build# 

执行后出现如下打印,则证明NG设置流程成功。后续的ueransim操作需要另开一个终端窗口。

(3)用户签约

查找用户签约需要的信息

  1. 查看/UERANSIM/config下的open5gs-ue.yaml,执行以下命令获取其中的supi、key、op、opType和amf的值
  2. cat /UERANSIM/config/open5gs-ue.yaml
  3. guoliang@guoliang:~$ cat UERANSIM/config/open5gs-ue.yaml
  4. # IMSI number of the UE. IMSI = [MCC|MNC|MSISDN] (In total 15 digits)
  5. supi: 'imsi-901700000000001'
  6. # Mobile Country Code value of HPLMN
  7. mcc: '901'
  8. # Mobile Network Code value of HPLMN (2 or 3 digits)
  9. mnc: '70'
  10. # Permanent subscription key
  11. key: '465B5CE8B199B49FAA5F0A2EE238A6BC'
  12. # Operator code (OP or OPC) of the UE
  13. op: 'E8ED289DEBA952E4283B54E88E6183CA'
  14. # This value specifies the OP type and it can be either 'OP' or 'OPC'
  15. opType: 'OPC'
  16. # Authentication Management Field (AMF) value
  17. amf: '8000'
  18. # IMEI number of the device. It is used if no SUPI is provided
  19. imei: '356938035643803'
  20. # IMEISV number of the device. It is used if no SUPI and IMEI is provided
  21. imeiSv: '4370816125816151'
  22. # List of gNB IP addresses for Radio Link Simulation
  23. gnbSearchList:
  24. - 127.0.0.1
  25. # UAC Access Identities Configuration
  26. uacAic:
  27. mps: false
  28. mcs: false
  29. # UAC Access Control Class
  30. uacAcc:
  31. normalClass: 0
  32. class11: false
  33. class12: false
  34. class13: false
  35. class14: false
  36. class15: false
  37. # Initial PDU sessions to be established
  38. sessions:
  39. - type: 'IPv4'
  40. apn: 'internet'
  41. slice:
  42. sst: 1
  43. # Configured NSSAI for this UE by HPLMN
  44. configured-nssai:
  45. - sst: 1
  46. # Default Configured NSSAI for this UE
  47. default-nssai:
  48. - sst: 1
  49. sd: 1
  50. # Supported integrity algorithms by this UE
  51. integrity:
  52. IA1: true
  53. IA2: true
  54. IA3: true
  55. # Supported encryption algorithms by this UE
  56. ciphering:
  57. EA1: true
  58. EA2: true
  59. EA3: true
  60. # Integrity protection maximum data rate for user plane
  61. integrityMaxRate:
  62. uplink: 'full'
  63. downlink: 'full'
  64. guoliang@guoliang:~$

在网页输入
http://172.16.190.214:3000/登录签约界面,并将上述关键信息填写到新建的Subscriber当中

(4)UE上线,UE上线成功后会创建接口uesimtun0

root@ueran:~/UERANSIM/build# ./nr-ue -c ../config/open5gs-ue.yaml 

执行后出现如下打印,表明UE的IP地址已经分配完成。后续的ueransim操作需要另开一个终端窗口。

在UERANSIM虚机上查看uesimtun0接口状态为UP,IP地址为10.45.0.6,该地址就是分配给UE的IP地址,用于GTP报文的转发。

在Open5GS虚机上查看ogstun接口,该接口IP地址与ueransim的uesimtun0的地址处于同一网段,两个接口可以带源互PING。(如:在UERANSIM节点上执行ping -I uesimtun0 10.45.0.1)

在open5gs上查看AMF的LOG:

$ tail -f /var/log/open5gs/amf.log

(5)用户打流

Open5GS虚机配置NAT:

  1. ### Enable IPv4/IPv6 Forwarding
  2. $ sudo sysctl -w net.ipv4.ip_forward=1
  3. $ sudo sysctl -w net.ipv6.conf.all.forwarding=1
  1. ### Add NAT Rule
  2. $ sudo iptables -t nat -A POSTROUTING -s 10.45.0.0/16 ! -o ogstun -j MASQUERADE
  3. $ sudo ip6tables -t nat -A POSTROUTING -s 2001:db8:cafe::/48 ! -o ogstun -j MASQUERADE

①Ping包

root@ueran:~/UERANSIM/build# ping -I uesimtun0 baidu.com

如果ping不通,首先检查uesimtun0和ogustun接口是否可以带源互ping,然后检查Open5GS上是否可以ping通外网地址(如:www.baidu.com),如果无法Ping通外部网络,请检查Open5GS本机的路由设置,default路由是否关联在NAT网络并拥有较小的metric值。

②http包(curl)

执行前需要检查./nr-binder是否有执行权限(没有权限的话执行chmod 777 ./nr-binder)

如果提示curl指令不存在,则安装curl(执行指令:apt-get install curl)

root@ueran:~/UERANSIM/build# ./nr-binder 10.45.0.5 curl baidu.com

(6)抓包

tcpdump -i any可以抓到VM内网元交互以及VM间网元交互的所有报文

6 UERANSIM操作命令

查看node

  1. root@guoliang:/home/guoliang/UERANSIM/build# ./nr-cli --dump
  2. UERANSIM-gnb-901-70-1
  3. imsi-901700000000001

查看gnb下可使用的命令

  1. root@guoliang:/home/guoliang/UERANSIM/build# ./nr-cli UERANSIM-gnb-901-70-1
  2. --------------------------------------------------------------------------------------------
  3. $ commands
  4. info | Show some information about the gNB
  5. status | Show some status information about the gNB
  6. amf-list | List all AMFs associated with the gNB
  7. amf-info | Show some status information about the given AMF
  8. ue-list | List all UEs associated with the gNB
  9. ue-count | Print the total number of UEs connected the this gNB
  10. ue-release | Request a UE context release for the given UE
  11. --------------------------------------------------------------------------------------------
  12. $
  1. $ info
  2. name: UERANSIM-gnb-901-70-1
  3. nci: 16
  4. plmn: 901/70
  5. tac: 1
  6. nssai:
  7. - sst: 0x01
  8. sd: null
  9. ngap-ip: 10.10.10.11
  10. gtp-ip: 10.10.10.21
  11. paging-drx: v128
  12. ignore-sctp-id: true
  1. $ status
  2. is-ngap-up: true
  1. $ amf-list
  2. - id: 2
  1. $ amf-info 2
  2. id: 2
  3. name: open5gs-amf0
  4. address: 10.10.10.12:38412
  5. state: CONNECTED
  6. capacity: 255
  7. association:
  8. id: 2
  9. rx-num: 10
  10. tx-num: 10
  11. served-guami:
  12. - guami:
  13. plmn: 901/70
  14. region-id: 2
  15. set-id: 1
  16. pointer: 0
  17. backup-amf:
  18. served-plmn:
  19. - plmn: 901/70
  20. nssai:
  21. - sst: 0x01
  22. sd: null
  1. $ ue-list
  2. - ue-id: 4
  3. ran-ngap-id: 4
  4. amf-ngap-id: 4
  1. $ ue-count
  2. 1
  1. $ ue-release 4
  2. Requesting UE context release

ue-release即UE释放,这里UE的ID值为4,执行ue-release 1后将发起UE释放的流程UE端显示UE切换为CM-IDLE状态

gNB端显示开始执行UE上下文的释放

在open5gs端抓取NGAP报文,能够看到UE上下文释放的流程及其内容(待补充)

查看UE下可使用的命令

  1. root@guoliang:/home/guoliang/UERANSIM/build# ./nr-cli imsi-901700000000001
  2. --------------------------------------------------------------------------------------------
  3. $ commands
  4. info | Show some information about the UE
  5. status | Show some status information about the UE
  6. timers | Dump current status of the timers in the UE
  7. rls-state | Show status information about RLS
  8. coverage | Dump available cells and PLMNs in the coverage
  9. ps-establish | Trigger a PDU session establishment procedure
  10. ps-list | List all PDU sessions
  11. ps-release | Trigger a PDU session release procedure
  12. ps-release-all | Trigger PDU session release procedures for all active sessions
  13. deregister | Perform a de-registration by the UE
  14. --------------------------------------------------------------------------------------------
  15. $
  1. $ info
  2. supi: imsi-901700000000001
  3. hplmn: 901/70
  4. imei: 356938035643803
  5. imeisv: 4370816125816151
  6. ecall-only: false
  7. uac-aic:
  8. mps: false
  9. mcs: false
  10. uac-acc:
  11. normal-class: 0
  12. class-11: false
  13. class-12: false
  14. class-13: false
  15. class-14: false
  16. class-15: false
  17. is-high-priority: false
  1. $ status
  2. cm-state: CM-IDLE
  3. rm-state: RM-REGISTERED
  4. mm-state: MM-REGISTERED/NORMAL-SERVICE
  5. 5u-state: 5U1-UPDATED
  6. sim-inserted: true
  7. selected-plmn: 901/70
  8. current-cell: 1
  9. current-plmn: 901/70
  10. current-tac: 1
  11. last-tai: PLMN[901/70] TAC[1]
  12. stored-suci: no-identity
  13. stored-guti:
  14. plmn: 901/70
  15. amf-region-id: 0x02
  16. amf-set-id: 1
  17. amf-pointer: 0
  18. tmsi: 0xcf0085b4
  19. has-emergency: false
  1. $ timers
  2. T3346: .
  3. T3396: .
  4. T3444: .
  5. T3445: .
  6. T3502: .
  7. T3510: .
  8. T3511: .
  9. T3512: rem[32171] int[32400]
  10. T3516: .
  11. T3517: .
  12. T3519: .
  13. T3520: .
  14. T3521: .
  15. T3525: .
  16. T3540: .
  17. T3584: .
  18. T3585: .
  1. $ rls-state
  2. sti: 269378BE453D856D
  3. gnb-search-space:
  4. - 127.0.0.1
  1. $ coverage
  2. [1]:
  3. signal: -1 dBm (Excellent)
  4. mib:
  5. barred: false
  6. intra-freq-reselection: allowed
  7. sib1:
  8. nr-cell-id: 0000000000000010
  9. plmn: 901/70
  10. tac: 1
  11. operator-reserved: false
  1. $ ps-establish
  2. Trigger a PDU session establishment procedure
  3. Usage:
  4. ps-establish <session-type> [options]
  5. Examples:
  6. ps-establish IPv4 --sst 1 --sd 1 --dnn internet
  7. ps-establish IPv4 --emergency
  8. Options:
  9. --sst <value> SST value of the PDU session
  10. --sd <value> SD value of the PDU session
  11. -n, --dnn <apn> DNN/APN value of the PDU session
  12. -e, --emergency Request as an emergency session
  13. --------------------------------------------------------------------------------------------
  14. $ ps-establish IPv4 --sst 1 sd 1 --dnn internet
  15. PDU session establishment procedure triggered

Gnb端的打印

UE端的打印

  1. $ ps-list
  2. PDU Session1:
  3. state: PS-ACTIVE
  4. session-type: IPv4
  5. apn: internet
  6. s-nssai:
  7. sst: 0x01
  8. sd: null
  9. emergency: false
  10. address: 10.45.0.8
  11. ambr: up[1Gb/s] down[1Gb/s]
  12. data-pending: false
  13. PDU Session2:
  14. state: PS-ACTIVE
  15. session-type: IPv4
  16. apn: internet
  17. s-nssai:
  18. sst: 0x01
  19. sd: null
  20. emergency: false
  21. address: 10.45.0.9
  22. ambr: up[1Gb/s] down[1Gb/s]
  23. data-pending: false
  1. $ ps-release 1
  2. PDU session release procedure(s) triggered

UE端的打印

Gnb端的打印

  1. $ ps-release-all
  2. PDU session release procedure(s) triggered

释放所有PDU Session之后,系统会自动激活一个PDU Session

  1. $ ps-list
  2. PDU Session1:
  3. state: PS-ACTIVE
  4. session-type: IPv4
  5. apn: internet
  6. s-nssai:
  7. sst: 0x01
  8. sd: null
  9. emergency: false
  10. address: 10.45.0.10
  11. ambr: up[1Gb/s] down[1Gb/s]
  12. data-pending: false
  1. $ deregister
  2. Perform a de-registration by the UE
  3. Usage:
  4. deregister <normal|disable-5g|switch-off|remove-sim>
  5. --------------------------------------------------------------------------------------------
  6. $ deregister switch-off
  7. De-registration procedure triggered. UE device will be switched off.

选择UE去注册,类型为关机

UE端的输出,显示UE已关机,且UE进程退出

Gnb端的输出

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号