Commit 0ceb5fd3 authored by Jaroslava Fiedlerova's avatar Jaroslava Fiedlerova

Merge remote-tracking branch 'origin/ue_nas_simulator' into integration_2026_w13 (!3973)

Introduce UE NAS Simulator

This MR introduces a simple standalone tester for 5G UE NAS signaling and NGAP
messages. It connects to the AMF to perform NGAP and NAS encoding/decoding and
validates the UE Registration and PDU Session Establishment processes without
the overhead of a full Radio Access Network (PHY/MAC/RLC).

The motivation for this tester is as follows,
- This tester is a lightweight, deterministic tool to test the UE NAS layer
directly.
- Developers can easily inject specific NAS messages depending on the use-case.
- Developers can validate custom NAS/NGAP messages without the need to implement
complete RRC/MAC etc procedures.

Start the 5G Core network to test the UE NAS simulator. The compiling and
testing procedure is described below.
To compile:
mkdir build && cd build && cmake .. -GNinja && ninja nr-ue-nas-simulator-test

To run:
  LD_LIBRARY_PATH=. ./tests/nr-ue-nas-simulator/nr-ue-nas-simulator-test -O ../tests/nr-ue-nas-simulator/test.conf
parents 8b9eada3 03ba636b
......@@ -124,6 +124,7 @@ The other SDRs (AW2S, LimeSDR, ...) have no READMEs.
- Component tests are under `tests/`. Currently, the following component tests are supported
- A simple CU-UP tester, see the corresponding [README.md](../tests/nr-cuup/README.md).
- A CU-NRPPA tester, see the corresponding [README.md](../tests/nr-cu-nrppa/README.md).
- A UE NAS tester, see the corresponding [README.md](../tests/nr-ue-nas-simulator/README.md).
- [TESTBenches.md](./TESTBenches.md) lists the CI setup and links to pipelines
- The CI setup uses a [custom framework](../ci-scripts/README.md) to run
end-to-end tests.
......
......@@ -78,6 +78,12 @@
static nr_ue_nas_t nr_ue_nas[MAX_NUM_NR_UE_INST] = {0};
nr_ue_nas_t *get_nr_ue_nas_info(uint8_t ue_inst)
{
AssertFatal(ue_inst >= 0 && ue_inst < MAX_NUM_NR_UE_INST, "Invalid UE instance\n");
return &nr_ue_nas[ue_inst];
}
#define FOREACH_STATE(TYPE_DEF) \
TYPE_DEF(NAS_SECURITY_NO_SECURITY_CONTEXT, 0) \
TYPE_DEF(NAS_SECURITY_UNPROTECTED, 1) \
......@@ -1166,6 +1172,10 @@ static void generateSecurityModeComplete(nr_ue_nas_t *nas, as_nas_info_t *initia
security_header_len
+ mm_msg_encode(plain, (uint8_t *)(initialNasMsg->nas_data + security_header_len), size - security_header_len);
if (rr.nas_data) {
free(rr.nas_data);
}
/* ciphering */
uint8_t buf[initialNasMsg->length - 7];
stream_cipher.context = nas->security_container->ciphering_context;
......
......@@ -113,5 +113,6 @@ void *nas_nrue(void *args_p);
void nas_init_nrue(int num_ues);
void nr_ue_create_ip_if(const char *ifnameprefix, const char *ipv4, const char *ipv6, int ue_id, int pdu_session_id);
void request_pdusession(nr_ue_nas_t *nas, const pdu_session_config_t *pdu);
nr_ue_nas_t *get_nr_ue_nas_info(uint8_t ue_inst);
#endif /* __NR_NAS_MSG_SIM_H__*/
add_subdirectory(nr-cuup)
add_subdirectory(nr-cu-nrppa)
add_subdirectory(nr-ue-nas-simulator)
add_executable(nr-ue-nas-simulator-test nr-ue-nas-simulator.c
${OPENAIR2_DIR}/GNB_APP/gnb_config_common.c
${OPENAIR2_DIR}/GNB_APP/gnb_config_ng.c)
target_link_libraries(nr-ue-nas-simulator-test PRIVATE nr_nas nr_common lib_uicc usim_lib)
target_link_libraries(nr-ue-nas-simulator-test PRIVATE
CONFIG_LIB ITTI SCTP_CLIENT
f1ap ngap SECURITY GTPV1U
UTIL softmodem_common)
target_link_libraries(nr-ue-nas-simulator-test PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs)
add_dependencies(nr-ue-nas-simulator-test params_libconfig)
This is a simple standalone tester for 5G UE NAS signaling and NGAP messages. It connects to the AMF to perform NGAP and NAS encoding/decoding and validates the UE Registration and PDU Session Establishment processes without the overhead of a full Radio Access Network (PHY/MAC/RLC).
[[_TOC_]]
# Motivation
- This tester is a lightweight, deterministic tool to **test the UE NAS layer directly**.
- Developers can easily inject specific NAS messages depending on the use-case.
- Developers can validate custom NAS/NGAP messages without the need to implement complete RRC/MAC etc procedures.
# Overview
From a schematic point of view, the tester and Core Network interaction looks like this:
```
+-------+
| AMF |
+-------+
|
NGAP/NAS | (N1/N2)
|
+-------+
|tester | (nr-ue-nas-simulator-test)
+-------+
```
The tester is designed to validate the integration of NAS and NGAP messages required for a 5G Standalone (SA) UE to attach to the network. It acts as a simulated gNB and a UE, bridging NAS messages directly into NGAP payloads and connecting to the 5G Core Network's AMF.
The following messages are integrated and tested:
* **NGAP:** NG Setup Request/Response, Initial UE Message, Downlink NAS Transport, Uplink NAS Transport, Initial Context Setup Request/Response, PDU Session Resource Setup Request/Response, UE Context Release Command/Complete.
* **NAS (5GMM/5GSM):** Registration Request/Accept/Complete, Authentication Request/Response, Security Mode Command/Complete, PDU Session Establishment Request/Accept, Deregistration Request/Accept.
* **RRC (Custom):** Forwards the uplink/downlink NAS messages directly between UE and AMF.
A test scenario is fixed to these steps:
1. The 5G Core Network is deployed via Docker.
2. The tester connects to the AMF and establishes the NGAP connection (NG Setup).
3. The tester automatically triggers an Initial UE Registration Request.
4. Authentication and NAS Security Mode procedures are completed.
5. The tester requests and successfully establishes an IPv4 PDU Session.
6. The tester finally initiates deregistration request and exits succesfully.
# Usage
To run this test, you need to set up the Core Network and build the tester.
**1. Core Network Deployment**
Pull the required Docker images for the OAI 5G Core:
docker pull oaisoftwarealliance/ims:latest
docker pull oaisoftwarealliance/oai-amf:develop
docker pull oaisoftwarealliance/oai-nrf:develop
docker pull oaisoftwarealliance/oai-smf:develop
docker pull oaisoftwarealliance/oai-udr:develop
docker pull oaisoftwarealliance/oai-upf:develop
docker pull oaisoftwarealliance/oai-udm:develop
docker pull oaisoftwarealliance/oai-ausf:develop
Deploy the network using the docker compose file:
cd doc/tutorial_resources/oai-cn5g
docker compose -f docker-compose.yaml up -d
At the end of all experiments, you can also undeploy the network with:
docker compose -f docker-compose.yaml down -t 0
**2. Building the Tester**
You can build the tester as follows:
cd ~/openairinterface5g
mkdir build && cd build && cmake .. -GNinja && ninja nr-ue-nas-simulator-test
**3. Running the Tester**
Start the tester with the dedicated configuration file:
openairinterface5g/build$ LD_LIBRARY_PATH=. ./tests/nr-ue-nas-simulator/nr-ue-nas-simulator-test -O ../tests/nr-ue-nas-simulator/test.conf
# Limitations
- The tester is limited to a fixed flow: Initial Attach -> PDU Session -> Deregistration.
- The tester doesnt create a GTP tunnel after PDU session and uses a harcoded teid.
# Future Enhancements
- A real GTP tunnel can be created to test various data related functionalities like QoS.
- Simulate the actual UE RRC layer, i.e., forwarding the CellGroupConfig, have the UE apply that (without actually using it).
- Make it scriptable to test custom message implementations.
This diff is collapsed.
Active_gNBs = ( "gNB-OAI");
# Asn1_verbosity, choice in: none, info, annoying
Asn1_verbosity = "none";
gNBs =
(
{
////////// Identification parameters:
gNB_ID = 0xe00;
gNB_name = "gNB-OAI";
// Tracking area code, 0x0000 and 0xfffe are reserved values
tracking_area_code = 1;
plmn_list = ({ mcc = 001; mnc = 01; mnc_length = 2; snssaiList = ({ sst = 1; }) });
nr_cellid = 12345678L;
# ------- SCTP definitions
SCTP :
{
# Number of streams to use in input/output
SCTP_INSTREAMS = 2;
SCTP_OUTSTREAMS = 2;
};
////////// AMF parameters:
amf_ip_address = ({ ipv4 = "192.168.70.132"; });
NETWORK_INTERFACES :
{
GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.70.129/24";
GNB_IPV4_ADDRESS_FOR_NGU = "192.168.70.129/24";
GNB_PORT_FOR_S1U = 2152; # Spec 2152
};
}
);
uicc0 = {
imsi = "001010000000001";
key = "fec86ba6eb707ed08905757b1bb44b8f";
opc = "C42449363BBAD02B66D16BC975D77CC1";
pdu_sessions = ({ dnn = "oai"; nssai_sst = 1; });
}
log_config :
{
global_log_level ="info";
hw_log_level ="info";
phy_log_level ="info";
mac_log_level ="info";
rlc_log_level ="info";
pdcp_log_level ="info";
rrc_log_level ="info";
ngap_log_level ="debug";
f1ap_log_level ="debug";
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment