aligungr / UERANSIM

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

Initial Registration failed [ILLEGAL_UE] after git pull #333

Open hw-zerozero opened 3 years ago

hw-zerozero commented 3 years ago

Hi, This may be a "new version has different config params" issue, look forward to your feedback Thanks.

My previous working version was v3.1.7 After git pull, the previous v3.1.7 successful Initial Reg is now failing (when executing the nr-ue)

[2021-05-26 17:06:57.846] [nas] [info] UE switches to state [CM-CONNECTED]
[2021-05-26 17:06:57.851] [nas] [error] Initial Registration failed [ILLEGAL_UE]
[2021-05-26 17:06:57.851] [nas] [info] UE switches to state [5U3-ROAMING-NOT-ALLOWED]
[2021-05-26 17:06:57.851] [nas] [info] UE switches to state [MM-DEREGISTERED/NA]
[2021-05-26 17:06:57.851] [nas] [info] UE switches to state [MM-DEREGISTERED/NO-SUPI]
...

The failure pcap (attached) shows that the UE MSIN which is 888888888 In the NGAP/NAS-5GS InitialUEMessage, Registration request, the MSIN has been encoded with an extra "0" i.e. 8888888880

After some investigation and debug o/p added to ie6.cpp (also attached) The IE5gsMobileIdentity::Encode() was OK But IE5gsMobileIdentity::Decode() was overwriting the UE ID properties and adding the extra "0"

Added to the attached ie6.cpp is the line of code (line 397) I temporarily hacked in, to fix the Reg Fail issue For your amusement here is the debug o/p from ie6.cpp

engineering@Ubuntu-20:~/UERANSIM/build$ sudo ./nr-ue -c ../config/n2test-ue.yaml
UERANSIM v3.1.9
[2021-05-26 17:06:57.842] [nas] [info] UE switches to state [MM-DEREGISTERED/PLMN-SEARCH]
[2021-05-26 17:06:57.842] [rls] [debug] New UE signal detected, total [1] UEs in coverage
[2021-05-26 17:06:57.844] [rls] [debug] Coverage change detected. [1] cell entered, [0] cell exited
[2021-05-26 17:06:57.844] [nas] [info] Serving cell determined [UERANSIM-gnb-200-111-1]
[2021-05-26 17:06:57.844] [nas] [info] UE switches to state [MM-DEREGISTERED/NORMAL-SERVICE]
[2021-05-26 17:06:57.844] [nas] [debug] Sending Initial Registration
[2021-05-26 17:06:57.844] [nas] [info] UE switches to state [MM-REGISTER-INITIATED/NA]
[2021-05-26 17:06:57.844] [nas] [error] HAW generateSuci 888888888
HAW Encode() schemeOutput 888888888
HAW Decode() schemeOutput 8888888880
HAW Encode() schemeOutput 8888888880
[2021-05-26 17:06:57.845] [rrc] [debug] Sending RRC Setup Request
[2021-05-26 17:06:57.845] [rrc] [info] RRC Setup for UE[15]
[2021-05-26 17:06:57.845] [rrc] [info] RRC connection established
[2021-05-26 17:06:57.845] [ngap] [debug] Initial NAS message received from UE[15]
[2021-05-26 17:06:57.846] [nas] [info] UE switches to state [CM-CONNECTED]
[2021-05-26 17:06:57.851] [nas] [error] Initial Registration failed [ILLEGAL_UE]
[2021-05-26 17:06:57.851] [nas] [info] UE switches to state [5U3-ROAMING-NOT-ALLOWED]
[2021-05-26 17:06:57.851] [nas] [info] UE switches to state [MM-DEREGISTERED/NA]
[2021-05-26 17:06:57.851] [nas] [info] UE switches to state [MM-DEREGISTERED/NO-SUPI]
[2021-05-26 17:06:58.054] [ngap] [debug] UE Context Release Command received
[2021-05-26 17:06:58.055] [rrc] [info] Releasing RRC connection for UE[15]
[2021-05-26 17:06:58.055] [rrc] [debug] RRC Release received
[2021-05-26 17:06:58.056] [nas] [info] UE switches to state [CM-IDLE]
^Cengineering@Ubuntu-20:~/UERANSIM/build$ [2021-05-26 17:07:07.504] [rls] [debug] Signal lost detected for UE[15]
[2021-05-26 17:07:07.504] [ngap] [debug] Sending UE Context release request (NG-RAN node initiated)
[2021-05-26 17:07:07.504] [ngap] [error] UE context not found with id: 15

config files attached in zip

Reg_Fail.zip

aligungr commented 3 years ago

@hw-zerozero

~Your supi: 'imsi-200111888888888' value in the UE config seems incorrect.~ ~IMSI must be either 15 or 16 digits. More specifically,~ ~If MNC is 2-digit then IMSI must be 15-digit,~ ~If MNC is 3-digit then IMSI must be 16-digit~ ~In your case IMSI number is still 15-digit but it should be 16-digit. (Since the MNC is 3-digit)~

UPDATE: Possibly there is a bug in our IMSI encoding in NAS messages, I'll try to check this

harminderharrysingh commented 3 years ago

Hi @aligungr ,

Is there any specific use-case where IMSI could be 16-digit?

With reference to spec 23.003-v16.03.00 - Section 2.2: (https://www.etsi.org/deliver/etsi_ts/123000_123099/123003/16.03.00_60/ts_123003v160300p.pdf), IMSI is written to be of "not more than 15-digits".

image

aligungr commented 3 years ago

@harminderharrysingh

My mistake, yes IMSI cannot be more than 15 digits. That was a ridiculous failure.

Thanks for the remind.

aligungr commented 3 years ago

This issue should be fixed now, you can try again with the latest code.