aligungr / UERANSIM

Open source 5G UE and RAN (gNodeB) implementation.
GNU General Public License v3.0
738 stars 309 forks source link

How to ping google using UERANSIM? #160

Open zyc1gq opened 3 years ago

zyc1gq commented 3 years ago

Now , I can establish PDU session with free5gc by UERANSIM. So, how to ping IPs like www.google.com use UERANSIM?

aligungr commented 3 years ago

Hi, this feature is currently in progress and will be completed soon.

aligungr commented 3 years ago

@zyc1gq This feature is now complete.

After successful establishment of PDU Session, UE automatically sends ping request to www.google.com. see testing.yaml for more details.

myonlystarWang commented 3 years ago

@zyc1gq This feature is now complete.

After successful establishment of PDU Session, UE automatically sends ping request to www.google.com. see testing.yaml for more details.

Wow,Real good news, I can't wait to test it out

BraedenDiaz commented 3 years ago

@aligungr @zyc1gq I am trying to achieve the same thing but using free5gc and am having some difficulties.

I am able to get a PDU session established but then get the following errors in UERANSIM immediately after:

[2020-11-18 00:03:35.059] [ERROR] [GTP] [gnb-1] TEID not found on GTP-U Uplink
[2020-11-18 00:03:38.066] [ERROR] [UE_APP] [ue-imsi-208930000000003] Ping timeout for google.com (216.58.193.142) after 3 sec no response

It should be noted that I am also getting the following errors in free5gc:

2020-11-18T00:55:27-07:00 [ERRO][AMF][Gmm] Registration Status Update Error[: server no response]
2020-11-18T00:55:27-07:00 [INFO][NRF][Discovery] Handle NFDiscoveryRequest
2020-11-18T00:55:27-07:00 [INFO][NRF][GIN] | 200 |       127.0.0.1 | GET     | /nnrf-disc/v1/nf-instances?requester-nf-type=AMF&target-nf-type=AMF |
2020-11-18T00:55:27-07:00 [ERRO][AMF][HTTP] unsupported scheme[]
.
.
.
2020-11-18T00:03:34-07:00 [ERRO][AMF][NGAP] [Build Error] DecodeString imeisv error: encoding/hex: odd length hex string

I have a feeling it may be my configuration but I am not exactly sure. I am using the following instructions and configurations from my project here.

Any help on getting a basic application running would be greatly appreciated.

aligungr commented 3 years ago

@BraedenDiaz It seems that AMF does not send a response to PDU session establishment request.

I strongly suspect that there is a bug on free5gc side regarding NGAP decoding. Could you post a pcap file related to this error?

BraedenDiaz commented 3 years ago

@aligungr

Sure thing, here you go: free5gc-ueransim.zip

I did also see some open issues with the AMF decoding on their issues page but I figured some people got it working, so I didn't know if I was doing anything wrong.

aligungr commented 3 years ago

