【Free5GC】test.sh脚本测试流程

1、test.sh测试的IP地址规划和参考拓扑

free5gc代码整体架构参考的是SBA 5GC架构,如下所示,free5gc涉及到的网元有AMF、SMF、UPF、AUSF、N3IWF、NRF、NSSF、PCF、UDM,各网元功能可以参考文章末尾解释说明:

【Free5GC】test.sh脚本测试流程_第1张图片

SBA 5GC架构图

搭建test.sh测试环境需要创建一个虚拟机,名称为free5gc,作为5GC核心网及(R)AN,用于部署free5gc程序并启动test.sh测试程序,具体IP配置如下图和配置文件所示:

【Free5GC】test.sh脚本测试流程_第2张图片

报文中的IP地址规划如下

网元 接口 IP地址 端口号
AMF N2 127.0.0.1 38412
AMF SBI 127.0.0.18 8000
AUSF SBI 127.0.0.9 8000
NRF SBI 127.0.0.10 8000
NSSF SBI 127.0.0.31 8000
PCF SBI 127.0.0.7 8000
UDM SBI 127.0.0.3 8000
UDR SBI 127.0.0.4 8000
UDR MongoDB 127.0.0.1 27017
SMF SBI 127.0.0.2 8000
SMF N4 10.200.200.1 8805
UPF N4 10.200.200.101 8805
UPF N3 10.200.200.102 2152
UPF UE地址池 60.60.0.0/16 N/A

1.1、AMF配置文件

路径为free5gc/config/amfcfg.yaml

info:
  version: 1.0.2
  description: AMF initial local configuration

configuration:
  amfName: AMF # the name of this AMF
  ngapIpList:  # the IP list of N2 interfaces on this AMF
    - 127.0.0.1
  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
    port: 8000 # port used to bind the service
  serviceNameList: # the SBI services provided by this AMF, refer to TS 29.518
    - namf-comm # Namf_Communication service
    - namf-evts # Namf_EventExposure service
    - namf-mt   # Namf_MT service
    - namf-loc  # Namf_Location service
    - namf-oam  # OAM service
  servedGuamiList: # Guami (Globally Unique AMF ID) list supported by this AMF
    #  = 
    - plmnId: # Public Land Mobile Network ID,  = 
        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)
  supportTaiList:  # the TAI (Tracking Area Identifier) list supported by this AMF
    - plmnId: # Public Land Mobile Network ID,  = 
        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)
  plmnSupportList: # the PLMNs (Public land mobile network) list supported by this AMF
    - plmnId: # Public Land Mobile Network ID,  = 
        mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9)
        mnc: 93 # 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
  security:  # NAS security parameters
    integrityOrder: # the priority of integrity algorithms
      - NIA2
      # - NIA0
    cipheringOrder: # the priority of ciphering algorithms
      - NEA0
      # - NEA2
  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
  networkFeatureSupport5GS: # 5gs Network Feature Support IE, refer to TS 24.501
    enable: true # append this IE in Registration accept or not
    imsVoPS: 0 # IMS voice over PS session indicator (uinteger, range: 0~1)
    emc: 0 # Emergency service support indicator for 3GPP access (uinteger, range: 0~3)
    emf: 0 # Emergency service fallback indicator for 3GPP access (uinteger, range: 0~3)
    iwkN26: 0 # Interworking without N26 interface indicator (uinteger, range: 0~1)
    mpsi: 0 # MPS indicator (uinteger, range: 0~1)
    emcN3: 0 # Emergency service support indicator for Non-3GPP access (uinteger, range: 0~1)
    mcsi: 0 # MCS indicator (uinteger, range: 0~1)
  t3502Value: 720  # timer value (seconds) at UE side
  t3512Value: 3600 # timer value (seconds) at UE side
  non3gppDeregistrationTimerValue: 3240 # timer value (seconds) at UE side
  # retransmission timer for paging message
  t3513:
    enable: true     # true or false
    expireTime: 6s   # default is 6 seconds
    maxRetryTimes: 4 # the max number of retransmission
  # retransmission timer for NAS Deregistration Request message
  t3522:
    enable: true     # true or false
    expireTime: 6s   # default is 6 seconds
    maxRetryTimes: 4 # the max number of retransmission
  # retransmission timer for NAS Registration Accept message
  t3550:
    enable: true     # true or false
    expireTime: 6s   # default is 6 seconds
    maxRetryTimes: 4 # the max number of retransmission
  # retransmission timer for NAS Authentication Request/Security Mode Command message
  t3560:
    enable: true     # true or false
    expireTime: 6s   # default is 6 seconds
    maxRetryTimes: 4 # the max number of retransmission
  # retransmission timer for NAS Notification message
  t3565:
    enable: true     # true or false
    expireTime: 6s   # default is 6 seconds
    maxRetryTimes: 4 # the max number of retransmission

