pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/35513?usp=email )
Change subject: WIP: mme: 2g->4g ......................................................................
WIP: mme: 2g->4g
Change-Id: I6f8f077b99e83e6467d2b0c05148b81dbcf2ede4 --- M mme/MME_Tests.ttcn 1 file changed, 178 insertions(+), 32 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/13/35513/1
diff --git a/mme/MME_Tests.ttcn b/mme/MME_Tests.ttcn index f4f41e2..1b4b548 100644 --- a/mme/MME_Tests.ttcn +++ b/mme/MME_Tests.ttcn @@ -856,6 +856,37 @@ } }
+ +/* 3GPP TS 23.401 D.3.5, TS 23.003 2.8.2.1 */ +private function guti2rai_ptmsi(in NAS_EPS_Types.GUTI guti, out RoutingAreaIdentity rai, out OCT4 ptmsi, out OCT3 ptmsi_sig) runs on ConnHdlr { + var bitstring mtmsi_bits := oct2bit(guti.mTMSI); + var bitstring ptmsi_bits; + var bitstring ptmsi_sig_bits; + + rai := valueof(ts_RoutingAreaIdentity(guti.mccDigit1 & guti.mccDigit2 & guti.mccDigit3, + guti.mncDigit3 & guti.mncDigit1 & guti.mncDigit2, + guti.mMEGI, guti.mMEC)); + /* 3GPP TS 23.003 2.8.2.0: "P-TMSI shall be of 32 bits length where the two topmost bits are + * reserved and always set to '11'. Hence, for a UE which may handover to GERAN/UTRAN (based on + * subscription and UE capabilities), the corresponding bits in the M-TMSI are set to '11'" + */ + ptmsi_bits := '11'B & substr(mtmsi_bits, 2, 6) & oct2bit(guti.mMEC) & substr(mtmsi_bits, 16, 16); + ptmsi_sig_bits := substr(mtmsi_bits, 8, 8) & oct2bit('0000'O); + ptmsi := bit2oct(ptmsi_bits); + ptmsi_sig := bit2oct(ptmsi_sig_bits); + /* TODO: The UE shall fill the remaining 2 octets of the <P-TMSI signature> according to clauses 9.1.1, 9.4.1, 10.2.1, or + * 10.5.1 of 3GPP TS.33.401 [89] , as appropriate, for RAU/Attach procedures.*/ + /* TODO: 3GPP TS 33.401 9.1.1 The 16 least significant bits available in + * the P-TMSI signature field shall be filled with the truncated NAS-token + * according to 3GPP TS 23.003 [3].The truncated NAS-token is defined as the 16 + * least significant bits of the NAS-token. + * The NAS-token is derived as specified in Annex A.9. The UE shall use the uplink NAS COUNT value that it would use + * in the next NAS message to calculate the NAS-token and increase the stored uplink NAS COUNT value by 1.*/ + /* TODO: mMEC "also copied into the 8 Most Significant Bits of the NRI field within the P-TMSI" */ +} +/* Test UE attached to EUTRAN reselecting a GERAN cell. In this scenario, the + * new SGSN will attempt to obtain information of the UE from the old SGSN (MME) + * through Gn interface using SGSN Context Request/Response procedure (OS#6294). */ private function f_gtp_sgsn_context_4g_to_2g(OCT4 new_sgsn_local_teid := '12345678'O) runs on ConnHdlr { var template (value) GTPC_PDUs SGSNContextReqPDU; var RoutingAreaIdentity rai; @@ -880,10 +911,10 @@ setverdict(pass); } [] GTP.receive { - setverdict(fail, "unexpected GTPC message from MME"); + Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("unexpected GTPC message from MME")); } [] T.timeout { - setverdict(fail, "no SGSN Context Response from MME"); + Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("no SGSN Context Response from MME")); } }
@@ -893,6 +924,43 @@
}
+private altstep as_gtp_sgsn_context_2g_to_4g(OCT4 new_sgsn_teid := 'ABABABAB'O, GTP_Templates.GTP_RATType rat_type := GTP_RAT_TYPE_EUTRAN) runs on ConnHdlr { + var Gtp1cUnitdata gtpc_pdu; + + [] GTP.receive(tr_GTPC_SGSNContextReq(g_gn_iface_peer, tr_SGSNContextReqPDU(rat_type := int2oct(enum2int(rat_type), 1)))) -> value gtpc_pdu { + var template (value) PDP_Context_GTPC pdp_ctx; + var template (value) GTPC_PDUs SGSNContextRespPDU; + var Gtp1cUnitdata gtpc_pdu_ack; + var OCT4 old_mme_remote_teid := gtpc_pdu.gtpc.gtpc_pdu.sgsn_ContextRequest.teidControlPlane.teidControlPlane; + + const OCT16 ck := '740d62df9803eebde5120acf358433d0'O; + const OCT16 ik := '11329aae8e8d2941bb226b2061137c58'O; + + pdp_ctx := ts_PDP_Context_GTPC(f_inet_addr(g_pars.ue_pars.ue_ip), + f_inet_addr(mp_gn_local_ip), + c_NAS_defaultAPN, + ggsn_teic := '12345678'O, + ggsn_teid := '87654321'O); + SGSNContextRespPDU := ts_SGSNContextRespPDU(GTP_CAUSE_REQUEST_ACCEPTED, + g_pars.ue_pars.imsi, + new_sgsn_teid, + f_inet_addr(mp_gn_local_ip), + ts_MM_ContextUMTS(ck, ik), + { pdp_ctx }); + GTP.send(ts_GTPC_SGSNContextResp(g_gn_iface_peer, + old_mme_remote_teid, + oct2int(gtpc_pdu.gtpc.opt_part.sequenceNumber), + SGSNContextRespPDU)); + + GTP.receive(tr_GTPC_SGSNContextAck(g_gn_iface_peer, new_sgsn_teid, + tr_SGSNContextAckPDU(GTP_CAUSE_REQUEST_ACCEPTED))) -> value gtpc_pdu; + setverdict(pass); + } + [] GTP.receive { + setverdict(fail, "unexpected GTPC message from MME"); + } +} + private function f_attach() runs on ConnHdlr { var template (value) EPS_MobileIdentityV mi := ts_NAS_MobileId_IMSI(g_pars.ue_pars.imsi); var template (value) PDU_NAS_EPS nas_esm, nas_emm; @@ -1312,36 +1380,6 @@ vc_conn.done; }
-/* Test UE attached to EUTRAN reselecting a GERAN cell. In this scenario, the - * new SGSN will attempt to obtain information of the UE from the old SGSN (MME) - * through Gn interface using SGSN Context Request/Response procedure (OS#6294). */ -/* TS 23.003 2.8.2.1 */ -private function guti2rai_ptmsi(in NAS_EPS_Types.GUTI guti, out RoutingAreaIdentity rai, out OCT4 ptmsi, out OCT3 ptmsi_sig) runs on ConnHdlr { - var bitstring mtmsi_bits := oct2bit(guti.mTMSI); - var bitstring ptmsi_bits; - var bitstring ptmsi_sig_bits; - - rai := valueof(ts_RoutingAreaIdentity(guti.mccDigit1 & guti.mccDigit2 & guti.mccDigit3, - guti.mncDigit3 & guti.mncDigit1 & guti.mncDigit2, - guti.mMEGI, guti.mMEC)); - /* 3GPP TS 23.003 2.8.2.0: "P-TMSI shall be of 32 bits length where the two topmost bits are - * reserved and always set to '11'. Hence, for a UE which may handover to GERAN/UTRAN (based on - * subscription and UE capabilities), the corresponding bits in the M-TMSI are set to '11'" - */ - ptmsi_bits := '11'B & substr(mtmsi_bits, 2, 6) & oct2bit(guti.mMEC) & substr(mtmsi_bits, 16, 16); - ptmsi_sig_bits := substr(mtmsi_bits, 8, 8) & oct2bit('0000'O); - ptmsi := bit2oct(ptmsi_bits); - ptmsi_sig := bit2oct(ptmsi_sig_bits); - /* TODO: The UE shall fill the remaining 2 octets of the <P-TMSI signature> according to clauses 9.1.1, 9.4.1, 10.2.1, or - * 10.5.1 of 3GPP TS.33.401 [89] , as appropriate, for RAU/Attach procedures.*/ - /* TODO: 3GPP TS 33.401 9.1.1 The 16 least significant bits available in - * the P-TMSI signature field shall be filled with the truncated NAS-token - * according to 3GPP TS 23.003 [3].The truncated NAS-token is defined as the 16 - * least significant bits of the NAS-token. - * The NAS-token is derived as specified in Annex A.9. The UE shall use the uplink NAS COUNT value that it would use - * in the next NAS message to calculate the NAS-token and increase the stored uplink NAS COUNT value by 1.*/ - /* TODO: mMEC "also copied into the 8 Most Significant Bits of the NRI field within the P-TMSI" */ -} private function f_TC_ue_cell_reselect_eutran_to_geran(ConnHdlrPars pars) runs on ConnHdlr { f_init_handler(pars); f_gtp_register_imsi(g_pars.ue_pars.imsi); @@ -1381,6 +1419,104 @@ vc_conn.done; }
+/* 3GPP TS 23.401 D.3.6, TS 23.003 2.8.2.2 */ +private function rai_ptmsi2_guti(in RoutingAreaIdentity rai, in OCT4 ptmsi, in OCT3 ptmsi_sig, out NAS_EPS_Types.GUTI guti) runs on ConnHdlr { + + + var bitstring ptmsi_bits := oct2bit(ptmsi); + var bitstring ptmsi_sig_bits := oct2bit(ptmsi_sig); + var bitstring mtmsi_bits := '11'B & + substr(ptmsi_bits, 2, 6) & + substr(ptmsi_sig_bits, 0, 8) & + substr(ptmsi_bits, 16, 16); + guti := valueof(ts_NAS_GUTI(mcc_mnc := rai.mcc_digits & rai.mnc_digits, + mmegi := rai.lac, + mmec := rai.rac, + tmsi := bit2oct(mtmsi_bits))); +} +/* Test UE attached to GERAN reselecting a EUTRAN cell. In this scenario, the + * new MME will attempt to obtain information of the UE from the old SGSN + * through Gn interface using SGSN Context Request/Response procedure (OS#6294). */ +/* 3GPP TS 23.401 D.3.6, TS 23.003 2.8.2.1 */ +private function f_TC_ue_cell_reselect_geran_to_eutran(ConnHdlrPars pars) runs on ConnHdlr { + f_init_handler(pars); + f_gtp_register_imsi(g_pars.ue_pars.imsi); + f_gtp2_register_imsi(g_pars.ue_pars.imsi); + /* SGSN Context Req doesn't necessarily contain IMSI, hence expect it through TEID=0 */ + f_gtp_register_teid('00000000'O); + /* passed in SGSN Context Resp to MME, will be used by MME when answering with SGSN Context Ack: */ + const OCT4 new_sgsn_teid := 'ABABABAB'O; + f_gtp_register_teid(new_sgsn_teid); + + var template (value) EPS_MobileIdentityV mi := ts_NAS_MobileId_IMSI(pars.ue_pars.imsi); + var template (value) S1AP_PDU tx; + var template (value) PDU_NAS_EPS nas_tau; + var RoutingAreaIdentity rai; + var OCT4 ptmsi := f_gen_tmsi(suffix := 0, nri_v := 0, nri_bitlen := 8); + var OCT3 ptmsi_sig := f_rnd_octstring(3); + var NAS_EPS_Types.GUTI guti_val; + var template (value) EPS_MobileIdentityLV old_guti; + timer T := 5.0; + + rai := valueof(ts_RoutingAreaIdentity(mp_gn_local_mcc, mp_gn_local_mnc, + int2oct(mp_gn_local_lac, 2), int2oct(mp_gn_local_rac, 1))); + rai_ptmsi2_guti(rai, ptmsi, ptmsi_sig, guti_val); + old_guti := ts_EPS_MobileId_GUTI_(guti_val); + + nas_tau := ts_PDU_NAS_EPS_TrackingAreaUpdateRequest(old_guti, + ts_PTMSI_SignatureTV(ptmsi_sig), + ts_GUTI_TypeTV(GUTI_TYPE_MAPPED)); + tx := ts_S1AP_InitialUE(p_eNB_value := 0, p_nasPdu := enc_PDU_NAS_EPS(valueof(nas_tau)), + p_tAI := ts_enb_S1AP_TAI(g_pars.enb_pars[g_pars.mme_idx]), + p_eUTRAN_CGI := ts_enb_S1AP_CGI(g_pars.enb_pars[g_pars.mme_idx]), + p_rrcCause := mo_Signalling); + + S1AP.send(tx); + + /* NAS counts are reset to zero when a mapped security context is created. */ + var S1APEM_Config cfg := { + reset_nas_counts := {} + }; + S1AP.send(cfg); + + as_gtp_sgsn_context_2g_to_4g(new_sgsn_teid); + + /* We now expect the MME to send a Create Session Request to the SGW-C */ + //f_gtp2_register_udmsg('20'O); + T.start; + alt { + [] as_GTP2C_CreateSession_success(); + [] T.timeout { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No message from MME")); } + } + + /* 3GPP TS 23.401 D.3.6 steps 14-21: */ + as_DIA_UpdLoc(); + + /* 3GPP TS 23.401 D.3.6 step 22: */ + S1AP.receive(tr_S1AP_IntialCtxSetupReq()) + S1AP.receive(tr_PDU_NAS_EPS_TrackingAreaUpdateAccept); + + /* 3GPP TS 23.401 D.3.6 step 23: */ + // TODO: S1AP.send(ts_PDU_NAS_EPS_TrackingAreaUpdateComplete); + + /* Leave some time for MME to handle TAU Complete: */ + f_sleep(3.0); +} +testcase TC_ue_cell_reselect_geran_to_eutran() runs on MTC_CT { + var charstring id := testcasename(); + + f_init_diameter(id); + f_init_s1ap(id, 6); + f_init_gtpv2_s11(id); + f_s1ap_setup(0); + f_init_gtp(id); + + var ConnHdlrPars pars := f_init_pars(ue_idx := 0); + var ConnHdlr vc_conn; + vc_conn := f_start_handler_with_pars(refers(f_TC_ue_cell_reselect_geran_to_eutran), pars); + vc_conn.done; +} + control { execute( TC_s1ap_setup_wrong_plmn() ); execute( TC_s1ap_setup_wrong_tac() ); @@ -1391,6 +1527,7 @@ execute( TC_RIM_RAN_INF() ); execute( TC_s1ap_reset() ); execute( TC_ue_cell_reselect_eutran_to_geran() ); + execute( TC_ue_cell_reselect_geran_to_eutran() ); }