@BraedenDiaz I think I need the logs files as well for detailed analysis. Please send them also, if you can. (Located at ./logs/*)

BraedenDiaz commented 3 years ago

@aligungr

Sure thing, here are the UERANSIM logs: logs.zip

aligungr commented 3 years ago

@BraedenDiaz

Apparently AMF does not send "Pdu Session Resource Setup Request" , but it sends "Dl Nas Transport" containing PduSessionEstablishmentAccept. But PduSessionEstablishmentAccept should be sent in "Pdu Session Resource Setup Request".

I think this is not the desired behavior. In this way gNB cannot know a PDU session has been established.

Maybe it's good to create an issue on free5gc side, so that they can discuss and possibly fix the issue.

Thanks.

ryanwwest commented 3 years ago

Hey @aligungr, I decided to add to this issue since I'm having the same problem, getting a PDU session established (and recognized by the gNB) but not being able to ping google afterwards. However, I'm using open5gs, not free5gc, so I don't think the bug Braeden mentioned applies.

In my case I get this this error from the gnb log, which seemed similar to something Braeden posted: [2021-04-27 14:52:18.899] [gtp] [error] TEID 10 not found on GTP-U Downlink. This line gets printed here but I can't figure out what config I need to change to fix it. The ping command I use is ping -I uesimtun0 google.com. I should also mention that I don't seem to be getting any sctp traffic besides heartbeats req/ack headed to my open5gs node when doing a tcpdump on the interface, so this seems confined to UERANSIM.

My gnb log:

root@pc798:~/UERANSIM# build/nr-gnb -c config/open5gs-gnb.yaml 
UERANSIM v3.1.7
[2021-04-27 14:51:17.511] [sctp] [info] Trying to establish SCTP connection... (10.10.1.2:38412)
[2021-04-27 14:51:17.516] [sctp] [info] SCTP connection established (10.10.1.2:38412)
[2021-04-27 14:51:17.516] [sctp] [debug] SCTP association setup ascId[4]
[2021-04-27 14:51:17.516] [ngap] [debug] Sending NG Setup Request
[2021-04-27 14:51:17.517] [ngap] [debug] NG Setup Response received
[2021-04-27 14:51:17.517] [ngap] [info] NG Setup procedure is successful
[2021-04-27 14:51:40.671] [rls] [debug] New UE signal detected, total [1] UEs in coverage
[2021-04-27 14:51:40.673] [rrc] [info] RRC Setup for UE[1]
[2021-04-27 14:51:40.674] [ngap] [debug] Initial NAS message received from UE[1]
[2021-04-27 14:51:40.693] [ngap] [debug] Initial Context Setup Request received
[2021-04-27 14:51:40.911] [ngap] [info] PDU session resource(s) setup for UE[1] count[1]
[2021-04-27 14:52:18.899] [gtp] [error] TEID 10 not found on GTP-U Downlink
<this message repeats every time the ping tries again; TEID number changes on different runs>

My ue log:

root@pc798:~/UERANSIM# build/nr-ue -c config/open5gs-ue.yaml 
UERANSIM v3.1.7
[2021-04-27 14:51:40.671] [nas] [info] UE switches to state [MM-DEREGISTERED/PLMN-SEARCH]
[2021-04-27 14:51:40.673] [rls] [debug] Coverage change detected. [1] cell entered, [0] cell exited
[2021-04-27 14:51:40.673] [nas] [info] Serving cell determined [UERANSIM-gnb-901-70-1]
[2021-04-27 14:51:40.673] [nas] [info] UE switches to state [MM-DEREGISTERED/NORMAL-SERVICE]
[2021-04-27 14:51:40.673] [nas] [debug] Sending Initial Registration
[2021-04-27 14:51:40.673] [nas] [info] UE switches to state [MM-REGISTER-INITIATED/NA]
[2021-04-27 14:51:40.673] [rrc] [debug] Sending RRC Setup Request
[2021-04-27 14:51:40.673] [rrc] [info] RRC connection established
[2021-04-27 14:51:40.674] [nas] [info] UE switches to state [CM-CONNECTED]
[2021-04-27 14:51:40.684] [nas] [debug] Security Mode Command received
[2021-04-27 14:51:40.684] [nas] [debug] Selected integrity[2] ciphering[0]
[2021-04-27 14:51:40.693] [nas] [debug] Registration accept received
[2021-04-27 14:51:40.693] [nas] [info] UE switches to state [MM-REGISTERED/NORMAL-SERVICE]
[2021-04-27 14:51:40.693] [nas] [info] Initial Registration is successful
[2021-04-27 14:51:40.693] [nas] [info] Initial PDU sessions are establishing [1#]
[2021-04-27 14:51:40.693] [nas] [debug] Sending PDU Session Establishment Request
[2021-04-27 14:51:40.911] [nas] [debug] PDU Session Establishment Accept received
[2021-04-27 14:51:40.911] [nas] [info] PDU Session establishment is successful PSI[1]
[2021-04-27 14:51:40.926] [app] [info] Connection setup for PDU session[1] is successful, TUN interface[uesimtun0, 10.45.0.4] is up.

gNB config:

mcc: '901'          # Mobile Country Code value
mnc: '70'           # 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: 10.10.1.1   # gNB's local IP address for Radio Link Simulation (Usually same with local IP)
ngapIp: 10.10.1.1   # gNB's local IP address for N2 Interface (Usually same with local IP)
gtpIp: 10.10.1.1    # gNB's local IP address for N3 Interface (Usually same with local IP)

# List of AMF address information
amfConfigs:
  - address: 10.10.1.2
    port: 38412

# List of supported S-NSSAIs by this gNB
slices:
  - sst: 1

# Indicates whether or not SCTP stream number errors should be ignored.
ignoreStreamIds: true

And finally UE config:

# IMSI number of the UE. IMSI = [MCC|MNC|MSISDN] (In total 15 or 16 digits)
supi: 'imsi-901700000000001'
# Mobile Country Code value of HPLMN
mcc: '901'
# Mobile Network Code value of HPLMN (2 or 3 digits)
mnc: '70'

# Permanent subscription key
key: '465B5CE8B199B49FAA5F0A2EE238A6BC'
# Operator code (OP or OPC) of the UE
op: 'E8ED289DEBA952E4283B54E88E6183CA'
# This value specifies the OP type and it can be either 'OP' or 'OPC'
opType: 'OPC'
# Authentication Management Field (AMF) value
amf: '8000'
# IMEI number of the device. It is used if no SUPI is provided
imei: '356938035643803'
# IMEISV number of the device. It is used if no SUPI and IMEI is provided
imeiSv: '4370816125816151'

# List of gNB IP addresses for Radio Link Simulation
gnbSearchList:
  - 10.10.1.1

# Initial PDU sessions to be established
sessions:
  - type: 'IPv4'
    apn: 'internet'
    slice:
      sst: 1
    emergency: false

# Configured NSSAI for this UE by HPLMN
configured-nssai:
  - sst: 1

# Default Configured NSSAI for this UE
default-nssai:
  - sst: 1

# Supported encryption algorithms by this UE
integrity:
  IA1: true
  IA2: true
  IA3: true

# Supported integrity algorithms by this UE
ciphering:
  EA1: true
  EA2: true
  EA3: true

# Integrity protection maximum data rate for user plane
integrityMaxRate:
  uplink: 'full'
  downlink: 'full'
aligungr commented 3 years ago

Hi @ryanwwest

I'll ask you if you can provide a PCAP file, and please UE and gNB log files again in the matter of this PCAP file.

--

By the way for the SCTP issue you mentioned:

Usually there is no SCTP message after a PDU session establishment, and it is normal. There is no problem if you can see the other SCTP messaging in the beginning (before the PDU session establishment)

However if you are unable to see any SCTP packet (even when gNB works and UE registers to the network) then we should suspect some other errors, but please confirm this case.

Regards

ryanwwest commented 3 years ago

Thanks for your help @aligungr and sorry for the delay.

Here's a zip of the logs, configs, and pcap file (plus another standalone pcap file with -vv flag on tcpdump—I wasn't sure what would be helpful): ueransim-debugging.zip.

You can maybe tell from the logs that I first start nr-gnb, then nr-ue, then run ping -I uesimtun0 google.com. The end of the cap files have some GTP-encapsulated ICMP ping requests from running the ping command:

image

Where the 74.213.193.65 is google.com, and 10.45.0.4 is (I think) the IP address assigned by the Open5GS UPF function after the PDU session is established. I'm very fuzzy on how this random IP address 10.45.0.4 can just be assumed at the UPF (that was a default IP address) so perhaps that could be part of the problem. I'm looking through the PCAP files myself to try to understand them but don't yet have a better idea than this.

There is SCTP packet data transfer and acks between the two hosts (10.10.1.1 for UERANSIM and 10.10.1.2 for Open5GS) for setting up gnb and UE so that part seems good.

aligungr commented 3 years ago

@ryanwwest

For the GTP packets, both source and destinations refer to the same address (10.10.1.1).

Probably UPF IP address is misconfigured in Open5GS side.

Please change GTP-U IP address value from 10.10.1.1 to 10.10.1.2 in the Open5GS UPF config file.

ryanwwest commented 3 years ago

@aligungr Thank you for pointing this out, I had not noticed it. The issue did turn out to be open5gs configuration. Thanks for the help!

subhakr commented 1 year ago

@zyc1gq This feature is now complete.

After successful establishment of PDU Session, UE automatically sends ping request to www.google.com. see testing.yaml for more details.

Hi Ali, May i know where is that code in UE . pls help me to get that code.

thanks/subha