# SMF Configuration
SMF configuration files includes:
- smf/smf1/config/smf.conf
- smf/smf1/xml/dnn.xml
- smf/smf1/xml/pfd.xml
- smf/smf1/xml/sm-policy-data.xml
- smf/smf1/xml/udm.xml
- smf/smf1/xml/upf.xml
## smf.conf
```xml
```
### N11 Interface (HTTP2)
- Local AMF Server IP: local IP address.
- Local AMF Server Port: local port, default 80.
- Local AMF Client IP: local IP address.
- Local AMF Client Port: local port, default 7012.
- Local UDM Server IP: local IP address.
- Local UDM Server Port: local port, default 8014.
- Local UDM Client IP: local IP address.
- Local UDM Client Port: local port, default 7012.
- Local PCF Server IP: local IP address.
- Local PCF Server Port: local port, default 8013.
- Local PCF Client IP: local IP address.
- Local PCF Client Port: local port, default 7012.
- AMF HTTP2 Server IP: remote IP address.
- AMF HTTP2 Server Port: remote port, default 81.
- UDM HTTP2 Client IP: remote IP address.
- UDM HTTP2 Client Port: remote port, default 3123.
- PCF HTTP2 Client IP: remote IP address.
- PCF HTTP2 Client Port: remote port, default 7081.
- NRF HTTP2 Client IP: remote IP address.
- PCF HTTP2 Client Port: remote port, default 8001.
### DSCP 配置
配置项格式:`dscp-qci-index-XXX=YYY`。
- XXX 为 QCI/5QI
- YYY 为 DSCP/ToS
EXAMPLE:
```xml
# smf.conf
dscp-qci-index-1="14"
dscp-qci-index-2="22"
# predefined-sm-policy-rules.xml
# UPF CLI output
Transport Level Marking: 0x38
Transport Level Marking: 0x58
0x38 => 0011 1000 -> 前 6 bit:001110 -> 14
0x58 => 0101 1000 -> 前 6 bit:010110 -> 22
```
### XML files
- local-sm-policy-filename: default value is set to "./xml/sm-policy-data.xml". This is for local configuration rules in SMF when embedded PCF is used.
- local-pfd-filename: default value is set to "./xml/pfd.xml". This is for PFD management procedures with UPF.
- local-dnn-filename: default value is set to "./xml/dnn.xml”. This is for configuring IPv4 address pool for different DNNs.
- local-upf-filename: default value is set to "./xml/upf.xml". This is for configuring UPFs and for performing UPF selection function.
- local-udm-filename: default value is set to "./xml/udm.xml". This is for configuration subscription parameters when embedded UDM is used.
## upf.xml
In this setup, the route is fixed during the PDU session establishment with all pass filters. Then when SMF receives the PCC rules from PCF with the indicated route information, SMF will decide which UPF the traffic will be routed thru and update the path accordingly on all UPFs along the path.
If the DNAI doesn’t match with any one of the UPFs along the path, the flow creation will be rejected and no signaling will send to the AMF.
SMF 基于 DNN + SNSSAI + PDU session type 来选择 UPF。
```xml
```
### N4 Interface (PFCP)
- Local IP: local IP address.
- Local Port: local port binding in sending out request message, default 8806.
- UPF IP: remote IP address. The remote port corresponding to this IP is always 8805 per PFCP protocol. The port 8805 is defined in specification and is not configurable.
### nssai-list
作用流程:
1、建立 N4 偶联时,UPF 会上报自身的网络接口资源信息,包括:Network interface 和 Network instanxe 的映射。
2、SMF 通过 nssai-list 来维护 UPF 的网络接口资源信息,并映射到不通的 NSSAI。
3、UE 业务建立时,SMF 会 UE 请求的 NSSAI 以及对应的 nssai-list 信息来为 UE 的 PDU Session 选择 UP Path 上的 UPF(I-UPF/PSA)以及实际的网络接口。
字段含义:
- value:指定 NSSAI 的 sst。
- intrf:指定 N3、N4、N9、N6 接口。
- srcintrf:指定 29.244 定义的 Source Interface IE,0: ul、1: dl、3: cp。
- ni:指定 Network Interface。
### dnai
DNAI(Data Network Access Identifier,数据网络访问标识)应用在 BP 或 UL CL 场景,用于标识接入到这个 DNN 的一个或多个 UPF(N6),一般是像 Domain Name 一样的一个标识符。DNN 下的 DNAI 是唯一的,但一个 DNN 可以有多个 DNAI,用于为 SDF 选择 UPF。
DNAI 可以配置在 PCC Rule 的 Traffic control data 中,作为通过 SMF 的 routing information,指定 FlowList 描述的 SDF 路由到指定的 DNN 中。常用与 UE 建立 PDU Session 后的,Traffic routing(流程重路由),例如:UL CL 场景的本地卸载。
### Network Intance
**NOTE**: The network instance could be set in the UPF. If it is set, then the same network instance needs to be set in the SMF upf.xml (n6-ni). In this example, the n6-ni of “default_n6” is being used.
### I-UPF
We have added the route-list. In this example, if both UPF1 (192.168.40.89) and UPF2 (192.168.40.90) are available, then if the UPF selection is carried out, for those destined with UPF2 (PSA) with be routed via UPF1 (I-UPF).
- ip-anchor:指定 PSA。
- up ip:指定 I-UPF。
I-UPF 的 TAC 应该与 gNB/AMF 的 TAC 一致,作为接入点的中继,PFCP session 也会保留在 I-UPF 上。route-list 的作用就是通过 I-UPF 中继,将流量路由到 PSA。
**NOTE 1**:PSA 的 TAC 不能与 gNB/AMF 的一致,否则 SMF 会优先选择 PSA 进行接入,即 I-UPF 没有参与,因为 PSA 本身就是 gNB/AMF 的服务区域内。
**NOTE 2**:I-UPF 的 N3、N9 接口可以共用一个 pPort,也可以分开两个 pPort,取决于 SMF 的配置。如果是两个 pPort 的话,需要再 SMF 上为 N3 和 N9 DL(src interface=1)配置上二個不同的 network instance,e.g. epc、upf1_n9,否则,SMF 沒法区分 N3 和 N9 的资源。
```xml
```
## dnn.xml
```xml
```
### UE IP Address Pool
UE IP address pool is configured in file **dnn.xml**. A UE IP address is assigned based on it associated DNN-NI, PDU type and pool index.
## pfd.xml (Packet Flow Description)
File pfd.xml is used to emulate the PfdDataForApp received from a NEF/PFDF.
All three pfd content types are supported namely flowDescriptions, url and domain names. All received packets will be looked up based on the flowDescriptions, if failed to match, then url and domain names will be used for the look up. Either url or domain name matches, then the corresponding application ID will be located. The ApplicationId field currently only allows digits.
NEF PFD Management API Body:
```json
[
{
"applicationId": "string",
"pfds": [
{
"pfdId": "string",
"flowDescriptions": [
"string"
],
"urls": [
"string"
],
"domainNames": [
"string"
]
}
],
"cachingTime": "2021-04-13T07:24:32.431Z",
"pfdTimestamp": "2021-04-13T07:24:32.431Z",
"partialFlag": true
}
]
```
pdf.xml Sample:
```xml
```
NOTE:Pure FD(只配置一个 FD)的场景中,只需要 permit out 就可以了;而其余的场景就配置 permit in,out 是多余的。
- flowDescriptions
```xml
```
- urls:可以在 UPF trace log 的 hs start 上面,有 正则表达式的打印。
```xml
```
- domainNames:FD 和 DN 是 and 的关系,只要数据不是属于该 DN,就会阻断该 SDF。
```xml
```
NOTE:FD + URL 的 pfd,只要配置 in 即可,out 是多余的。
## fr.xml (Framed Routing)
Framed Routing,称为:后路由、帧路由或批量路由,即:UE 后面的路由(IP routes behind the UE)。
### 应用场景
在工业制造领域,5G 移动网络服务的 UE 是各种类型的设备,比如:监控摄像头、机械臂、AGV 自动引导车、平板终端、手机终端等。其中一些 UE 载有 5G 模组可直接接入 5G 蜂窝网络,而不具备 5G 模组的 UE 只能通过 5G CPE(Customer Premise Equipment,客户前置设备)来接入 5G 网络。通常的,5GC 只会为 CPE 分配一个 IP 地址,而接入 CPE 的 UE 则通过 CPE 内部实现的 NAT 功能与 5GC 进行通信。在该场景中,这些 UE 的 IP 地址及其唯一标识对于 5GC 而言都是完全不感知的,导致了 5GC 无法对工厂设备进行直接管理。
### 实现原理
Framed Routing 用于支持处于 UE(e.g. CPE)后面的 IP 网络,使得在单个 PDU Session 中,UPF 可以完成对 UE 后面的 IPv4 地址池或 IPv6 前缀范围的路由转发。
1. 一方面,支持 Framed Routing 的 5GC 可以在 UDM 里配置 Frame Routing Parameters(连接到某个 UE(e.g. CPE)上的 Behind UE 的 IP Pool),并在 IP 类型 PDU Session 的辅助身份认证过程中由 UDM 提供给 SMF,再由 SMF 将 Behind UE IP Pool 发送给 UPF。UPF 会自动配置相关的 IP 路由,使得 PDU Session 中的、DL dstIP 处于该 Behind UE IP Pool 的数据报文可以正常转发出去。NOTE:SMF 会在 PFCP Association Request/Response message 中检查 UP features 来确定 UPF 是否支持 Frame Routing,若支持,则会携带 supported FRRT tag。如果 UPF 支持 Frame Routing,那么 Frame Routing parameters 将在 PFCP Session Establishment Request 期间由 SMF 提供给 UPF。
2. 另一方面,Framed Routing 参数(Behind UE IP Pool)传递给 UE 的方式有两种:
1. (标准做法)通過 Secondary Authentication(双重认证)时,UE 从 Access Request procedure 中获得,再分配给 IP network behind the UE。
2. (Workaround 做法)手动的将 CPE 的 VLAN IP Pool 配置成与 5GC 的 Framed Routing 参数保持一致。CPE 会从 VLAN IP Pool 中分配 IP 给该 UE 后面的 UEs。
**NOTE**:CPE 中的 NAT 和 Routing Behind MS 是互斥的,所以上述方式 2 是一种 Workaround 的方式。因为该功能的考察点在 UPF 的路由转发配置上,UPF 可以解析 SMF 下发的 FR IE(the Frame-Routing IE and Framed-IPv6-Route IEs in PDRs to describe framed routes associated to the PDU session.)并配置相应的 IP 路由规则即可。
UPF 根据配置的 IP 路由规则:
- **对于 UL**:根据 UL PDR 中的 Framed-Route IE or Framed-IPv6-Route IE 匹配 UL SDF 的 source IP address 或 IP address of IPv6 prefix。
- **对于 DL**:根据 DL PDR 中的 Framed-Route IE or Framed-IPv6-Route IE 匹配 DL SDF 的 destination IP address 或 IP address of IPv6 prefix。
### 配置方式
当前实现的 Framed Routing,SMF 根據 SMF fr.xml 是否有配置 IMSI 的 FR 参数,以及 UPF 是否支持 FR,来判斷是否要把 FR IE 下发到 UPF。
1. 修改 smf.conf 添加后路由配置文件路径。
```xml
local-fr-filename="./xml/fr.xml"
```
2. 添加后路由配置文件。
```xml
```
**参数清单**:
- **frameRouting**:指定了 UE 的路由方式。
- 0:None
- 1:Send routing packets
- 2:Listen for routing packets
- 3:Send and Listen
- **framedRouteV4**:定义了 UE 的 IP 路由,支持 CIDR 格式,例如:192.168.1.0/24,如果存在多个 IP 路由,则使用 `,` 分隔。
- **framedRouteV6**:同上,IPv6 类型。
### 使用示例
#### Routing Behind MS (Routing Behind the Mobile Station)

