前回まではfree5gcをInstallしテストコールを行い取得したキャプチャを詳しく見る事によって5GCとは何かをみてきました。
今回はUERANSIMというUE+gNodeBのシュミレーターをInstallしてみます。大体30分くらいかかるかと思います。
#1. UERANSIM Install
これまた優れたシュミレーターです。公式はこちら。
#1.1 Network Diagram
Host PC上にVMをもう一つ作成し以下の様な構成のネットワークを構築します。
#1.2 VM Clone
今回はfree5gcで使ったVMをクローンしたVMにueransim入れてみます。
ますはVirtualBoxのメニューからVMのクローン。

ホストネームとIPアドレスを変更しrebootします。
q14537@free5gc:~$ sudo hostname ueransim
[sudo] password for q14537:
q14537@free5gc:~$ cat /etc/hostname
free5gc
q14537@free5gc:~$ sudo vi /etc/hostname
q14537@free5gc:~$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 free5gc
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
q14537@free5gc:~$ sudo vi /etc/hosts
q14537@free5gc:~$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 ueransim
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
q14537@free5gc:~$ cat /etc/hostname
ueransim
q14537@free5gc:~$ vi /etc/
Display all 190 possibilities? (y or n)
q14537@free5gc:~$ vi /etc/ne
netplan/ network/ networkd-dispatcher/ networks newt/
q14537@free5gc:~$ sudo vi /etc/netplan/00-installer-config.yaml
q14537@free5gc:~$ cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
enp0s3:
dhcp4: true
enp0s8:
addresses:
- 192.168.56.102/24
# gateway4: 192.168.56.1
nameservers:
addresses: []
search: []
version: 2
#1.3 UERANSIM Install
Insatall手順はこちらの通りなのですが、そのまま実行すると以下の様にcmakeのversionが古いと怒られます。
q14537@ueransim:~$ cd UERANSIM/
q14537@ueransim:~/UERANSIM$ make
rm -fr logs # Old version log files
mkdir -p build
rm -fr build/*
# cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" . -B cmake-build-debug
cmake -DCMAKE_BUILD_TYPE=Release -G "CodeBlocks - Unix Makefiles" . -B cmake-build-release
CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
CMake 3.17 or higher is required. You are running version 3.16.3
-- Configuring incomplete, errors occurred!
make: *** [makefile:10: build] Error 1
仕方がないのでちょっとだけ時間かかりますが新しいcmakeをコンパイルします。
そのままだとまたしても以下の様にSSL Development packageがないとか怒られるので、先にSSLのパッケージをいれておきます。
-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR)
CMake Error at Utilities/cmcurl/CMakeLists.txt:525 (message):
Could not find OpenSSL. Install an OpenSSL development package or
configure CMake with -DCMAKE_USE_OPENSSL=OFF to build without OpenSSL.
sudo apt-get install libssl-dev
wget https://github.com/Kitware/CMake/releases/download/v3.21.2/cmake-3.21.2.tar.gz
そしてbootstrapしてmakeしてmake installします。
q14537@ueransim:~/cmake-3.21.2$ ./bootstrap
q14537@ueransim:~/cmake-3.21.2$ make
q14537@ueransim:~/cmake-3.21.2$ sudo make install
新しいVersionのcmakeが入ったらUERANSIMのコンパイル。うまくコンパイル出来るとbuild配下に以下のコマンドが出来上がります。
UERANSIM successfully built.
q14537@ueransim:~/UERANSIM$ pwd
/home/q14537/UERANSIM
q14537@ueransim:~/UERANSIM$ ls
build cmake-build-release CMakeLists.txt config LICENSE makefile README.md src tools
q14537@ueransim:~/UERANSIM$ cd build/
q14537@ueransim:~/UERANSIM/build$ ls
libdevbnd.so nr-binder nr-cli nr-gnb nr-ue
#1.4 UERANSIM Configuration
コンフィグの手順は公式サイトの以下に記載してあります。
free5gcとインテグするためのコンフィグファイルが用意されています。
以下gNodeB用。PLMNIDにいくつを使うか、どのAMFと接続するか等々書いてあります。
q14537@ueransim:~/UERANSIM/config$ cat free5gc-gnb.yaml
mcc: '208' # Mobile Country Code value
mnc: '93' # Mobile Network Code value (2 or 3 digits)
nci: '0x000000010' # NR Cell Identity (36-bit)
idLength: 32 # NR gNB ID length in bits [22...32]
tac: 1 # Tracking Area Code
linkIp: 127.0.0.1 # gNB's local IP address for Radio Link Simulation (Usually same with local IP)
ngapIp: 127.0.0.1 # gNB's local IP address for N2 Interface (Usually same with local IP)
gtpIp: 127.0.0.1 # gNB's local IP address for N3 Interface (Usually same with local IP)
# List of AMF address information
amfConfigs:
- address: 127.0.0.1
port: 38412
# List of supported S-NSSAIs by this gNB
slices:
- sst: 0x1
sd: 0x010203
# Indicates whether or not SCTP stream number errors should be ignored.
ignoreStreamIds: true
以下UE用。SUPIに何番を使うか、PLMNIDに何を設定するか、DNN(apnになってますが。。)は何を使うか等々設定できます。
q14537@ueransim:~/UERANSIM/config$ cat free5gc-ue.yaml
# IMSI number of the UE. IMSI = [MCC|MNC|MSISDN] (In total 15 digits)
supi: 'imsi-208930000000003'
# Mobile Country Code value of HPLMN
mcc: '208'
# Mobile Network Code value of HPLMN (2 or 3 digits)
mnc: '93'
# Permanent subscription key
key: '8baf473f2f8fd09487cccbd7097c6862'
# Operator code (OP or OPC) of the UE
op: '8e27b6af0e692e750f32667a3b14605d'
# This value specifies the OP type and it can be either 'OP' or 'OPC'
opType: 'OPC'
# Authentication Management Field (AMF) value
amf: '8000'
# IMEI number of the device. It is used if no SUPI is provided
imei: '356938035643803'
# IMEISV number of the device. It is used if no SUPI and IMEI is provided
imeiSv: '4370816125816151'
# List of gNB IP addresses for Radio Link Simulation
gnbSearchList:
- 127.0.0.1
# UAC Access Identities Configuration
uacAic:
mps: false
mcs: false
# UAC Access Control Class
uacAcc:
normalClass: 0
class11: false
class12: false
class13: false
class14: false
class15: false
# Initial PDU sessions to be established
sessions:
- type: 'IPv4'
apn: 'internet'
slice:
sst: 0x01
sd: 0x010203
# Configured NSSAI for this UE by HPLMN
configured-nssai:
- sst: 0x01
sd: 0x010203
# Default Configured NSSAI for this UE
default-nssai:
- sst: 1
sd: 1
# Supported integrity algorithms by this UE
integrity:
IA1: true
IA2: true
IA3: true
# Supported encryption algorithms by this UE
ciphering:
EA1: true
EA2: true
EA3: true
# Integrity protection maximum data rate for user plane
integrityMaxRate:
uplink: 'full'
downlink: 'full'
折角なのでPLMNIDをソフトバンク(MCC=440+MNC=20)に変更してfree5gcと接続してみましょう。
free5gc-ue.yamlの該当部分を編集します。接続先のgNodeBのアドレスも自分自身のアドレスである192.168.56.102に変更します。
q14537@ueransim:~/UERANSIM/build$ cat ../config/free5gc-ue.yaml
# IMSI number of the UE. IMSI = [MCC|MNC|MSISDN] (In total 15 digits)
supi: 'imsi-440200000000003'
# Mobile Country Code value of HPLMN
mcc: '440'
# Mobile Network Code value of HPLMN (2 or 3 digits)
mnc: '20'
# Permanent subscription key
key: '8baf473f2f8fd09487cccbd7097c6862'
# Operator code (OP or OPC) of the UE
op: '8e27b6af0e692e750f32667a3b14605d'
# This value specifies the OP type and it can be either 'OP' or 'OPC'
opType: 'OPC'
# Authentication Management Field (AMF) value
amf: '8000'
# IMEI number of the device. It is used if no SUPI is provided
imei: '356938035643803'
# IMEISV number of the device. It is used if no SUPI and IMEI is provided
imeiSv: '4370816125816151'
# List of gNB IP addresses for Radio Link Simulation
gnbSearchList:
- 192.168.56.102
free5gc-gnb.yamlの方も編集します。ここで自分自身のアドレスを192.168.56.102、AMF向けのアドレスをfree5gcのVMのアドレス(192.168.56.103)に変更します。
mcc: '440' # Mobile Country Code value
mnc: '20' # Mobile Network Code value (2 or 3 digits)
nci: '0x000000010' # NR Cell Identity (36-bit)
idLength: 32 # NR gNB ID length in bits [22...32]
tac: 1 # Tracking Area Code
linkIp: 192.168.56.102 # gNB's local IP address for Radio Link Simulation (Usually same with local IP)
ngapIp: 192.168.56.102 # gNB's local IP address for N2 Interface (Usually same with local IP)
gtpIp: 192.168.56.102 # gNB's local IP address for N3 Interface (Usually same with local IP)
# List of AMF address information
amfConfigs:
- address: 192.168.56.103
port: 38412
これでUERANSIM側の準備は整いました。
#2. free5gc側の変更
以下の様にconfigディレクトリ配下の各NFのコンフィグファイル内のPLMNIDをすべて書き換えます。
q14537@free5gc:~/free5gc/config$ egrep 'mcc|mnc' *.yaml |egrep '208|93'
amfcfg.n3test.yaml: mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9)
amfcfg.n3test.yaml: mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9)
amfcfg.n3test.yaml: mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9)
amfcfg.n3test.yaml: mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9)
amfcfg.n3test.yaml: mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9)
amfcfg.n3test.yaml: mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9)
amfcfg.yaml: mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9)
amfcfg.yaml: mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9)
amfcfg.yaml: mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9)
amfcfg.yaml: mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9)
amfcfg.yaml: mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9)
amfcfg.yaml: mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9)
ausfcfg.yaml: - mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9)
ausfcfg.yaml: mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9)
nrfcfg.yaml: mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9)
nrfcfg.yaml: mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9)
nssfcfg.yaml: - mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9)
nssfcfg.yaml: mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9)
nssfcfg.yaml: mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9)
nssfcfg.yaml: mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9)
AMFに関してはgNodeBから接続してくるN2 Interfaceのアドレス(192.168.56.103)も変更します。
diff --git a/config/amfcfg.yaml b/config/amfcfg.yaml
index 3fb2fa4..b6c4372 100644
--- a/config/amfcfg.yaml
+++ b/config/amfcfg.yaml
@@ -5,7 +5,7 @@ info:
configuration:
amfName: AMF # the name of this AMF
ngapIpList: # the IP list of N2 interfaces on this AMF
- - 127.0.0.1
+ - 192.168.56.103
sbi: # Service-based interface information
scheme: http # the protocol for sbi (http or https)
registerIPv4: 127.0.0.18 # IP used to register to NRF
@@ -20,18 +20,18 @@ configuration:
servedGuamiList: # Guami (Globally Unique AMF ID) list supported by this AMF
# <GUAMI> = <MCC><MNC><AMF ID>
- plmnId: # Public Land Mobile Network ID, <PLMN ID> = <MCC><MNC>
- mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9)
- mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9)
+ mcc: 440 # Mobile Country Code (3 digits string, digit: 0~9)
+ mnc: 20 # Mobile Network Code (2 or 3 digits string, digit: 0~9)
amfId: cafe00 # AMF identifier (3 bytes hex string, range: 000000~FFFFFF)
supportTaiList: # the TAI (Tracking Area Identifier) list supported by this AMF
- plmnId: # Public Land Mobile Network ID, <PLMN ID> = <MCC><MNC>
- mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9)
- mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9)
+ mcc: 440 # Mobile Country Code (3 digits string, digit: 0~9)
+ mnc: 20 # Mobile Network Code (2 or 3 digits string, digit: 0~9)
tac: 1 # Tracking Area Code (uinteger, range: 0~16777215)
plmnSupportList: # the PLMNs (Public land mobile network) list supported by this AMF
- plmnId: # Public Land Mobile Network ID, <PLMN ID> = <MCC><MNC>
- mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9)
- mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9)
+ mcc: 440 # Mobile Country Code (3 digits string, digit: 0~9)
+ mnc: 20 # Mobile Network Code (2 or 3 digits string, digit: 0~9)
snssaiList: # the S-NSSAI (Single Network Slice Selection Assistance Information) list supported by this AMF
- sst: 1 # Slice/Service Type (uinteger, range: 0~255)
sd: 010203 # Slice Differentiator (3 bytes hex string, range: 000000~FFFFFF)
SMFもgNodeBから接続してくるUPFのN3/N4のアドレスを変更します。
diff --git a/config/smfcfg.yaml b/config/smfcfg.yaml
index 586fe32..ec42f7b 100644
--- a/config/smfcfg.yaml
+++ b/config/smfcfg.yaml
@@ -58,7 +58,7 @@ configuration:
interfaces: # Interface list for this UPF
- interfaceType: N3 # the type of the interface (N3 or N9)
endpoints: # the IP address of this N3/N9 interface on this UPF
- - 127.0.0.8
+ - 192.168.56.103
networkInstance: internet # Data Network Name (DNN)
links: # the topology graph of userplane, A and B represent the two nodes of each link
- A: gNB1
#3. UERANSIMとfree5gcの接続
前回まではfree5gc上でtest.shを使ってコールテストを行いましたが、今回からは単独で5GC NF達を起動していきます。といっても面倒なのでrun.shというシェルスクリプトで起動していく事が出来ます。
free5gc側のVMでrun.shを実行
q14537@free5gc:~/free5gc$ ./run.sh
NF達が各プロセスとして起動してます。
q14537 1170 994 0 16:04 pts/0 00:00:00 bash ./run.sh
root 1171 1170 0 16:04 pts/0 00:00:00 sudo -E ./bin/free5gc-upfd
root 1173 1171 0 16:04 pts/0 00:00:00 ./bin/free5gc-upfd
q14537 1182 1170 0 16:04 pts/0 00:00:00 ./bin/nrf
q14537 1190 1170 0 16:04 pts/0 00:00:00 ./bin/amf
q14537 1200 1170 0 16:04 pts/0 00:00:00 ./bin/smf
q14537 1206 1170 0 16:04 pts/0 00:00:00 ./bin/udr
q14537 1215 1170 0 16:04 pts/0 00:00:00 ./bin/pcf
q14537 1225 1170 0 16:04 pts/0 00:00:00 ./bin/udm
q14537 1233 1170 0 16:04 pts/0 00:00:00 ./bin/nssf
q14537 1241 1170 0 16:04 pts/0 00:00:00 ./bin/ausf
ueransim側のVMで以下のコマンドを実行するとgNodeBとfree5gcが接続されます。
SCTPを使って192.168.56.103:38412に接続に行っている事がわかります。
q14537@ueransim:~/UERANSIM/build$ ./nr-gnb -c ../config/free5gc-gnb.yaml
free5gc側でもgNodeB(192.168.56.102:39882)から接続要求が来た事が確認ができます。
Wiresharkでキャプチャを取ってみると以下の様に最初にSCTPのアソシエーションを確立(INIT,INIT_ACK,COOKIE_ECHO,COOKIE_ACKの4-way handshake)し、その後NGAPで接続要求をやりとりしているのが見えます。PLMNIDをSoftbankに変えたのでWiresharkもちゃんとSoftbankとしてデコードしてくれています。
ここまででueransim(gNodeB)とfree5gc(AMF)が接続されました。
#4. UE電源ON!(Registration)
ueransim側からue電源ONしてみます。
なんだかメッセージが出て「おっ!」と思うかもしれませんが、free5gc側では以下のエラーが出ます。
これはまだfree5gc側にUEの情報が登録されていないのでAUSFで認証をはじかれているのですね。なのでRegistrationが完了しません。
WiresharkでHTTP/2メッセージを見ると404 "User not found"がUDRから返ってきています。HTTPの404 Page Not Foundみたいですね。
#5.最後に
今回はここまでです。UEの情報が5GC側に登録されていないと怒られてしまいました。ネットワーク側にちゃんと登録されていないSIMは勝手に使えないの仕組みはこういう事です。次回はfree5gc側でUEの情報を登録していきましょう。その5に続きます。