# the kind of log output
  # debugLevel: how detailed to output, value: trace, debug, info, warn, error, fatal, panic
  # ReportCaller: enable the caller report or not, value: true or false
logger:
  AMF:
    debugLevel: info
    ReportCaller: false
  NAS:
    debugLevel: info
    ReportCaller: false
  FSM:
    debugLevel: info
    ReportCaller: false
  NGAP:
    debugLevel: info
    ReportCaller: false
  Aper:
    debugLevel: info
    ReportCaller: false
  PathUtil:
    debugLevel: info
    ReportCaller: false
  OpenApi:
    debugLevel: info
    ReportCaller: false

1.2、SMF配置文件

路径为free5gc/config/test/smfcfg.test.yaml

info:
  version: 1.0.2
  description: SMF initial local configuration

configuration:
  smfName: SMF
  sbi:
    scheme: http
    registerIPv4: 127.0.0.2 # IP used to register to NRF
    bindingIPv4: 127.0.0.2 # IP used to bind the service
    port: 8000
    tls:
      key: free5gc/support/TLS/smf.key
      pem: free5gc/support/TLS/smf.pem
  serviceNameList:
    - nsmf-pdusession
    - nsmf-event-exposure
    - nsmf-oam
  snssaiInfos:
    - sNssai:
        sst: 1
        sd: 010203
      dnnInfos:
        - dnn: internet
          dns: 
            ipv4: 8.8.8.8
            ipv6: 2001:4860:4860::8888
    - sNssai:
        sst: 1
        sd: 112233
      dnnInfos:
        - dnn: internet
          dns: 
            ipv4: 8.8.8.8
            ipv6: 2001:4860:4860::8888
  pfcp:
    addr: 10.200.200.1
  userplane_information:
    up_nodes:
      gNB1:
        type: AN
            an_ip: 192.188.2.3
      UPF:
        type: UPF
        node_id: 10.200.200.101
        sNssaiUpfInfos:
          - sNssai:
              sst: 1
              sd: 010203
            dnnUpfInfoList:
              - dnn: internet
                pools:
                  - cidr: 60.60.0.0/16
          - sNssai:
              sst: 1
              sd: 112233
            dnnUpfInfoList:
              - dnn: internet
                pools:
                  - cidr: 60.61.0.0/16
        interfaces:
          - interfaceType: N3
            endpoints:
              - 10.200.200.102
            networkInstance: internet
    links:
      - A: gNB1
        B: UPF
  nrfUri: http://127.0.0.10:8000
  locality: area1

logger:
  SMF:
    debugLevel: info
    ReportCaller: false
  NAS:
    debugLevel: info
    ReportCaller: false
  NGAP:
    debugLevel: info
    ReportCaller: false
  Aper:
    debugLevel: info
    ReportCaller: false
  PathUtil:
    debugLevel: info
    ReportCaller: false
  OpenApi:
    debugLevel: info
    ReportCaller: false
  PFCP:
    debugLevel: info
    ReportCaller: false

1.3、UPF配置文件

路径为free5gc/NFs/upf/build/config/upfcfg.test.yaml

info:
  version: 1.0.0
  description: UPF configuration