**功能描述**:behind MS allows a UE device (Phone, Wi-Fi Box, CPE ...) to act as a router (Tethering) for an IP network behind the UE device. The routing behind the Mobile Station(MS) feature enables the routing of packets to IPv4 addresses that do not belong to the PDN Session (the MS), but exist behind it. The network address of the destination can be different than the Mobile Station address.
**优势**:Network expansion.
**应用场景**:An operator can extend its mobile data network by deploying 3G/4G WIFI BOX in the wide areas like Airports, cafe, Hypermarket, attraction park, ZOO, restaurant, Club etc...)
#### HUAWEI CPE 开启 Routing Behind MS
**Prerequisites**:
- Install EPC and CPE and commission them so that they are ready to be connected.
- Configure the NAT Settings on EPC.
**Background Information**: NAT and Routing Behind MS are mutually exclusive features. On the CPE's web interface, select Enable under NAT and click Submit to enable NAT or deselect Enable under NAT and click Submit to enable Routing Behind MS.
**Procedure**:
1. Log in to the WebUI, Please refer to the procedure 4.1 Log in to the WebUI
2. Go to Security > NAT. Deselect Enable under NAT and click Submit to enable Routing Behind MS.
## sm-policy-data.xml
This file has been voided, but we use it in the case of no external PCF. However, in this setting, only one default flow can be triggered. All additional flows could only be installed dynamically thru PCF, therefore without PCF, only single default flow is allowed when no external PCF is used.
### Embedded PCF
如果 SMF 没有连接 PCF,那么 SMF 可以使用本地的 sm-policy-data.xml 配置文件,即:Embedded PCF。该场景中,sm-policy-data.xml 中定义的 Rules 只能被激活,而不能被修改,因此不允许 UE/NW 侧触发的修改。
在 PDU Session 建立期间,SMF 必须将至少一个 Session Rule 和可选的一些 PCC Rules 绑定到 PDU Session。sm-policy-data.xml 中定义的策略将发送给 UPF。SMF 将此 PDU Session 的信息(e.g. DNN、TAC 和 SSC)与 Session Rule 匹配。之后,SMF 将执行所选 Session Rule 以及 PCC 列表中的其他 PCC Rule。
### External PCF
External PCF 模式中,SMF 会通过 N7 参考点向 PCF 请求 PCC Rule。PCF 会通过 PDU Session 中包含的特征参数(e.g. SmPolicyDecision:sst="1", sd="", dnn="default", and tac="any")来匹配得到应该进行授权的 Session Rule 和 PCC Rule。
在 “预定义规则激活” 场景中,SMF sm-policy-data.xml 将会被作为 SMF 本地的(静态)预定义规则配置文件,内含的静态规则只能由 PCF 进行激活或去激活。所以,在 SMF sm-policy-data.xml 中的 pccId 命名的前缀必须使用 “pre_”。
**NOTE 1**:如果 SMF smf.conf 不包含以下选项,或者以下选项没有配置则表示 SMF 使用 Embedded PCF 模式,反正使用 External PCF 模式。
```bash
local-pcf-client-ipv4="192.168.70.53"
local-pcf-client-port="2133"
local-pcf-notifServer-ipv4="192.168.70.53"
local-pcf-notifServer-port="8013"
pcf-ipv4="192.168.70.54"
pcf-port="7081"
```
**NOTE 2**:无论是 Embedded PCF 还是 External PCF 模式,如果在本地的 SmPolicyDecision 中找不到匹配的 Session Rule,那么 SMF 将尝试匹配 UDM 中的 Session Rule。
```xml
```
- defQosFlowIndication:用于描述这个 QoSList 对应的 QoS Flow 是不是一个 Default QoS Flow。若为 true,那么该 PCC Rule 的 QoS 就会把 Session Rule 的 QoS 覆盖掉。例如:Session Rule 通常是 non-GBR 的 Flow,GBR 参数只能在 PCC Rule 內存在,这时就需要使用到这个参数来 overwrite Session Rule 的內容。
## sm-charge.xml(Charging)
`` 与 `` 不同:
- pccrule-binding 用于 SMF Embedded PCF 的场景,这种场景下 SMF 将要授权的 URR 就从 pccrule-binding 下的 PCC rule 获取。
- pccrules 用于 External PCF 场景,External PCF 下发的 predefine rule name 为 pccrules 内定义的 rule 时,则从 pccrules 获取该PCC Rule 的 URR。
- 在 UPF Predefined Rule 的场景中,不需要配置 pccrules 或 pccrule-binding。
pduVolumeLimit:单位 Byte,104857600 == 100MB。
pduTimeLimit:单位 s。
`` 的时间要晚于当前时间。到达指定时间后,自动触发费率切换。
```xml
```
## pcf.xml (PCC Rule)
File pcf.xml is used to emulate the SmPolicyDecision from a PCF.
## udm.xml
File udm.xml is used to emulate the UDM.
## TS
问题 1:UE 业务请求失败。
```
UID466920100001101 Failed to get FSEID, psa PFCP Session Establishment, message:
-------------------------------------------------
Version=1
MP BIT=0
S BIT=1
MessageType=Pfcp_Session_Establishment_Rsp (51)
Length=33
SEID=65
Sequence Number=1281
MessagePriority0
MSID=317101356768825601
|--IE: NodeID (Type=NodeID(60) Value=00 c0 a8 28 5a
|--IE: Cause (Type=Cause(19) Value=73
|--IE: FailedRuleID (Type=FailedRuleID(114) Value=00 30 02
-------------------------------------------------
```
解决 1:UPF 的预定义规则没有绑定 DNN。
问题 2:UE 业务请求失败。
```
UID466920100001101 not found UP by tac:81
UID466920100001101 selectUP fail.
UID466920100001101 UP selection failed!
```
分析 2:upf.xml 配置有误。