LoginSignup
4
7

More than 1 year has passed since last update.

教養としての5GC(free5gc+UERANSIMで学ぶ5Gコアネットワーク)その5

Last updated at Posted at 2021-09-11

前回まではueransimをinstallして疑似5G基地局、疑似UEから5GCにRegistrationを試みてみました。

前回は失敗してしまったので今回はUEを5GC側に登録します。

1. free5gcのwebconsoleを使ってみる

free5gcには加入者データやUEの状態遷移を確認できるGUI(webconsole)がついています。
free5gc VM上で以下の通り起動します。ポート5000番でWeb Serverが起動します。

q14537@free5gc:~/free5gc/webconsole/bin$ ls
webconsole
q14537@free5gc:~/free5gc/webconsole/bin$ ./webconsole

Host PC上のブラウザからアクセスしてみます。今回の環境では192.168.56.103:5000です。
そうすると以下のようなログイン画面が出てきます。

image.png

username:admin/password:free5gcでログインしてみます。

image.png

左のSubscriberのメニュをクリックするとNew Subscriberが登録できますので、ここで前回のueransimで使っていたUE情報を登録します。基本的にueransimのfree5gc-ue.yamlの内容が既に入っているのですがPLMINDを変えたのでそこだけ44020に変更します。

image.png

一番下のSubmitを押すと加入者情報が登録されます。

image.png

2. 再度ueransimから電源ONを試してみる。

今回は以下の様に成功しました。

UERANSIM v3.2.3
[2021-09-11 09:37:44.840] [rrc] [debug] New signal detected for cell[1], total [1] cells in coverage
[2021-09-11 09:37:44.840] [nas] [info] UE switches to state [MM-DEREGISTERED/PLMN-SEARCH]
[2021-09-11 09:37:44.841] [nas] [info] Selected plmn[440/20]
[2021-09-11 09:37:44.841] [rrc] [info] Selected cell plmn[440/20] tac[1] category[SUITABLE]
[2021-09-11 09:37:44.841] [nas] [info] UE switches to state [MM-DEREGISTERED/PS]
[2021-09-11 09:37:44.841] [nas] [info] UE switches to state [MM-DEREGISTERED/NORMAL-SERVICE]
[2021-09-11 09:37:44.841] [nas] [debug] Initial registration required due to [MM-DEREG-NORMAL-SERVICE]
[2021-09-11 09:37:44.844] [nas] [debug] UAC access attempt is allowed for identity[0], category[MO_sig]
[2021-09-11 09:37:44.844] [nas] [debug] Sending Initial Registration
[2021-09-11 09:37:44.845] [rrc] [debug] Sending RRC Setup Request
[2021-09-11 09:37:44.845] [rrc] [info] RRC connection established
[2021-09-11 09:37:44.845] [rrc] [info] UE switches to state [RRC-CONNECTED]
[2021-09-11 09:37:44.845] [nas] [info] UE switches to state [MM-REGISTER-INITIATED]
[2021-09-11 09:37:44.845] [nas] [info] UE switches to state [CM-CONNECTED]
[2021-09-11 09:37:44.865] [nas] [debug] Authentication Request received
[2021-09-11 09:37:44.873] [nas] [debug] Security Mode Command received
[2021-09-11 09:37:44.873] [nas] [debug] Selected integrity[2] ciphering[0]
[2021-09-11 09:37:44.945] [nas] [debug] Registration accept received
[2021-09-11 09:37:44.945] [nas] [info] UE switches to state [MM-REGISTERED/NORMAL-SERVICE]
[2021-09-11 09:37:44.945] [nas] [debug] Sending Registration Complete
[2021-09-11 09:37:44.946] [nas] [info] Initial Registration is successful
[2021-09-11 09:37:44.946] [nas] [debug] Sending PDU Session Establishment Request
[2021-09-11 09:37:44.946] [nas] [debug] UAC access attempt is allowed for identity[0], category[MO_sig]
[2021-09-11 09:37:45.192] [nas] [debug] PDU Session Establishment Accept received
[2021-09-11 09:37:45.192] [nas] [warning] SM cause received in PduSessionEstablishmentAccept [PDU_SESSION_TYPE_IPV4_ONLY_ALLOWED]
[2021-09-11 09:37:45.200] [nas] [info] PDU Session establishment is successful PSI[1]
[2021-09-11 09:37:45.207] [app] [info] Connection setup for PDU session[1] is successful, TUN interface[uesimtun0, 60.60.0.1] is up.

