HewlettPackard / PacketRusher

High performance 5G UE/gNB Simulator and CP/UP load tester.
Apache License 2.0
109 stars 25 forks source link

[BUG] wrong gNB ID #48

Closed yoursunny closed 9 months ago

yoursunny commented 9 months ago

Describe the bug packetrusher ue command does not follow the .gnodeb.plmnlist.gnbid configuration option in its NGSetupRequest packet. Instead, it always sends gNB ID starting with "000001".

To Reproduce

  1. Create config.yml as below.
  2. Capture traffic on N2 interface.
  3. Invoke sudo ./packetrusher ue command.
  4. Analyze traffic by Wireshark.
gnodeb:
  controlif:
    ip: 172.25.200.12
    port: 9487
  dataif:
    ip: 172.25.195.12
    port: 2152
  plmnlist:
    mcc: "001"
    mnc: "01"
    tac: "000005"
    gnbid: "000008"
  slicesupportlist:
    sst: "04"
    sd: "000000" # optional, can be removed if not used
ue:
  msin: "7005554000"
  key: ad5f6ba8aaafa72e9b7132dc0ef2819e
  opc: 17e524ea73ab1877b3af891c459cf58b
  amf: "8000"
  sqn: "00000000"
  dnn: vcam
  routingindicator: "0000"
  hplmn:
    mcc: "001"
    mnc: "01"
  snssai:
    sst: 4
    sd: "000000" # optional, can be removed if not used
  integrity:
    nia0: false
    nia1: false
    nia2: true
    nia3: false
  ciphering:
    nea0: true
    nea1: false
    nea2: true
    nea3: false
amfif:
  ip: 172.25.200.10
  port: 38412
logs:
  level: 4

Expected behavior The traffic capture should have an NGSetupRequest message sent from PacketRusher gNB to the AMF. In id-GlobalRANNodeID IE of this message, the gNB should indicate itself to have gNB ID 000008.

Screenshots None.

Architecture (please complete the following information):

Log:

