free5GC 5GCとUERANSIM UE/RANでgNodeBの最寄りのUPFを選択する設定

本記事は、free5GCとUERANSIMを使用して、UEが接続したgNodeBの最寄りのUPFを選択する場合の簡単な設定について説明します。これにより、UEからのトラフィックを最寄りの基地局のDNにルーティングしてMECを実現する際の設定のヒントになることを期待しています。
なお、5GCのコア網に登場する各NF(Network Function)の役割やインターフェースについて概ね知っていることを期待して書いており、これらの説明は省略します。

---

## 目次

- [free5GC 5GCのシミュレーション携帯網の概要](#free5gc-5gcのシミュレーション携帯網の概要)
- [free5GC 5GCとUERANSIM UE/RANの設定ファイルの変更点](#free5gc-5gcとueransim-ueranの設定ファイルの変更点)
    - [free5GC 5GC C-Planeの設定ファイルの変更点](#free5gc-5gc-c-planeの設定ファイルの変更点)
    - [free5GC 5GC U-Plane1の設定ファイルの変更点](#free5gc-5gc-u-plane1の設定ファイルの変更点)
    - [free5GC 5GC U-Plane2の設定ファイルの変更点](#free5gc-5gc-u-plane2の設定ファイルの変更点)
    - [UERANSIM UE/RANの設定ファイルの変更点](#ueransim-ueranの設定ファイルの変更点)
        - [RAN(gNodeB1)の設定ファイルの変更点](#rangnodeb1の設定ファイルの変更点)
        - [RAN(gNodeB2)の設定ファイルの変更点](#rangnodeb2の設定ファイルの変更点)
        - [Loc1のUE(IMSI-001010000000000)の設定ファイルの変更点](#loc1のueimsi-001010000000000の設定ファイルの変更点)
        - [Loc2のUE(IMSI-001010000000000)の設定ファイルの変更点](#loc2のueimsi-001010000000000の設定ファイルの変更点)
- [free5GC 5GCとUERANSIM UE/RANのネットワーク設定](#free5gc-5gcとueransim-ueranのネットワーク設定)
    - [free5GC 5GC C-Planeのネットワーク設定](#free5gc-5gc-c-planeのネットワーク設定)
    - [free5GC 5GC U-Plane1のネットワーク設定](#free5gc-5gc-u-plane1のネットワーク設定)
    - [free5GC 5GC U-Plane2のネットワーク設定](#free5gc-5gc-u-plane2のネットワーク設定)
- [free5GCとUERANSIMのビルド](#free5gcとueransimのビルド)
- [free5GC 5GCとUERANSIM UE/RANを実行](#free5gc-5gcとueransim-ueranを実行)
    - [free5GC 5GC U-Plane1とU-Plane2を実行](#free5gc-5gc-u-plane1とu-plane2を実行)
    - [free5GC 5GC C-Planeを実行](#free5gc-5gc-c-planeを実行)
    - [UERANSIM(gNodeBs)を実行](#ueransimgnodebsを実行)
        - [Loc1にあるTAC=1のgNodeB1を起動](#loc1にあるtac1のgnodeb1を起動)
        - [Loc2にあるTAC=1のgNodeB2を起動](#loc2にあるtac2のgnodeb2を起動)
    - [UERANSIM(Loc1のUE)を実行](#ueransimloc1のueを実行)
        - [Loc1のgNodeB1にUEを接続](#loc1のgnodeb1にueを接続)
        - [Loc1のDN=10.60.0.0/16を経由してgoogle.comにpingする](#loc1のdn10600016を経由してgooglecomにpingする)
    - [UERANSIM(Loc2のUE)を実行](#ueransimloc2のueを実行)
        - [Loc2のgNodeB2にUEを接続](#loc2のgnodeb2にueを接続)
        - [Loc2のDN=10.61.0.0/16を経由してgoogle.comにpingする](#loc2のdn10610016を経由してgooglecomにpingする)
- [最後に](#最後に)
- [主な変更履歴](#主な変更履歴)

---

## free5GC 5GCのシミュレーション携帯網の概要

このシミュレーション環境は以下の条件を満たす最小構成になります。

- gNodeBとUPFのペアは同じロケーションに存在します。
- gNodeBに接続したUEは、同じロケーションにあるUPFによって管理されているDNに接続します。

**この例では、TACはgNodeBをAMFに接続するために照合され、AMFは`preferred target NF location`をパラメータの一つに用いて、SMFを検索します。**

構築したシミュレーション環境は以下の通りです。
<img width="800" alt="network-overview.png" src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/457466/437e3d23-4e0d-1949-f72d-30cc4ee792d4.png">

5GCとUE/RANに使用しているOSSは以下の通りです。

- 5GC - free5GC v3.2.1 - https://github.com/free5gc/free5gc
- UE / RAN - UERANSIM v3.2.6 - https://github.com/aligungr/UERANSIM

各VMは以下の通りです。

| VM# | SW & Role | IP address | OS | Memory (Min) | HDD (Min) |
| --- | --- | --- | --- | --- | --- |
| VM1 | free5GC  5GC C-Plane | 192.168.0.141/24 <br> 192.168.0.142/24 <br> 192.168.0.143/24 | Ubuntu 20.04 | 2GB | 20GB |
| VM2 | free5GC  5GC U-Plane1  | 192.168.0.144/24 | Ubuntu 20.04 | 1GB | 20GB |
| VM3 | free5GC  5GC U-Plane2  | 192.168.0.145/24 | Ubuntu 20.04 | 1GB | 20GB |
| VM4 | UERANSIM RAN (gNodeB1) | 192.168.0.131/24 | Ubuntu 20.04 | 1GB | 10GB |
| VM5 | UERANSIM RAN (gNodeB2) | 192.168.0.132/24 | Ubuntu 20.04 | 1GB | 10GB |
| VM6 | UERANSIM UE | 192.168.0.133/24 | Ubuntu 20.04 | 1GB | 10GB |

AMFとSMFのIPアドレスは以下の通りです。

| NF | IP address | IP address on SBI | Supported TACs | preferred target NF location |
| --- | --- | --- | --- | --- |
| AMF1 | 192.168.0.142 | 127.0.0.18 | 1 | loc1 |
| SMF1 | 192.168.0.142 | 127.0.0.2 | -- | loc1 |
| PCF1 | -- | 127.0.0.7 | -- | loc1 |
| AMF2 | 192.168.0.143 | 127.0.0.28 | 2 | loc2 |
| SMF2 | 192.168.0.143 | 127.0.0.12 | -- | loc2 |
| PCF2 | -- | 127.0.0.17 | -- | loc2 |

AMFのGUAMIは以下の通りです。

| AMF | MCC | MNC | AMF ID |
| --- | --- | --- | --- |
| AMF1 | 001 | 01 | cafe00 |
| AMF2 | 001 | 01 | cafe01 |

gNodeBの情報は以下の通りです。(その他の項目はデフォルト値)

| gNodeB# | Location# | TAC# | IP address |
| --- | --- | --- | --- |
| gNodeB1 | Loc1 | 1 | 192.168.0.131 |
| gNodeB2 | Loc2 | 2 | 192.168.0.132 |

加入者情報は以下の通りです。(その他の項目はデフォルト値)
注意。UERANSIMのUEの設定に合わせて、OPあるいはOPcを選択してください。

| UE | IMSI | DNN | OP/OPc | gNodeB# |
| --- | --- | --- | --- | --- |
| UE | 001010000000000 | internet | OPc | gNodeB1 in Loc1 <br> gNodeB2 in Loc2|

これらの情報の登録には、free5GCが提供するWebUIを使用しました。なお、3GPP認証とキー生成機能(MILENAGE)の試験データとして、[3GPP TS 35.208](https://www.3gpp.org/DynaReport/35208.htm) "4.3 Test Sets"が公開されています。

各DNは以下の通りです。

| DN | Location# |  TUNnel interface of DN | DNN | TUNnel interface of UE | U-Plane# |
| --- | --- | --- | --- | --- | --- |
| 10.60.0.0/16 | Loc1 | upfgtp | internet | uesimtun0 | U-Plane1 |
| 10.61.0.0/16 | Loc2 | upfgtp | internet | uesimtun0 | U-Plane2 |

## free5GC 5GCとUERANSIM UE/RANの設定ファイルの変更点

free5GCとUERANSIMのビルド方法は以下を参照して下さい。

- free5GC v3.2.1 - https://github.com/free5gc/free5gc/wiki/Installation
- UERANSIM v3.2.6 - https://github.com/aligungr/UERANSIM/wiki/Installation

### free5GC 5GC C-Planeの設定ファイルの変更点

- `free5gc/config/amfcfg1.yaml`

```diff
--- amfcfg.yaml.orig    2022-04-01 20:25:53.176313323 +0900
+++ amfcfg1.yaml        2022-04-03 22:17:29.059691038 +0900
@@ -5,7 +5,7 @@
 configuration:
   amfName: AMF # the name of this AMF
   ngapIpList:  # the IP list of N2 interfaces on this AMF
-    - 127.0.0.18
+    - 192.168.0.142
   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
@@ -23,23 +23,21 @@
   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: 001 # Mobile Country Code (3 digits string, digit: 0~9)
+        mnc: 01 # 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: 001 # Mobile Country Code (3 digits string, digit: 0~9)
+        mnc: 01 # 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: 001 # Mobile Country Code (3 digits string, digit: 0~9)
+        mnc: 01 # 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)
-        - sst: 1 # Slice/Service Type (uinteger, range: 0~255)
-          sd: 112233 # Slice Differentiator (3 bytes hex string, range: 000000~FFFFFF)
   supportDnnList:  # the DNN (Data Network Name) list supported by this AMF
     - internet
   nrfUri: http://127.0.0.10:8000 # a valid URI of NRF
@@ -53,7 +51,7 @@
   networkName:  # the name of this core network
     full: free5GC
     short: free
-  locality: area1 # Name of the location where a set of AMF, SMF and UPFs are located
+  locality: loc1 # Name of the location where a set of AMF, SMF and UPFs are located
   networkFeatureSupport5GS: # 5gs Network Feature Support IE, refer to TS 24.501
     enable: true # append this IE in Registration accept or not
     length: 1 # IE content length (uinteger, range: 1~3)
```

- `free5gc/config/amfcfg2.yaml`

```diff
--- amfcfg.yaml.orig    2022-04-01 20:25:54.000000000 +0900
+++ amfcfg2.yaml        2022-08-11 16:45:08.075088545 +0900
@@ -5,11 +5,11 @@
 configuration:
   amfName: AMF # the name of this AMF
   ngapIpList:  # the IP list of N2 interfaces on this AMF
-    - 127.0.0.18
+    - 192.168.0.143
   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
-    bindingIPv4: 127.0.0.18  # IP used to bind the service
+    registerIPv4: 127.0.0.28 # IP used to register to NRF
+    bindingIPv4: 127.0.0.28  # IP used to bind the service
     port: 8000 # port used to bind the service
     tls: # the local path of TLS key
       pem: config/TLS/amf.pem # AMF TLS Certificate
@@ -23,23 +23,21 @@
   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)
-      amfId: cafe00 # AMF identifier (3 bytes hex string, range: 000000~FFFFFF)
+        mcc: 001 # Mobile Country Code (3 digits string, digit: 0~9)
+        mnc: 01 # Mobile Network Code (2 or 3 digits string, digit: 0~9)
+      amfId: cafe01 # 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)
-      tac: 1 # Tracking Area Code (uinteger, range: 0~16777215)
+        mcc: 001 # Mobile Country Code (3 digits string, digit: 0~9)
+        mnc: 01 # Mobile Network Code (2 or 3 digits string, digit: 0~9)
+      tac: 2 # 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: 001 # Mobile Country Code (3 digits string, digit: 0~9)
+        mnc: 01 # 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)
-        - sst: 1 # Slice/Service Type (uinteger, range: 0~255)
-          sd: 112233 # Slice Differentiator (3 bytes hex string, range: 000000~FFFFFF)
   supportDnnList:  # the DNN (Data Network Name) list supported by this AMF
     - internet
   nrfUri: http://127.0.0.10:8000 # a valid URI of NRF
@@ -53,7 +51,7 @@
   networkName:  # the name of this core network
     full: free5GC
     short: free
-  locality: area1 # Name of the location where a set of AMF, SMF and UPFs are located
+  locality: loc2 # Name of the location where a set of AMF, SMF and UPFs are located
   networkFeatureSupport5GS: # 5gs Network Feature Support IE, refer to TS 24.501
     enable: true # append this IE in Registration accept or not
     length: 1 # IE content length (uinteger, range: 1~3)
```

- `free5gc/config/smfcfg1.yaml`

```diff
--- smfcfg.yaml.orig    2022-04-01 20:25:53.177313344 +0900
+++ smfcfg1.yaml        2022-04-03 22:13:41.582022190 +0900
@@ -32,18 +32,18 @@
           dns: # the IP address of DNS
             ipv4: 8.8.8.8
   plmnList: # the list of PLMN IDs that this SMF belongs to (optional, remove this key when unnecessary)
-    - mcc: "208" # Mobile Country Code (3 digits string, digit: 0~9)
-      mnc: "93" # Mobile Network Code (2 or 3 digits string, digit: 0~9)
-  locality: area1 # Name of the location where a set of AMF, SMF and UPFs are located
+    - mcc: "001" # Mobile Country Code (3 digits string, digit: 0~9)
+      mnc: "01" # Mobile Network Code (2 or 3 digits string, digit: 0~9)
+  locality: loc1 # Name of the location where a set of AMF, SMF and UPFs are located
   pfcp: # the IP address of N4 interface on this SMF (PFCP)
-    addr: 127.0.0.1
+    addr: 192.168.0.142
   userplaneInformation: # list of userplane information
     upNodes: # information of userplane node (AN or UPF)
       gNB1: # the name of the node
         type: AN # the type of the node (AN or UPF)
       UPF:  # the name of the node
         type: UPF # the type of the node (AN or UPF)
-        nodeID: 127.0.0.8 # the IP/FQDN of N4 interface on this UPF (PFCP)
+        nodeID: 192.168.0.144 # the IP/FQDN of N4 interface on this UPF (PFCP)
         sNssaiUpfInfos: # S-NSSAI information list for this UPF
           - sNssai: # S-NSSAI (Single Network Slice Selection Assistance Information)
               sst: 1 # Slice/Service Type (uinteger, range: 0~255)
@@ -52,22 +52,16 @@
               - dnn: internet
                 pools:
                   - cidr: 10.60.0.0/16
-          - sNssai: # S-NSSAI (Single Network Slice Selection Assistance Information)
-              sst: 1 # Slice/Service Type (uinteger, range: 0~255)
-              sd: 112233 # Slice Differentiator (3 bytes hex string, range: 000000~FFFFFF)
-            dnnUpfInfoList: # DNN information list for this S-NSSAI
-              - dnn: internet
-                pools:
-                  - cidr: 10.61.0.0/16
         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.0.144
             networkInstance: internet # Data Network Name (DNN)
     links: # the topology graph of userplane, A and B represent the two nodes of each link
       - A: gNB1
         B: UPF
   nrfUri: http://127.0.0.10:8000 # a valid URI of NRF
+  ulcl: false
 
 # the kind of log output
 # debugLevel: how detailed to output, value: trace, debug, info, warn, error, fatal, panic
```

- `free5gc/config/smfcfg2.yaml`

```diff
--- smfcfg.yaml.orig    2022-04-01 20:25:53.177313344 +0900
+++ smfcfg2.yaml        2022-04-03 22:16:16.540556548 +0900
@@ -6,8 +6,8 @@
   smfName: SMF # the name of this SMF
   sbi: # Service-based interface information
     scheme: http # the protocol for sbi (http or https)
-    registerIPv4: 127.0.0.2 # IP used to register to NRF
-    bindingIPv4: 127.0.0.2  # IP used to bind the service
+    registerIPv4: 127.0.0.12 # IP used to register to NRF
+    bindingIPv4: 127.0.0.12  # IP used to bind the service
     port: 8000 # Port used to bind the service
     tls: # the local path of TLS key
       key: config/TLS/smf.key # SMF TLS Certificate
@@ -32,18 +32,18 @@
           dns: # the IP address of DNS
             ipv4: 8.8.8.8
   plmnList: # the list of PLMN IDs that this SMF belongs to (optional, remove this key when unnecessary)
-    - mcc: "208" # Mobile Country Code (3 digits string, digit: 0~9)
-      mnc: "93" # Mobile Network Code (2 or 3 digits string, digit: 0~9)
-  locality: area1 # Name of the location where a set of AMF, SMF and UPFs are located
+    - mcc: "001" # Mobile Country Code (3 digits string, digit: 0~9)
+      mnc: "01" # Mobile Network Code (2 or 3 digits string, digit: 0~9)
+  locality: loc2 # Name of the location where a set of AMF, SMF and UPFs are located
   pfcp: # the IP address of N4 interface on this SMF (PFCP)
-    addr: 127.0.0.1
+    addr: 192.168.0.143
   userplaneInformation: # list of userplane information
     upNodes: # information of userplane node (AN or UPF)
       gNB1: # the name of the node
         type: AN # the type of the node (AN or UPF)
       UPF:  # the name of the node
         type: UPF # the type of the node (AN or UPF)
-        nodeID: 127.0.0.8 # the IP/FQDN of N4 interface on this UPF (PFCP)
+        nodeID: 192.168.0.145 # the IP/FQDN of N4 interface on this UPF (PFCP)
         sNssaiUpfInfos: # S-NSSAI information list for this UPF
           - sNssai: # S-NSSAI (Single Network Slice Selection Assistance Information)
               sst: 1 # Slice/Service Type (uinteger, range: 0~255)
@@ -51,23 +51,17 @@
             dnnUpfInfoList: # DNN information list for this S-NSSAI
               - dnn: internet
                 pools:
-                  - cidr: 10.60.0.0/16
-          - sNssai: # S-NSSAI (Single Network Slice Selection Assistance Information)
-              sst: 1 # Slice/Service Type (uinteger, range: 0~255)
-              sd: 112233 # Slice Differentiator (3 bytes hex string, range: 000000~FFFFFF)
-            dnnUpfInfoList: # DNN information list for this S-NSSAI
-              - dnn: internet
-                pools:
                   - cidr: 10.61.0.0/16
         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.0.145
             networkInstance: internet # Data Network Name (DNN)
     links: # the topology graph of userplane, A and B represent the two nodes of each link
       - A: gNB1
         B: UPF
   nrfUri: http://127.0.0.10:8000 # a valid URI of NRF
+  ulcl: false
 
 # the kind of log output
 # debugLevel: how detailed to output, value: trace, debug, info, warn, error, fatal, panic
```

- `free5gc/config/pcfcfg1.yaml`

```diff
--- pcfcfg.yaml.orig    2022-04-03 19:31:43.524558018 +0900
+++ pcfcfg1.yaml        2022-04-03 22:20:00.252348433 +0900
@@ -27,7 +27,7 @@
   mongodb:       # the mongodb connected by this PCF
     name: free5gc                  # name of the mongodb
     url: mongodb://localhost:27017 # a valid URL of the mongodb
-  locality: area1 # Name of the location where a set of AMF, SMF, PCF and UPFs are located
+  locality: loc1 # Name of the location where a set of AMF, SMF, PCF and UPFs are located
 
 # the kind of log output
 # debugLevel: how detailed to output, value: trace, debug, info, warn, error, fatal, panic
```

- `free5gc/config/pcfcfg2.yaml`

```diff
--- pcfcfg.yaml.orig    2022-04-03 19:31:43.524558018 +0900
+++ pcfcfg2.yaml        2022-04-03 22:20:33.389124657 +0900
@@ -6,8 +6,8 @@
   pcfName: PCF # the name of this PCF
   sbi: # Service-based interface information
     scheme: http # the protocol for sbi (http or https)
-    registerIPv4: 127.0.0.7 # IP used to register to NRF
-    bindingIPv4: 127.0.0.7  # IP used to bind the service
+    registerIPv4: 127.0.0.17 # IP used to register to NRF
+    bindingIPv4: 127.0.0.17  # IP used to bind the service
     port: 8000              # port used to bind the service
     tls: # the local path of TLS key
       pem: config/TLS/pcf.pem # PCF TLS Certificate
@@ -27,7 +27,7 @@
   mongodb:       # the mongodb connected by this PCF
     name: free5gc                  # name of the mongodb
     url: mongodb://localhost:27017 # a valid URL of the mongodb
-  locality: area1 # Name of the location where a set of AMF, SMF, PCF and UPFs are located
+  locality: loc2 # Name of the location where a set of AMF, SMF, PCF and UPFs are located
 
 # the kind of log output
 # debugLevel: how detailed to output, value: trace, debug, info, warn, error, fatal, panic
```

- `free5gc/config/ausfcfg.yaml`

```diff
--- ausfcfg.yaml.orig   2022-04-01 20:25:53.176313323 +0900
+++ ausfcfg.yaml        2022-04-03 21:56:52.574055040 +0900
@@ -15,8 +15,8 @@
     - nausf-auth # Nausf_UEAuthentication service
   nrfUri: http://127.0.0.10:8000 # a valid URI of NRF
   plmnSupportList: # the PLMNs (Public Land Mobile Network) list supported by this AUSF
-    - 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: 001 # Mobile Country Code (3 digits string, digit: 0~9)
+      mnc: 01  # Mobile Network Code (2 or 3 digits string, digit: 0~9)
     - mcc: 123 # Mobile Country Code (3 digits string, digit: 0~9)
       mnc: 45  # Mobile Network Code (2 or 3 digits string, digit: 0~9)
   groupId: ausfGroup001 # ID for the group of the AUSF
```

- `free5gc/config/nrfcfg.yaml`

```diff
--- nrfcfg.yaml.orig    2022-04-01 20:25:53.177313344 +0900
+++ nrfcfg.yaml 2022-04-03 21:57:18.376344873 +0900
@@ -14,8 +14,8 @@
       pem: config/TLS/nrf.pem # NRF TLS Certificate
       key: config/TLS/nrf.key # NRF TLS Private key
   DefaultPlmnId:
-    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: 001 # Mobile Country Code (3 digits string, digit: 0~9)
+    mnc: 01 # Mobile Network Code (2 or 3 digits string, digit: 0~9)
   serviceNameList: # the SBI services provided by this NRF, refer to TS 29.510
     - nnrf-nfm # Nnrf_NFManagement service
     - nnrf-disc # Nnrf_NFDiscovery service
```

- `free5gc/config/nssfcfg.yaml`

```diff
--- nssfcfg.yaml.orig   2022-04-01 20:25:53.177313344 +0900
+++ nssfcfg.yaml        2022-04-03 21:58:01.240821301 +0900
@@ -17,12 +17,12 @@
     - nnssf-nssaiavailability # Nnssf_NSSAIAvailability service
   nrfUri: http://127.0.0.10:8000 # a valid URI of NRF
   supportedPlmnList: # the PLMNs (Public land mobile network) list supported by this NSSF
-    - 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: 001 # Mobile Country Code (3 digits string, digit: 0~9)
+      mnc: 01 # Mobile Network Code (2 or 3 digits string, digit: 0~9)
   supportedNssaiInPlmnList: # Supported S-NSSAI List for each PLMN
     - 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: 001 # Mobile Country Code (3 digits string, digit: 0~9)
+        mnc: 01 # Mobile Network Code (2 or 3 digits string, digit: 0~9)
       supportedSnssaiList: # Supported S-NSSAIs of the PLMN
         - sst: 1 # Slice/Service Type (uinteger, range: 0~255)
           sd: 010203 # Slice Differentiator (3 bytes hex string, range: 000000~FFFFFF)
```

### free5GC 5GC U-Plane1の設定ファイルの変更点

- `free5gc/config/upfcfg.yaml`

```diff
--- upfcfg.yaml.orig    2022-08-11 14:42:32.545805826 +0900
+++ upfcfg.yaml 2022-08-11 16:52:48.563998874 +0900
@@ -3,8 +3,8 @@
 
 # The listen IP and nodeID of the N4 interface on this UPF (Can't set to 0.0.0.0)
 pfcp:
-  addr: 127.0.0.8   # IP addr for listening
-  nodeID: 127.0.0.8 # External IP or FQDN can be reached
+  addr: 192.168.0.144   # IP addr for listening
+  nodeID: 192.168.0.144 # External IP or FQDN can be reached
   retransTimeout: 1s # retransmission timeout
   maxRetrans: 3 # the max number of retransmission
 
@@ -13,7 +13,7 @@
   # The IP list of the N3/N9 interfaces on this UPF
   # If there are multiple connection, set addr to 0.0.0.0 or list all the addresses
   ifList:
-    - addr: 127.0.0.8
+    - addr: 192.168.0.144
       type: N3
       # name: upf.5gc.nctu.me
       # ifname: gtpif
@@ -21,7 +21,7 @@
 # The DNN list supported by UPF
 dnnList:
   - dnn: internet # Data Network Name
-    cidr: 10.60.0.0/24 # Classless Inter-Domain Routing for assigned IPv4 pool of UE
+    cidr: 10.60.0.0/16 # Classless Inter-Domain Routing for assigned IPv4 pool of UE
     # natifname: eth0
 
 logger: # log output setting
```

### free5GC 5GC U-Plane2の設定ファイルの変更点

- `free5gc/config/upfcfg.yaml`

```diff
--- upfcfg.yaml.orig    2022-08-11 14:44:10.418739050 +0900
+++ upfcfg.yaml 2022-08-11 16:56:14.233871256 +0900
@@ -3,8 +3,8 @@
 
 # The listen IP and nodeID of the N4 interface on this UPF (Can't set to 0.0.0.0)
 pfcp:
-  addr: 127.0.0.8   # IP addr for listening
-  nodeID: 127.0.0.8 # External IP or FQDN can be reached
+  addr: 192.168.0.145   # IP addr for listening
+  nodeID: 192.168.0.145 # External IP or FQDN can be reached
   retransTimeout: 1s # retransmission timeout
   maxRetrans: 3 # the max number of retransmission
 
@@ -13,7 +13,7 @@
   # The IP list of the N3/N9 interfaces on this UPF
   # If there are multiple connection, set addr to 0.0.0.0 or list all the addresses
   ifList:
-    - addr: 127.0.0.8
+    - addr: 192.168.0.145
       type: N3
       # name: upf.5gc.nctu.me
       # ifname: gtpif
@@ -21,7 +21,7 @@
 # The DNN list supported by UPF
 dnnList:
   - dnn: internet # Data Network Name
-    cidr: 10.60.0.0/24 # Classless Inter-Domain Routing for assigned IPv4 pool of UE
+    cidr: 10.61.0.0/16 # Classless Inter-Domain Routing for assigned IPv4 pool of UE
     # natifname: eth0
 
 logger: # log output setting
```

### UERANSIM UE/RANの設定ファイルの変更点

#### RAN(gNodeB1)の設定ファイルの変更点

- `UERANSIM/config/free5gc-gnb.yaml`

```diff
--- free5gc-gnb.yaml.orig       2021-02-11 11:03:28.000000000 +0000
+++ free5gc-gnb.yaml    2021-08-10 00:28:30.000000000 +0000
@@ -1,17 +1,17 @@
-mcc: '208'          # Mobile Country Code value
-mnc: '93'           # Mobile Network Code value (2 or 3 digits)
+mcc: '001'          # Mobile Country Code value
+mnc: '01'           # 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)
+linkIp: 192.168.0.131   # gNB's local IP address for Radio Link Simulation (Usually same with local IP)
+ngapIp: 192.168.0.131   # gNB's local IP address for N2 Interface (Usually same with local IP)
+gtpIp: 192.168.0.131    # gNB's local IP address for N3 Interface (Usually same with local IP)
 
 # List of AMF address information
 amfConfigs:
-  - address: 127.0.0.1
+  - address: 192.168.0.142
     port: 38412
 
 # List of supported S-NSSAIs by this gNB
```

#### RAN(gNodeB2)の設定ファイルの変更点

- `UERANSIM/config/free5gc-gnb.yaml`

```diff
--- free5gc-gnb.yaml.orig       2021-02-11 11:03:28.000000000 +0000
+++ free5gc-gnb.yaml    2021-08-10 00:30:54.000000000 +0000
@@ -1,17 +1,17 @@
-mcc: '208'          # Mobile Country Code value
-mnc: '93'           # Mobile Network Code value (2 or 3 digits)
+mcc: '001'          # Mobile Country Code value
+mnc: '01'           # 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
+tac: 2              # 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)
+linkIp: 192.168.0.132   # gNB's local IP address for Radio Link Simulation (Usually same with local IP)
+ngapIp: 192.168.0.132   # gNB's local IP address for N2 Interface (Usually same with local IP)
+gtpIp: 192.168.0.132    # gNB's local IP address for N3 Interface (Usually same with local IP)
 
 # List of AMF address information
 amfConfigs:
-  - address: 127.0.0.1
+  - address: 192.168.0.143
     port: 38412
 
 # List of supported S-NSSAIs by this gNB
```

#### Loc1のUE(IMSI-001010000000000)の設定ファイルの変更点

- `UERANSIM/config/free5gc-ue-loc1.yaml`

```diff
--- free5gc-ue.yaml.orig        2021-09-18 21:11:52.000000000 +0900
+++ free5gc-ue-loc1.yaml        2022-04-04 19:33:36.993974680 +0900
@@ -1,9 +1,9 @@
 # IMSI number of the UE. IMSI = [MCC|MNC|MSISDN] (In total 15 digits)
-supi: 'imsi-208930000000003'
+supi: 'imsi-001010000000000'
 # Mobile Country Code value of HPLMN
-mcc: '208'
+mcc: '001'
 # Mobile Network Code value of HPLMN (2 or 3 digits)
-mnc: '93'
+mnc: '01'
 
 # Permanent subscription key
 key: '8baf473f2f8fd09487cccbd7097c6862'
@@ -20,7 +20,7 @@
 
 # List of gNB IP addresses for Radio Link Simulation
 gnbSearchList:
-  - 127.0.0.1
+  - 192.168.0.131
 
 # UAC Access Identities Configuration
 uacAic:
```

#### Loc2のUE(IMSI-001010000000000)の設定ファイルの変更点

- `UERANSIM/config/free5gc-ue-loc2.yaml`

```diff
--- free5gc-ue.yaml.orig        2021-09-18 21:11:52.000000000 +0900
+++ free5gc-ue-loc2.yaml        2022-04-04 19:34:35.676208193 +0900
@@ -1,9 +1,9 @@
 # IMSI number of the UE. IMSI = [MCC|MNC|MSISDN] (In total 15 digits)
-supi: 'imsi-208930000000003'
+supi: 'imsi-001010000000000'
 # Mobile Country Code value of HPLMN
-mcc: '208'
+mcc: '001'
 # Mobile Network Code value of HPLMN (2 or 3 digits)
-mnc: '93'
+mnc: '01'
 
 # Permanent subscription key
 key: '8baf473f2f8fd09487cccbd7097c6862'
@@ -20,7 +20,7 @@
 
 # List of gNB IP addresses for Radio Link Simulation
 gnbSearchList:
-  - 127.0.0.1
+  - 192.168.0.132
 
 # UAC Access Identities Configuration
 uacAic:
```

## free5GC 5GCとUERANSIM UE/RANのネットワーク設定

### free5GC 5GC C-Planeのネットワーク設定

(AMF1,SMF1)と(AMF2,SMF2)に以下の通りIPアドレスを追加します。

```
ip addr add 192.168.0.142/24 dev enp0s8
ip addr add 192.168.0.143/24 dev enp0s8
```

注意。本記事のVirtualBoxの環境では、`enp0s8`は`192.168.0.0/24`のネットワークインターフェースです。環境に応じて変更して下さい。

### free5GC 5GC U-Plane1のネットワーク設定

最初に、`/etc/sysctl.conf`ファイルの以下の行のコメントを外し、OSに反映します。

```
net.ipv4.ip_forward=1
```

```
# sysctl -p
```

次に、NAPTを設定します。

```
# iptables -t nat -A POSTROUTING -s 10.60.0.0/16 ! -o upfgtp -j MASQUERADE
```

### free5GC 5GC U-Plane2のネットワーク設定

最初に、`/etc/sysctl.conf`ファイルの以下の行のコメントを外し、OSに反映します。

```
net.ipv4.ip_forward=1
```

```
# sysctl -p
```

次に、NAPTを設定します。

```
# iptables -t nat -A POSTROUTING -s 10.61.0.0/16 ! -o upfgtp -j MASQUERADE
```

## free5GCとUERANSIMのビルド

free5GCとUERANSIMのビルド方法は以下を参照して下さい。

- free5GC v3.2.1 - https://github.com/free5gc/free5gc/wiki/Installation
- UERANSIM v3.2.6 - https://github.com/aligungr/UERANSIM/wiki/Installation

注意。free5GC 5GC C-PlaneマシンにMongoDBをインストールして下さい。なお、MongoDBのデータベースを簡単に確認するには、[MongoDB Compass](https://www.mongodb.com/products/compass)が便利です。

```
# apt update
# apt install mongodb
# systemctl start mongodb
# systemctl enable mongodb
```

なお、free5GC 5GC U-PlaneマシンにはMongoDBをインストールする必要はありません。

注意。最新のコミットされたバージョンを使用する場合は、ビルドする前に以下のスクリプトを実行して、全てのNFとWebコンソールを最新のmainブランチにcheckoutして下さい。

```bash
#!/usr/bin/env bash

NF_LIST="nrf amf smf udr pcf udm nssf ausf upf n3iwf"

for NF in ${NF_LIST}; do
    cd NFs/${NF}
    git checkout main
    cd ../..
done

cd webconsole
git checkout main

cd ..
git checkout main
```

## free5GC 5GCとUERANSIM UE/RANを実行

最初に5GCを起動し、次にUERANSIM(UEとRANのシミュレータ)を起動します。

### free5GC 5GC U-Plane1とU-Plane2を実行

最初に、free5GC 5GC U-Planeを実行して下さい。理由は[こちら](https://github.com/free5gc/free5gc/issues/170#issuecomment-773214169)です。

- free5GC 5GC U-Plane1

```
# cd free5gc/NFs/upf/build
# bin/free5gc-upfd
```

- free5GC 5GC U-Plane2

```
# cd free5gc/NFs/upf/build
# bin/free5gc-upfd
```

また、各U-PlaneのVMに追加で端末を開き、`tcpdump`を実行します。

- VM2 (U-Plane1)で`tcpdump`を実行

```
# tcpdump -i upfgtp -n
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on upfgtp, link-type RAW (Raw IP), capture size 262144 bytes
```

- VM3 (U-Plane2)で`tcpdump`を実行

```
# tcpdump -i upfgtp -n
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on upfgtp, link-type RAW (Raw IP), capture size 262144 bytes
```

### free5GC 5GC C-Planeを実行

次に、free5GC 5GC C-Planeを起動します。

- free5GC 5GC C-Plane

次のスクリプトを作成して、実行します。

```bash
#!/usr/bin/env bash

PID_LIST=()

NF_LIST1="amf smf pcf"
NF_LIST2="udr udm nssf ausf"

export GIN_MODE=release

./bin/nrf &
PID_LIST+=($!)
sleep 1

for NF in ${NF_LIST1}; do
    ./bin/${NF} -c config/${NF}cfg1.yaml &
    PID_LIST+=($!)
    sleep 1
    ./bin/${NF} -c config/${NF}cfg2.yaml &
    PID_LIST+=($!)
    sleep 1
done

for NF in ${NF_LIST2}; do
    ./bin/${NF} &
    PID_LIST+=($!)
    sleep 1
done

function terminate()
{
    sudo kill -SIGTERM ${PID_LIST[${#PID_LIST[@]}-2]} ${PID_LIST[${#PID_LIST[@]}-1]}
    sleep 2
}

trap terminate SIGINT
wait ${PID_LIST}
```

### UERANSIM(gNodeBs)を実行

二つのロケーションにある、TAC=1,2の各gNodeBを稼働します。
UERANSIMの使い方は以下を参照して下さい。

- https://github.com/aligungr/UERANSIM/wiki/Usage

#### Loc1にあるTAC=1のgNodeB1を起動

次のようにgNBを起動します。

```
# ./nr-gnb -c ../config/free5gc-gnb.yaml
UERANSIM v3.2.6
[2022-08-11 17:15:23.053] [sctp] [info] Trying to establish SCTP connection... (192.168.0.142:38412)
[2022-08-11 17:15:23.055] [sctp] [info] SCTP connection established (192.168.0.142:38412)
[2022-08-11 17:15:23.056] [sctp] [debug] SCTP association setup ascId[6]
[2022-08-11 17:15:23.056] [ngap] [debug] Sending NG Setup Request
[2022-08-11 17:15:23.058] [ngap] [debug] NG Setup Response received
[2022-08-11 17:15:23.058] [ngap] [info] NG Setup procedure is successful
```

free5GC C-Planeのログは以下の通りです。

```
2022-08-11T17:15:23+09:00 [INFO][AMF][NGAP] [AMF] SCTP Accept from: 192.168.0.131:45635
2022-08-11T17:15:23+09:00 [INFO][AMF][NGAP] Create a new NG connection for: 192.168.0.131:45635
2022-08-11T17:15:23+09:00 [INFO][AMF][NGAP][192.168.0.131:45635] Handle NG Setup request
2022-08-11T17:15:23+09:00 [INFO][AMF][NGAP][192.168.0.131:45635] Send NG-Setup response
```

#### Loc2にあるTAC=2のgNodeB2を起動

次のようにgNBを起動します。

```
# ./nr-gnb -c ../config/free5gc-gnb.yaml
UERANSIM v3.2.6
[2022-08-11 17:16:15.782] [sctp] [info] Trying to establish SCTP connection... (192.168.0.143:38412)
[2022-08-11 17:16:15.785] [sctp] [info] SCTP connection established (192.168.0.143:38412)
[2022-08-11 17:16:15.785] [sctp] [debug] SCTP association setup ascId[4]
[2022-08-11 17:16:15.786] [ngap] [debug] Sending NG Setup Request
[2022-08-11 17:16:15.788] [ngap] [debug] NG Setup Response received
[2022-08-11 17:16:15.788] [ngap] [info] NG Setup procedure is successful
```

free5GC C-Planeのログは以下の通りです。

```
2022-08-11T17:16:15+09:00 [INFO][AMF][NGAP] [AMF] SCTP Accept from: 192.168.0.132:45375
2022-08-11T17:16:15+09:00 [INFO][AMF][NGAP] Create a new NG connection for: 192.168.0.132:45375
2022-08-11T17:16:15+09:00 [INFO][AMF][NGAP][192.168.0.132:45375] Handle NG Setup request
2022-08-11T17:16:15+09:00 [INFO][AMF][NGAP][192.168.0.132:45375] Send NG-Setup response
```

### UERANSIM(Loc1のUE)を実行

Loc1のgNodeB1にUEを接続して、パケットが同じLoc1のU-Plane1のDNを通過することを確認します。

#### Loc1のgNodeB1にUEを接続

```
# ./nr-ue -c ../config/free5gc-ue-loc1.yaml 
UERANSIM v3.2.6
[2022-08-11 17:16:56.819] [nas] [info] UE switches to state [MM-DEREGISTERED/PLMN-SEARCH]
[2022-08-11 17:16:56.820] [rrc] [debug] New signal detected for cell[1], total [1] cells in coverage
[2022-08-11 17:16:56.821] [nas] [info] Selected plmn[001/01]
[2022-08-11 17:16:56.822] [rrc] [info] Selected cell plmn[001/01] tac[1] category[SUITABLE]
[2022-08-11 17:16:56.822] [nas] [info] UE switches to state [MM-DEREGISTERED/PS]
[2022-08-11 17:16:56.822] [nas] [info] UE switches to state [MM-DEREGISTERED/NORMAL-SERVICE]
[2022-08-11 17:16:56.822] [nas] [debug] Initial registration required due to [MM-DEREG-NORMAL-SERVICE]
[2022-08-11 17:16:56.823] [nas] [debug] UAC access attempt is allowed for identity[0], category[MO_sig]
[2022-08-11 17:16:56.823] [nas] [debug] Sending Initial Registration
[2022-08-11 17:16:56.823] [nas] [info] UE switches to state [MM-REGISTER-INITIATED]
[2022-08-11 17:16:56.823] [rrc] [debug] Sending RRC Setup Request
[2022-08-11 17:16:56.824] [rrc] [info] RRC connection established
[2022-08-11 17:16:56.825] [rrc] [info] UE switches to state [RRC-CONNECTED]
[2022-08-11 17:16:56.825] [nas] [info] UE switches to state [CM-CONNECTED]
[2022-08-11 17:16:56.848] [nas] [debug] Authentication Request received
[2022-08-11 17:16:56.860] [nas] [debug] Security Mode Command received
[2022-08-11 17:16:56.860] [nas] [debug] Selected integrity[2] ciphering[0]
[2022-08-11 17:16:56.903] [nas] [debug] Registration accept received
[2022-08-11 17:16:56.904] [nas] [info] UE switches to state [MM-REGISTERED/NORMAL-SERVICE]
[2022-08-11 17:16:56.904] [nas] [debug] Sending Registration Complete
[2022-08-11 17:16:56.904] [nas] [info] Initial Registration is successful
[2022-08-11 17:16:56.904] [nas] [debug] Sending PDU Session Establishment Request
[2022-08-11 17:16:56.905] [nas] [debug] UAC access attempt is allowed for identity[0], category[MO_sig]
[2022-08-11 17:16:57.165] [nas] [debug] PDU Session Establishment Accept received
[2022-08-11 17:16:57.168] [nas] [info] PDU Session establishment is successful PSI[1]
[2022-08-11 17:16:57.190] [app] [info] Connection setup for PDU session[1] is successful, TUN interface[uesimtun0, 10.60.0.1] is up.
```

free5GC C-Planeのログは以下の通りです。

```
2022-08-11T17:16:56+09:00 [INFO][AMF][NGAP][192.168.0.131:45635] Handle Initial UE Message
2022-08-11T17:16:56+09:00 [INFO][LIB][FSM] Handle event[Gmm Message], transition from [Deregistered] to [Deregistered]
2022-08-11T17:16:56+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1] Handle Registration Request
2022-08-11T17:16:56+09:00 [INFO][LIB][FSM] Handle event[Start Authentication], transition from [Deregistered] to [Authentication]
2022-08-11T17:16:56+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1] Authentication procedure
2022-08-11T17:16:56+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:16:56+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?requester-nf-type=AMF&target-nf-type=AUSF |
2022-08-11T17:16:56+09:00 [INFO][AUSF][UeAuthPost] HandleUeAuthPostRequest
2022-08-11T17:16:56+09:00 [INFO][AUSF][UeAuthPost] Serving network authorized
2022-08-11T17:16:56+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:16:56+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?requester-nf-type=AUSF&service-names=nudm-ueau&target-nf-type=UDM |
2022-08-11T17:16:56+09:00 [INFO][UDM][UEAU] Handle GenerateAuthDataRequest
2022-08-11T17:16:56+09:00 [INFO][UDM][Suci] suciPart: [suci 0 001 01 0000 0 0 0000000000]
2022-08-11T17:16:56+09:00 [INFO][UDM][Suci] scheme 0
2022-08-11T17:16:56+09:00 [INFO][UDM][Suci] SUPI type is IMSI
http://127.0.0.10:8000
2022-08-11T17:16:56+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:16:56+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?requester-nf-type=UDM&target-nf-type=UDR |
2022-08-11T17:16:56+09:00 [INFO][UDR][DRepo] Handle QueryAuthSubsData
2022-08-11T17:16:56+09:00 [INFO][UDR][GIN] | 200 |       127.0.0.1 | GET     | /nudr-dr/v1/subscription-data/imsi-001010000000000/authentication-data/authentication-subscription |
2022-08-11T17:16:56+09:00 [ERRO][UDM][UEAU] opStr length is  0
2022-08-11T17:16:56+09:00 [INFO][UDR][DRepo] Handle ModifyAuthentication
2022-08-11T17:16:56+09:00 [INFO][UDR][GIN] | 204 |       127.0.0.1 | PATCH   | /nudr-dr/v1/subscription-data/imsi-001010000000000/authentication-data/authentication-subscription |
2022-08-11T17:16:56+09:00 [INFO][UDM][GIN] | 200 |       127.0.0.1 | POST    | /nudm-ueau/v1/suci-0-001-01-0000-0-0-0000000000/security-information/generate-auth-data |
2022-08-11T17:16:56+09:00 [INFO][AUSF][UeAuthPost] Add SuciSupiPair (suci-0-001-01-0000-0-0-0000000000, imsi-001010000000000) to map.
2022-08-11T17:16:56+09:00 [INFO][AUSF][UeAuthPost] Use 5G AKA auth method
2022-08-11T17:16:56+09:00 [INFO][AUSF][5gAkaAuth] XresStar = 6265363635386332376533306163656162636339613936353264656663303635
2022-08-11T17:16:56+09:00 [INFO][AUSF][GIN] | 201 |       127.0.0.1 | POST    | /nausf-auth/v1/ue-authentications |
2022-08-11T17:16:56+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1] Send Authentication Request
2022-08-11T17:16:56+09:00 [INFO][AMF][NGAP][192.168.0.131:45635][AMF_UE_NGAP_ID:1] Send Downlink Nas Transport
2022-08-11T17:16:56+09:00 [INFO][AMF][NGAP][192.168.0.131:45635][AMF_UE_NGAP_ID:1] Uplink NAS Transport (RAN UE NGAP ID: 1)
2022-08-11T17:16:56+09:00 [INFO][LIB][FSM] Handle event[Gmm Message], transition from [Authentication] to [Authentication]
2022-08-11T17:16:56+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1] Handle Authentication Response
2022-08-11T17:16:56+09:00 [INFO][AUSF][5gAkaAuth] Auth5gAkaComfirmRequest
2022-08-11T17:16:56+09:00 [INFO][AUSF][5gAkaAuth] res*: 6265363635386332376533306163656162636339613936353264656663303635
Xres*: 6265363635386332376533306163656162636339613936353264656663303635
2022-08-11T17:16:56+09:00 [INFO][AUSF][5gAkaAuth] 5G AKA confirmation succeeded
2022-08-11T17:16:56+09:00 [INFO][UDM][UEAU] Handle ConfirmAuthDataRequest
2022-08-11T17:16:56+09:00 [INFO][UDR][DRepo] Handle CreateAuthenticationStatus
2022-08-11T17:16:56+09:00 [INFO][UDR][GIN] | 204 |       127.0.0.1 | PUT     | /nudr-dr/v1/subscription-data/imsi-001010000000000/authentication-data/authentication-status |
2022-08-11T17:16:56+09:00 [INFO][UDM][GIN] | 201 |       127.0.0.1 | POST    | /nudm-ueau/v1/imsi-001010000000000/auth-events |
2022-08-11T17:16:56+09:00 [INFO][AUSF][GIN] | 200 |       127.0.0.1 | PUT     | /nausf-auth/v1/ue-authentications/suci-0-001-01-0000-0-0-0000000000/5g-aka-confirmation |
2022-08-11T17:16:56+09:00 [INFO][LIB][FSM] Handle event[Authentication Success], transition from [Authentication] to [SecurityMode]
2022-08-11T17:16:56+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1][SUPI:imsi-001010000000000] Send Security Mode Command
2022-08-11T17:16:56+09:00 [INFO][AMF][NGAP][192.168.0.131:45635][AMF_UE_NGAP_ID:1] Send Downlink Nas Transport
2022-08-11T17:16:56+09:00 [INFO][AMF][NGAP][192.168.0.131:45635][AMF_UE_NGAP_ID:1] Uplink NAS Transport (RAN UE NGAP ID: 1)
2022-08-11T17:16:56+09:00 [INFO][LIB][FSM] Handle event[Gmm Message], transition from [SecurityMode] to [SecurityMode]
2022-08-11T17:16:56+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1][SUPI:imsi-001010000000000] Handle Security Mode Complete
2022-08-11T17:16:56+09:00 [INFO][LIB][FSM] Handle event[SecurityMode Success], transition from [SecurityMode] to [ContextSetup]
2022-08-11T17:16:56+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1][SUPI:imsi-001010000000000] Handle InitialRegistration
2022-08-11T17:16:56+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:16:56+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?requester-nf-type=AMF&supi=imsi-001010000000000&target-nf-type=UDM |
2022-08-11T17:16:56+09:00 [INFO][UDM][SDM] Handle GetNssai
2022-08-11T17:16:56+09:00 [INFO][UDR][DRepo] Handle QueryAmData
2022-08-11T17:16:56+09:00 [INFO][UDR][GIN] | 200 |       127.0.0.1 | GET     | /nudr-dr/v1/subscription-data/imsi-001010000000000/00101/provisioned-data/am-data?supported-features= |
2022-08-11T17:16:56+09:00 [INFO][UDM][GIN] | 200 |       127.0.0.1 | GET     | /nudm-sdm/v1/imsi-001010000000000/nssai?plmn-id=%7B%22mcc%22%3A%22001%22%2C%22mnc%22%3A%2201%22%7D |
2022-08-11T17:16:56+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1][SUPI:imsi-001010000000000] RequestedNssai - ServingSnssai: &{Sst:1 Sd:010203}, HomeSnssai: <nil>
2022-08-11T17:16:56+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:16:56+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?requester-nf-type=AMF&supi=imsi-001010000000000&target-nf-type=UDM |
2022-08-11T17:16:56+09:00 [INFO][UDM][UECM] Handle RegistrationAmf3gppAccess
2022-08-11T17:16:56+09:00 [INFO][UDM][UECM] UEID: imsi-001010000000000
2022-08-11T17:16:56+09:00 [INFO][UDR][DRepo] Handle CreateAmfContext3gpp
2022-08-11T17:16:56+09:00 [INFO][UDR][GIN] | 204 |       127.0.0.1 | PUT     | /nudr-dr/v1/subscription-data/imsi-001010000000000/context-data/amf-3gpp-access |
2022-08-11T17:16:56+09:00 [INFO][UDM][GIN] | 201 |       127.0.0.1 | PUT     | /nudm-uecm/v1/imsi-001010000000000/registrations/amf-3gpp-access |
2022-08-11T17:16:56+09:00 [INFO][UDM][SDM] Handle GetAmData
2022-08-11T17:16:56+09:00 [INFO][UDR][DRepo] Handle QueryAmData
2022-08-11T17:16:56+09:00 [INFO][UDR][GIN] | 200 |       127.0.0.1 | GET     | /nudr-dr/v1/subscription-data/imsi-001010000000000/00101/provisioned-data/am-data?supported-features=%7B%22mcc%22%3A%22001%22%2C%22mnc%22%3A%2201%22%7D |
2022-08-11T17:16:56+09:00 [INFO][UDM][GIN] | 200 |       127.0.0.1 | GET     | /nudm-sdm/v1/imsi-001010000000000/am-data?plmn-id=%7B%22mcc%22%3A%22001%22%2C%22mnc%22%3A%2201%22%7D |
2022-08-11T17:16:56+09:00 [INFO][UDM][SDM] Handle GetSmfSelectData
2022-08-11T17:16:56+09:00 [INFO][UDR][DRepo] Handle QuerySmfSelectData
2022-08-11T17:16:56+09:00 [INFO][UDR][GIN] | 200 |       127.0.0.1 | GET     | /nudr-dr/v1/subscription-data/imsi-001010000000000/00101/provisioned-data/smf-selection-subscription-data?supported-features= |
2022-08-11T17:16:56+09:00 [INFO][UDM][GIN] | 200 |       127.0.0.1 | GET     | /nudm-sdm/v1/imsi-001010000000000/smf-select-data?plmn-id=%7B%22mcc%22%3A%22001%22%2C%22mnc%22%3A%2201%22%7D |
2022-08-11T17:16:56+09:00 [INFO][UDM][SDM] Handle GetUeContextInSmfData
2022-08-11T17:16:56+09:00 [INFO][UDR][DRepo] Handle QuerySmfRegList
2022-08-11T17:16:56+09:00 [INFO][UDR][GIN] | 200 |       127.0.0.1 | GET     | /nudr-dr/v1/subscription-data/imsi-001010000000000/context-data/smf-registrations?supported-features= |
2022-08-11T17:16:56+09:00 [INFO][UDM][GIN] | 200 |       127.0.0.1 | GET     | /nudm-sdm/v1/imsi-001010000000000/ue-context-in-smf-data |
2022-08-11T17:16:56+09:00 [INFO][UDM][SDM] Handle Subscribe
2022-08-11T17:16:56+09:00 [INFO][UDR][DRepo] Handle CreateSdmSubscriptions
2022-08-11T17:16:56+09:00 [INFO][UDR][GIN] | 201 |       127.0.0.1 | POST    | /nudr-dr/v1/subscription-data/imsi-001010000000000/context-data/sdm-subscriptions |
2022-08-11T17:16:56+09:00 [INFO][UDM][GIN] | 201 |       127.0.0.1 | POST    | /nudm-sdm/v1/imsi-001010000000000/sdm-subscriptions |
2022-08-11T17:16:56+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:16:56+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?preferred-locality=loc1&requester-nf-type=AMF&supi=imsi-001010000000000&target-nf-type=PCF |
2022-08-11T17:16:56+09:00 [INFO][PCF][Ampolicy] Handle AM Policy Create Request
2022-08-11T17:16:56+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:16:56+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?requester-nf-type=PCF&target-nf-type=UDR |
2022-08-11T17:16:56+09:00 [INFO][UDR][DRepo] Handle PolicyDataUesUeIdAmDataGet
2022-08-11T17:16:56+09:00 [INFO][UDR][GIN] | 200 |       127.0.0.1 | GET     | /nudr-dr/v1/policy-data/ues/imsi-001010000000000/am-data |
2022-08-11T17:16:56+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:16:56+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?guami=%7B%22plmnId%22%3A%7B%22mcc%22%3A%22001%22%2C%22mnc%22%3A%2201%22%7D%2C%22amfId%22%3A%22cafe00%22%7D&requester-nf-type=PCF&target-nf-type=AMF |
2022-08-11T17:16:56+09:00 [INFO][AMF][Comm] Handle AMF Status Change Subscribe Request
2022-08-11T17:16:56+09:00 [INFO][AMF][Comm] new AMF Status Subscription[1]
2022-08-11T17:16:56+09:00 [INFO][AMF][GIN] | 201 |       127.0.0.1 | POST    | /namf-comm/v1/subscriptions |
2022-08-11T17:16:56+09:00 [INFO][PCF][GIN] | 201 |       127.0.0.1 | POST    | /npcf-am-policy-control/v1/policies |
2022-08-11T17:16:56+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1][SUPI:imsi-001010000000000] Send Registration Accept
2022-08-11T17:16:56+09:00 [INFO][AMF][NGAP][192.168.0.131:45635][AMF_UE_NGAP_ID:1] Send Initial Context Setup Request
2022-08-11T17:16:56+09:00 [INFO][AMF][NGAP][192.168.0.131:45635][AMF_UE_NGAP_ID:1] Handle Initial Context Setup Response
2022-08-11T17:16:57+09:00 [INFO][AMF][NGAP][192.168.0.131:45635][AMF_UE_NGAP_ID:1] Uplink NAS Transport (RAN UE NGAP ID: 1)
2022-08-11T17:16:57+09:00 [INFO][LIB][FSM] Handle event[Gmm Message], transition from [ContextSetup] to [ContextSetup]
2022-08-11T17:16:57+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1][SUPI:imsi-001010000000000] Handle Registration Complete
2022-08-11T17:16:57+09:00 [INFO][LIB][FSM] Handle event[ContextSetup Success], transition from [ContextSetup] to [Registered]
2022-08-11T17:16:57+09:00 [INFO][AMF][NGAP][192.168.0.131:45635][AMF_UE_NGAP_ID:1] Uplink NAS Transport (RAN UE NGAP ID: 1)
2022-08-11T17:16:57+09:00 [INFO][LIB][FSM] Handle event[Gmm Message], transition from [Registered] to [Registered]
2022-08-11T17:16:57+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1][SUPI:imsi-001010000000000] Handle UL NAS Transport
2022-08-11T17:16:57+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1][SUPI:imsi-001010000000000] Transport 5GSM Message to SMF
2022-08-11T17:16:57+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1][SUPI:imsi-001010000000000] Select SMF [snssai: {Sst:1 Sd:010203}, dnn: internet]
2022-08-11T17:16:57+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:16:57+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?requester-nf-type=AMF&target-nf-type=NSSF |
2022-08-11T17:16:57+09:00 [INFO][NSSF][NsSelect] Handle NSSelectionGet
2022-08-11T17:16:57+09:00 [INFO][NSSF][GIN] | 200 |       127.0.0.1 | GET     | /nnssf-nsselection/v1/network-slice-information?nf-id=cc20b04f-f17c-4cda-9f48-733299e2fdcd&nf-type=AMF&slice-info-request-for-pdu-session=%7B%22sNssai%22%3A%7B%22sst%22%3A1%2C%22sd%22%3A%22010203%22%7D%2C%22roamingIndication%22%3A%22NON_ROAMING%22%7D |
2022-08-11T17:16:57+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:16:57+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?dnn=internet&preferred-locality=loc1&requester-nf-type=AMF&service-names=nsmf-pdusession&snssais=%7B%22sst%22%3A1%2C%22sd%22%3A%22010203%22%7D&target-nf-type=SMF&target-plmn-list=%7B%22mcc%22%3A%22001%22%2C%22mnc%22%3A%2201%22%7D |
2022-08-11T17:16:57+09:00 [INFO][SMF][PduSess] Receive Create SM Context Request
2022-08-11T17:16:57+09:00 [INFO][SMF][PduSess] In HandlePDUSessionSMContextCreate
2022-08-11T17:16:57+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:16:57+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?requester-nf-type=SMF&target-nf-type=UDM |
2022-08-11T17:16:57+09:00 [INFO][SMF][PduSess] Send NF Discovery Serving UDM Successfully
2022-08-11T17:16:57+09:00 [INFO][SMF][CTX] Allocated UE IP address: 10.60.0.1
2022-08-11T17:16:57+09:00 [INFO][SMF][CTX] Selected UPF: UPF
2022-08-11T17:16:57+09:00 [INFO][SMF][PduSess] UE[imsi-001010000000000] PDUSessionID[1] IP[10.60.0.1]
2022-08-11T17:16:57+09:00 [INFO][UDM][SDM] Handle GetSmData
2022-08-11T17:16:57+09:00 [INFO][UDM][SDM] getSmDataProcedure: SUPI[imsi-001010000000000] PLMNID[00101] DNN[internet] SNssai[{"sst":1,"sd":"010203"}]
2022-08-11T17:16:57+09:00 [INFO][UDR][DRepo] Handle QuerySmData
2022-08-11T17:16:57+09:00 [INFO][UDR][GIN] | 200 |       127.0.0.1 | GET     | /nudr-dr/v1/subscription-data/imsi-001010000000000/00101/provisioned-data/sm-data?single-nssai=%7B%22sst%22%3A1%2C%22sd%22%3A%22010203%22%7D |
2022-08-11T17:16:57+09:00 [INFO][UDM][GIN] | 200 |       127.0.0.1 | GET     | /nudm-sdm/v1/imsi-001010000000000/sm-data?dnn=internet&plmn-id=%7B%22mcc%22%3A%22001%22%2C%22mnc%22%3A%2201%22%7D&single-nssai=%7B%22sst%22%3A1%2C%22sd%22%3A%22010203%22%7D |
2022-08-11T17:16:57+09:00 [INFO][SMF][GSM] In HandlePDUSessionEstablishmentRequest
2022-08-11T17:16:57+09:00 [INFO][NAS][Convert] ProtocolOrContainerList:  [0xc00000de20 0xc00000de60]
2022-08-11T17:16:57+09:00 [INFO][SMF][GSM] Protocol Configuration Options
2022-08-11T17:16:57+09:00 [INFO][SMF][GSM] &{[0xc00000de20 0xc00000de60]}
2022-08-11T17:16:57+09:00 [INFO][SMF][GSM] Didn't Implement container type IPAddressAllocationViaNASSignallingUL
2022-08-11T17:16:57+09:00 [INFO][SMF][PduSess] PCF Selection for SMContext SUPI[imsi-001010000000000] PDUSessionID[1]
2022-08-11T17:16:57+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:16:57+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?preferred-locality=loc1&requester-nf-type=SMF&target-nf-type=PCF |
2022-08-11T17:16:57+09:00 [INFO][PCF][SMpolicy] Handle CreateSmPolicy
2022-08-11T17:16:57+09:00 [INFO][UDR][DRepo] Handle PolicyDataUesUeIdSmDataGet
2022-08-11T17:16:57+09:00 [INFO][UDR][GIN] | 200 |       127.0.0.1 | GET     | /nudr-dr/v1/policy-data/ues/imsi-001010000000000/sm-data?dnn=internet&snssai=%7B%22sst%22%3A1%2C%22sd%22%3A%22010203%22%7D |
2022-08-11T17:16:57+09:00 [INFO][PCF][GIN] | 201 |       127.0.0.1 | POST    | /npcf-smpolicycontrol/v1/sm-policies |
2022-08-11T17:16:57+09:00 [INFO][SMF][PduSess] SUPI[imsi-001010000000000] has no pre-config route
2022-08-11T17:16:57+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:16:57+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?requester-nf-type=SMF&target-nf-instance-id=cc20b04f-f17c-4cda-9f48-733299e2fdcd&target-nf-type=AMF |
2022-08-11T17:16:57+09:00 [INFO][SMF][Consumer] SendNFDiscoveryServingAMF ok
2022-08-11T17:16:57+09:00 [INFO][SMF][GIN] | 201 |       127.0.0.1 | POST    | /nsmf-pdusession/v1/sm-contexts |
2022-08-11T17:16:57+09:00 [INFO][SMF][PduSess] Sending PFCP Session Establishment Request
2022-08-11T17:16:57+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1][SUPI:imsi-001010000000000] create smContext[pduSessionID: 1] Success
2022-08-11T17:16:57+09:00 [INFO][LIB][PFCP] Remove Request Transaction [2]
2022-08-11T17:16:57+09:00 [INFO][SMF][PduSess] Received PFCP Session Establishment Accepted Response
2022-08-11T17:16:57+09:00 [INFO][AMF][Producer] Handle N1N2 Message Transfer Request
2022-08-11T17:16:57+09:00 [INFO][AMF][NGAP][192.168.0.131:45635][AMF_UE_NGAP_ID:1] Send PDU Session Resource Setup Request
2022-08-11T17:16:57+09:00 [INFO][AMF][GIN] | 200 |       127.0.0.1 | POST    | /namf-comm/v1/ue-contexts/imsi-001010000000000/n1-n2-messages |
2022-08-11T17:16:57+09:00 [INFO][AMF][NGAP][192.168.0.131:45635][AMF_UE_NGAP_ID:1] Handle PDU Session Resource Setup Response
2022-08-11T17:16:57+09:00 [INFO][SMF][PduSess] Receive Update SM Context Request
2022-08-11T17:16:57+09:00 [INFO][SMF][PduSess] In HandlePDUSessionSMContextUpdate
2022-08-11T17:16:57+09:00 [INFO][SMF][PduSess] Sending PFCP Session Modification Request to AN UPF
2022-08-11T17:16:57+09:00 [INFO][LIB][PFCP] Remove Request Transaction [3]
2022-08-11T17:16:57+09:00 [INFO][SMF][PduSess] Received PFCP Session Modification Accepted Response from AN UPF
2022-08-11T17:16:57+09:00 [INFO][SMF][GIN] | 200 |       127.0.0.1 | POST    | /nsmf-pdusession/v1/sm-contexts/urn:uuid:ed9f05c9-09e0-4628-b04f-2dbb1e88ecd1/modify |
```

free5GC U-Plane1のログは以下の通りです。

```
2022-08-11T17:16:57+09:00 [INFO][UPF][Pfcp][192.168.0.144:8805] handleSessionEstablishmentRequest
2022-08-11T17:16:57+09:00 [INFO][UPF][Pfcp][192.168.0.144:8805][rNodeID:192.168.0.142][SEID:L(0x1),R(0x1)] New session
2022-08-11T17:16:57+09:00 [INFO][UPF][Pfcp][192.168.0.144:8805] handleSessionModificationRequest
```

TUNnelインターフェース`uesimtun0`は次のように作成され、IPアドレス`10.60.0.1`がUEに割り当てられたことが分かります。

```
# ip addr show
...
6: uesimtun0: <POINTOPOINT,PROMISC,NOTRAILERS,UP,LOWER_UP> mtu 1400 qdisc fq_codel state UNKNOWN group default qlen 500
    link/none 
    inet 10.60.0.1/32 scope global uesimtun0
       valid_lft forever preferred_lft forever
    inet6 fe80::6ccf:a815:3ea3:5278/64 scope link stable-privacy 
       valid_lft forever preferred_lft forever
...
```

#### Loc1のDN=10.60.0.0/16を経由してgoogle.comにpingする

`tcpdump`を使用して、パケットがU-Plane1の`if=upfgtp`を通過することを確認します。

```
# ping google.com -I uesimtun0 -n
PING google.com (172.217.31.142) from 10.60.0.1 uesimtun0: 56(84) bytes of data.
64 bytes from 172.217.31.142: icmp_seq=1 ttl=61 time=19.1 ms
64 bytes from 172.217.31.142: icmp_seq=2 ttl=61 time=19.8 ms
64 bytes from 172.217.31.142: icmp_seq=3 ttl=61 time=19.6 ms
```

U-Plane1の`tcpdump`のログは以下の通りです。

```
17:19:31.293704 IP 10.60.0.1 > 172.217.31.142: ICMP echo request, id 3, seq 1, length 64
17:19:31.311046 IP 172.217.31.142 > 10.60.0.1: ICMP echo reply, id 3, seq 1, length 64
17:19:32.295029 IP 10.60.0.1 > 172.217.31.142: ICMP echo request, id 3, seq 2, length 64
17:19:32.312711 IP 172.217.31.142 > 10.60.0.1: ICMP echo reply, id 3, seq 2, length 64
17:19:33.296769 IP 10.60.0.1 > 172.217.31.142: ICMP echo request, id 3, seq 3, length 64
17:19:33.314139 IP 172.217.31.142 > 10.60.0.1: ICMP echo reply, id 3, seq 3, length 64
```

注意。パケットがU-Plane2を通過しないことを確認して下さい。UEは接続したLoc1のgNodeB1に従って、同じLoc1のU-Plane1のDNに接続します。

### UERANSIM(Loc2のUE)を実行

gNodeB1との接続を切り、Loc2のgNodeB2にUEを接続して、パケットが同じLoc2のU-Plane2のDNを通過することを確認します。

#### Loc2のgNodeB2にUEを接続

```
# ./nr-ue -c ../config/free5gc-ue-loc2.yaml 
UERANSIM v3.2.6
[2022-08-11 17:21:47.921] [nas] [info] UE switches to state [MM-DEREGISTERED/PLMN-SEARCH]
[2022-08-11 17:21:47.922] [rrc] [debug] New signal detected for cell[1], total [1] cells in coverage
[2022-08-11 17:21:47.922] [nas] [info] Selected plmn[001/01]
[2022-08-11 17:21:47.922] [rrc] [info] Selected cell plmn[001/01] tac[2] category[SUITABLE]
[2022-08-11 17:21:47.923] [nas] [info] UE switches to state [MM-DEREGISTERED/PS]
[2022-08-11 17:21:47.923] [nas] [info] UE switches to state [MM-DEREGISTERED/NORMAL-SERVICE]
[2022-08-11 17:21:47.923] [nas] [debug] Initial registration required due to [MM-DEREG-NORMAL-SERVICE]
[2022-08-11 17:21:47.923] [nas] [debug] UAC access attempt is allowed for identity[0], category[MO_sig]
[2022-08-11 17:21:47.923] [nas] [debug] Sending Initial Registration
[2022-08-11 17:21:47.924] [nas] [info] UE switches to state [MM-REGISTER-INITIATED]
[2022-08-11 17:21:47.924] [rrc] [debug] Sending RRC Setup Request
[2022-08-11 17:21:47.925] [rrc] [info] RRC connection established
[2022-08-11 17:21:47.925] [rrc] [info] UE switches to state [RRC-CONNECTED]
[2022-08-11 17:21:47.925] [nas] [info] UE switches to state [CM-CONNECTED]
[2022-08-11 17:21:47.941] [nas] [debug] Authentication Request received
[2022-08-11 17:21:47.949] [nas] [debug] Security Mode Command received
[2022-08-11 17:21:47.950] [nas] [debug] Selected integrity[2] ciphering[0]
[2022-08-11 17:21:47.984] [nas] [debug] Registration accept received
[2022-08-11 17:21:47.985] [nas] [info] UE switches to state [MM-REGISTERED/NORMAL-SERVICE]
[2022-08-11 17:21:47.985] [nas] [debug] Sending Registration Complete
[2022-08-11 17:21:47.985] [nas] [info] Initial Registration is successful
[2022-08-11 17:21:47.985] [nas] [debug] Sending PDU Session Establishment Request
[2022-08-11 17:21:47.986] [nas] [debug] UAC access attempt is allowed for identity[0], category[MO_sig]
[2022-08-11 17:21:48.243] [nas] [debug] PDU Session Establishment Accept received
[2022-08-11 17:21:48.248] [nas] [info] PDU Session establishment is successful PSI[1]
[2022-08-11 17:21:48.272] [app] [info] Connection setup for PDU session[1] is successful, TUN interface[uesimtun0, 10.61.0.1] is up.
```

free5GC C-Planeのログは以下の通りです。

```
2022-08-11T17:21:47+09:00 [INFO][AMF][NGAP][192.168.0.132:45375] Handle Initial UE Message
2022-08-11T17:21:47+09:00 [INFO][LIB][FSM] Handle event[Gmm Message], transition from [Deregistered] to [Deregistered]
2022-08-11T17:21:47+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1] Handle Registration Request
2022-08-11T17:21:47+09:00 [INFO][LIB][FSM] Handle event[Start Authentication], transition from [Deregistered] to [Authentication]
2022-08-11T17:21:47+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1] Authentication procedure
2022-08-11T17:21:47+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:21:47+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?requester-nf-type=AMF&target-nf-type=AUSF |
2022-08-11T17:21:47+09:00 [INFO][AUSF][UeAuthPost] HandleUeAuthPostRequest
2022-08-11T17:21:47+09:00 [INFO][AUSF][UeAuthPost] Serving network authorized
2022-08-11T17:21:47+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:21:47+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?requester-nf-type=AUSF&service-names=nudm-ueau&target-nf-type=UDM |
2022-08-11T17:21:47+09:00 [INFO][UDM][UEAU] Handle GenerateAuthDataRequest
2022-08-11T17:21:47+09:00 [INFO][UDM][Suci] suciPart: [suci 0 001 01 0000 0 0 0000000000]
2022-08-11T17:21:47+09:00 [INFO][UDM][Suci] scheme 0
2022-08-11T17:21:47+09:00 [INFO][UDM][Suci] SUPI type is IMSI
2022-08-11T17:21:47+09:00 [INFO][UDR][DRepo] Handle QueryAuthSubsData
2022-08-11T17:21:47+09:00 [INFO][UDR][GIN] | 200 |       127.0.0.1 | GET     | /nudr-dr/v1/subscription-data/imsi-001010000000000/authentication-data/authentication-subscription |
2022-08-11T17:21:47+09:00 [ERRO][UDM][UEAU] opStr length is  0
2022-08-11T17:21:47+09:00 [INFO][UDR][DRepo] Handle ModifyAuthentication
2022-08-11T17:21:47+09:00 [INFO][UDR][GIN] | 204 |       127.0.0.1 | PATCH   | /nudr-dr/v1/subscription-data/imsi-001010000000000/authentication-data/authentication-subscription |
2022-08-11T17:21:47+09:00 [INFO][UDM][GIN] | 200 |       127.0.0.1 | POST    | /nudm-ueau/v1/suci-0-001-01-0000-0-0-0000000000/security-information/generate-auth-data |
2022-08-11T17:21:47+09:00 [INFO][AUSF][UeAuthPost] Add SuciSupiPair (suci-0-001-01-0000-0-0-0000000000, imsi-001010000000000) to map.
2022-08-11T17:21:47+09:00 [INFO][AUSF][UeAuthPost] Use 5G AKA auth method
2022-08-11T17:21:47+09:00 [INFO][AUSF][5gAkaAuth] XresStar = 6462626561356534343436636634303638323165353265393834636263343238
2022-08-11T17:21:47+09:00 [INFO][AUSF][GIN] | 201 |       127.0.0.1 | POST    | /nausf-auth/v1/ue-authentications |
2022-08-11T17:21:47+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1] Send Authentication Request
2022-08-11T17:21:47+09:00 [INFO][AMF][NGAP][192.168.0.132:45375][AMF_UE_NGAP_ID:1] Send Downlink Nas Transport
2022-08-11T17:21:47+09:00 [INFO][AMF][NGAP][192.168.0.132:45375][AMF_UE_NGAP_ID:1] Uplink NAS Transport (RAN UE NGAP ID: 1)
2022-08-11T17:21:47+09:00 [INFO][LIB][FSM] Handle event[Gmm Message], transition from [Authentication] to [Authentication]
2022-08-11T17:21:47+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1] Handle Authentication Response
2022-08-11T17:21:47+09:00 [INFO][AUSF][5gAkaAuth] Auth5gAkaComfirmRequest
2022-08-11T17:21:47+09:00 [INFO][AUSF][5gAkaAuth] res*: 6462626561356534343436636634303638323165353265393834636263343238
Xres*: 6462626561356534343436636634303638323165353265393834636263343238
2022-08-11T17:21:47+09:00 [INFO][AUSF][5gAkaAuth] 5G AKA confirmation succeeded
2022-08-11T17:21:47+09:00 [INFO][UDM][UEAU] Handle ConfirmAuthDataRequest
2022-08-11T17:21:47+09:00 [INFO][UDR][DRepo] Handle CreateAuthenticationStatus
2022-08-11T17:21:47+09:00 [INFO][UDR][GIN] | 204 |       127.0.0.1 | PUT     | /nudr-dr/v1/subscription-data/imsi-001010000000000/authentication-data/authentication-status |
2022-08-11T17:21:47+09:00 [INFO][UDM][GIN] | 201 |       127.0.0.1 | POST    | /nudm-ueau/v1/imsi-001010000000000/auth-events |
2022-08-11T17:21:47+09:00 [INFO][AUSF][GIN] | 200 |       127.0.0.1 | PUT     | /nausf-auth/v1/ue-authentications/suci-0-001-01-0000-0-0-0000000000/5g-aka-confirmation |
2022-08-11T17:21:47+09:00 [INFO][LIB][FSM] Handle event[Authentication Success], transition from [Authentication] to [SecurityMode]
2022-08-11T17:21:47+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1][SUPI:imsi-001010000000000] Send Security Mode Command
2022-08-11T17:21:47+09:00 [INFO][AMF][NGAP][192.168.0.132:45375][AMF_UE_NGAP_ID:1] Send Downlink Nas Transport
2022-08-11T17:21:47+09:00 [INFO][AMF][NGAP][192.168.0.132:45375][AMF_UE_NGAP_ID:1] Uplink NAS Transport (RAN UE NGAP ID: 1)
2022-08-11T17:21:47+09:00 [INFO][LIB][FSM] Handle event[Gmm Message], transition from [SecurityMode] to [SecurityMode]
2022-08-11T17:21:47+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1][SUPI:imsi-001010000000000] Handle Security Mode Complete
2022-08-11T17:21:47+09:00 [INFO][LIB][FSM] Handle event[SecurityMode Success], transition from [SecurityMode] to [ContextSetup]
2022-08-11T17:21:47+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1][SUPI:imsi-001010000000000] Handle InitialRegistration
2022-08-11T17:21:47+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:21:47+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?requester-nf-type=AMF&supi=imsi-001010000000000&target-nf-type=UDM |
2022-08-11T17:21:47+09:00 [INFO][UDM][SDM] Handle GetNssai
2022-08-11T17:21:47+09:00 [INFO][UDR][DRepo] Handle QueryAmData
2022-08-11T17:21:47+09:00 [INFO][UDR][GIN] | 200 |       127.0.0.1 | GET     | /nudr-dr/v1/subscription-data/imsi-001010000000000/00101/provisioned-data/am-data?supported-features= |
2022-08-11T17:21:47+09:00 [INFO][UDM][GIN] | 200 |       127.0.0.1 | GET     | /nudm-sdm/v1/imsi-001010000000000/nssai?plmn-id=%7B%22mcc%22%3A%22001%22%2C%22mnc%22%3A%2201%22%7D |
2022-08-11T17:21:47+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1][SUPI:imsi-001010000000000] RequestedNssai - ServingSnssai: &{Sst:1 Sd:010203}, HomeSnssai: <nil>
2022-08-11T17:21:47+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:21:47+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?requester-nf-type=AMF&supi=imsi-001010000000000&target-nf-type=UDM |
2022-08-11T17:21:47+09:00 [INFO][UDM][UECM] Handle RegistrationAmf3gppAccess
2022-08-11T17:21:47+09:00 [INFO][UDM][UECM] UEID: imsi-001010000000000
2022-08-11T17:21:47+09:00 [INFO][UDR][DRepo] Handle CreateAmfContext3gpp
2022-08-11T17:21:47+09:00 [INFO][UDR][GIN] | 204 |       127.0.0.1 | PUT     | /nudr-dr/v1/subscription-data/imsi-001010000000000/context-data/amf-3gpp-access |
2022-08-11T17:21:47+09:00 [ERRO][UDM][HTTP] unsupported scheme[]
2022-08-11T17:21:47+09:00 [INFO][UDM][GIN] | 204 |       127.0.0.1 | PUT     | /nudm-uecm/v1/imsi-001010000000000/registrations/amf-3gpp-access |
2022-08-11T17:21:47+09:00 [INFO][UDM][SDM] Handle GetAmData
2022-08-11T17:21:47+09:00 [INFO][UDR][DRepo] Handle QueryAmData
2022-08-11T17:21:47+09:00 [INFO][UDR][GIN] | 200 |       127.0.0.1 | GET     | /nudr-dr/v1/subscription-data/imsi-001010000000000/00101/provisioned-data/am-data?supported-features=%7B%22mcc%22%3A%22001%22%2C%22mnc%22%3A%2201%22%7D |
2022-08-11T17:21:47+09:00 [INFO][UDM][GIN] | 200 |       127.0.0.1 | GET     | /nudm-sdm/v1/imsi-001010000000000/am-data?plmn-id=%7B%22mcc%22%3A%22001%22%2C%22mnc%22%3A%2201%22%7D |
2022-08-11T17:21:47+09:00 [INFO][UDM][SDM] Handle GetSmfSelectData
2022-08-11T17:21:47+09:00 [INFO][UDR][DRepo] Handle QuerySmfSelectData
2022-08-11T17:21:47+09:00 [INFO][UDR][GIN] | 200 |       127.0.0.1 | GET     | /nudr-dr/v1/subscription-data/imsi-001010000000000/00101/provisioned-data/smf-selection-subscription-data?supported-features= |
2022-08-11T17:21:47+09:00 [INFO][UDM][GIN] | 200 |       127.0.0.1 | GET     | /nudm-sdm/v1/imsi-001010000000000/smf-select-data?plmn-id=%7B%22mcc%22%3A%22001%22%2C%22mnc%22%3A%2201%22%7D |
2022-08-11T17:21:47+09:00 [INFO][UDM][SDM] Handle GetUeContextInSmfData
2022-08-11T17:21:47+09:00 [INFO][UDR][DRepo] Handle QuerySmfRegList
2022-08-11T17:21:47+09:00 [INFO][UDR][GIN] | 200 |       127.0.0.1 | GET     | /nudr-dr/v1/subscription-data/imsi-001010000000000/context-data/smf-registrations?supported-features= |
2022-08-11T17:21:47+09:00 [INFO][UDM][GIN] | 200 |       127.0.0.1 | GET     | /nudm-sdm/v1/imsi-001010000000000/ue-context-in-smf-data |
2022-08-11T17:21:47+09:00 [INFO][UDM][SDM] Handle Subscribe
2022-08-11T17:21:47+09:00 [INFO][UDR][DRepo] Handle CreateSdmSubscriptions
2022-08-11T17:21:47+09:00 [INFO][UDR][GIN] | 201 |       127.0.0.1 | POST    | /nudr-dr/v1/subscription-data/imsi-001010000000000/context-data/sdm-subscriptions |
2022-08-11T17:21:47+09:00 [INFO][UDM][GIN] | 201 |       127.0.0.1 | POST    | /nudm-sdm/v1/imsi-001010000000000/sdm-subscriptions |
2022-08-11T17:21:47+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:21:47+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?preferred-locality=loc2&requester-nf-type=AMF&supi=imsi-001010000000000&target-nf-type=PCF |
2022-08-11T17:21:47+09:00 [INFO][PCF][Ampolicy] Handle AM Policy Create Request
2022-08-11T17:21:47+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:21:47+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?requester-nf-type=PCF&target-nf-type=UDR |
2022-08-11T17:21:47+09:00 [INFO][UDR][DRepo] Handle PolicyDataUesUeIdAmDataGet
2022-08-11T17:21:47+09:00 [INFO][UDR][GIN] | 200 |       127.0.0.1 | GET     | /nudr-dr/v1/policy-data/ues/imsi-001010000000000/am-data |
2022-08-11T17:21:47+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:21:47+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?guami=%7B%22plmnId%22%3A%7B%22mcc%22%3A%22001%22%2C%22mnc%22%3A%2201%22%7D%2C%22amfId%22%3A%22cafe01%22%7D&requester-nf-type=PCF&target-nf-type=AMF |
2022-08-11T17:21:47+09:00 [INFO][PCF][GIN] | 201 |       127.0.0.1 | POST    | /npcf-am-policy-control/v1/policies |
2022-08-11T17:21:47+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1][SUPI:imsi-001010000000000] Send Registration Accept
2022-08-11T17:21:47+09:00 [INFO][AMF][NGAP][192.168.0.132:45375][AMF_UE_NGAP_ID:1] Send Initial Context Setup Request
2022-08-11T17:21:47+09:00 [INFO][AMF][NGAP][192.168.0.132:45375][AMF_UE_NGAP_ID:1] Handle Initial Context Setup Response
2022-08-11T17:21:48+09:00 [INFO][AMF][NGAP][192.168.0.132:45375][AMF_UE_NGAP_ID:1] Uplink NAS Transport (RAN UE NGAP ID: 1)
2022-08-11T17:21:48+09:00 [INFO][LIB][FSM] Handle event[Gmm Message], transition from [ContextSetup] to [ContextSetup]
2022-08-11T17:21:48+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1][SUPI:imsi-001010000000000] Handle Registration Complete
2022-08-11T17:21:48+09:00 [INFO][LIB][FSM] Handle event[ContextSetup Success], transition from [ContextSetup] to [Registered]
2022-08-11T17:21:48+09:00 [INFO][AMF][NGAP][192.168.0.132:45375][AMF_UE_NGAP_ID:1] Uplink NAS Transport (RAN UE NGAP ID: 1)
2022-08-11T17:21:48+09:00 [INFO][LIB][FSM] Handle event[Gmm Message], transition from [Registered] to [Registered]
2022-08-11T17:21:48+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1][SUPI:imsi-001010000000000] Handle UL NAS Transport
2022-08-11T17:21:48+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1][SUPI:imsi-001010000000000] Transport 5GSM Message to SMF
2022-08-11T17:21:48+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1][SUPI:imsi-001010000000000] Select SMF [snssai: {Sst:1 Sd:010203}, dnn: internet]
2022-08-11T17:21:48+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:21:48+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?requester-nf-type=AMF&target-nf-type=NSSF |
2022-08-11T17:21:48+09:00 [INFO][NSSF][NsSelect] Handle NSSelectionGet
2022-08-11T17:21:48+09:00 [INFO][NSSF][GIN] | 200 |       127.0.0.1 | GET     | /nnssf-nsselection/v1/network-slice-information?nf-id=ccc15824-b48b-4977-9afd-3c15484993d0&nf-type=AMF&slice-info-request-for-pdu-session=%7B%22sNssai%22%3A%7B%22sst%22%3A1%2C%22sd%22%3A%22010203%22%7D%2C%22roamingIndication%22%3A%22NON_ROAMING%22%7D |
2022-08-11T17:21:48+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:21:48+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?dnn=internet&preferred-locality=loc2&requester-nf-type=AMF&service-names=nsmf-pdusession&snssais=%7B%22sst%22%3A1%2C%22sd%22%3A%22010203%22%7D&target-nf-type=SMF&target-plmn-list=%7B%22mcc%22%3A%22001%22%2C%22mnc%22%3A%2201%22%7D |
2022-08-11T17:21:48+09:00 [INFO][SMF][PduSess] Receive Create SM Context Request
2022-08-11T17:21:48+09:00 [INFO][SMF][PduSess] In HandlePDUSessionSMContextCreate
2022-08-11T17:21:48+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:21:48+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?requester-nf-type=SMF&target-nf-type=UDM |
2022-08-11T17:21:48+09:00 [INFO][SMF][PduSess] Send NF Discovery Serving UDM Successfully
2022-08-11T17:21:48+09:00 [INFO][SMF][CTX] Allocated UE IP address: 10.61.0.1
2022-08-11T17:21:48+09:00 [INFO][SMF][CTX] Selected UPF: UPF
2022-08-11T17:21:48+09:00 [INFO][SMF][PduSess] UE[imsi-001010000000000] PDUSessionID[1] IP[10.61.0.1]
2022-08-11T17:21:48+09:00 [INFO][UDM][SDM] Handle GetSmData
2022-08-11T17:21:48+09:00 [INFO][UDM][SDM] getSmDataProcedure: SUPI[imsi-001010000000000] PLMNID[00101] DNN[internet] SNssai[{"sst":1,"sd":"010203"}]
2022-08-11T17:21:48+09:00 [INFO][UDR][DRepo] Handle QuerySmData
2022-08-11T17:21:48+09:00 [INFO][UDR][GIN] | 200 |       127.0.0.1 | GET     | /nudr-dr/v1/subscription-data/imsi-001010000000000/00101/provisioned-data/sm-data?single-nssai=%7B%22sst%22%3A1%2C%22sd%22%3A%22010203%22%7D |
2022-08-11T17:21:48+09:00 [INFO][UDM][GIN] | 200 |       127.0.0.1 | GET     | /nudm-sdm/v1/imsi-001010000000000/sm-data?dnn=internet&plmn-id=%7B%22mcc%22%3A%22001%22%2C%22mnc%22%3A%2201%22%7D&single-nssai=%7B%22sst%22%3A1%2C%22sd%22%3A%22010203%22%7D |
2022-08-11T17:21:48+09:00 [INFO][SMF][GSM] In HandlePDUSessionEstablishmentRequest
2022-08-11T17:21:48+09:00 [INFO][NAS][Convert] ProtocolOrContainerList:  [0xc00000de20 0xc00000de60]
2022-08-11T17:21:48+09:00 [INFO][SMF][GSM] Protocol Configuration Options
2022-08-11T17:21:48+09:00 [INFO][SMF][GSM] &{[0xc00000de20 0xc00000de60]}
2022-08-11T17:21:48+09:00 [INFO][SMF][GSM] Didn't Implement container type IPAddressAllocationViaNASSignallingUL
2022-08-11T17:21:48+09:00 [INFO][SMF][PduSess] PCF Selection for SMContext SUPI[imsi-001010000000000] PDUSessionID[1]
2022-08-11T17:21:48+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:21:48+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?preferred-locality=loc2&requester-nf-type=SMF&target-nf-type=PCF |
2022-08-11T17:21:48+09:00 [INFO][PCF][SMpolicy] Handle CreateSmPolicy
2022-08-11T17:21:48+09:00 [INFO][UDR][DRepo] Handle PolicyDataUesUeIdSmDataGet
2022-08-11T17:21:48+09:00 [INFO][UDR][GIN] | 200 |       127.0.0.1 | GET     | /nudr-dr/v1/policy-data/ues/imsi-001010000000000/sm-data?dnn=internet&snssai=%7B%22sst%22%3A1%2C%22sd%22%3A%22010203%22%7D |
2022-08-11T17:21:48+09:00 [INFO][PCF][GIN] | 201 |       127.0.0.1 | POST    | /npcf-smpolicycontrol/v1/sm-policies |
2022-08-11T17:21:48+09:00 [INFO][SMF][PduSess] SUPI[imsi-001010000000000] has no pre-config route
2022-08-11T17:21:48+09:00 [INFO][NRF][DSCV] Handle NFDiscoveryRequest
2022-08-11T17:21:48+09:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?requester-nf-type=SMF&target-nf-instance-id=ccc15824-b48b-4977-9afd-3c15484993d0&target-nf-type=AMF |
2022-08-11T17:21:48+09:00 [INFO][SMF][Consumer] SendNFDiscoveryServingAMF ok
2022-08-11T17:21:48+09:00 [INFO][SMF][GIN] | 201 |       127.0.0.1 | POST    | /nsmf-pdusession/v1/sm-contexts |
2022-08-11T17:21:48+09:00 [INFO][SMF][PduSess] Sending PFCP Session Establishment Request
2022-08-11T17:21:48+09:00 [INFO][AMF][GMM][AMF_UE_NGAP_ID:1][SUPI:imsi-001010000000000] create smContext[pduSessionID: 1] Success
2022-08-11T17:21:48+09:00 [INFO][LIB][PFCP] Remove Request Transaction [2]
2022-08-11T17:21:48+09:00 [INFO][SMF][PduSess] Received PFCP Session Establishment Accepted Response
2022-08-11T17:21:48+09:00 [INFO][AMF][Producer] Handle N1N2 Message Transfer Request
2022-08-11T17:21:48+09:00 [INFO][AMF][NGAP][192.168.0.132:45375][AMF_UE_NGAP_ID:1] Send PDU Session Resource Setup Request
2022-08-11T17:21:48+09:00 [INFO][AMF][GIN] | 200 |       127.0.0.1 | POST    | /namf-comm/v1/ue-contexts/imsi-001010000000000/n1-n2-messages |
2022-08-11T17:21:48+09:00 [INFO][AMF][NGAP][192.168.0.132:45375][AMF_UE_NGAP_ID:1] Handle PDU Session Resource Setup Response
2022-08-11T17:21:48+09:00 [INFO][SMF][PduSess] Receive Update SM Context Request
2022-08-11T17:21:48+09:00 [INFO][SMF][PduSess] In HandlePDUSessionSMContextUpdate
2022-08-11T17:21:48+09:00 [INFO][SMF][PduSess] Sending PFCP Session Modification Request to AN UPF
2022-08-11T17:21:48+09:00 [INFO][LIB][PFCP] Remove Request Transaction [3]
2022-08-11T17:21:48+09:00 [INFO][SMF][PduSess] Received PFCP Session Modification Accepted Response from AN UPF
2022-08-11T17:21:48+09:00 [INFO][SMF][GIN] | 200 |       127.0.0.1 | POST    | /nsmf-pdusession/v1/sm-contexts/urn:uuid:0626b41f-0c48-4c81-97d7-b21ca25fdb75/modify |
```

free5GC U-Plane2のログは以下の通りです。

```
2022-08-11T17:21:48+09:00 [INFO][UPF][Pfcp][192.168.0.145:8805] handleSessionEstablishmentRequest
2022-08-11T17:21:48+09:00 [INFO][UPF][Pfcp][192.168.0.145:8805][rNodeID:192.168.0.143][SEID:L(0x1),R(0x1)] New session
2022-08-11T17:21:48+09:00 [INFO][UPF][Pfcp][192.168.0.145:8805] handleSessionModificationRequest
```

TUNnelインターフェース`uesimtun0`は次のように作成され、IPアドレス`10.61.0.1`がUEに割り当てられたことが分かります。

```
# ip addr show
...
7: uesimtun0: <POINTOPOINT,PROMISC,NOTRAILERS,UP,LOWER_UP> mtu 1400 qdisc fq_codel state UNKNOWN group default qlen 500
    link/none 
    inet 10.61.0.1/32 scope global uesimtun0
       valid_lft forever preferred_lft forever
    inet6 fe80::4d16:9ca0:7a90:38ea/64 scope link stable-privacy 
       valid_lft forever preferred_lft forever
...
```

#### Loc2のDN=10.61.0.0/16を経由してgoogle.comにpingする

`tcpdump`を使用して、パケットがU-Plane2の`if=upfgtp`を通過することを確認します。

```
# ping google.com -I uesimtun0 -n
PING google.com (172.217.31.142) from 10.61.0.1 uesimtun0: 56(84) bytes of data.
64 bytes from 172.217.31.142: icmp_seq=1 ttl=61 time=19.9 ms
64 bytes from 172.217.31.142: icmp_seq=2 ttl=61 time=20.1 ms
64 bytes from 172.217.31.142: icmp_seq=3 ttl=61 time=25.8 ms
```

U-Plane2の`tcpdump`のログは以下の通りです。

```
17:23:58.380217 IP 10.61.0.1 > 172.217.31.142: ICMP echo request, id 4, seq 1, length 64
17:23:58.398164 IP 172.217.31.142 > 10.61.0.1: ICMP echo reply, id 4, seq 1, length 64
17:23:59.382056 IP 10.61.0.1 > 172.217.31.142: ICMP echo request, id 4, seq 2, length 64
17:23:59.400024 IP 172.217.31.142 > 10.61.0.1: ICMP echo reply, id 4, seq 2, length 64
17:24:00.383294 IP 10.61.0.1 > 172.217.31.142: ICMP echo request, id 4, seq 3, length 64
17:24:00.406703 IP 172.217.31.142 > 10.61.0.1: ICMP echo reply, id 4, seq 3, length 64
```

注意。パケットがU-Plane1を通過しないことを確認して下さい。UEは接続したLoc2のgNodeB2に従って、同じLoc2のU-Plane2のDNに接続します。

これで、UEが接続したgNodeBと同じロケーションにあるUPFのDNに接続するという非常にシンプルな構成を確認できました。UEからのトラフィックを最寄りの基地局のDNにルーティングしてMECを実現する際の設定のヒントになることを期待しています。

## 最後に

本記事の[Open5GS版](https://qiita.com/s5uishida/items/03a2bff732e60a4e631d)の最後にも書きましたが、端末が接続した基地局に応じて、最寄りのネットワークのサーバにトラフィックを集約して処理することは、MECの視点からポピュラーなニーズと思います。free5GCとOpen5GSで対応に違いがありますが、両者の仕組みが使えると、とても柔軟にAMF、SMF、UPFを構成できるようになると思います。

最後に、元記事は[Github](https://github.com/s5uishida/free5gc_ueransim_nearby_upf_sample_config)に書いたものです。free5GCの[Wiki](https://github.com/free5gc/free5gc/wiki)からもリンクして頂きました。

## 主な変更履歴

- [2022.08.29] free5GC v3.2.1に対応。
- [2022.07.13] free5GC v3.1.0に対応し、UERANSIM v3.2.6に対応。
- [2022.03.11] 初版。