configuration:
  # the kind of log output
    # debugLevel: how detailed to output, value: trace, debug, info, warn, error, fatal, panic
    # ReportCaller: enable the caller report or not, value: true or false
  debugLevel: info
  ReportCaller: false

  # The IP list of the N4 interface on this UPF (Can't set to 0.0.0.0)
  pfcp:
    - addr: 10.200.200.101

  # 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
  gtpu:
    - addr: 10.200.200.102
    # [optional] gtpu.name
    # - name: upf.5gc.nctu.me
    # [optional] gtpu.ifname
    # - ifname: gtpif

  # The DNN list supported by UPF
  dnn_list:
    - dnn: internet # Data Network Name
      cidr: 60.60.0.0/24 # Classless Inter-Domain Routing for assigned IPv4 pool of UE
      # [optional] dnn_list[*].natifname
      # natifname: eth0

1.4、( R )AN配置文件

(R)AN各个接口IP地址在代码为常量,不可以通过配置文件更改,代码文件路径 free5gc/test/registration_test.go

【Free5GC】test.sh脚本测试流程_第3张图片

【Free5GC】test.sh脚本测试流程_第4张图片

2、执行test.sh

1)、配置文件完成之后,首先在虚拟机free5GC上启动测试程序test.sh,以注册为例,如下:

【Free5GC】test.sh脚本测试流程_第5张图片

2)、执行成功最后面会出现PASS

【Free5GC】test.sh脚本测试流程_第6张图片

3、抓包分析

3.1、抓包步骤

1)、首先执行tcpdump -i any -w TestRegistration.pcap监听抓取所有网卡报文

2)、切换到free5gc目录下,执行./test.sh TestRegistration

3)、执行成功后,停止抓包,将抓取的TestRegistration.pcap报文通过wireshark打开,并筛选出ngappfcpgtp协议

4)、进行分析。

3.2、报文分析

TestRegistration.pcap报文

【Free5GC】test.sh脚本测试流程_第7张图片

【Free5GC】test.sh脚本测试流程_第8张图片

【Free5GC】test.sh脚本测试流程_第9张图片

总结

(R)AN网元各个接口的IP为代码固定写死的,不通过配置文件配置

UPF网元各个接口的IP可通过free5gc/NFs/upf/build/config/upfcfg.test.yaml文件修改

SMF网元各个接口的IP可通过free5gc/config/test/smfcfg.test.yaml文件进行修改

AMF网元各个接口的IP可通过free5gc/config/amfcfg.yaml文件进行修改

参考解释:

AMF:负 责 UE(User Equipment,用 户 终 端)的 注 册、连接、访问验证授权、移动性和可达性管理,在 UE 和 SMF(Session Management function,会话管理功能) 之间提供 SM(Session Management,会话管理)消息的 传 输,UE 和 SMSF(Short Message Service Function,短 消息服务功能)之间提供 SMS(Short Message Service, 短 信 息 服 务)消 息 的 传 输,提 供 UE 和 LMF(Location Management Function,定 位 管 理 功 能)之 间 以 及 RAN (Radio Access Network,无线局域网)和 LMF 之间的位 置服务消息的传输等。

AUSF(Authentication Server Function,认证服务器 功能):负责对 3GPP 和非 3GPP 的 UE 的接入进行认证。

SMF:负责与分离的数据面交互,根据自身配置或与 PCF(Policy Control Function,策略控制功能)交互来制 定策略和流模板,为会话选择和控制 UPF 和 SSC(Session and Service Continuity,会话和服务连续性)模式,管理 会话的建立、更新和释放以及维护着 PDU(Protocol Data Unit,协议数据单元)会话状态、群组管理、控制和协调 UPF 的收费数据收集和流量控制等。负责 UE 的 IP 分配 管理,具备 DHCP、ARP 代理或 IPv6 邻居请求代理功能。

UPF:响应 SMF 请求,作为移动基础设施 RAN 和 DN 之间的互连点,PDU 会话锚点负责完成用户平面上 GTP-U 协议的封装和解封装、分组路由和转发、数据包 检查、QoS 流映射等网络用户面的处理。完成用户平 面部分策略规则实施,例如门控、重定向和流量转向。 为计费以及合法拦截提供用户流量收集接口以及流量 使用报告。