前回はUDRでそんなUE情報知らないと怒られましたが、今回はUDR(127.0.0.4)はちゃんと返事をしています。

image.png

ueransim上のVMでは以下の様にuesimtun0と言う名前でGTPトンネル用のインターフェイスが追加されています。

uesimtun0: flags=369<UP,POINTOPOINT,NOTRAILERS,RUNNING,PROMISC>  mtu 1400
        inet 60.60.0.1  netmask 255.255.255.255  destination 60.60.0.1
        inet6 fe80::4eb3:fe43:8c48:641d  prefixlen 64  scopeid 0x20<link>
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 500  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 7  bytes 448 (448.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

このインターフェイスを使ってDN(Data Network、いわゆる外のネットワーク)にpingしてみます。
見事にpingの返信がgoogleから返ってきます。

q14537@ueransim:~$ ping -I uesimtun0 www.google.com
PING www.google.com (142.250.199.100) from 60.60.0.1 uesimtun0: 56(84) bytes of data.
64 bytes from nrt13s52-in-f4.1e100.net (142.250.199.100): icmp_seq=1 ttl=115 time=5.22 ms
64 bytes from nrt13s52-in-f4.1e100.net (142.250.199.100): icmp_seq=2 ttl=115 time=5.70 ms
64 bytes from nrt13s52-in-f4.1e100.net (142.250.199.100): icmp_seq=3 ttl=115 time=5.16 ms

Wiresharkで見てもGTPパケットがちゃんと下のレイヤではUERANSIM(192.168.56.102)からfree5gc(192.168.56.103)に流れており、上のGTPレイヤではUEのアドレス(60.60.0.1)からgoogleのアドレス(142.250.199.100)に流れています。

image.png

webconsoleで5GCのNFの状態が見れますので見てみましょう。

image.png

AMFの保持している情報。UE情報とかUEに割り振っているGUTIとか見えます。

image.png

SMFの保持している情報。DNNとかPDUAddress(UEに割り振っているアドレス)等が見えます。

image.png

3. UERANSIMのCLIを使ってみる

ueransim側でもnr-cliというCLI Toolで色々状態が見えますので見てみましょう。
まずはgNodeBの情報。gNodeBが接続されているAMFの情報やこのgNodeBに接続されているUEの数等が見えます。

q14537@ueransim:~/UERANSIM/build$ ./nr-cli -d
UERANSIM-gnb-440-20-1
imsi-440200000000003
q14537@ueransim:~/UERANSIM/build$ ./nr-cli UERANSIM-gnb-440-20-1
--------------------------------------------------------------------------------------------
$ commands
info       | Show some information about the gNB
status     | Show some status information about the gNB
amf-list   | List all AMFs associated with the gNB
amf-info   | Show some status information about the given AMF
ue-list    | List all UEs associated with the gNB
ue-count   | Print the total number of UEs connected the this gNB
ue-release | Request a UE context release for the given UE
--------------------------------------------------------------------------------------------
$ info
name: UERANSIM-gnb-440-20-1
nci: 16
plmn: 440/20
tac: 1
nssai:
 - sst: 0x01
   sd: 0x010203
ngap-ip: 192.168.56.102
gtp-ip: 192.168.56.102
paging-drx: v128
ignore-sctp-id: true
--------------------------------------------------------------------------------------------
$ status
is-ngap-up: true
--------------------------------------------------------------------------------------------
$ amf-list
- id: 2
--------------------------------------------------------------------------------------------
$ amf-info 2
id: 2
name: AMF
address: 192.168.56.103:38412
state: CONNECTED
capacity: 255
association:
 id: 2
 rx-num: 3
 tx-num: 5
served-guami:
 - guami:
    plmn: 440/20
    region-id: 202
    set-id: 1016
    pointer: 0
   backup-amf:
served-plmn:
 - plmn: 440/20
   nssai:
    - sst: 0x01
      sd: 0x010203
    - sst: 0x01
      sd: 0x112233
--------------------------------------------------------------------------------------------
$ ue-list
- ue-id: 1
  ran-ngap-id: 1
  amf-ngap-id: 1
--------------------------------------------------------------------------------------------
$ ue-count
1
--------------------------------------------------------------------------------------------

そしてUEの情報。UE側でも、振られているアドレス、QoSの値などが見えます。

q14537@ueransim:~/UERANSIM/build$ ./nr-cli imsi-440200000000003
--------------------------------------------------------------------------------------------
$ commands
info           | Show some information about the UE
status         | Show some status information about the UE
timers         | Dump current status of the timers in the UE
rls-state      | Show status information about RLS
coverage       | Dump available cells and PLMNs in the coverage
ps-establish   | Trigger a PDU session establishment procedure
ps-list        | List all PDU sessions
ps-release     | Trigger a PDU session release procedure
ps-release-all | Trigger PDU session release procedures for all active sessions
deregister     | Perform a de-registration by the UE
--------------------------------------------------------------------------------------------
$ info
supi: imsi-440200000000003
hplmn: 440/20
imei: 356938035643803
imeisv: 4370816125816151
ecall-only: false
uac-aic:
 mps: false
 mcs: false
uac-acc:
 normal-class: 0
 class-11: false
 class-12: false
 class-13: false
 class-14: false
 class-15: false
is-high-priority: false
--------------------------------------------------------------------------------------------
$ status
cm-state: CM-CONNECTED
rm-state: RM-REGISTERED
mm-state: MM-REGISTERED/NORMAL-SERVICE
5u-state: 5U1-UPDATED
sim-inserted: true
selected-plmn: 440/20
current-cell: 1
current-plmn: 440/20
current-tac: 1
last-tai: PLMN[440/20] TAC[1]
stored-suci: no-identity
stored-guti:
 plmn: 440/20
 amf-region-id: 0xca
 amf-set-id: 1016
 amf-pointer: 0
 tmsi: 0x00000001
has-emergency: false
--------------------------------------------------------------------------------------------
$ coverage
[1]:
 signal: -1 dBm (Excellent)
 mib:
  barred: false
  intra-freq-reselection: allowed
 sib1:
  nr-cell-id: 0000000000000010
  plmn: 440/20
  tac: 1
  operator-reserved: false
--------------------------------------------------------------------------------------------
$ ps-list
PDU Session1:
 state: PS-ACTIVE
 session-type: IPv4
 apn: internet
 s-nssai:
  sst: 0x01
  sd: 0x010203
 emergency: false
 address: 60.60.0.1
 ambr: up[200Mb/s] down[100Mb/s]
 data-pending: false
--------------------------------------------------------------------------------------------

3.1 State Machine

このUEのstatusコマンドで見える以下の情報が、それぞれConnetion Management, Registration Management, Mobility Management?で5GC側とUEがメッセージをやりとりし状態遷移をします。CM-Connected, RM-Registredの状態でないとパケットが送信出来ないとかルールがあります。

cm-state: CM-CONNECTED
rm-state: RM-REGISTERED
mm-state: MM-REGISTERED/NORMAL-SERVICE

image.png

image.png

引用元:3GPP TS23.501

4. mongodbにストアされているデータを見てみる

webconsole経由で加入者データを登録しましたがバックエンドはMongoDBを使っている様です。free5gc内ではUDRが実際にMongoDBを読み書きしているのですね。
直接MongoDBにアクセスして情報を見る事もできます。

q14537@free5gc:~$ mongo
MongoDB shell version v3.6.8
connecting to: mongodb://127.0.0.1:27017
Implicit session: session { "id" : UUID("7f01f3e7-d3da-4440-a5b1-2bd756cf4556") }
MongoDB server version: 3.6.8
> show dbs
admin    0.000GB
config   0.000GB
free5gc  0.001GB
local    0.000GB
> use free5gc
switched to db free5gc
> show collections
NfProfile
policyData.ues.amData
policyData.ues.smData
subscriptionData.authenticationData.authenticationStatus
subscriptionData.authenticationData.authenticationSubscription
subscriptionData.contextData.amf3gppAccess
subscriptionData.provisionedData.amData
subscriptionData.provisionedData.smData
subscriptionData.provisionedData.smfSelectionSubscriptionData
urilist
> db.subscriptionData.provisionedData.amData.find()
{ "_id" : ObjectId("613b76748e1b2adeb79ecf7b"), "gpsis" : [ "msisdn-0900000000" ], "subscribedUeAmbr" : { "uplink" : "1 Gbps", "downlink" : "2 Gbps" }, "nssai" : { "defaultSingleNssais" : [ { "sst" : 1, "sd" : "010203" }, { "sst" : 1, "sd" : "112233" } ] }, "ueId" : "imsi-440200000000003", "servingPlmnId" : "44020" }
{ "_id" : ObjectId("613ca8532195f9a233697ac5"), "gpsis" : [ "msisdn-0900000000" ], "subscribedUeAmbr" : { "uplink" : "1 Gbps", "downlink" : "2 Gbps" }, "nssai" : { "defaultSingleNssais" : [ { "sd" : "010203", "sst" : 1 }, { "sst" : 1, "sd" : "112233" } ] }, "ueId" : "imsi-440200000000004", "servingPlmnId" : "44020" }

db.subscriptionData.provisionedData.amData.find()で見てみると先ほどwebconsoleで登録したimsi-440200000000003が入っている事が分かります。

5. Deregistationしてみる

UERANSIMのCLIから電源OFFのオプションでDeregistratonしてみます。
これでネットワークからこのUEはいなくなった事になります。
(ちなみに電源OFF以外のオプションはうまく動作しませんでした。なんでだろ。。)

q14537@ueransim:~/UERANSIM/build$ ./nr-cli imsi-440200000000003
--------------------------------------------------------------------------------------------
$ deregister switch-off
De-registration procedure triggered. UE device will be switched off.
--------------------------------------------------------------------------------------------

UERANSIMのログでも確認できます。

[2021-09-11 13:58:26.000] [nas] [debug] De-registration required due to [SWITCH-OFF]
[2021-09-11 13:58:26.011] [nas] [debug] Starting de-registration procedure due to [SWITCH-OFF]
[2021-09-11 13:58:26.011] [nas] [debug] Performing local release of PDU session[1]
[2021-09-11 13:58:26.012] [nas] [info] UE switches to state [MM-DEREGISTER-INITIATED]
[2021-09-11 13:58:26.017] [rrc] [debug] RRC Release received
[2021-09-11 13:58:26.017] [nas] [info] UE switches to state [CM-IDLE]
[2021-09-11 13:58:26.526] [app] [info] UE device is switching off

Wiresharkでも見てみます。Deregistration Requestが送られています。

image.png

6. 最後に

教養としての5GCの連載は今回で終わりです。あまり5GCならではの機能、例えばネットワークスライシング、ユニークなNFであるNEF(free5gcでは未実装)等の説明はしませんでしたが、UERANSIM+free5gcのインテグをする事でかなり遊べる物だとは感じて頂けたかなと思います。UPFもMECの為に多段構成に出来たりするみたいので挑戦しても良いかもです。

オープンソース物でここまで色々出来るとは正直思っていなかったので思わず記事にしてみました。まだまだ動作に不安定な部分がありますが、PoCや学習目的で気軽に使うには十分なのではと思います。実際の5GCは当然5-6000万人の加入者を支えないといけないので、スケールも違うし、事業者が商用運用していく上での耐障害性や統計データなどのいわゆるFCAPS機能は実装されていないので、商用利用には難しいかな思います。

しかしながらオープンソースなので自分でもっと色々機能を追加してみる事も簡単にできるので是非NEFあたりを実装してみては如何でしょうか。

7. 参考にしたサイト

4
7
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
7