aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2024-04-06 05:38:35 +0700
committerVadim Yanitskiy <vyanitskiy@sysmocom.de>2024-04-06 05:39:27 +0700
commitd5674c41ccbe286874365d577d6fbf01866324d2 (patch)
treee5112cd774d69e6a988c63623da0775d048167c6
parentd65846c6966ac638dc2b588c1f468977eb9d015b (diff)
sgsn: add testcases for SGSN Context Request procedurefixeria/sgsn_ctx
-rw-r--r--sgsn/SGSN_Tests.ttcn133
1 files changed, 133 insertions, 0 deletions
diff --git a/sgsn/SGSN_Tests.ttcn b/sgsn/SGSN_Tests.ttcn
index 92b744fa..8f119a52 100644
--- a/sgsn/SGSN_Tests.ttcn
+++ b/sgsn/SGSN_Tests.ttcn
@@ -3727,6 +3727,139 @@ testcase TC_cell_change_different_ci_data() runs on test_CT {
f_cleanup();
}
+/* SGSN terminated SGSN Context Request procedure (we request, SGSN responds) */
+private function f_TC_sgsn_context_req(charstring id) runs on BSSGP_ConnHdlr {
+ var integer seq_nr := f_rnd_int(65535);
+ var Gtp1cUnitdata gtpc_ud;
+ timer T;
+
+ var Gtp1cPeer peer := {
+ connId := 1,
+ remName := mp_sgsn_gtp_ip,
+ remPort := GTP1C_PORT
+ }
+
+ /* The MS attaches to GERAN/UTRAN and enjoys the service */
+ f_gmm_attach(false, false);
+
+ /* The MS switches to an LTE cell and performs Tracking Area Update Request there.
+ * The MME requests information about the MS by sending SGSN Context Request. */
+ var template (value) GTPC_PDUs ctx_req;
+ ctx_req := ts_SGSNContextReqPDU(rai := ts_RoutingAreaIdentity('250'H, 'F99'H, '4242'O, 'DE'O),
+ teic := '12345678'O,
+ sgsn_addr_control := f_inet_addr(mp_ggsn_ip),
+ ptmsi := ts_PTMSI(g_pars.p_tmsi),
+ ptmsi_sig := ts_PTMSI_sig('010203'O));
+ GTP.send(ts_GTPC_SGSNContextReq(peer, seq_nr, ctx_req));
+
+ /* The SGSN responds with subscriber's IMSI */
+ var template (present) GTPC_PDUs ctx_rsp;
+ ctx_rsp := tr_SGSNContextRespPDU(cause := GTP_CAUSE_REQUEST_ACCEPTED,
+ imsi := g_pars.imsi);
+ /* TODO: match MM/PDP Context, GSN Address */
+
+ T.start(2.0);
+ alt {
+ [] GTP.receive(tr_GTPC_SGSNContextResp(?, ?, ctx_rsp)) -> value gtpc_ud {
+ GTP.send(ts_GTPC_SGSNContextAck(gtpc_ud.peer, '12345678'O, seq_nr));
+ setverdict(pass);
+ }
+ [] GTP.receive(tr_GTPC_SGSNContextResp) {
+ setverdict(fail, "Rx unexpected SGSN Context Resp");
+ }
+ [] T.timeout {
+ setverdict(fail, "Timeout waiting for SGSN Contect Resp");
+ }
+ }
+}
+testcase TC_sgsn_context_req() runs on test_CT {
+ var BSSGP_ConnHdlr vc_conn;
+ f_init();
+ f_sleep(1.0);
+ vc_conn := f_start_handler(refers(f_TC_sgsn_context_req), testcasename(), g_gb, 72);
+ vc_conn.done;
+ f_cleanup();
+}
+
+/* SGSN originated SGSN Context Request procedure (SGSN requests, we respond) */
+private function f_TC_sgsn_context_req2(charstring id) runs on BSSGP_ConnHdlr {
+ var integer seq_nr := f_rnd_int(65535);
+ var Gtp1cUnitdata gtpc_ud;
+ timer T;
+
+ /* The MS goes to GERAN/UTRAN from an LTE cell */
+ f_send_l3(ts_GMM_RAU_REQ(mi_lv := valueof(ts_MI_TMSI_LV('DE42DE42'O)),
+ upd_type := GPRS_UPD_T_RA,
+ old_ra := f_random_RAI()), 0);
+
+ /* The SGSN has no idea about the MS and inquires the MME about it */
+ T.start(2.0);
+ alt {
+ [] GTP.receive(tr_GTPC_SGSNContextReq(?, ?)) -> value gtpc_ud {
+ log("Rx SGSN Context Request from SGSN: ", gtpc_ud.gtpc);
+ setverdict(pass);
+ T.stop;
+ }
+ [] GTP.receive(tr_GTPC_SGSNContextResp) {
+ setverdict(fail, "Rx unexpected SGSN Context Req");
+ mtc.stop;
+ }
+ [] T.timeout {
+ setverdict(fail, "Timeout waiting for SGSN Contect Req");
+ mtc.stop;
+ }
+ }
+
+ /* The MME responds */
+ var OCT8 kc := f_rnd_octstring(8);
+
+ var template (value) PDP_Context_GTPC pdp_ctx;
+ pdp_ctx := ts_PDP_Context_GTPC(pdp_addr := f_inet_addr("10.10.10.10"),
+ ggsn_gsn_addr := f_inet_addr(mp_ggsn_ip),
+ apn := '08696E7465726E6574'O);
+
+ var template (value) GTPC_PDUs ctx_rsp;
+ ctx_rsp := ts_SGSNContextRespPDU(cause := GTP_CAUSE_REQUEST_ACCEPTED,
+ imsi := g_pars.imsi,
+ teic := '12345678'O,
+ mm_context := ts_MM_ContextGSM(kc),
+ pdp_ctx_list := { pdp_ctx });
+ GTP.send(ts_GTPC_SGSNContextResp(gtpc_ud.peer, '12345678'O, seq_nr, ctx_rsp));
+
+ /* The SGSN ACKs */
+ T.start(2.0);
+ alt {
+ [] GTP.receive(tr_GTPC_SGSNContextAck) -> value gtpc_ud {
+ log("Rx SGSN Context ACK from SGSN: ", gtpc_ud.gtpc);
+ setverdict(pass);
+ T.stop;
+ }
+ [] T.timeout {
+ setverdict(fail, "Timeout waiting for SGSN Contect ACK");
+ mtc.stop;
+ }
+ }
+
+ /* TODO: the RAU procedure continues, see f_routing_area_update() */
+ T.start(2.0);
+ alt {
+ [] as_routing_area_update_gb(0) { setverdict(pass); }
+ [] BSSGP[0].receive { repeat; }
+ [] T.timeout {
+ setverdict(fail, "Timeout completing the RAU procedure");
+ mtc.stop;
+ }
+ }
+}
+testcase TC_sgsn_context_req2() runs on test_CT {
+ var BSSGP_ConnHdlr vc_conn;
+ f_init();
+ f_sleep(1.0);
+ vc_conn := f_start_handler(refers(f_TC_sgsn_context_req2), testcasename(), g_gb, 73);
+ vc_conn.done;
+ f_cleanup();
+}
+
control {
execute( TC_attach() );
execute( TC_attach_mnc3() );