PCF:负责用户的策略管理和实施,包括会话的策 略、移动性策略等。

UDM(Unified Data Management,统一数据管理): 存储和管理用户数据和配置文件。

UDR(Unified Data Repository,统一数据存储库): 支持 UDM 订阅数据、PCF 策略数据和应用程序数据等 的存储和检索。

UDSF(Unstructured Data Storage Function,非 结 构 化数据存储功能):NF 可在 UDSF 中存储和检索其未在 3GPP 规范中定义其结构的非结构化数据。

NSSF(Network Slice Selection Function,网 络 切 片 选择功能):选择服务于 UE 的网络切片实例的集合。

NRF(Network Repository Function,网 络 功 能 注 册 功能):负责网络功能实例及配置文件的注册、更新、注 销,使各 NF 可以相互发现选择并通过 API 进行通信。

NEF:作 为 外 部 用 户 接 入 的 API 网 关,负 责 将 5G 网络的能力开放给外部网元,同时网络内的 NF 可通过 NEF 向其他 NF 公开功能和事件,NEF 完成网络能力的 收集、分析和重组。

N3IWFNon-3GPP InterWorking Function,非 3GPP 互通功能):负责将不可信的非 3GPP 接入网(如 Wi-Fi) 接入到 5G 核心网。UEN3IWF 建立一个 IPsec 隧道, N3IWF 分别通过 N2 接口和 N3 接口接入 5G 核心网的 控制面和用户面。

UCMF(UE radio Capability Management Function, UE 无线能力管理功能):存储 UE 无线功能 ID。AMF 可 以订阅 UCMF 获得分配的 UE 无线电功能 ID 的新值,并 在本地缓存它们。

CHF(Charging Function,计费功能):负责用户计费、 配额授信等,也支持融合的在线和离线计费 。

LMF:负责向 5GC 注册或访问的 UE 的定位所需资 源的整体调度和协调,还可以计算或验证最终位置、速度 和精度。5G 可基于无线、终端以及用户面等多种手段 提供定位能力,但定位方法因访问类型而异,定位精度也 很大一部分取决于接入网所作的增强。

SMSF:用 于 提 供 NAS(non-access-stratum,非 接 入 层)短信服务。

5G-EIR(5G-Equipment Identity Register,5G 设备身 份注册):检查 PEI(Permanent Equipment Identifier,永久 设备标识符)的状态,例如检查其是否未列入黑名单。

NWDAF(Network Data Analytics Function,网 络 数 据分析功能):NWDAF 用人工智能技术从网络功能、 OAM(Operation Administration and Maintenance,运维管 理系统)和应用层获取的数据,进行分析,以生成需要的 数据结果。NF、OAM 或 AF 可以利用 NWDAF 的分析结果进行不同的优化操作。

SCP(Service Communication Proxy,服务通信代理): 在间接通信模式下,业务功能和网络路由功能分离,NF 服务使用者通过用 SCP 使用请求的 NF。从而各 NF 可 专心于业务功能的实现,路由控制等功能统一由 SCP 来 实现。

SEPP(Security Edge Protection Proxy,安 全 边 缘 保 护代理):用于 5G 用户国际漫游,与他网运营商的 5G 互 通,负责 PLMN 间控制平面接口上的消息过滤和策略管理。

:NWDAF 用人工智能技术从网络功能、 OAM(Operation Administration and Maintenance,运维管 理系统)和应用层获取的数据,进行分析,以生成需要的 数据结果。NF、OAM 或 AF 可以利用 NWDAF 的分析结果进行不同的优化操作。

SCP(Service Communication Proxy,服务通信代理): 在间接通信模式下,业务功能和网络路由功能分离,NF 服务使用者通过用 SCP 使用请求的 NF。从而各 NF 可 专心于业务功能的实现,路由控制等功能统一由 SCP 来 实现。

SEPP(Security Edge Protection Proxy,安 全 边 缘 保 护代理):用于 5G 用户国际漫游,与他网运营商的 5G 互 通,负责 PLMN 间控制平面接口上的消息过滤和策略管理。

你可能感兴趣的:(【Free5GC】,Free5gc,5G,C,GO)