time="2023-12-21T16:59:06Z" level=info msg="Loaded config at: /config.yml"
time="2023-12-21T16:59:06Z" level=info msg="PacketRusher version 1.0.1"
time="2023-12-21T16:59:06Z" level=info msg=---------------------------------------
time="2023-12-21T16:59:06Z" level=info msg="[TESTER] Starting test function: Testing an ue attached with configuration"
time="2023-12-21T16:59:06Z" level=info msg="[TESTER][UE] Number of UEs: 1"
time="2023-12-21T16:59:06Z" level=info msg="[TESTER][UE] disableTunnel is false"
time="2023-12-21T16:59:06Z" level=info msg="[TESTER][GNB] Control interface IP/Port: 172.25.200.12/9487"
time="2023-12-21T16:59:06Z" level=info msg="[TESTER][GNB] Data interface IP/Port: 172.25.195.12/2152"
time="2023-12-21T16:59:06Z" level=info msg="[TESTER][AMF] AMF IP/Port: 172.25.200.10/38412"
time="2023-12-21T16:59:06Z" level=info msg=---------------------------------------
time="2023-12-21T16:59:06Z" level=info msg="[GNB] SCTP/NGAP service is running"
time="2023-12-21T16:59:06Z" level=info msg="[GNB] Initiating NG Setup Request"
time="2023-12-21T16:59:06Z" level=info msg="[GNB][SCTP] Receive message in 0 stream\n"
time="2023-12-21T16:59:06Z" level=info msg="[GNB][NGAP] Receive NG Setup Response"
time="2023-12-21T16:59:06Z" level=info msg="[GNB][AMF] AMF Name: amf.amf.5gc.mnc001.mcc001.3gppnetwork.org"
time="2023-12-21T16:59:06Z" level=info msg="[GNB][AMF] State of AMF: Active"
time="2023-12-21T16:59:06Z" level=info msg="[GNB][AMF] Capacity of AMF: 5"
time="2023-12-21T16:59:06Z" level=info msg="[GNB][AMF] PLMNs Identities Supported by AMF -- mcc: 001 mnc:01"
time="2023-12-21T16:59:06Z" level=info msg="[GNB][AMF] List of AMF slices Supported by AMF -- sst:04 sd:000000"
time="2023-12-21T16:59:07Z" level=info msg="[TESTER] TESTING REGISTRATION USING IMSI 7005554000 UE"
time="2023-12-21T16:59:07Z" level=info msg="[UE] Initiating Registration"
time="2023-12-21T16:59:07Z" level=info msg="[UE] Switched from state 0 to state 1"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][SCTP] Receive message in 1 stream\n"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][NGAP] Receive Downlink NAS Transport"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] Message without security header"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] Receive Authentication Request"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS][MAC] Authenticity of the authentication request message: OK"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS][SQN] SQN of the authentication request message: VALID"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] Send authentication response"
time="2023-12-21T16:59:07Z" level=info msg="[UE] Switched from state 1 to state 2"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][SCTP] Receive message in 1 stream\n"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][NGAP] Receive Downlink NAS Transport"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] Message with security header"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] Message with integrity and with NEW 5G NAS SECURITY CONTEXT"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] successful NAS MAC verification"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] Receive Security Mode Command"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] Type of ciphering algorithm is 5G-EA0"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] Type of integrity protection algorithm is 128-5G-IA2"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][SCTP] Receive message in 1 stream\n"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][NGAP] Receive Initial Context Setup Request"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][UE] UE Context was created with successful"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][UE] UE RAN ID 1"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][UE] UE AMF ID 1"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][UE] UE Mobility Restrict --Plmn-- Mcc: not informed Mnc: not informed"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][UE] UE Masked Imeisv: "
time="2023-12-21T16:59:07Z" level=info msg="[GNB][UE] Allowed Nssai-- Sst: [04] Sd: [000000]"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][NAS][UE] Send Registration Accept."
time="2023-12-21T16:59:07Z" level=info msg="[GNB][NGAP][AMF] Send Initial Context Setup Response."
time="2023-12-21T16:59:07Z" level=info msg="[GNB] Initiating Initial Context Setup Response"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] Message with security header"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] Message with integrity and ciphered"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] successful NAS MAC verification"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] successful NAS CIPHERING"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] Receive Registration Accept"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] UE 5G GUTI: [210 0 0 1]"
time="2023-12-21T16:59:07Z" level=info msg="[UE] Switched from state 2 to state 3"
time="2023-12-21T16:59:07Z" level=info msg="[UE] Initiating New PDU Session"
time="2023-12-21T16:59:07Z" level=info msg="[UE] Initiating New PDU Session"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][SCTP] Receive message in 1 stream\n"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][NGAP] Receive Downlink NAS Transport"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] Message with security header"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] Message with integrity and ciphered"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] successful NAS MAC verification"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] successful NAS CIPHERING"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] Receive Configuration Update Command"
time="2023-12-21T16:59:07Z" level=info msg="[UE] Initiating Configuration Update Complete"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][SCTP] Receive message in 1 stream\n"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][NGAP] Receive PDU Session Resource Setup Request"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][NGAP][UE] PDU Session was created with successful."
time="2023-12-21T16:59:07Z" level=info msg="[GNB][NGAP][UE] PDU Session Id: 1"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][NGAP][UE] NSSAI Selected --- sst: NSSAI was not selected sd: NSSAI was not selected"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][NGAP][UE] PDU Session Type: ipv4"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][NGAP][UE] QOS Flow Identifier: 1"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][NGAP][UE] Uplink Teid: 268435457"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][NGAP][UE] Downlink Teid: 1"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][NGAP][UE] Non-Dynamic-5QI: 9"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][NGAP][UE] Priority Level ARP: 2"
time="2023-12-21T16:59:07Z" level=info msg="[GNB][NGAP][UE] UPF Address: 172.25.195.5 :2152"
time="2023-12-21T16:59:07Z" level=info msg="[GNB] Initiating PDU Session Resource Setup Response"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] Message with security header"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] Message with integrity and ciphered"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] successful NAS MAC verification"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] successful NAS CIPHERING"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] Receive DL NAS Transport"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] Receiving PDU Session Establishment Accept"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] PDU session QoS RULES: [1 0 6 49 49 1 1 255 1]"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] PDU session DNN: vcam.mnc001.mcc001.gprs"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] PDU session NSSAI -- sst: 4 sd: 000"
time="2023-12-21T16:59:07Z" level=info msg="[UE][NAS] PDU address received: 10.140.0.1"
time="2023-12-21T16:59:08Z" level=info msg="[UE][GTP] Interface val7005554000 has successfully been configured for UE 10.140.0.1"
time="2023-12-21T16:59:08Z" level=info msg="[UE][GTP] You can do traffic for this UE using VRF vrf7005554000, eg:"
time="2023-12-21T16:59:08Z" level=info msg="[UE][GTP] sudo ip vrf exec vrf7005554000 iperf3 -c IPERF_SERVER -p PORT -t 9000"

Pcap: 1.pcapng.gz The relevant packet is frame 16. The relevant section is decoded as:

Item 0: id-GlobalRANNodeID
    ProtocolIE-Field
        id: id-GlobalRANNodeID (27)
        criticality: reject (0)
        value
            GlobalRANNodeID: globalGNB-ID (0)
                globalGNB-ID
                    pLMNIdentity: 00f110
                        Mobile Country Code (MCC): Unknown (001)
                        Mobile Network Code (MNC): Unknown (01)
                    gNB-ID: gNB-ID (0)
                        gNB-ID: 000001 [bit length 24, 0000 0000  0000 0000  0000 0001 decimal value 1]

Additional context This bug is caused by this line: https://github.com/HewlettPackard/PacketRusher/blob/c10560874c0bbd8241f75c5aaa44536b528e1d74/internal/common/tools/tools.go#L36 It overwrites the configured gNB ID with numbers starting with 1.

To solve this issue, I'd recommend this logic:

  1. Use the configured gNB ID for the first gNB.
  2. Increment the gNB ID from there for subsequent gNBs.
linouxis9 commented 9 months ago

Hi @yoursunny,

Very impressive to see someone from the niche green forum interested in the 5G niche ;-)

Thanks a lot for your detailed issue, the issue is indeed at the line you mentioned, I'll fix it ASAP!

Thanks and cheers, Valentin

linouxis9 commented 9 months ago

Hi @yoursunny,

PR #49 will fix your reported issue.

Thanks a lot for your report! Valentin