I can not capture the last UE ID that is generated by UERAMSIN during a simulation

Currently, I am using two virtual machines (VM) to simulate UEs behaviour, the first VM has the control plane, and the second one has GNb/UERAMSIN. I am registering some UEs simultaneously using multiprocessing techniques in python and bash script (let’s say 20 UEs at the same time). Immediately when I trigger the registration of each UE, I need to capture the last UE ID that is generated by UERAMSIN during the simulation. Theoretically, these UE IDs are generated and assigned sequentially (1,2,3,4……) using ascending order. Therefore, I used the command “nr-cli UERANSIM-gnb-208-93-1 -e ue-list”, which displays the generated UEIDs in a descendent order, to read the first line of its output and save it in a txt file with the UE’s IMSI
The problem in this scenario using multiprocessing techniques to register several UEs simultaneously is that when I read the last UE ID generated by UERANSIM , I get the same value for all the UEs that are being registered. Consequently, I can not know or determine which will be the UE ID for each UE

Could you help me with this issue?

Hi,
Could you provide python script and detailed set up?

Hello JimmyMatrix.

Thanks for your help.

This is the python code:

from multiprocessing import Process

processes = []
UEs=[“ue100.yaml”,“ue101.yaml”,“ue102.yaml”,“ue103.yaml”,“ue104.yaml”,“ue105.yaml”,“ue106.yaml”,“ue107.yaml”,“ue108.yaml”,“ue109.yaml”]
for ue in UEs:
print("==========process number==============>",i,ue)
p = Process(target=run_command, args=([‘bash’, ‘./registration.sh’, ue],))
processes.append§
p.start()
time.sleep(1)

registration.sh is called from python: It is its code:

sudo $HOME/UERANSIM/build/nr-ue -c $HOME/UERANSIM/config/ue$1.yaml -n 1
textfile=“ueidlist.txt”
$HOME/UERANSIM/build/nr-cli UERANSIM-gnb-208-93-1 -e ue-list > $textfile

val=$(head -n 1 $textfile)

find="- ue-id: "

replace=""
ueid=${val//$find/$replace}
echo “imsi-208930000000$1,$ueid” >> ue$1.txt

and this is one example of a yaml file configuration. (it is the same for all UEs, the only difference with the rest one is the supi value)

IMSI number of the UE. IMSI = [MCC|MNC|MSISDN] (In total 15 digits)

supi: ‘imsi-208930000000100’

Mobile Country Code value of HPLMN

mcc: ‘208’

Mobile Network Code value of HPLMN (2 or 3 digits)

mnc: ‘93’

Permanent subscription key

key: ‘8baf473f2f8fd09487cccbd7097c6862’

Operator code (OP or OPC) of the UE

op: ‘8e27b6af0e692e750f32667a3b14605d’

This value specifies the OP type and it can be either ‘OP’ or ‘OPC’

opType: ‘OP’

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:

  • 129.192.83.238 #127.0.0.1

UAC Access Identities Configuration

uacAic:
mps: false
mcs: false

UAC Access Control Class

uacAcc:
normalClass: 0
class11: false
class12: false
class13: false
class14: false
class15: false

Initial PDU sessions to be established

sessions:

  • type: ‘IPv4’
    apn: ‘internet’
    slice:
    sst: 0x01
    sd: 0x010203

Configured NSSAI for this UE by HPLMN

configured-nssai:

  • sst: 0x01
    sd: 0x010203

Default Configured NSSAI for this UE

default-nssai:

  • sst: 1
    sd: 1

Supported integrity algorithms by this UE

integrity:
IA1: true
IA2: true
IA3: true

Supported encryption algorithms by this UE

ciphering:
EA1: true
EA2: true
EA3: true

Integrity protection maximum data rate for user plane

integrityMaxRate:
uplink: ‘full’
downlink: ‘full’

I do not have any problems to capture the last UE ID that is generated by UERAMSIN when I register each UE sequentially, the problem is when I use a multiprocessing technique to register several UEs at the same time.

Hi,
following are my scripts
python:

from multiprocessing import Process
import time
import subprocess

i = 0
processes = []
UEs=['ue100.yaml', 'ue101.yaml', 'ue102.yaml', 'ue103.yaml', 'ue104.yaml','ue105.yaml','ue106.yaml','ue107.yaml', 'ue108.yaml', 'ue109.yaml' ]
for ue in UEs:
    print("==========process number==============>", i, ue)
    p = Process(target=subprocess.run, args=([["bash", "./registration.sh", ue],]))
    processes.append(p)
    p.start()
    time.sleep(1)
    i+=1

shell script:

sudo $HOME/UERANSIM/build/nr-ue -c $HOME/UERANSIM/config/$1 -n 1
textfile=“ueidlist.txt”
$HOME/UERANSIM/build/nr-cli UERANSIM-gnb-208-93-1 -e ue-list > $textfile

val=$(head -n 1 $textfile)

find="- ue-name: "

replace=""
ueid=${val//$find/$replace}

touch $1.txt

sudo chmod 777 $1.txt

echo “imsi-208930000000$1,$ueid” >> $1.txt

And according to shell script, it could happen race condition and synchronization problem:

$HOME/UERANSIM/build/nr-cli UERANSIM-gnb-208-93-1 -e ue-list > $textfile

val=$(head -n 1 $textfile)

If I/O halt the process or cost too many cpu time, system will context switch to another process. And when ctrl-c to interrupt the UERANSIM, the last ue id process would write ue-list to ueidlist.txt. Since there are 10 ue attaching to core network and executing in UERANSIM, the ue-list will output all ue id including the last one in the top of file, then remaining processes would perform val=$(head -n 1 $textfile), getting the last ue id.
Maybe more precise python and shell code for testing is required.