def test_attach_service_multi_ue(self): """ Test with multi-UE attach, UE context release, service request """ num_ues = 32 self._s1ap_wrapper.configUEDevice(num_ues) reqs = tuple(self._s1ap_wrapper.ue_req for _ in range(num_ues)) for req in reqs: print( "************************* Running End to End attach for UE ", "id ", req.ue_id) # Now actually complete the attach self._s1ap_wrapper._s1_util.attach( req.ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Delay to ensure S1APTester sends attach complete before sending UE # context release time.sleep(0.5) for req in reqs: ue_id = req.ue_id print( "************************* Sending UE context release " "request for UE id ", ue_id) # Send UE context release request to move UE to idle mode req = s1ap_types.ueCntxtRelReq_t() req.ue_Id = ue_id req.cause.causeVal = gpp_types.CauseRadioNetwork.USER_INACTIVITY.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, req) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value) for req in reqs: ue_id = req.ue_id print( "************************* Sending Service request for UE " "id ", ue_id) # Send service request to reconnect UE req = s1ap_types.ueserviceReq_t() req.ue_Id = ue_id req.ueMtmsi = s1ap_types.ueMtmsi_t() req.ueMtmsi.pres = False req.rrcCause = s1ap_types.Rrc_Cause.TFW_MO_DATA.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SERVICE_REQUEST, req) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value) for req in reqs: print("************************* Running UE detach for UE id ", req.ue_id) # Now detach the UE self._s1ap_wrapper.s1_util.detach( req.ue_id, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, True)
def test_attach_service_with_multi_pdns_and_bearers_looped(self): """ Test with a single UE attach + add secondary PDN + add 2 dedicated bearers + (UE context release + service request) repeat 3 times + detach""" self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id loop = 3 # APN of the secondary PDN ims = { "apn_name": "ims", # APN-name "qci": 5, # qci "priority": 15, # priority "pre_cap": 0, # preemption-capability "pre_vul": 0, # preemption-vulnerability "mbr_ul": 200000000, # MBR UL "mbr_dl": 100000000, # MBR DL } # APN list to be configured apn_list = [ims] self._s1ap_wrapper.configAPN( "IMSI" + "".join([str(i) for i in req.imsi]), apn_list, ) print( "************************* Running End to End attach for UE id ", ue_id, ) # UL Flow description #1 ulFlow1 = { "ipv4_dst": "192.168.129.42", # IPv4 destination address "tcp_dst_port": 5002, # TCP dest port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.UPLINK, # Direction } # UL Flow description #2 ulFlow2 = { "ipv4_dst": "192.168.129.42", # IPv4 destination address "tcp_dst_port": 5001, # TCP dest port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.UPLINK, # Direction } # UL Flow description #3 ulFlow3 = { "ipv4_dst": "192.168.129.64", # IPv4 destination address "tcp_dst_port": 5003, # TCP dest port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.UPLINK, # Direction } # UL Flow description #4 ulFlow4 = { "ipv4_dst": "192.168.129.42", # IPv4 destination address "tcp_dst_port": 5001, # TCP dest port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.UPLINK, # Direction } # DL Flow description #1 dlFlow1 = { "ipv4_src": "192.168.129.42", # IPv4 source address "tcp_src_port": 5001, # TCP source port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.DOWNLINK, # Direction } # DL Flow description #2 dlFlow2 = { "ipv4_src": "192.168.129.64", # IPv4 source address "tcp_src_port": 5002, # TCP source port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.DOWNLINK, # Direction } # DL Flow description #3 dlFlow3 = { "ipv4_src": "192.168.129.64", # IPv4 source address "tcp_src_port": 5003, # TCP source port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.DOWNLINK, # Direction } # DL Flow description #4 dlFlow4 = { "ipv4_src": "192.168.129.42", # IPv4 source address "tcp_src_port": 5001, # TCP source port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.DOWNLINK, # Direction } # Flow lists to be configured flow_list1 = [ ulFlow1, ulFlow2, ulFlow3, dlFlow1, dlFlow2, dlFlow3, ] flow_list2 = [ ulFlow4, dlFlow4, ] # QoS qos1 = { "qci": 1, # qci value [1 to 9] "priority": 1, # Range [0-255] "max_req_bw_ul": 10000000, # MAX bw Uplink "max_req_bw_dl": 15000000, # MAX bw Downlink "gbr_ul": 1000000, # GBR Uplink "gbr_dl": 2000000, # GBR Downlink "arp_prio": 1, # ARP priority "pre_cap": 1, # pre-emption capability "pre_vul": 1, # pre-emption vulnerability } qos2 = { "qci": 2, # qci value [1 to 9] "priority": 5, # Range [0-255] "max_req_bw_ul": 10000000, # MAX bw Uplink "max_req_bw_dl": 15000000, # MAX bw Downlink "gbr_ul": 1000000, # GBR Uplink "gbr_dl": 2000000, # GBR Downlink "arp_prio": 1, # ARP priority "pre_cap": 1, # pre-emption capability "pre_vul": 1, # pre-emption vulnerability } policy_id1 = "internet" policy_id2 = "ims" # Now actually complete the attach attach = self._s1ap_wrapper._s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) addr = attach.esmInfo.pAddr.addrInfo default_ip = ipaddress.ip_address(bytes(addr[:4])) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Delay to ensure S1APTester sends attach complete before sending UE # context release print("Sleeping for 5 seconds") time.sleep(5) # Add dedicated bearer for default bearer 5 print( "********************** Adding dedicated bearer to magma.ipv4" " PDN", ) print( "********************** Sending RAR for IMSI", "".join([str(i) for i in req.imsi]), ) self._sessionManager_util.send_ReAuthRequest( "IMSI" + "".join([str(i) for i in req.imsi]), policy_id1, flow_list1, qos1, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_ACT_DED_BER_REQ.value, ) act_ded_ber_req_oai_apn = response.cast( s1ap_types.UeActDedBearCtxtReq_t, ) self._s1ap_wrapper.sendActDedicatedBearerAccept( req.ue_id, act_ded_ber_req_oai_apn.bearerId, ) print("Sleeping for 5 seconds") time.sleep(5) # Send PDN Connectivity Request apn = "ims" self._s1ap_wrapper.sendPdnConnectivityReq(ue_id, apn) # Receive PDN CONN RSP/Activate default EPS bearer context request response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_PDN_CONN_RSP_IND.value, ) act_def_bearer_req = response.cast(s1ap_types.uePdnConRsp_t) addr = act_def_bearer_req.m.pdnInfo.pAddr.addrInfo sec_ip = ipaddress.ip_address(bytes(addr[:4])) print( "********************** Sending Activate default EPS bearer " "context accept for UE id ", ue_id, ) print("Sleeping for 5 seconds") time.sleep(5) # Add dedicated bearer to 2nd PDN print("********************** Adding dedicated bearer to ims PDN") print( "********************** Sending RAR for IMSI", "".join([str(i) for i in req.imsi]), ) self._sessionManager_util.send_ReAuthRequest( "IMSI" + "".join([str(i) for i in req.imsi]), policy_id2, flow_list2, qos2, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_ACT_DED_BER_REQ.value, ) act_ded_ber_req_ims_apn = response.cast( s1ap_types.UeActDedBearCtxtReq_t, ) self._s1ap_wrapper.sendActDedicatedBearerAccept( req.ue_id, act_ded_ber_req_ims_apn.bearerId, ) print( "************* Added dedicated bearer", act_ded_ber_req_ims_apn.bearerId, ) print("Sleeping for 5 seconds") time.sleep(5) dl_flow_rules = { default_ip: [flow_list1], sec_ip: [flow_list2], } # 1 UL flow is created per bearer num_ul_flows = 4 # Verify if flow rules are created self._s1ap_wrapper.s1_util.verify_flow_rules( num_ul_flows, dl_flow_rules, ) print("*********** Moving UE to idle mode") print( "************* Sending UE context release request ", "for UE id ", ue_id, ) for j in range(loop): print("********************* Iteration - ", j + 1) # Send UE context release request to move UE to idle mode rel_req = s1ap_types.ueCntxtRelReq_t() rel_req.ue_Id = ue_id rel_req.cause.causeVal = ( gpp_types.CauseRadioNetwork.USER_INACTIVITY.value) self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, rel_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) # Verify if paging flow rules are created ip_list = [default_ip, sec_ip] self._s1ap_wrapper.s1_util.verify_paging_flow_rules(ip_list) print( "************************* Sending Service request for UE id ", ue_id, ) # Send service request to reconnect UE ser_req = s1ap_types.ueserviceReq_t() ser_req.ue_Id = ue_id ser_req.ueMtmsi = s1ap_types.ueMtmsi_t() ser_req.ueMtmsi.pres = False ser_req.rrcCause = s1ap_types.Rrc_Cause.TFW_MO_SIGNALLING.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SERVICE_REQUEST, ser_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value, ) print("Sleeping for 5 seconds") time.sleep(5) # Verify if flow rules are created self._s1ap_wrapper.s1_util.verify_flow_rules( num_ul_flows, dl_flow_rules, ) print("Sleeping for 5 seconds") time.sleep(5) print("************************* Running UE detach for UE id ", ue_id) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue_id, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, True, )
def test_dedicated_bearer_activation_idle_mode_pag_tmr_exp(self): """ Test with a single UE attach + UE context release + dedicated bearer activation + page the UE + Paging timer expires + send dedicated bearer activation reject to SPGW""" self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id imsi = req.imsi # Add dedicated bearer for default bearer 5 # UL Flow description #1 ulFlow1 = { "ipv4_dst": "192.168.129.42", # IPv4 destination address "tcp_dst_port": 5002, # TCP dest port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.UPLINK, # Direction } # UL Flow description #2 ulFlow2 = { "ipv4_dst": "192.168.129.42", # IPv4 destination address "tcp_dst_port": 5001, # TCP dest port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.UPLINK, # Direction } # UL Flow description #3 ulFlow3 = { "ipv4_dst": "192.168.129.64", # IPv4 destination address "tcp_dst_port": 5003, # TCP dest port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.UPLINK, # Direction } # UL Flow description #4 ulFlow4 = { "ipv4_dst": "192.168.129.42", # IPv4 destination address "tcp_dst_port": 5004, # TCP dest port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.UPLINK, # Direction } # DL Flow description #1 dlFlow1 = { "ipv4_src": "192.168.129.42", # IPv4 source address "tcp_src_port": 5001, # TCP source port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.DOWNLINK, # Direction } # DL Flow description #2 dlFlow2 = { "ipv4_src": "192.168.129.64", # IPv4 source address "tcp_src_port": 5002, # TCP source port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.DOWNLINK, # Direction } # DL Flow description #3 dlFlow3 = { "ipv4_src": "192.168.129.64", # IPv4 source address "tcp_src_port": 5003, # TCP source port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.DOWNLINK, # Direction } # DL Flow description #4 dlFlow4 = { "ipv4_src": "192.168.129.42", # IPv4 source address "tcp_src_port": 5004, # TCP source port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.DOWNLINK, # Direction } # Flow list to be configured flow_list = [ ulFlow1, ulFlow2, ulFlow3, ulFlow4, dlFlow1, dlFlow2, dlFlow3, dlFlow4, ] # QoS qos = { "qci": 1, # qci value [1 to 9] "priority": 1, # Range [0-255] "max_req_bw_ul": 10000000, # MAX bw Uplink "max_req_bw_dl": 15000000, # MAX bw Downlink "gbr_ul": 1000000, # GBR Uplink "gbr_dl": 2000000, # GBR Downlink "arp_prio": 1, # ARP priority "pre_cap": 1, # pre-emption capability "pre_vul": 1, # pre-emption vulnerability } policy_id = "internet" print("*********** Running End to End attach for UE id ", ue_id) attach = self._s1ap_wrapper._s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) addr = attach.esmInfo.pAddr.addrInfo default_ip = ipaddress.ip_address(bytes(addr[:4])) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Delay to ensure S1APTester sends attach complete before sending UE # context release print("*********** Sleeping for 5 seconds") time.sleep(5) print("*********** Moving UE to idle mode") print( "*********** Sending UE context release request ", "for UE id ", ue_id, ) # Send UE context release request to move UE to idle mode req = s1ap_types.ueCntxtRelReq_t() req.ue_Id = ue_id req.cause.causeVal = gpp_types.CauseRadioNetwork.USER_INACTIVITY.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, req) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value) # Verify if paging flow rules are created ip_list = [default_ip] self._s1ap_wrapper.s1_util.verify_paging_flow_rules(ip_list) print("Sleeping for 5 seconds") time.sleep(5) print("************* Adding dedicated bearer to magma.ipv4" " PDN in idle mode") print( "************* Sending RAR for IMSI", "".join([str(i) for i in imsi]), ) self._sessionManager_util.send_ReAuthRequest( "IMSI" + "".join([str(i) for i in imsi]), policy_id, flow_list, qos, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_PAGING_IND.value) print("*********** Received Paging for UE id ", ue_id) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_PAGING_IND.value) print("*********** Received second Paging for UE id ", ue_id) print("*********** Sleeping for 5 seconds") time.sleep(5) print("*********** Running UE detach for UE id ", ue_id) # Now detach the UE detach_req = s1ap_types.uedetachReq_t() detach_req.ue_Id = ue_id detach_req.ueDetType = ( s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value) self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_DETACH_REQUEST, detach_req)
def test_implicit_detach_timer_with_mme_restart(self): """ The test case validates implicit detach timer resumes the configured timer value on MME restart NOTE: Before execution of this test case, run the test case, test_modify_mme_config_for_sanity.py to modify the default 3412 timer value from 54 minutes to 1 minute Step1 : UE attaches to network Step2 : UE moves to Idle state Step3 : Let mobile reachability timer expire, on expiry of which, MME starts implicit detach timer. While implicit detach timer is running, send "mme restart" command. After MME restart, mme shall start implicit detach timer for remaining duration, on expiry of which MME shall delete the contexts locally Step4 : Send Service Request, after Implicit Detach Timer expiry expecting Service Reject, as MME has released the UE contexts """ self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id print( "************************* Running End to End attach for UE id ", ue_id, ) # Now actually complete the attach self._s1ap_wrapper._s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Delay to ensure S1APTester sends attach complete before sending UE # context release time.sleep(0.5) print( "************************* Sending UE context release request ", "for UE id ", ue_id, ) # Send UE context release request to move UE to idle mode req = s1ap_types.ueCntxtRelReq_t() req.ue_Id = ue_id req.cause.causeVal = gpp_types.CauseRadioNetwork.USER_INACTIVITY.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, req) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value) # Delay by 6 minutes to ensure Mobile reachability timer expires. # Mobile Reachability Timer value = 1 minute (conf file) + delta value # at mme (4 minute) print("************************* Waiting for Mobile Reachability Timer" " to expire. Sleeping for 6 minutes") timeSlept = 0 while timeSlept < 360: time.sleep(10) timeSlept += 10 print("*********** Slept for", timeSlept, "seconds") print("************************* Restarting MME service on gateway") self._s1ap_wrapper.magmad_util.restart_services(["mme"]) for j in range(60): print("Waiting for", j, "seconds") time.sleep(1) # Wait for Implicit detach timer to expire, on expiry of which MME deletes # UE contexts locally, S1ap tester shall send Service Request expecting # Service Reject as UE contexts are already deleted # Implicit detach timer = Mobile reachability timer print("************************* Waiting for Implicit Detach Timer" " to expire. Sleeping for 6 minutes..") timeSlept = 0 while timeSlept < 360: time.sleep(10) timeSlept += 10 print("*********** Slept for", timeSlept, "seconds") print( "************************* Sending Service request for UE id ", ue_id, ) # Send service request to reconnect UE req = s1ap_types.ueserviceReq_t() req.ue_Id = ue_id req.ueMtmsi = s1ap_types.ueMtmsi_t() req.ueMtmsi.pres = False req.rrcCause = s1ap_types.Rrc_Cause.TFW_MO_DATA.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SERVICE_REQUEST, req) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_SERVICE_REJECT_IND.value) print( "************************* Received Service Reject for UE id ", ue_id, ) # Wait for UE Context Release command response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value)
def test_tau_ta_updating_reject(self): """Attach a UE. Move the UE to idle mode. Send tracking area update(TAU)request with TAC=55 MME sends TAU reject as the tac is not configured in mme.conf """ num_ues = 1 wait_for_s1_context_rel = False self._s1ap_wrapper.configUEDevice(num_ues) # Attach req = self._s1ap_wrapper.ue_req ue_id = req.ue_id self._s1ap_wrapper.s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, id_type=s1ap_types.TFW_MID_TYPE_GUTI, ) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Add delay to ensure that S1APTester sends Attach Complete time.sleep(0.5) # Configure TAC=5 in s1aptester config_tai = s1ap_types.nbConfigTai_t() config_tai.ue_Id = req.ue_id config_tai.tac = 55 self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.ENB_CONFIG_TAI, config_tai, ) print( "************************* Sending ENB_CONFIG_TAI ", "for UE id ", req.ue_id, ) # Move the UE to idle state print( "************************* Sending UE context release request ", "for UE id ", req.ue_id, ) cntxt_rel_req = s1ap_types.ueCntxtRelReq_t() cntxt_rel_req.ue_Id = req.ue_id cntxt_rel_req.cause.causeVal = ( gpp_types.CauseRadioNetwork.USER_INACTIVITY.value ) self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, cntxt_rel_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) print( "************************* Sending Tracking Area Update ", "request for UE id ", req.ue_id, ) tau_req = s1ap_types.ueTauReq_t() tau_req.ue_Id = req.ue_id tau_req.type = s1ap_types.Eps_Updt_Type.TFW_TA_UPDATING.value tau_req.Actv_flag = False tau_req.ueMtmsi.pres = False self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_TAU_REQ, tau_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEquals( response.msg_type, s1ap_types.tfwCmd.UE_TAU_REJECT_IND.value, ) tau_rej = response.cast(s1ap_types.ueTauRejInd_t) print( "************************* Received Tracking Area Update ", "reject for UE id ", tau_rej.ue_Id, ) print("************************* Sleeping for 2 seconds") time.sleep(2) print( "************************* Running UE detach (switch-off) for ", "UE id ", req.ue_id, ) # Now detach the UE self._s1ap_wrapper.s1_util.detach( req.ue_id, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, wait_for_s1_context_rel, )
def test_ipv6_paging(self): """ IPv4v6 Attach, add dedicated bearer, ue context release, paging request """ # Ground work. self._s1ap_wrapper.configUEDevice(1) # Default apn over-write magma_apn = { "apn_name": "magma", # APN-name "qci": 9, # qci "priority": 15, # priority "pre_cap": 1, # preemption-capability "pre_vul": 0, # preemption-vulnerability "mbr_ul": 200000000, # MBR UL "mbr_dl": 100000000, # MBR DL "pdn_type": 2, # PDN Type 0-IPv4,1-IPv6,2-IPv4v6 } ue_ctxt_rel = False apn_list = [magma_apn] req = self._s1ap_wrapper.ue_req ue_id = req.ue_id print( "********** Running End to End attach for UE id ", ue_id, ) self._s1ap_wrapper.configAPN( "IMSI" + "".join([str(j) for j in req.imsi]), apn_list, default=False, ) # Now actually complete the attach attach = self._s1ap_wrapper.s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, pdn_type=3, ) addr = attach.esmInfo.pAddr.addrInfo default_ipv4 = ipaddress.ip_address(bytes(addr[8:12])) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Delay to ensure S1APTester sends attach complete before sending UE # context release time.sleep(5) # Receive Router Advertisement message apn = "magma" response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_ROUTER_ADV_IND.value, ) router_adv = response.cast(s1ap_types.ueRouterAdv_t) print( "********** Received Router Advertisement for APN-%s" " bearer id-%d" % (apn, router_adv.bearerId), ) ipv6_addr = "".join([chr(i) for i in router_adv.ipv6Addr]).rstrip("\x00", ) print("********** UE IPv6 address: ", ipv6_addr) default_ipv6 = ipaddress.ip_address(ipv6_addr) self._s1ap_wrapper.s1_util.update_ipv6_address(ue_id, ipv6_addr) print("********************** Adding dedicated bearer") print( "********************** Sending RAR for IMSI", "".join([str(i) for i in req.imsi]), ) # QoS qos = { "qci": 1, # qci value [1 to 9] "priority": 1, # Range [0-255] "max_req_bw_ul": 10000000, # MAX bw Uplink "max_req_bw_dl": 15000000, # MAX bw Downlink "gbr_ul": 1000000, # GBR Uplink "gbr_dl": 2000000, # GBR Downlink "arp_prio": 1, # ARP priority "pre_cap": 1, # pre-emption capability "pre_vul": 1, # pre-emption vulnerability } flow_list = self._spgw_util.create_default_ipv6_flows() policy_id = "magma" self._sessionManager_util.send_ReAuthRequest( "IMSI" + "".join([str(i) for i in req.imsi]), policy_id, flow_list, qos, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_ACT_DED_BER_REQ.value, ) act_ded_ber_req = response.cast(s1ap_types.UeActDedBearCtxtReq_t) self._s1ap_wrapper.sendActDedicatedBearerAccept( req.ue_id, act_ded_ber_req.bearerId, ) print( "************* Added dedicated bearer", act_ded_ber_req.bearerId, ) # Sleep before verifying flows print("********** Sleeping for 5 seconds") time.sleep(5) # Verify flow rules num_ul_flows = 2 dl_flow_rules = { default_ipv4: [flow_list], default_ipv6: [flow_list], } # Verify if flow rules are created self._s1ap_wrapper.s1_util.verify_flow_rules( num_ul_flows, dl_flow_rules, ) print( "********** Sending UE context release request ", "for UE id ", ue_id, ) # Send UE context release request to move UE to idle mode ue_cntxt_rel_req = s1ap_types.ueCntxtRelReq_t() ue_cntxt_rel_req.ue_Id = ue_id ue_cntxt_rel_req.cause.causeVal = ( gpp_types.CauseRadioNetwork.USER_INACTIVITY.value) self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, ue_cntxt_rel_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) print("********** UE moved to idle mode") print("********** Sleeping for 5 seconds") time.sleep(5) # Verify paging rules ip_list = [default_ipv4, default_ipv6] self._s1ap_wrapper.s1_util.verify_paging_flow_rules(ip_list) print( "********** Running UE downlink (UDP) for UE id ", ue_id, ) self._s1ap_wrapper.s1_util.run_ipv6_data(default_ipv6) response = self._s1ap_wrapper.s1_util.get_response() self.assertTrue(response, s1ap_types.tfwCmd.UE_PAGING_IND.value) print("********** Received UE_PAGING_IND") # Send service request to reconnect UE ser_req = s1ap_types.ueserviceReq_t() ser_req.ue_Id = ue_id ser_req.ueMtmsi = s1ap_types.ueMtmsi_t() ser_req.ueMtmsi.pres = False ser_req.rrcCause = s1ap_types.Rrc_Cause.TFW_MT_ACCESS.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SERVICE_REQUEST, ser_req, ) print("********** Sent UE_SERVICE_REQUEST") response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value, ) print("********** Received INT_CTX_SETUP_IND") print("********** Sleeping for 5 seconds") time.sleep(5) # Verify flow rules num_ul_flows = 2 dl_flow_rules = { default_ipv4: [flow_list], default_ipv6: [flow_list], } # Verify if flow rules are created self._s1ap_wrapper.s1_util.verify_flow_rules( num_ul_flows, dl_flow_rules, ) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue_id, s1ap_types.ueDetachType_t.UE_NORMAL_DETACH.value, ue_ctxt_rel, )
def test_idle_mode_with_mme_restart(self): """ The test case checks that state of UE in idle mode is resumed when stateles MME restarts Step1 : UE attaches to network Step2 : UE moves to Idle state Step3 : Restart MME Step4 : Send Service Request, which should be accepted by the network Step5 : Detach UE """ self._s1ap_wrapper.configUEDevice(1) time.sleep(20) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id print( "************************* Running End to End attach for UE id ", ue_id, ) # Now actually complete the attach self._s1ap_wrapper._s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Delay to ensure S1APTester sends attach complete before sending UE # context release time.sleep(0.5) print( "************************* Sending UE context release request ", "for UE id ", ue_id, ) # Send UE context release request to move UE to idle mode req = s1ap_types.ueCntxtRelReq_t() req.ue_Id = ue_id req.cause.causeVal = gpp_types.CauseRadioNetwork.USER_INACTIVITY.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) print("************************* Restarting MME service on gateway") self._s1ap_wrapper.magmad_util.restart_services(["mme"]) for j in range(30): print("Waiting for", j, "seconds") time.sleep(1) print( "************************* Sending Service request for UE id ", ue_id, ) # Send service request to reconnect UE req = s1ap_types.ueserviceReq_t() req.ue_Id = ue_id req.ueMtmsi = s1ap_types.ueMtmsi_t() req.ueMtmsi.pres = False req.rrcCause = s1ap_types.Rrc_Cause.TFW_MO_DATA.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SERVICE_REQUEST, req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value, ) print("************************* Running UE detach for UE id ", ue_id) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue_id, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, True, )
def test_tau_mixed_partial_lists(self): """Attach 3 UEs. Move the UEs to idle mode. Send tracking area update(TAU)request with TACs belonging to different partial TAI lists """ num_ues = 3 ue_ids = [] tac = [1, 20, 45] wait_for_s1_context_rel = False self._s1ap_wrapper.configUEDevice(num_ues) # Attach for _ in range(num_ues): req = self._s1ap_wrapper.ue_req self._s1ap_wrapper.s1_util.attach( req.ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) ue_ids.append(req.ue_id) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Add delay to ensure that S1APTester sends Attach Complete time.sleep(0.5) for i in range(num_ues): # Configure tacs in s1aptester config_tai = s1ap_types.nbConfigTai_t() config_tai.ue_Id = ue_ids[i] config_tai.tac = tac[i] self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.ENB_CONFIG_TAI, config_tai, ) print( "************************* Sending ENB_CONFIG_TAI ", "for UE id ", ue_ids[i], ) # Move the UE to idle state print( "************************* Sending UE context release request ", "for UE id ", ue_ids[i], ) cntxt_rel_req = s1ap_types.ueCntxtRelReq_t() cntxt_rel_req.ue_Id = ue_ids[i] cntxt_rel_req.cause.causeVal = ( gpp_types.CauseRadioNetwork.USER_INACTIVITY.value) self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, cntxt_rel_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) print( "************************* Sending Tracking Area Update ", "request for UE id ", ue_ids[i], ) tau_req = s1ap_types.ueTauReq_t() tau_req.ue_Id = ue_ids[i] tau_req.type = s1ap_types.Eps_Updt_Type.TFW_TA_UPDATING.value tau_req.Actv_flag = False tau_req.ueMtmsi.pres = False self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_TAU_REQ, tau_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_TAU_ACCEPT_IND.value, ) tau_acc = response.cast(s1ap_types.ueTauAccept_t) print( "************************* Received Tracking Area Update ", "accept for UE id ", tau_acc.ue_Id, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) print("************************* Sleeping for 2 seconds") time.sleep(2) for ue in ue_ids: print( "************************* Running UE detach (switch-off) for ", "UE id ", ue, ) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, wait_for_s1_context_rel, )
def test_attach_service_ue_radio_capability(self): """ Test with a single UE attach, UE context release, service request, check for presence in UE radio capability in Initial context setup message sent during service request """ self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id print( "************************* Running End to End attach for UE id ", ue_id, ) # Now actually complete the attach self._s1ap_wrapper._s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Delay to ensure S1APTester sends attach complete before sending UE # context release time.sleep(0.5) print( "************************* Sending UE context release request ", "for UE id ", ue_id, ) # Send UE context release request to move UE to idle mode req = s1ap_types.ueCntxtRelReq_t() req.ue_Id = ue_id req.cause.causeVal = gpp_types.CauseRadioNetwork.USER_INACTIVITY.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) print( "************************* Sending Service request for UE id ", ue_id, ) # Send service request to reconnect UE req = s1ap_types.ueserviceReq_t() req.ue_Id = ue_id req.ueMtmsi = s1ap_types.ueMtmsi_t() req.ueMtmsi.pres = False req.rrcCause = s1ap_types.Rrc_Cause.TFW_MO_DATA.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SERVICE_REQUEST, req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value, ) print( "************************* Running UE detach for UE id ", ue_id, ) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue_id, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, True, )
def test_mobile_reachability_timer_with_mme_restart(self): """ The test case validates Mobile Reachability Timer resumes the configured timer value on MME restart Step1 : UE attaches to network Step2 : UE moves to Idle state Step3 : Once MME restarts, MME shall resume the Mobile reachability timer for remaining time, on expiry MME starts the Implicit Detach Timer. On expiry of Implicit Detach Timer, MME implicitly detaches UE. MME shall delete the contexts locally Step4 : Send Service Request, after Implicit Detach Timer expiry expecting Service Reject, as MME has released the UE contexts """ self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id print("************************* Running End to End attach for UE id ", ue_id) # Now actually complete the attach self._s1ap_wrapper._s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Delay to ensure S1APTester sends attach complete before sending UE # context release time.sleep(0.5) print("************************* Sending UE context release request ", "for UE id ", ue_id) # Send UE context release request to move UE to idle mode req = s1ap_types.ueCntxtRelReq_t() req.ue_Id = ue_id req.cause.causeVal = gpp_types.CauseRadioNetwork.USER_INACTIVITY.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, req) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value) print("************************* Restarting MME service on", "gateway") self._s1ap_wrapper.magmad_util.restart_services(["mme"]) for j in range(30): print("Waiting for", j, "seconds") time.sleep(1) print("Waiting for Mobile Reachability Timer (58 Minutes) and" " Implicit Detach Timer (58 minutes) to expire" " together timer value is set to 7020 seconds") # 58 Minutes + 58 minutes = 116 minutes (6960 seconds) # 6960 seconds + 60 seconds, delta(Randomly chosen) time.sleep(7020) print("************************* Sending Service request for UE id ", ue_id) # Send service request to reconnect UE req = s1ap_types.ueserviceReq_t() req.ue_Id = ue_id req.ueMtmsi = s1ap_types.ueMtmsi_t() req.ueMtmsi.pres = False req.rrcCause = s1ap_types.Rrc_Cause.TFW_MO_DATA.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SERVICE_REQUEST, req) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_SERVICE_REJECT_IND.value) print("************************* Received Service Reject for UE id ", ue_id) # Wait for UE Context Release command response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value)
def test_data_flow_after_service_request(self): """ Test data flow after service request """ num_ues = 2 self._s1ap_wrapper.configUEDevice(num_ues) reqs = tuple(self._s1ap_wrapper.ue_req for _ in range(num_ues)) for req in reqs: print( "************************* Running End to End attach for ", "UE id", req.ue_id, ) # Now actually complete the attach self._s1ap_wrapper._s1_util.attach( req.ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() dl_reqs = reqs[::2] ul_reqs = reqs[1::2] print( "************************* Running UE downlink (TCP) for UE Ids", [req.ue_id for req in dl_reqs], "and uplink (TCP) for UE Ids", [req.ue_id for req in ul_reqs], ) dl_tests = self._s1ap_wrapper.configDownlinkTest(*dl_reqs, duration=1) ul_tests = self._s1ap_wrapper.configUplinkTest(*ul_reqs, duration=1) test = dl_tests.combine(dl_tests, ul_tests) with test: test.verify() # Added sleep to avoid chances of incoming paging indication time.sleep(0.5) for req in reqs: ue_id = req.ue_id print( "************************* Sending UE context release " "request for UE id", ue_id, ) # Send UE context release request to move UE to idle mode req = s1ap_types.ueCntxtRelReq_t() req.ue_Id = ue_id req.cause.causeVal = ( gpp_types.CauseRadioNetwork.USER_INACTIVITY.value ) self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) for req in reqs: ue_id = req.ue_id print( "************************* Sending Service request for UE Id", ue_id, ) # Send service request to reconnect UE req = s1ap_types.ueserviceReq_t() req.ue_Id = ue_id req.ueMtmsi = s1ap_types.ueMtmsi_t() req.ueMtmsi.pres = False req.rrcCause = s1ap_types.Rrc_Cause.TFW_MO_DATA.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SERVICE_REQUEST, req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value, ) with test: test.verify() for req in reqs: print( "************************* Running UE detach for UE id", req.ue_id, ) # Now detach the UE self._s1ap_wrapper.s1_util.detach( req.ue_id, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, False, )
def test_ics_timer_expiry_ue_registered(self): """ Simulating ICS timer expiry by dropping ICS req when UE moves from idle to connected mode i.e UE is in registered state. Network sends UE context release cmd after ICS timer expires """ self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id print( "************************* Running End to End attach for UE id ", ue_id, ) # Attach self._s1ap_wrapper._s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Delay to ensure S1APTester sends attach complete before sending UE # context release time.sleep(0.5) print( "************************* Sending UE context release request ", "for UE id ", ue_id, ) # Send UE context release request to move UE to idle mode req = s1ap_types.ueCntxtRelReq_t() req.ue_Id = ue_id req.cause.causeVal = gpp_types.CauseRadioNetwork.USER_INACTIVITY.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, req ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value ) print("*** Sending indication to drop Initial Context Setup Req ***") drop_init_ctxt_setup_req = s1ap_types.UeDropInitCtxtSetup() drop_init_ctxt_setup_req.ue_Id = ue_id drop_init_ctxt_setup_req.flag = 1 # Timer to release UE context at s1ap tester drop_init_ctxt_setup_req.tmrVal = 2000 self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SET_DROP_ICS, drop_init_ctxt_setup_req ) print("**** Sleeping for 5 seconds *****") time.sleep(5) print( "************************* Sending Service request for UE id ", ue_id, ) # Send service request to reconnect UE req = s1ap_types.ueserviceReq_t() req.ue_Id = ue_id req.ueMtmsi = s1ap_types.ueMtmsi_t() req.ueMtmsi.pres = False req.rrcCause = s1ap_types.Rrc_Cause.TFW_MO_DATA.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SERVICE_REQUEST, req ) # enbApp sends UE_ICS_DROPD_IND message to tfwApp after dropping # ICS request response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_ICS_DROPD_IND.value ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value ) print( "************************* Received UE_CTX_REL_IND for UE id ", ue_id, ) print("************************* Running UE detach for UE id ", ue_id) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue_id, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, False )
def test_tau_ta_updating(self): """Attach 2 UEs. Move the UEs to idle mode. 1. For the 1st UE, send tracking area update(TAU) with EPS Update Type=TA Updating and active flag set to true 2. For the 2nd UE, send tracking area update(TAU) with EPS Update Type=TA Updating and active flag set to false """ num_ues = 2 wait_for_s1_context_rel = False self._s1ap_wrapper.configUEDevice(num_ues) ue_ids = [] # Attach for _ in range(num_ues): req = self._s1ap_wrapper.ue_req ue_id = req.ue_id self._s1ap_wrapper.s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, id_type=s1ap_types.TFW_MID_TYPE_GUTI, ) ue_ids.append(req.ue_id) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Add delay to ensure that S1APTester sends Attach Complete time.sleep(0.5) # Move the UEs to idle state for ue in ue_ids: print( "************************* Sending UE context release request ", "for UE id ", ue, ) # Send UE context release request to move UE to idle mode cntxt_rel_req = s1ap_types.ueCntxtRelReq_t() cntxt_rel_req.ue_Id = ue cntxt_rel_req.cause.causeVal = ( gpp_types.CauseRadioNetwork.USER_INACTIVITY.value ) self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, cntxt_rel_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) # For the 1st UE, send TAU with Eps_Updt_Type # TA_UPDATING and active flag set to true print( "************************* Sending Tracking Area Update ", "request for UE id ", ue_ids[0], ) tau_req = s1ap_types.ueTauReq_t() tau_req.ue_Id = ue_ids[0] tau_req.type = s1ap_types.Eps_Updt_Type.TFW_TA_UPDATING.value tau_req.Actv_flag = True tau_req.ueMtmsi.pres = False self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_TAU_REQ, tau_req, ) response = ( self._s1ap_wrapper._s1_util .receive_initial_ctxt_setup_and_tau_accept() ) tau_acc = response.cast(s1ap_types.ueTauAccept_t) print( "************************* Received Tracking Area Update ", "accept for UE id ", tau_acc.ue_Id, ) # For the 2nd UE, send TAU with Eps_Updt_Type # TA_UPDATING and active flag set to false print( "************************* Sending Tracking Area Update ", "request for UE id ", ue_ids[1], ) tau_req = s1ap_types.ueTauReq_t() tau_req.ue_Id = ue_ids[1] tau_req.type = s1ap_types.Eps_Updt_Type.TFW_TA_UPDATING.value tau_req.Actv_flag = False tau_req.ueMtmsi.pres = False self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_TAU_REQ, tau_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_TAU_ACCEPT_IND.value, ) tau_acc = response.cast(s1ap_types.ueTauAccept_t) print( "************************* Received Tracking Area Update ", "accept for UE id ", tau_acc.ue_Id, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) for ue in ue_ids: print( "************************* Running UE detach (switch-off) for ", "UE id ", ue, ) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, wait_for_s1_context_rel, )
def test_multi_enb_paging_request(self): """ Multi Enb Multi UE attach detach """ # column is a enb parameter, row is a number of enbs # column description: 1.Cell Id, 2.Tac, 3.EnbType, 4.PLMN Id enb_list = [ (1, 1, 1, "001010"), (2, 2, 1, "001010"), (3, 3, 1, "001010"), (4, 4, 1, "001010"), (5, 5, 1, "001010"), ] self._s1ap_wrapper.multiEnbConfig(len(enb_list), enb_list) time.sleep(2) ue_ids = [] # UEs will attach to the ENBs in a round-robin fashion # each ENBs will be connected with 32UEs num_ues = 1 # Ground work. self._s1ap_wrapper.configUEDevice(num_ues) for _ in range(num_ues): req = self._s1ap_wrapper.ue_req print("******************** Calling attach for UE id ", req.ue_id) self._s1ap_wrapper.s1_util.attach( req.ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() ue_ids.append(req.ue_id) # Delay to ensure S1APTester sends attach complete before # sending UE context release time.sleep(0.5) print( "********************* Sending UE context release request ", "for UE id ", req.ue_id, ) # Send UE context release request to move UE to idle mode ue_cntxt_rel_req = s1ap_types.ueCntxtRelReq_t() ue_cntxt_rel_req.ue_Id = req.ue_id ue_cntxt_rel_req.cause.causeVal = ( gpp_types.CauseRadioNetwork.USER_INACTIVITY.value) self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, ue_cntxt_rel_req) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value) time.sleep(0.5) print( "********************* Running UE downlink (UDP) for UE id ", req.ue_id, ) with self._s1ap_wrapper.configDownlinkTest(req, duration=1, is_udp=True) as test: response = self._s1ap_wrapper.s1_util.get_response() self.assertTrue(response, s1ap_types.tfwCmd.UE_PAGING_IND.value) response = self._s1ap_wrapper.s1_util.get_response() self.assertTrue(response, s1ap_types.tfwCmd.UE_PAGING_IND.value) response = self._s1ap_wrapper.s1_util.get_response() self.assertTrue(response, s1ap_types.tfwCmd.UE_PAGING_IND.value) response = self._s1ap_wrapper.s1_util.get_response() self.assertTrue(response, s1ap_types.tfwCmd.UE_PAGING_IND.value) response = self._s1ap_wrapper.s1_util.get_response() self.assertTrue(response, s1ap_types.tfwCmd.UE_PAGING_IND.value) # Send service request to reconnect UE ser_req = s1ap_types.ueserviceReq_t() ser_req.ue_Id = req.ue_id ser_req.ueMtmsi = s1ap_types.ueMtmsi_t() ser_req.ueMtmsi.pres = False ser_req.rrcCause = s1ap_types.Rrc_Cause.TFW_MT_ACCESS.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SERVICE_REQUEST, ser_req) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value, ) test.verify() time.sleep(0.5) # Now detach the UE for ue in ue_ids: print("************************* Calling detach for UE id ", ue) self._s1ap_wrapper.s1_util.detach( ue, s1ap_types.ueDetachType_t.UE_NORMAL_DETACH.value, True) time.sleep(1)
def test_paging_request(self): """ Multi Enb Multi UE attach detach """ # column is a enb parameter, row is a number of enbs # column description: 1.Cell Id, 2.Tac, 3.EnbType, 4.PLMN Id enb_list = [(1, 1, 1, "001010")] self._s1ap_wrapper.multiEnbConfig(len(enb_list), enb_list) time.sleep(2) """ Attach, paging request """ # Ground work. self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id print( "************************* Running End to End attach for UE id ", ue_id, ) # Now actually complete the attach self._s1ap_wrapper.s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Delay to ensure S1APTester sends attach complete before sending UE # context release time.sleep(0.5) print( "************************* Sending UE context release request ", "for UE id ", ue_id, ) # Send UE context release request to move UE to idle mode ue_cntxt_rel_req = s1ap_types.ueCntxtRelReq_t() ue_cntxt_rel_req.ue_Id = ue_id ue_cntxt_rel_req.cause.causeVal = ( gpp_types.CauseRadioNetwork.USER_INACTIVITY.value) self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, ue_cntxt_rel_req) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value) time.sleep(0.3) print( "************************* Running UE downlink (UDP) for UE id ", ue_id, ) with self._s1ap_wrapper.configDownlinkTest(req, duration=1, is_udp=True) as test: response = self._s1ap_wrapper.s1_util.get_response() self.assertTrue(response, s1ap_types.tfwCmd.UE_PAGING_IND.value) # Send service request to reconnect UE ser_req = s1ap_types.ueserviceReq_t() ser_req.ue_Id = ue_id ser_req.ueMtmsi = s1ap_types.ueMtmsi_t() ser_req.ueMtmsi.pres = False ser_req.rrcCause = s1ap_types.Rrc_Cause.TFW_MO_DATA.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SERVICE_REQUEST, ser_req) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value) test.verify() time.sleep(0.5) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue_id, s1ap_types.ueDetachType_t.UE_NORMAL_DETACH.value, True) time.sleep(0.5)
def test_attach_mobile_reachability_timer_expiry(self): """ Test Mobile Reachability timer expiry handling """ """ Note: Before execution of this test case, Run the test script s1aptests/test_modify_mme_config_for_sanity.py to reduce mobile reachability timer value to 1 minute (default is 54 minutes) in MME configuration and after test case execution, restore the MME configuration by running the test script s1aptests/test_restore_mme_config_after_sanity.py Or Manually update the mme.conf.template file to make sure that the value of T3412 timer is set to 1 minute (default is 54 minutes) """ self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id print( "************************* Running End to End attach for UE id ", ue_id, ) # Now actually complete the attach self._s1ap_wrapper._s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Delay to ensure S1APTester sends attach complete before sending UE # context release time.sleep(0.5) print( "************************* Sending UE context release request ", "for UE id ", ue_id, ) # Send UE context release request to move UE to idle mode req = s1ap_types.ueCntxtRelReq_t() req.ue_Id = ue_id req.cause.causeVal = gpp_types.CauseRadioNetwork.USER_INACTIVITY.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) # Delay by 6 minutes to ensure Mobile reachability timer expires. # MOBILE REACHABILITY TIMER VALUE = 1 minute (conf file) + delta value print( "************************* Waiting for Mobile Reachability Timer" " to expire. Sleeping for 360 seconds..", ) timeSlept = 0 while timeSlept < 360: time.sleep(5) timeSlept += 5 print("*********** Slept for " + str(timeSlept) + " seconds") print( "************************* Sending Service request for UE id ", ue_id, ) # Send service request to reconnect UE req = s1ap_types.ueserviceReq_t() req.ue_Id = ue_id req.ueMtmsi = s1ap_types.ueMtmsi_t() req.ueMtmsi.pres = False req.rrcCause = s1ap_types.Rrc_Cause.TFW_MO_DATA.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SERVICE_REQUEST, req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value, ) print("************************* Running UE detach for UE id ", ue_id) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue_id, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, True, )
def test_paging_with_mme_restart(self): """ The test case validates resumption of Paging Response Timer on mme restart Step1 : UE attaches to network Step2 : UE moves to Idle state Step3 : Send DL data, on arrival of DL data mme sends Paging message and starts Paging Response timer, while timer is running mme restarts, once mme restarts, mme shall be able to resume Paging response timer Step4 : On expiry of Paging Response timer, mme shall re-send Paging message Step5 : In response to Paging message, UE sends Service Request message Step6 : Expecting normal flow of DL data """ self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id print( "************************* Running End to End attach for UE id ", ue_id, ) # Now actually complete the attach self._s1ap_wrapper.s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Delay to ensure S1APTester sends attach complete before sending UE # context release time.sleep(0.5) print( "************************* Sending UE context release request ", "for UE id ", ue_id, ) # Send UE context release request to move UE to idle mode ue_cntxt_rel_req = s1ap_types.ueCntxtRelReq_t() ue_cntxt_rel_req.ue_Id = ue_id ue_cntxt_rel_req.cause.causeVal = ( gpp_types.CauseRadioNetwork.USER_INACTIVITY.value) self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, ue_cntxt_rel_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) time.sleep(0.3) print( "************************* Running UE downlink (UDP) for UE id ", ue_id, ) with self._s1ap_wrapper.configDownlinkTest( req, duration=1, is_udp=True, ) as test: response = self._s1ap_wrapper.s1_util.get_response() self.assertTrue(response, s1ap_types.tfwCmd.UE_PAGING_IND.value) print("************************ Received Paging Indication") print( "************************* Restarting MME service on", "gateway", ) self._s1ap_wrapper.magmad_util.restart_services(["mme"]) for j in range(30): print("Waiting for", j, "seconds") time.sleep(1) # Send service request to reconnect UE ser_req = s1ap_types.ueserviceReq_t() ser_req.ue_Id = ue_id ser_req.ueMtmsi = s1ap_types.ueMtmsi_t() ser_req.ueMtmsi.pres = False ser_req.rrcCause = s1ap_types.Rrc_Cause.TFW_MT_ACCESS.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SERVICE_REQUEST, ser_req, ) # It has been observed that despite getting the restart command on # time, MME sometimes restarts after a delay of 5-6 seconds. # Currently Paging response timer is set to 4 seconds defined by # macro, MME_APP_PAGING_RESPONSE_TIMER_VALUE in the file # mme_app_ue_context.h. If MME restarts after expiry of paging # response timer of 4 sec, it will again send the Paging indication resp_count = 0 while True: response = self._s1ap_wrapper.s1_util.get_response() if response.msg_type == s1ap_types.tfwCmd.UE_PAGING_IND.value: resp_count += 1 print( "******************** Ignoring re-transmitted (", resp_count, ") Paging indication", ) else: break self.assertEqual( response.msg_type, s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value, ) test.verify() time.sleep(0.5) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue_id, s1ap_types.ueDetachType_t.UE_NORMAL_DETACH.value, )
def test_eps_bearer_context_status_multiple_ded_bearer_deact(self): """Attach a single UE. Add dedicated bearer to the default PDN. Create 2 secondary PDNs and add 2 dedicated bearers to each of the secondary PDNs. Send EPS bearer context status IE in TAU request with bearer ids 5(def br),7(def br),8(ded br-LBI 7) and 10(def br) as active and bearers 6(ded br LBI-5),9(ded br LBI-7),11(ded br LBI-10) and 12(ded br LBI-10) as inactive. Set active flag to false. """ num_ue = 1 num_pdns = 2 sec_ip = [] flow_list2 = [] wait_for_s1_context_rel = False self._s1ap_wrapper.configUEDevice(num_ue) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id # APN of the secondary PDN ims = { "apn_name": "ims", # APN-name "qci": 5, # qci "priority": 15, # priority "pre_cap": 0, # preemption-capability "pre_vul": 0, # preemption-vulnerability "mbr_ul": 200000000, # MBR UL "mbr_dl": 100000000, # MBR DL } internet = { "apn_name": "internet", # APN-name "qci": 9, # qci "priority": 15, # priority "pre_cap": 0, # preemption-capability "pre_vul": 0, # preemption-vulnerability "mbr_ul": 250000000, # MBR UL "mbr_dl": 150000000, # MBR DL } # APN list to be configured apn_list = [ims, internet] self._s1ap_wrapper.configAPN( "IMSI" + "".join([str(i) for i in req.imsi]), apn_list, ) print( "************************* Running End to End attach for UE id ", ue_id, ) # Attach attach = self._s1ap_wrapper.s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) addr = attach.esmInfo.pAddr.addrInfo default_ip = ipaddress.ip_address(bytes(addr[:4])) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Add dedicated bearer to the default bearer print( "********************** Adding dedicated bearer to IMSI", "".join([str(i) for i in req.imsi]), ) # Create default flow list flow_list1 = self._spgw_util.create_default_ipv4_flows() self._spgw_util.create_bearer( "IMSI" + "".join([str(i) for i in req.imsi]), attach.esmInfo.epsBearerId, flow_list1, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_ACT_DED_BER_REQ.value, ) act_ded_ber_ctxt_req = response.cast(s1ap_types.UeActDedBearCtxtReq_t) self._s1ap_wrapper.sendActDedicatedBearerAccept( ue_id, act_ded_ber_ctxt_req.bearerId, ) # APNs of the secondary PDNs apn = ["ims", "internet"] for i in range(num_pdns): # Send PDN Connectivity Request self._s1ap_wrapper.sendPdnConnectivityReq(ue_id, apn[i]) # Receive PDN CONN RSP/Activate default EPS bearer context request response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_PDN_CONN_RSP_IND.value, ) act_def_bearer_req = response.cast(s1ap_types.uePdnConRsp_t) print( "********************** Sending Activate default EPS bearer " "context accept for UE id ", ue_id, ) print( "********************** Added default bearer with bearer id:", act_def_bearer_req.m.pdnInfo.epsBearerId, ) addr = act_def_bearer_req.m.pdnInfo.pAddr.addrInfo sec_ip.append(ipaddress.ip_address(bytes(addr[:4]))) # Add dedicated bearer for the default bearers print( "********************** Adding 1st dedicated bearer to IMSI", "".join([str(i) for i in req.imsi]), ) # Create default flow list flow_list2.append(self._spgw_util.create_default_ipv4_flows()) self._spgw_util.create_bearer( "IMSI" + "".join([str(i) for i in req.imsi]), act_def_bearer_req.m.pdnInfo.epsBearerId, flow_list2[i], ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_ACT_DED_BER_REQ.value, ) act_ded_ber_ctxt_req = response.cast( s1ap_types.UeActDedBearCtxtReq_t, ) self._s1ap_wrapper.sendActDedicatedBearerAccept( ue_id, act_ded_ber_ctxt_req.bearerId, ) # Create 2nd dedicated bearer print( "********************** Adding 2nd dedicated bearer to IMSI", "".join([str(i) for i in req.imsi]), ) flow_list2.append(self._spgw_util.create_default_ipv4_flows()) self._spgw_util.create_bearer( "IMSI" + "".join([str(i) for i in req.imsi]), act_def_bearer_req.m.pdnInfo.epsBearerId, flow_list2[i], ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_ACT_DED_BER_REQ.value, ) act_ded_ber_ctxt_req = response.cast( s1ap_types.UeActDedBearCtxtReq_t, ) self._s1ap_wrapper.sendActDedicatedBearerAccept( ue_id, act_ded_ber_ctxt_req.bearerId, ) print("Sleeping for 5 seconds") time.sleep(5) # Verify if flow rules are created for i in range(num_pdns): dl_flow_rules = { default_ip: [flow_list1], sec_ip[i]: [flow_list2[i]], } # 1 UL flow is created per bearer num_ul_flows = 8 self._s1ap_wrapper.s1_util.verify_flow_rules( num_ul_flows, dl_flow_rules, ) print( "************************* Sending UE context release request ", "for UE id ", ue_id, ) # Send UE context release request to move UE to idle mode cntxt_rel_req = s1ap_types.ueCntxtRelReq_t() cntxt_rel_req.ue_Id = ue_id cntxt_rel_req.cause.causeVal = ( gpp_types.CauseRadioNetwork.USER_INACTIVITY.value) self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, cntxt_rel_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) print(" Sleeping for 2 seconds") time.sleep(2) print( "************************* Sending Tracking Area Update ", "request for UE id ", ue_id, ) tau_req = s1ap_types.ueTauReq_t() tau_req.ue_Id = ue_id tau_req.type = s1ap_types.Eps_Updt_Type.TFW_TA_UPDATING.value tau_req.Actv_flag = True # Set default bearers 5,7,8 and 10 as active and # dedicated bearers 6,9,11 and 12 as inactive # epsBearerCtxSts IE is 16 bits # Ref: 3gpp 24.301 sec-9.9.2.1 tau_req.epsBearerCtxSts = 0x5A0 tau_req.ueMtmsi.pres = False self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_TAU_REQ, tau_req, ) # Receive initial context setup and attach accept indication response = (self._s1ap_wrapper._s1_util. receive_initial_ctxt_setup_and_tau_accept()) tau_acc = response.cast(s1ap_types.ueTauAccept_t) print( "************************* Received Tracking Area Update ", "accept for UE Id:", tau_acc.ue_Id, ) # Verify if flow rules are created dl_flow_rules = { default_ip: [], sec_ip[0]: [flow_list2[0]], sec_ip[1]: [], } # 1 UL flow is created per bearer num_ul_flows = 4 self._s1ap_wrapper.s1_util.verify_flow_rules( num_ul_flows, dl_flow_rules, ) print( "************************* Running UE detach (switch-off) for ", "UE id ", ue_id, ) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue_id, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, wait_for_s1_context_rel, ) print("Sleeping for 5 seconds") time.sleep(5) # Verify that all UL/DL flows are deleted self._s1ap_wrapper.s1_util.verify_flow_rules_deletion()
def test_attach_enb_rlf(self): """ Attach, after attach procedure is completed, eNB detects the RLF i.e., releasing the context by sending UE context release request with cause Radio Link Failure by that time we sending one more attach request """ # Ground work. self._s1ap_wrapper.configUEDevice(1) # Trigger Attach Request attach_req = s1ap_types.ueAttachRequest_t() sec_ctxt = s1ap_types.TFW_CREATE_NEW_SECURITY_CONTEXT id_type = s1ap_types.TFW_MID_TYPE_IMSI eps_type = s1ap_types.TFW_EPS_ATTACH_TYPE_EPS_ATTACH attach_req.ue_Id = 1 attach_req.mIdType = id_type attach_req.epsAttachType = eps_type attach_req.useOldSecCtxt = sec_ctxt print("***Triggering Attach Request ***") self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_ATTACH_REQUEST, attach_req) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_AUTH_REQ_IND.value) # Trigger Authentication Response auth_res = s1ap_types.ueAuthResp_t() auth_res.ue_Id = 1 sqnRecvd = s1ap_types.ueSqnRcvd_t() sqnRecvd.pres = 0 auth_res.sqnRcvd = sqnRecvd self._s1ap_wrapper._s1_util.issue_cmd(s1ap_types.tfwCmd.UE_AUTH_RESP, auth_res) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_SEC_MOD_CMD_IND.value) # Trigger Security Mode Complete sec_mode_complete = s1ap_types.ueSecModeComplete_t() sec_mode_complete.ue_Id = 1 self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SEC_MOD_COMPLETE, sec_mode_complete) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND.value) # Trigger Attach Complete attach_complete = s1ap_types.ueAttachComplete_t() attach_complete.ue_Id = 1 self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_ATTACH_COMPLETE, attach_complete) print("***Triggering Re-Attach Request ***") attach_req = s1ap_types.ueAttachRequest_t() sec_ctxt = s1ap_types.TFW_CREATE_NEW_SECURITY_CONTEXT id_type = s1ap_types.TFW_MID_TYPE_IMSI eps_type = s1ap_types.TFW_EPS_ATTACH_TYPE_EPS_ATTACH attach_req.ue_Id = 1 attach_req.mIdType = id_type attach_req.epsAttachType = eps_type attach_req.useOldSecCtxt = sec_ctxt self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_ATTACH_REQUEST, attach_req) # Send UE context release request with cause Radio Link Failure ue_ctxt_rel_req = s1ap_types.ueCntxtRelReq_t() ue_ctxt_rel_req.ue_Id = 1 ue_ctxt_rel_req.cause.causeVal = ( gpp_types.CauseRadioNetwork.RADIO_CONNECTION_WITH_UE_LOST.value) self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, ue_ctxt_rel_req) time.sleep(1)
def test_guti_attach_with_zero_mtmsi(self): """ 1. Perform IMSI attach 2. Move UE to idle mode 3. Send GUTI attach request for the same UE with M-TMSI value 0 4. Detach the UE """ num_ues = 1 self._s1ap_wrapper.configUEDevice(num_ues) req = self._s1ap_wrapper.ue_req print( "************************* Running End to End attach for " "UE id ", req.ue_id, ) # Now actually complete the attach self._s1ap_wrapper._s1_util.attach( req.ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() time.sleep(0.5) # Send UE context release request to move UE to idle mode print( "************************* Sending UE context release request ", "for UE id ", req.ue_id, ) ureq = s1ap_types.ueCntxtRelReq_t() ureq.ue_Id = req.ue_id ureq.cause.causeVal = gpp_types.CauseRadioNetwork.USER_INACTIVITY.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, ureq, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) time.sleep(5) # Send GUTI attach request with M-TMSI value as 0 attach_req = s1ap_types.ueAttachRequest_t() sec_ctxt = s1ap_types.TFW_CREATE_NEW_SECURITY_CONTEXT id_type = s1ap_types.TFW_MID_TYPE_GUTI eps_type = s1ap_types.TFW_EPS_ATTACH_TYPE_EPS_ATTACH pdn_type = s1ap_types.pdn_Type() pdn_type.pres = True pdn_type.pdn_type = 1 mcc = "001" mnc = "01" mcc_len = len(mcc) mnc_len = len(mnc) attach_req.ue_Id = req.ue_id attach_req.mIdType = id_type attach_req.epsAttachType = eps_type attach_req.useOldSecCtxt = sec_ctxt attach_req.pdnType_pr = pdn_type attach_req.guti_mi.pres = True for i in range(0, mcc_len): attach_req.guti_mi.guti.mcc[i] = ctypes.c_ubyte(int(mcc[i])) for i in range(0, mnc_len): attach_req.guti_mi.guti.mnc[i] = ctypes.c_ubyte(int(mnc[i])) attach_req.guti_mi.guti.mmeGrdId = 314 attach_req.guti_mi.guti.mmeCode = 30 attach_req.guti_mi.guti.mTmsi = 0 self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_ATTACH_REQUEST, attach_req, ) print( "********************** Sent attach req for UE id ", attach_req.ue_Id, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_IDENTITY_REQ_IND.value, ) id_req = response.cast(s1ap_types.ueIdentityReqInd_t) print( "********************** Received identity req for UE id", id_req.ue_Id, ) identity_resp = s1ap_types.ueIdentityResp_t() identity_resp.ue_Id = id_req.ue_Id identity_resp.idType = s1ap_types.TFW_MID_TYPE_IMSI self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_IDENTITY_RESP, identity_resp, ) print( "********************** Sent identity rsp for UE id", id_req.ue_Id, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_AUTH_REQ_IND.value, ) auth_req = response.cast(s1ap_types.ueAuthReqInd_t) print( "********************** Received auth req for UE id", auth_req.ue_Id, ) # Send Authentication Response auth_res = s1ap_types.ueAuthResp_t() auth_res.ue_Id = auth_req.ue_Id sqn_recvd = s1ap_types.ueSqnRcvd_t() sqn_recvd.pres = 0 auth_res.sqnRcvd = sqn_recvd self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_AUTH_RESP, auth_res, ) print("********************** Sent auth rsp for UE id", auth_req.ue_Id) response = self._s1ap_wrapper.s1_util.get_response() sec_mode_cmd = response.cast(s1ap_types.ueSecModeCmdInd_t) self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_SEC_MOD_CMD_IND.value, ) print( "********************** Received security mode cmd for UE id", sec_mode_cmd.ue_Id, ) sec_mode_complete = s1ap_types.ueSecModeComplete_t() sec_mode_complete.ue_Id = sec_mode_cmd.ue_Id self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SEC_MOD_COMPLETE, sec_mode_complete, ) print( "********************** Sent security mode complete for UE id", sec_mode_cmd.ue_Id, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND.value, ) attach_acc = response.cast(s1ap_types.ueAttachAccept_t) print( "********************** Received Attach accept for UE id", attach_acc.ue_Id, ) # Trigger Attach Complete attach_complete = s1ap_types.ueAttachComplete_t() attach_complete.ue_Id = attach_acc.ue_Id self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_ATTACH_COMPLETE, attach_complete, ) print( "********************** Sent attach complete for UE id", attach_complete.ue_Id, ) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() print( "************************* Running UE detach for UE id ", attach_complete.ue_Id, ) # Now detach the UE detach_req = s1ap_types.uedetachReq_t() detach_req.ue_Id = attach_complete.ue_Id detach_req.ueDetType = ( s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value) self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_DETACH_REQUEST, detach_req, ) # Wait for UE context release command response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, )
def test_attach_inactive_tau_with_combined_tala_update_reattach(self): """This test case validates reattach after inactive combined TAU reject 1. End-to-end attach with attach type COMBINED_EPS_IMSI_ATTACH 2. Send inactive TAU request (Combined TALA update) 3. Receive TAU reject (Combined TALA update not supported) 4. Retry end-to-end combined EPS IMSI attach to verify if UE context was released properly after combined TAU reject """ self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id print( "************************* Running End to End attach for UE id ", ue_id, ) # Now actually complete the attach self._s1ap_wrapper._s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, eps_type=s1ap_types.TFW_EPS_ATTACH_TYPE_COMB_EPS_IMSI_ATTACH, ) # Wait for EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Delay to ensure S1APTester sends attach complete before sending UE # context release time.sleep(0.5) print( "************************* Sending UE context release request ", "for UE id ", ue_id, ) # Send UE context release request to move UE to idle mode req = s1ap_types.ueCntxtRelReq_t() req.ue_Id = ue_id req.cause.causeVal = gpp_types.CauseRadioNetwork.USER_INACTIVITY.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) print( "************************* Received UE context release indication", ) print( "************************* Sending inactive TAU request (Combined " "TALA update) for UE id ", ue_id, ) # Send inactive TAU request with combined TALA update as update type req = s1ap_types.ueTauReq_t() req.ue_Id = ue_id req.type = s1ap_types.Eps_Updt_Type.TFW_COMB_TALA_UPDATING.value req.Actv_flag = False req.ueMtmsi.pres = False self._s1ap_wrapper.s1_util.issue_cmd(s1ap_types.tfwCmd.UE_TAU_REQ, req) # Waiting for TAU Reject Indication -Combined TALA update not supported response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_TAU_REJECT_IND.value, ) print( "************************* Received Tracking Area Update Reject " "Indication", ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) print( "************************* Received UE context release indication", ) print( "************************* Running End to End attach to verify if " "UE context was released properly after combined TAU reject for " "UE id ", ue_id, ) # Now actually complete the attach self._s1ap_wrapper._s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, eps_type=s1ap_types.TFW_EPS_ATTACH_TYPE_COMB_EPS_IMSI_ATTACH, ) # Wait for EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() print( "************************* Running UE detach (switch-off) for ", "UE id ", ue_id, ) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue_id, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, True, )
def test_mobile_reachability_timer_with_mme_restart(self): """ The test case validates Mobile Reachability Timer resumes the configured timer value on MME restart NOTE: Before execution of this test case, run the test case, test_modify_mme_config_for_sanity.py to modify the default 3412 timer value from 54 minutes to 1 minute Step1 : UE attaches to network Step2 : UE moves to Idle state Step3 : Once MME restarts, MME shall resume the Mobile reachability timer for remaining time, on expiry MME starts the Implicit Detach Timer. On expiry of Implicit Detach Timer, MME implicitly detaches UE. MME shall delete the contexts locally Step4 : Send Service Request, after Implicit Detach Timer expiry expecting Service Reject, as MME has released the UE contexts """ self._s1ap_wrapper.configUEDevice(1) time.sleep(20) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id print( "************************* Running End to End attach for UE id ", ue_id, ) # Now actually complete the attach self._s1ap_wrapper._s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Delay to ensure S1APTester sends attach complete before sending UE # context release time.sleep(0.5) print( "************************* Sending UE context release request ", "for UE id ", ue_id, ) # Send UE context release request to move UE to idle mode req = s1ap_types.ueCntxtRelReq_t() req.ue_Id = ue_id req.cause.causeVal = gpp_types.CauseRadioNetwork.USER_INACTIVITY.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) print("************************* Restarting MME service on gateway") self._s1ap_wrapper.magmad_util.restart_services(["mme"]) for j in range(30): print("Waiting for", j, "seconds") time.sleep(1) # Delay by 11 minutes to ensure Mobile reachability timer and Implicit # detach timer expires # Mobile Reachability Timer value = 1 minute (conf file) + delta value # at mme (4 minute) # Implicit Detach Timer value = 1 minute (conf file) + delta value # at mme (4 minute) print( "************************* Waiting for Mobile Reachability Timer" " (5 Minutes) and Implicit Detach Timer (5 minutes) to expire." " Together timer value is set to 660 seconds", ) # 5 Minutes + 5 minutes = 10 minutes (600 seconds) # 600 seconds + 60 seconds, delta(Randomly chosen) timeSlept = 0 while timeSlept < 660: time.sleep(10) timeSlept += 10 print("*********** Slept for", timeSlept, "seconds") print( "************************* Sending Service request for UE id ", ue_id, ) # Send service request to reconnect UE req = s1ap_types.ueserviceReq_t() req.ue_Id = ue_id req.ueMtmsi = s1ap_types.ueMtmsi_t() req.ueMtmsi.pres = False req.rrcCause = s1ap_types.Rrc_Cause.TFW_MO_DATA.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SERVICE_REQUEST, req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_SERVICE_REJECT_IND.value, ) print( "************************* Received Service Reject for UE id ", ue_id, ) # Wait for UE Context Release command response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, )
def test_attach_delay_ue_ctxt_rel_cmp(self): """ Attach, Delay Ue context release complete """ # Ground work. self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req # Trigger Attach Request attach_req = s1ap_types.ueAttachRequest_t() sec_ctxt = s1ap_types.TFW_CREATE_NEW_SECURITY_CONTEXT id_type = s1ap_types.TFW_MID_TYPE_IMSI eps_type = s1ap_types.TFW_EPS_ATTACH_TYPE_EPS_ATTACH attach_req.ue_Id = req.ue_id attach_req.mIdType = id_type attach_req.epsAttachType = eps_type attach_req.useOldSecCtxt = sec_ctxt print("********Triggering Attach Request ") self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_ATTACH_REQUEST, attach_req) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_AUTH_REQ_IND.value) # Trigger Authentication Response auth_res = s1ap_types.ueAuthResp_t() auth_res.ue_Id = req.ue_id sqnRecvd = s1ap_types.ueSqnRcvd_t() sqnRecvd.pres = 0 auth_res.sqnRcvd = sqnRecvd self._s1ap_wrapper._s1_util.issue_cmd(s1ap_types.tfwCmd.UE_AUTH_RESP, auth_res) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_SEC_MOD_CMD_IND.value) # Trigger Security Mode Complete sec_mode_complete = s1ap_types.ueSecModeComplete_t() sec_mode_complete.ue_Id = req.ue_id self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SEC_MOD_COMPLETE, sec_mode_complete) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND.value) delay_ue_ctxt_rel_cmp = s1ap_types.UeDelayUeCtxtRelCmp() delay_ue_ctxt_rel_cmp.ue_Id = req.ue_id delay_ue_ctxt_rel_cmp.flag = 1 delay_ue_ctxt_rel_cmp.tmrVal = 1000 print("*** Setting Delay for Ue context release complete ***") self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SET_DELAY_UE_CTXT_REL_CMP, delay_ue_ctxt_rel_cmp, ) # Trigger Attach Complete attach_complete = s1ap_types.ueAttachComplete_t() attach_complete.ue_Id = req.ue_id self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_ATTACH_COMPLETE, attach_complete) time.sleep(0.5) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_EMM_INFORMATION.value) time.sleep(0.5) # Now detach the UE detach_req = s1ap_types.uedetachReq_t() detach_req.ue_Id = req.ue_id detach_req.ueDetType = s1ap_types.ueDetachType_t.UE_NORMAL_DETACH.value self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_DETACH_REQUEST, detach_req) response = self._s1ap_wrapper._s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_DETACH_ACCEPT_IND.value) print( "*** Sending UE context release request ", "for UE id ***", req.ue_id, ) # Send UE context release request to move UE to idle mode # ue_ctxt_rel_req = s1ap_types.ueCntxtRelReq_t() uectxtrel_req = s1ap_types.ueCntxtRelReq_t() uectxtrel_req.ue_Id = req.ue_id uectxtrel_req.cause.causeVal = ( gpp_types.CauseRadioNetwork.RELEASE_DUE_TO_EUTRAN_GENERATED_REASON. value) self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, uectxtrel_req) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value) time.sleep(10)
def test_dedicated_bearer_activation_idle_mode(self): """ Test with a single UE attach + UE context release + trigger dedicated bearer activation + Page the UE + detach""" # UL Flow description #1 ulFlow1 = { "ipv4_dst": "192.168.129.42", # IPv4 destination address "tcp_dst_port": 5002, # TCP dest port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.UPLINK, # Direction } # UL Flow description #2 ulFlow2 = { "ipv4_dst": "192.168.129.42", # IPv4 destination address "tcp_dst_port": 5001, # TCP dest port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.UPLINK, # Direction } # UL Flow description #3 ulFlow3 = { "ipv4_dst": "192.168.129.64", # IPv4 destination address "tcp_dst_port": 5003, # TCP dest port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.UPLINK, # Direction } # UL Flow description #4 ulFlow4 = { "ipv4_dst": "192.168.129.42", # IPv4 destination address "tcp_dst_port": 5001, # TCP dest port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.UPLINK, # Direction } # DL Flow description #1 dlFlow1 = { "ipv4_src": "192.168.129.42", # IPv4 source address "tcp_src_port": 5001, # TCP source port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.DOWNLINK, # Direction } # DL Flow description #2 dlFlow2 = { "ipv4_src": "192.168.129.64", # IPv4 source address "tcp_src_port": 5002, # TCP source port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.DOWNLINK, # Direction } # DL Flow description #3 dlFlow3 = { "ipv4_src": "192.168.129.64", # IPv4 source address "tcp_src_port": 5003, # TCP source port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.DOWNLINK, # Direction } # DL Flow description #4 dlFlow4 = { "ipv4_src": "192.168.129.42", # IPv4 source address "tcp_src_port": 5001, # TCP source port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.DOWNLINK, # Direction } # Flow list to be configured flow_list1 = [ ulFlow1, ulFlow2, ulFlow3, dlFlow1, dlFlow2, dlFlow3, ] flow_list2 = [ ulFlow4, dlFlow4, ] # QoS qos1 = { "qci": 5, # qci value [1 to 9] "priority": 5, # Range [0-255] "max_req_bw_ul": 10000000, # MAX bw Uplink "max_req_bw_dl": 15000000, # MAX bw Downlink "gbr_ul": 1000000, # GBR Uplink "gbr_dl": 2000000, # GBR Downlink "arp_prio": 15, # ARP priority "pre_cap": 1, # pre-emption capability "pre_vul": 1, # pre-emption vulnerability } qos2 = { "qci": 1, # qci value [1 to 9] "priority": 1, # Range [0-255] "max_req_bw_ul": 10000000, # MAX bw Uplink "max_req_bw_dl": 15000000, # MAX bw Downlink "gbr_ul": 1000000, # GBR Uplink "gbr_dl": 2000000, # GBR Downlink "arp_prio": 1, # ARP priority "pre_cap": 1, # pre-emption capability "pre_vul": 1, # pre-emption vulnerability } policy_id1 = "ims-voice" policy_id2 = "internet" self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id imsi = req.imsi print("*********** Running End to End attach for UE id ", ue_id) # Now actually complete the attach attach = self._s1ap_wrapper._s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) addr = attach.esmInfo.pAddr.addrInfo default_ip = ipaddress.ip_address(bytes(addr[:4])) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Delay to ensure S1APTester sends attach complete before sending UE # context release print("*********** Sleeping for 5 seconds") time.sleep(5) # Move UE to idle mode print("*********** Moving UE to idle mode") print( "*********** Sending UE context release request ", "for UE id ", ue_id, ) # Send UE context release request to move UE to idle mode rel_req = s1ap_types.ueCntxtRelReq_t() rel_req.ue_Id = ue_id rel_req.cause.causeVal = ( gpp_types.CauseRadioNetwork.USER_INACTIVITY.value ) self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, rel_req ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value ) # Verify if paging flow rules are created ip_list = [default_ip] self._s1ap_wrapper.s1_util.verify_paging_flow_rules(ip_list) print("*********** Sleeping for 5 seconds") time.sleep(5) # Add dedicated bearers for default bearer 5 print( "************* Adding dedicated bearers to magma.ipv4" " PDN in idle mode for UE", ue_id, ) print( "********************** Sending 1st RAR for IMSI", "".join([str(i) for i in imsi]), ) self._sessionManager_util.send_ReAuthRequest( "IMSI" + "".join([str(i) for i in imsi]), policy_id1, flow_list1, qos1, ) # Add 2nd dedicated bearer for default bearer 5 print( "********************** Sending 2nd RAR for IMSI", "".join([str(i) for i in imsi]), ) self._sessionManager_util.send_ReAuthRequest( "IMSI" + "".join([str(i) for i in imsi]), policy_id2, flow_list2, qos2, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_PAGING_IND.value ) print("*********** Received Paging for UE id ", ue_id) print("*********** Sending Service request for UE id ", ue_id) # Send service request to reconnect UE ser_req = s1ap_types.ueserviceReq_t() ser_req.ue_Id = ue_id ser_req.ueMtmsi = s1ap_types.ueMtmsi_t() ser_req.ueMtmsi.pres = False ser_req.rrcCause = s1ap_types.Rrc_Cause.TFW_MO_SIGNALLING.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SERVICE_REQUEST, ser_req ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value ) print("*********** Received ICS Request for UE id ", ue_id) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_ACT_DED_BER_REQ.value ) act_ded_ber_req_oai_apn1 = response.cast( s1ap_types.UeActDedBearCtxtReq_t ) print( "*********** Received Activate dedicated EPS bearer" " req for bearer ", act_ded_ber_req_oai_apn1.bearerId, ) self._s1ap_wrapper.sendActDedicatedBearerAccept( ue_id, act_ded_ber_req_oai_apn1.bearerId ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_ACT_DED_BER_REQ.value ) act_ded_ber_req_oai_apn2 = response.cast( s1ap_types.UeActDedBearCtxtReq_t ) print( "*********** Received Activate dedicated EPS bearer" " req for bearer ", act_ded_ber_req_oai_apn2.bearerId, ) self._s1ap_wrapper.sendActDedicatedBearerAccept( ue_id, act_ded_ber_req_oai_apn2.bearerId ) # Verify if flow rules are created dl_flow_rules = {default_ip: [flow_list1, flow_list2]} # 1 UL flow is created per bearer num_ul_flows = 3 self._s1ap_wrapper.s1_util.verify_flow_rules( num_ul_flows, dl_flow_rules ) print("*********** Sleeping for 5 seconds") time.sleep(5) print("*********** Running UE detach for UE id ", ue_id) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue_id, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, True )
def test_detach_timer_expiry_handle(self): """ Test Detach timer expiry handling currenly manually need to verify through mme log """ self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id print("************************* Running End to End attach for UE id ", ue_id) # Now actually complete the attach self._s1ap_wrapper._s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Delay to ensure S1APTester sends attach complete before sending UE # context release time.sleep(0.5) print("************************* Sending UE context release request ", "for UE id ", ue_id) # Send UE context release request to move UE to idle mode req = s1ap_types.ueCntxtRelReq_t() req.ue_Id = ue_id req.cause.causeVal = gpp_types.CauseRadioNetwork.USER_INACTIVITY.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, req) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value) print("************************* Sending Service request for UE id ", ue_id) # To expires detach timer, first ensure # mobile reachability timer expired or not and then # delay sending initial ue message(service req) by detach timer value. # For testing purpose manually reduce the mobile reachability time to # 1minute in mme.conf.template file # DETACH TIMER VALUE = mobile reachability timer value + delta value time.sleep(740) # Send service request to reconnect UE req = s1ap_types.ueserviceReq_t() req.ue_Id = ue_id req.ueMtmsi = s1ap_types.ueMtmsi_t() req.ueMtmsi.pres = False req.rrcCause = s1ap_types.Rrc_Cause.TFW_MO_DATA.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SERVICE_REQUEST, req) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_SERVICE_REJECT_IND.value) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value) time.sleep(0.5)
def test_agw_offload_mixed_idle_active_multiue(self): """ Basic attach/detach test with a single UE """ num_ues = 100 # column is a enb parameter, row is a number of enbs # column description: # 1.Cell Id, 2.Tac, 3.EnbType, 4.PLMN Id 5. PLMN length enb_list = [(1, 1, 1, "00101", 5)] self._s1ap_wrapper.multiEnbConfig(len(enb_list), enb_list) time.sleep(2) self._s1ap_wrapper.configUEDevice(num_ues) ue_ids = [] for _ in range(num_ues): req = self._s1ap_wrapper.ue_req print( "************************* Running End to End attach for ", "UE id ", req.ue_id, ) # Now actually complete the attach self._s1ap_wrapper._s1_util.attach( req.ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() ue_ids.append(req.ue_id) # Send UE context release request for half of UEs to move them # to ECM-IDLE state for i in range(math.floor(num_ues / 2)): ue_cntxt_rel_req = s1ap_types.ueCntxtRelReq_t() ue_cntxt_rel_req.ue_Id = ue_ids[i] ue_cntxt_rel_req.cause.causeVal = ( gpp_types.CauseRadioNetwork.USER_INACTIVITY.value) self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, ue_cntxt_rel_req) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value) print("************************* Send Offload Request to AGW") # Send offloading request self.assertTrue(self._ha_util.offload_agw(None, enb_list[0][0])) # All UEs should eventually receive Context Release Request # The first half should get it immediately # The second half should first get paging for i in range(num_ues): response = self._s1ap_wrapper.s1_util.get_response() self.assertIn( response.msg_type, [ s1ap_types.tfwCmd.UE_CTX_REL_IND.value, s1ap_types.tfwCmd.UE_PAGING_IND.value, ], "Not a paging or ue context release message", ) # Send service request as paging response for i in range(math.floor(num_ues / 2)): # Send service request to reconnect UE # Auto-release should happen ser_req = s1ap_types.ueserviceReq_t() ser_req.ue_Id = ue_ids[i] ser_req.ueMtmsi = s1ap_types.ueMtmsi_t() ser_req.ueMtmsi.pres = False ser_req.rrcCause = s1ap_types.Rrc_Cause.TFW_MO_DATA.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SERVICE_REQUEST, ser_req) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value) for i in range(num_ues): # Send service request again: ser_req = s1ap_types.ueserviceReq_t() ser_req.ue_Id = ue_ids[i] ser_req.ueMtmsi = s1ap_types.ueMtmsi_t() ser_req.ueMtmsi.pres = False ser_req.rrcCause = s1ap_types.Rrc_Cause.TFW_MO_DATA.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SERVICE_REQUEST, ser_req) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value) # Now detach the UEs normally for ue in ue_ids: print("************************* Running UE detach for UE id ", ue) self._s1ap_wrapper.s1_util.detach( ue, s1ap_types.ueDetachType_t.UE_NORMAL_DETACH.value, True)
def test_tau_periodic_active(self): """ Attach a single UE and send active period tracking area updates (TAU)""" num_taus = 4 tau_period = 0.5 # seconds between TAU updates self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id print( "************************* Running End to End attach for UE id ", ue_id, ) # Now actually complete the attach self._s1ap_wrapper.s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, id_type=s1ap_types.TFW_MID_TYPE_GUTI, ) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Add delay to ensure that S1APTester sends Attach Complete before # UE context release request message. time.sleep(0.5) print( "************************* Sending UE context release request ", "for UE id ", ue_id, ) # Send UE context release request to move UE to idle mode req = s1ap_types.ueCntxtRelReq_t() req.ue_Id = ue_id req.cause.causeVal = gpp_types.CauseRadioNetwork.USER_INACTIVITY.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) for _ in range(num_taus): timer = threading.Timer(tau_period, lambda: None) timer.start() timer.join() print( "************************* Sending Tracking Area Update ", "request for UE id ", ue_id, ) # Send UE context release request to move UE to idle mode req = s1ap_types.ueTauReq_t() req.ue_Id = ue_id req.type = s1ap_types.Eps_Updt_Type.TFW_PERIODIC_UPDATING.value req.Actv_flag = True req.ueMtmsi.pres = False self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_TAU_REQ, req, ) response = self._s1ap_wrapper.s1_util.get_response() if s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value == response.msg_type: response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_TAU_ACCEPT_IND.value, ) print( "************************* Sending UE context release ", "request for UE id ", ue_id, ) # Send UE context release request to move UE to idle mode req = s1ap_types.ueCntxtRelReq_t() req.ue_Id = ue_id req.cause.causeVal = gpp_types.CauseRadioNetwork.USER_INACTIVITY.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) else: self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_TAU_REJECT_IND.value, ) print( "************************* Running UE detach (switch-off) for ", "UE id ", ue_id, ) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue_id, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, False, )
def test_paging_after_mme_restart(self): """Test case validates resumption ueip_imsi map after mme restart Step1 : UE attaches to network Step2 : UE moves to idle state Step3 : Issue command to restart mme service Step4 : Initiate DL data to make MME to send Paging message Step5 : In response to Paging message, UE sends Service Request message Step6 : Expecting normal flow of DL data """ self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id print( '************************* Running End to End attach for UE id ', ue_id, ) # Now actually complete the attach self._s1ap_wrapper.s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Delay to ensure S1APTester sends attach complete before sending UE # context release time.sleep(0.5) print( '************************* Sending UE context release request ', 'for UE id ', ue_id, ) # Send UE context release request to move UE to idle mode ue_cntxt_rel_req = s1ap_types.ueCntxtRelReq_t() ue_cntxt_rel_req.ue_Id = ue_id ue_cntxt_rel_req.cause.causeVal = ( gpp_types.CauseRadioNetwork.USER_INACTIVITY.value) self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, ue_cntxt_rel_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) wait_time = 0.3 time.sleep(wait_time) print('************************* Restarting MME service on', 'gateway') self._s1ap_wrapper.magmad_util.restart_services(['mme']) wait_time = 20 for j in range(wait_time, 0, -1): print('Waiting for', j, 'seconds') time.sleep(1) print( '************************* Running UE downlink (UDP) for UE id ', ue_id, ) with self._s1ap_wrapper.configDownlinkTest( req, duration=1, is_udp=True, ) as test: response = self._s1ap_wrapper.s1_util.get_response() self.assertTrue(response, s1ap_types.tfwCmd.UE_PAGING_IND.value) print('************************ Received Paging Indication') # Send service request to reconnect UE ser_req = s1ap_types.ueserviceReq_t() ser_req.ue_Id = ue_id ser_req.ueMtmsi = s1ap_types.ueMtmsi_t() ser_req.ueMtmsi.pres = False ser_req.rrcCause = s1ap_types.Rrc_Cause.TFW_MT_ACCESS.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SERVICE_REQUEST, ser_req, ) # Ignore PAGING_IND and wait for INT_CTX_SETUP_IND response = self._s1ap_wrapper.s1_util.get_response() while response.msg_type == s1ap_types.tfwCmd.UE_PAGING_IND.value: print( "Received Paging Indication for ue-id", ue_id, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value, ) test.verify() time.sleep(0.5) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue_id, s1ap_types.ueDetachType_t.UE_NORMAL_DETACH.value, wait_for_s1_ctxt_release=True, ) time.sleep(0.5)
def test_stateless_multi_ue_mixedstate_mme_restart(self): """Testing of sending Esm Information procedure""" ue_ids = [] num_ues_idle = 10 num_ues_active = 10 num_attached_ues = num_ues_idle + num_ues_active # each list item can be a number in [1,3] and be repeated stateof_ues_in_attachproc_before_restart = [ 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, ] num_ues_attaching = len(stateof_ues_in_attachproc_before_restart) attach_steps = [ self.exec_attach_req_step, self.exec_auth_resp_step, self.exec_sec_mode_complete_step, self.exec_esm_inf_req_step, ] num_of_steps = len(attach_steps) tot_num_ues = num_ues_idle + num_ues_active + num_ues_attaching self._s1ap_wrapper.configUEDevice(tot_num_ues) idle_session_ips = [] # Prep attached UEs for i in range(num_ues_idle + num_ues_active): req = self._s1ap_wrapper.ue_req print( "************************* Sending Attach Request for UE Id:", req.ue_id, ) attach = self._s1ap_wrapper._s1_util.attach( req.ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) addr = attach.esmInfo.pAddr.addrInfo default_ip = ipaddress.ip_address(bytes(addr[:4])) if i < num_ues_idle: idle_session_ips.append(default_ip) else: self.dl_flow_rules[default_ip] = [] # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() ue_ids.append(req.ue_id) # Move first num_ues_idle UEs to idle state for i in range(num_ues_idle): print( "************************* Sending UE context release request ", "for UE id ", ue_ids[i], ) # Send UE context release request to move UE to idle mode ue_cntxt_rel_req = s1ap_types.ueCntxtRelReq_t() ue_cntxt_rel_req.ue_Id = ue_ids[i] ue_cntxt_rel_req.cause.causeVal = ( gpp_types.CauseRadioNetwork.USER_INACTIVITY.value) self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, ue_cntxt_rel_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) tid = {} # start attach procedures for the remaining UEs for i in range(num_ues_attaching): req = self._s1ap_wrapper.ue_req print( "************************* Starting Attach procedure UE Id:", req.ue_id, ) # bring each newly attaching UE to the desired point during # attach procedure before restarting mme service ue_ids.append(req.ue_id) for step in range(stateof_ues_in_attachproc_before_restart[i]): if attach_steps[step] == self.exec_sec_mode_complete_step: tid[req.ue_id] = attach_steps[step](req.ue_id) elif attach_steps[step] == self.exec_esm_inf_req_step: attach_steps[step](req.ue_id, tid[req.ue_id]) else: attach_steps[step](req.ue_id) # Restart mme self._s1ap_wrapper.magmad_util.restart_mme_and_wait() # Post restart, complete the attach procedures that were cut in between for i in range(num_ues_attaching): # resume attach for attaching UEs print( "************************* Resuming Attach procedure UE Id:", ue_ids[i + num_attached_ues], ) for step in range( stateof_ues_in_attachproc_before_restart[i], num_of_steps, ): if attach_steps[step] == self.exec_sec_mode_complete_step: tid[ue_ids[i + num_attached_ues]] = attach_steps[step]( ue_ids[i + num_attached_ues], ) elif attach_steps[step] == self.exec_esm_inf_req_step: attach_steps[step]( ue_ids[i + num_attached_ues], tid[ue_ids[i + num_attached_ues]], ) else: attach_steps[step](ue_ids[i + num_attached_ues]) # Verify steady state flows in Table-0 # Idle users will have paging rules installed # Active users will have tunnel rules # 1 UL flow is created per active bearer num_ul_flows = num_ues_active + num_ues_attaching # Verify if flow rules are created self._s1ap_wrapper.s1_util.verify_flow_rules( num_ul_flows, self.dl_flow_rules, ) # Verify paging flow rules for idle sessions self._s1ap_wrapper.s1_util.verify_paging_flow_rules(idle_session_ips) # Try to bring idle mode users into active state for i in range(num_ues_idle): print( "************************* Sending Service Request for UE Id:", ue_ids[i], ) # Send service request to reconnect UE ser_req = s1ap_types.ueserviceReq_t() ser_req.ue_Id = ue_ids[i] ser_req.ueMtmsi = s1ap_types.ueMtmsi_t() ser_req.ueMtmsi.pres = False ser_req.rrcCause = s1ap_types.Rrc_Cause.TFW_MO_DATA.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SERVICE_REQUEST, ser_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value, ) self.dl_flow_rules[idle_session_ips[i]] = [] # Verify default bearer rules self._s1ap_wrapper.s1_util.verify_flow_rules( tot_num_ues, self.dl_flow_rules, ) # detach everyone print("*** Starting Detach Procedure for all UEs ***") for ue in ue_ids: print( "************************* Detaching UE Id:", ue, ) # Now detach the UE detach_req = s1ap_types.uedetachReq_t() detach_req.ue_Id = ue detach_req.ueDetType = ( s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value) self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_DETACH_REQUEST, detach_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, )
def test_ics_timer_expiry_with_mme_restart(self): """ The test case validates the functionality of ICS timer expiry while UE is in idle mode after mme restart Step 1: Attach UE to network Step 2: Let the UE go to Idle mode Step 3: Send Service Request to move the ECM state to connected mode Step 4: Send an indication to s1ap module to drop ICS Request message So s1ap shall not send ICS Response message to mme Step 5: While ICS timer is running at mme, restart mme service Step 6: On mme recovery, it is expected that ICS timer has lapsed and Send Ue Context Release Command to s1ap """ self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id print( "************************* Running End to End attach for UE id ", ue_id, ) # Attach self._s1ap_wrapper._s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() time.sleep(0.5) print( "************************* Sending UE context release request ", "for UE id ", ue_id, ) # Send UE context release request to move UE to idle mode req = s1ap_types.ueCntxtRelReq_t() req.ue_Id = ue_id req.cause.causeVal = gpp_types.CauseRadioNetwork.USER_INACTIVITY.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) print("*** Sending indication to drop Initial Context Setup Req ***") drop_init_ctxt_setup_req = s1ap_types.UeDropInitCtxtSetup() drop_init_ctxt_setup_req.ue_Id = ue_id drop_init_ctxt_setup_req.flag = 1 # Timer to release UE context at s1ap tester drop_init_ctxt_setup_req.tmrVal = 2000 self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SET_DROP_ICS, drop_init_ctxt_setup_req, ) print( "************************* Sending Service request for UE id ", ue_id, ) # Send service request to reconnect UE req = s1ap_types.ueserviceReq_t() req.ue_Id = ue_id req.ueMtmsi = s1ap_types.ueMtmsi_t() req.ueMtmsi.pres = False req.rrcCause = s1ap_types.Rrc_Cause.TFW_MO_DATA.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SERVICE_REQUEST, req, ) # enbApp sends UE_ICS_DROPD_IND message to tfwApp after dropping # ICS request response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_ICS_DROPD_IND.value, ) print("************************* Restarting MME service on gateway") self._s1ap_wrapper.magmad_util.restart_services(["mme"]) for j in range(30): print("Waiting for", j, "seconds") time.sleep(1) print("************************* Waiting for response from MME") response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) print( "************************* Received UE_CTX_REL_IND for UE id ", ue_id, ) print("************************* Running UE detach for UE id ", ue_id) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue_id, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, False, )