pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/41756?usp=email )
Change subject: 5gc: Network Triggered Service Request ......................................................................
5gc: Network Triggered Service Request
Change-Id: I42e422d104f254bc27d5f3bb3e8df0cba6380648 --- M 5gc/C5G_Tests.ttcn M 5gc/ConnHdlr.ttcn M library/GTPv1U_Emulation.ttcnpp 3 files changed, 93 insertions(+), 10 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/56/41756/1
diff --git a/5gc/C5G_Tests.ttcn b/5gc/C5G_Tests.ttcn index 22c67e0..9e9d750 100644 --- a/5gc/C5G_Tests.ttcn +++ b/5gc/C5G_Tests.ttcn @@ -499,6 +499,46 @@ vc_conn.done; }
+/* 3GPP TS 23.502 4.2.3.3 Network Triggered Service Request */ +private function f_TC_net_triggered_service_req() runs on ConnHdlr { + var PDU_SessionStatus pdu_session_status; + + f_register(); + f_pdu_sess_establish(); + f_sleep(1.0); + f_ue_context_release(); + f_sleep(1.0); + f_create_ngap_expect_proc(id_Paging, self); + + /* NOTE: In theory we should generate DL-originated traffic here, but since + * UPF let our UL traffic pass (bug?), make use of it to generate some DL + * traffic (ping reply) triggering the Paging: */ + var integer pid := f_ping4_async(g_pars.ue_pars.sess_pars.run_prog_pars.ping_hostname, interval := 1, count := 1); + + NGAP.receive(mw_ngap_initMsg(mw_n2_Paging(?, ?))); + log("Rx Paging") + + /* We emulate UE in CM-IDLE: */ + pdu_session_status := f_PDU_SessionStatus(); + f_service_request_cm_idle(pdu_sess_status := pdu_session_status); + /* open5gs GH#771: open5gs-amfd sends InitialContextSetupRequest instead of PDUSessionResourceSetupRequest */ + as_ngap_handle_InitialCtxReq_withPDUSessionList(); + NGAP.receive(cr_NG_SERVICE_ACCEPT(p_PDU_SessionStatus := cr_PDU_SessionStatus('00000010'B, '00000000'B))); + as_ngap_handle_configuration_update(); + + f_gtp1u_wait_term(pid, 0, 1.0); + + f_deregister(); +} +testcase TC_net_triggered_service_req() runs on MTC_CT { + f_init(); + f_ngap_setup(0); + + var ConnHdlrPars pars := f_init_pars(ue_idx := 0); + var ConnHdlr vc_conn; + vc_conn := f_start_handler_with_pars(refers(f_TC_net_triggered_service_req), pars); + vc_conn.done; +}
control { execute( TC_ng_setup() ); @@ -520,13 +560,14 @@ execute( TC_ue_service_request_cm_idle_inact_sess() ); execute( TC_ue_service_request_cm_idle_unknown_sess_active() ); execute( TC_ue_service_request_cm_connected() ); + + execute( TC_net_triggered_service_req() ); }
/* TODO: * - 3GPP TS 23.502 4.2.2.2.3 Registration with AMF re-allocation: Not supported by open5gs (https://github.com/open5gs/open5gs/issues/4214). * - 3GPP TS 23.502 4.2.2.2.4 Registration with Onboarding SNPN: Not supported by open5gs (https://github.com/open5gs/open5gs/issues/4215) * - 3GPP TS 23.502 4.2.2.3.3 Network-initiated Deregistration: Not supported by open5gs (https://github.com/open5gs/open5gs/issues/4216) - * - 3GPP TS 23.502 4.2.3.3 Network Triggered Service Request * - 3GPP TS 23.502 4.2.4.3 UE Configuration Update procedure for transparent UE Policy delivery * - 3GPP TS 23.502 4.2.5.2 UE Reachability Notification Request procedure * - 3GPP TS 23.502 4.2.5.3 UE Activity Notification procedure diff --git a/5gc/ConnHdlr.ttcn b/5gc/ConnHdlr.ttcn index 1e7ed5a..aa932bf 100644 --- a/5gc/ConnHdlr.ttcn +++ b/5gc/ConnHdlr.ttcn @@ -293,7 +293,7 @@ } }
-private altstep as_ngap_handle_configuration_update() runs on ConnHdlr { +altstep as_ngap_handle_configuration_update() runs on ConnHdlr { var NG_NAS_DL_Message_Type rx_nas;
[] NGAP.receive(cr_NG_CONFIGURATION_UPDATE_COMMAND) -> value rx_nas { @@ -359,20 +359,31 @@ }
/* 3GPP TS 23.502 Figure 4.3.2.2.1-1 steps 12-14. */ -private altstep as_ngap_handle_InitialCtxReq_withPDUSessionList() runs on ConnHdlr { +altstep as_ngap_handle_InitialCtxReq_withPDUSessionList(template (present) AMF_UE_NGAP_ID amf_id := ?) runs on ConnHdlr { var NGAP_PDU rx_ngap; var template (present) NGAP_PDU exp_ngap := - mw_ngap_initMsg(f_mw_n2_InitialContextSetupRequest(g_pars.ue_pars.amf_id, - g_pars.ue_pars.ran_id, - p_uEAggregateMaximumBitRate := ?, - p_pDUSessionResourceSetupListCxtReq := ?, - p_nextHopNH := ?, - p_maskedIMEISV := ?)); + mw_ngap_initMsg((f_mw_n2_InitialContextSetupRequest(amf_id, + g_pars.ue_pars.ran_id, + p_uEAggregateMaximumBitRate := ?, + p_pDUSessionResourceSetupListCxtReq := ?, + p_nextHopNH := ?, + p_maskedIMEISV := ?), + f_mw_n2_InitialContextSetupRequest(amf_id, + g_pars.ue_pars.ran_id, + p_uEAggregateMaximumBitRate := ?, + p_pDUSessionResourceSetupListCxtReq := ?, + p_nextHopNH := ?, + p_maskedIMEISV := ?, + p_nAS_PDU := ?) + ));
[] NGAP.receive(exp_ngap) -> value rx_ngap { var InitialContextSetupRequest ctx_setup_req := rx_ngap.initiatingMessage.value_.initialContextSetupRequest; var PDUSessionResourceSetupListCxtRes resources;
+ /* Update amf_id: */ + g_pars.ue_pars.amf_id := ctx_setup_req.protocolIEs[0].value_.aMF_UE_NGAP_ID; + for (var integer i := 0; i < lengthof(ctx_setup_req.protocolIEs); i := i + 1) { if (ctx_setup_req.protocolIEs[i].id != id_PDUSessionResourceSetupListCxtReq) { continue; @@ -463,7 +474,7 @@ p_RequestType := cs_NG_Request_TypeTV('001'B), p_DNN := cs_DNN_TLV(f_enc_dns_hostname(g_pars.ue_pars.apn))); NGAP.send(nas_ul_msg); - as_ngap_handle_InitialCtxReq_withPDUSessionList(); + as_ngap_handle_InitialCtxReq_withPDUSessionList(g_pars.ue_pars.amf_id);
/* PDU Session Establishment Accept: This DL NAS arrives contained in InitialCtxReq handled above: */ NGAP.receive(cr_NG_DL_NAS_TRANSPORT) -> value rx_nas; @@ -966,4 +977,15 @@ redirect_output_path_prefix := f_run_prog_unique_log_path()); }
+function f_ping4_async(charstring host, integer interval := 1, integer count := 10) runs on ConnHdlr return integer +{ + /* command will be filled in by f_gtp1u_ping4() below: */ + var UECUPS_StartProgram sprog := f_run_prog_init(""); + var integer pid := f_gtp1u_ping4_async(sprog, host, + interval, count, g_pars.ue_pars.sess_pars.ue_ip, + redirect_output := true, + redirect_output_path_prefix := f_run_prog_unique_log_path()); + return pid; +} + } diff --git a/library/GTPv1U_Emulation.ttcnpp b/library/GTPv1U_Emulation.ttcnpp index aa97210..51fc5a1 100644 --- a/library/GTPv1U_Emulation.ttcnpp +++ b/library/GTPv1U_Emulation.ttcnpp @@ -454,6 +454,26 @@ f_gtp1u_wait_term(pid, exit_code, tout, port_idx); }
+function f_gtp1u_ping4_async(UECUPS_StartProgram sprog, + charstring host, integer interval := 1, integer count := 10, + template (omit) charstring src_ip := omit, + boolean redirect_output := false, + charstring redirect_output_path_prefix := "gtp1u_run_prog", + integer port_idx := 0) runs on GTP1U_ConnHdlr return integer +{ + var charstring ping :="ping -c " & int2str(count) & " -i " & int2str(interval); + var integer pid; + + if (isvalue(src_ip)) { + ping := ping & " -I " & valueof(src_ip); + } + ping := ping & " " & host; + sprog.command := ping; + pid := f_gtp1u_start_prog(sprog, redirect_output, redirect_output_path_prefix, port_idx); + return pid; + +} + /* execute ping command and wait for result. sprog.command is filled in based on params. */ function f_gtp1u_ping4(UECUPS_StartProgram sprog, charstring host, integer interval := 1, integer count := 10,