def test_mobile_reachability_timer_expiry_handler(self): """ Test Mobile Reachability 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) # Delay by 6minutes to ensure Mobile reachability timer expires. # By default, mobile reachability timer value configured to 54 mins in # mme.conf.template file.For testing purpose manually reduce the mobile # reachability time to 1minute in mme.conf.template file # MOBILE REACHABILITY TIMER VALUE = 1minutes(conf file) + delta value time.sleep(360) # 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_attach_service(self): """ Test with a single UE attach, UE context release, 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_attach_service_ue_radio_capability(self): """ Test with a single UE attach, UE context release, service request, check for UE radio capability """ self._test_wrapper.configUEDevice(1) req = self._test_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._test_wrapper._s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND) 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 = gpp_types.CauseRadioNetwork.USER_INACTIVITY.value self._test_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, req) response = self._test_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._test_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SERVICE_REQUEST, req) response = self._test_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._test_wrapper.s1_util.detach( ue_id, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, False)
def test_attach_detach_service(self): """ Test with a single UE attach, detach, 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() 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_NORMAL_DETACH.value, True) print("************************* Sending Service request for UE id ", ue_id) # Send Service Request from the UE which is already detached in EPC 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_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_agw_offload_idle_active_ue(self): """Test case to offload 1 UE in both active and idle states NOTE: HA service must be enabled for running this test case. Set the parameter 'use_ha' in configuration file /etc/magma/mme.yml to 'true' on magma-dev VM and restart MME to enable the HA service """ # 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) 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() print( "************************* Offloading UE at state ECM-CONNECTED", ) # Send offloading request self.assertTrue( self._ha_util.offload_agw( "".join(["IMSI"] + [str(i) for i in req.imsi]), enb_list[0][0], ), ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) print("************************* Offloading UE at state ECM-IDLE") # Send offloading request self.assertTrue( self._ha_util.offload_agw( "".join(["IMSI"] + [str(i) for i in req.imsi]), enb_list[0][0], ), ) response = self._s1ap_wrapper.s1_util.get_response() self.assertTrue(response, s1ap_types.tfwCmd.UE_PAGING_IND.value) # Send service request to reconnect UE # Auto-release should happen 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_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, ) # Send service request again: # This time auto-release should not happen 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 2 sec") time.sleep(2) 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_NORMAL_DETACH.value, wait_for_s1_ctxt_release=True, )
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": "TCP", # Protocol Type "direction": "UL", # Direction } # UL Flow description #2 ulFlow2 = { "ipv4_dst": "192.168.129.42", # IPv4 destination address "tcp_dst_port": 5001, # TCP dest port "ip_proto": "TCP", # Protocol Type "direction": "UL", # Direction } # UL Flow description #3 ulFlow3 = { "ipv4_dst": "192.168.129.64", # IPv4 destination address "tcp_dst_port": 5003, # TCP dest port "ip_proto": "TCP", # Protocol Type "direction": "UL", # Direction } # UL Flow description #4 ulFlow4 = { "ipv4_dst": "192.168.129.42", # IPv4 destination address "tcp_dst_port": 5001, # TCP dest port "ip_proto": "TCP", # Protocol Type "direction": "UL", # Direction } # DL Flow description #1 dlFlow1 = { "ipv4_src": "192.168.129.42", # IPv4 source address "tcp_src_port": 5001, # TCP source port "ip_proto": "TCP", # Protocol Type "direction": "DL", # Direction } # DL Flow description #2 dlFlow2 = { "ipv4_src": "192.168.129.64", # IPv4 source address "tcp_src_port": 5002, # TCP source port "ip_proto": "TCP", # Protocol Type "direction": "DL", # Direction } # DL Flow description #3 dlFlow3 = { "ipv4_src": "192.168.129.64", # IPv4 source address "tcp_src_port": 5003, # TCP source port "ip_proto": "TCP", # Protocol Type "direction": "DL", # Direction } # DL Flow description #4 dlFlow4 = { "ipv4_src": "192.168.129.42", # IPv4 source address "tcp_src_port": 5001, # TCP source port "ip_proto": "TCP", # Protocol Type "direction": "DL", # 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.create_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.create_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_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_attach_service_with_multi_pdns_and_bearers_failure(self): """Test with a single UE attach + add secondary PDN + add 2 dedicated bearers + UE context release + service request + ICS Rsp with failed bearers + detach""" self._s1ap_wrapper.configUEDevice(1) 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 } # APN list to be configured apn_list = [ims] self._s1ap_wrapper.configAPN( "IMSI" + "".join([str(i) for i in req.imsi]), apn_list, ) # 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" 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) # 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( "********************** 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) # Verify if flow rules are created 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("************************* Sleeping for 5 seconds") time.sleep(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, ) # Send the bearers to be included in failed to setup list in ICS Rsp init_ctxt_setup_failed_erabs = s1ap_types.UeInitCtxtSetupFailedErabs() init_ctxt_setup_failed_erabs.ue_Id = ue_id init_ctxt_setup_failed_erabs.failedErabs[ 0] = act_ded_ber_req_oai_apn.bearerId init_ctxt_setup_failed_erabs.failedErabs[ 1] = act_ded_ber_req_ims_apn.bearerId init_ctxt_setup_failed_erabs.numFailedErabs = 2 self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SET_INIT_CTXT_SETUP_RSP_FAILED_ERABS, init_ctxt_setup_failed_erabs, ) # 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("************************* 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, ) 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 dl_flow_rules = { default_ip: [], sec_ip: [], } # 1 UL flow is created per bearer # Dedicated bearers are deleted as eNB could not establish context. num_ul_flows = 2 # 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_enb_partial_reset_multi_ue_with_mme_restart(self): """ENB Partial Reset with MME restart for multiple UEs: 1) Attach 32 UEs 2) Send partial reset for a random subset of the attached UEs 3) Restart MME 4) Send service request for all the UEs which were reset 5) Detach all the 32 UEs """ ue_ids = [] num_ues = 32 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, ) ue_ids.append(req.ue_id) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Add delay to ensure S1APTester sends attach complete before sending # eNB Reset Request time.sleep(0.5) # Set the reset UEs list random.seed(time.clock()) reset_ue_count = random.randint(1, num_ues) random.seed(time.clock()) reset_ue_list = random.sample(range(num_ues), reset_ue_count) print( "************************* Sending eNB Partial Reset Request for", reset_ue_count, "UEs", ) reset_req = s1ap_types.ResetReq() reset_req.rstType = s1ap_types.resetType.PARTIAL_RESET.value reset_req.cause = s1ap_types.ResetCause() reset_req.cause.causeType = ( s1ap_types.NasNonDelCauseType.TFW_CAUSE_MISC.value) # Set the cause to MISC.hardware-failure reset_req.cause.causeVal = 3 reset_req.r = s1ap_types.R() reset_req.r.partialRst = s1ap_types.PartialReset() reset_req.r.partialRst.numOfConn = reset_ue_count reset_req.r.partialRst.ueS1apIdPairList = ( (s1ap_types.UeS1apIdPair) * reset_req.r.partialRst.numOfConn)() for indx in range(reset_req.r.partialRst.numOfConn): reset_req.r.partialRst.ueS1apIdPairList[indx].ueId = ue_ids[ reset_ue_list[indx]] print( "Reset_req.r.partialRst.ueS1apIdPairList[", indx, "].ueId", reset_req.r.partialRst.ueS1apIdPairList[indx].ueId, ) # Send eNB Partial Reset self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.RESET_REQ, reset_req, ) 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) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.RESET_ACK.value) # Send service request for all the Reset UE Ids for indx in range(reset_req.r.partialRst.numOfConn): print( "************************* Sending Service request for UE id", reset_req.r.partialRst.ueS1apIdPairList[indx].ueId, ) req = s1ap_types.ueserviceReq_t() req.ue_Id = reset_req.r.partialRst.ueS1apIdPairList[indx].ueId 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, ) # Trigger detach request 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, )
def test_attach_service_with_multi_pdns_and_bearers_multi_ue(self): """ Attach + add dedicated bearer + add secondary PDN + add dedicated bearer + UE context release + service request + detach. Repeat for 4 UEs""" num_ues = 4 ue_ids = [] default_ips = [] sec_ips = [] # 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" self._s1ap_wrapper.configUEDevice(num_ues) for i in range(num_ues): 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 } # 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, ) # 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_ips.append(ipaddress.ip_address(bytes(addr[:4]))) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() ue_ids.append(ue_id) print("Sleeping for 5 seconds") time.sleep(5) # Add dedicated bearer for default bearer 5 print( "********************** Adding dedicated bearer to magma.ipv4" " PDN for UE", ue_id, ) print( "********************** Sending RAR for IMSI", "".join([str(i) for i in req.imsi]), ) self._sessionManager_util.create_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) # Add secondary PDN and dedicated bearers for all the UEs print("Sleeping for 5 seconds") time.sleep(5) self._s1ap_wrapper._ue_idx = 0 for i in range(num_ues): req = self._s1ap_wrapper.ue_req # Send PDN Connectivity Request apn = "ims" ue_id = req.ue_id imsi = req.imsi 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_ips.append(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 " "for UE", ue_id, ) print( "********************** Sending RAR for IMSI", "".join([str(i) for i in req.imsi]), ) self._sessionManager_util.create_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_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) # 1 UL flow is created per bearer # 4 UEs * 4 bearers per UE = 16 UL flows num_ul_flows = 16 for i in range(num_ues): dl_flow_rules = { default_ips[i]: [flow_list1], sec_ips[i]: [flow_list2], } # Verify if flow rules are created self._s1ap_wrapper.s1_util.verify_flow_rules( num_ul_flows, dl_flow_rules) # Send UE context release request to move UEs to idle mode self._s1ap_wrapper._ue_idx = 0 for i in range(num_ues): # time.sleep(2) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id print("*********** Moving UE %d to idle mode" % ue_id) 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_ips[i], sec_ips[i]] self._s1ap_wrapper.s1_util.verify_paging_flow_rules(ip_list) # Bring back UEs to connected mode self._s1ap_wrapper._ue_idx = 0 for i in range(num_ues): # time.sleep(2) req = self._s1ap_wrapper.ue_req ue_id = req.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 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) # Delay of 10 seconds to make sure flows are added print("Sleeping for 10 seconds") time.sleep(10) for i in range(num_ues): dl_flow_rules = { default_ips[i]: [flow_list1], sec_ips[i]: [flow_list2], } self._s1ap_wrapper.s1_util.verify_flow_rules( num_ul_flows, dl_flow_rules) print("Sleeping for 5 seconds") time.sleep(5) # Detach the UEs for ue in ue_ids: print("************************* Running UE detach for UE id ", ue) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, True)
def test_ipv4v6_paging_with_dedicated_bearer(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_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 ", dl_reqs, " and uplink (TCP) for UE ids", 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() 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) with test: test.verify() 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.wait() 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_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_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_agw_offload_idle_active_ue(self): """ Basic attach/detach test with a single UE """ # 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) 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() print( "************************* Offloading UE at state ECM-CONNECTED") # Send offloading request self._ha_util.offload_agw("IMSI" + "".join([str(i) for i in req.imsi]), enb_list[0][0]) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value) print("************************* Offloading UE at state ECM-IDLE") # Send offloading request self._ha_util.offload_agw("IMSI" + "".join([str(i) for i in req.imsi]), enb_list[0][0]) response = self._s1ap_wrapper.s1_util.get_response() self.assertTrue(response, s1ap_types.tfwCmd.UE_PAGING_IND.value) # Send service request to reconnect UE # Auto-release should happen 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_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) # Send service request again: # This time auto-release should not happen 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 2 sec") time.sleep(2) 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_NORMAL_DETACH.value, True)
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_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_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) 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_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_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) 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 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) ''' Note: Below commented lines needs to be uncommented in case if Paging Response timer is configured more than mme restart time (~40 seconds) because on expiry MME re-transmits the Paging Indication again Currently Paging Response timer is set to 4 seconds defined by macro, MME_APP_PAGING_RESPONSE_TIMER_VALUE in mme_app_ue_context.h file With current timer value, Paging Indication is not re-transmitted because timer expires before MME restarts ''' '''print("************************ wait on Paging Indication"); 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) 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_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_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_service_req_ul_udp_data_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 : Send UL UDP data Step6 : 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) ul_test = self._s1ap_wrapper.configUplinkTest(req, duration=1, is_udp=True) 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 uplink (UDP) for UE id ", req.ue_Id, ) with ul_test: ul_test.verify() 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_attach_implicit_detach_timer_expiry(self): """ Test Implicit Detach timer expiry handling """ """ Note: Implicit Detach Timer value is calculated based on Mobile Rechability Timer value. Therefore, 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) # For implicit detach timer to expire, first ensure that # mobile reachability timer is expired or not and then # delay sending initial ue message (service req) by detach timer value. # DETACH TIMER VALUE = mobile reachability timer value + delta value print("************************* Waiting for Implicit Detach Timer" " to expire. Sleeping for 740 seconds..") timeSlept = 0 while timeSlept < 740: 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.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_attach_service_with_multi_pdns_and_bearers_mt_data(self): """ Attach a UE + add secondary PDN + add 2 dedicated bearers + UE context release + trigger MT data + service request + PDN disconnect + detach """ self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id ips = [] # 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) # 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" 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])) ips.append(default_ip) # 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.create_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])) ips.append(sec_ip) 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.create_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, ) # 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( "************************* 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 print( "************************* Sending Service request for UE id ", ue_id, ) 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) # Wait for INT_CTX_SETUP_IND 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() 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) pdn_disconnect_req = s1ap_types.uepdnDisconnectReq_t() pdn_disconnect_req.ue_Id = ue_id pdn_disconnect_req.epsBearerId = ( act_def_bearer_req.m.pdnInfo.epsBearerId) self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_PDN_DISCONNECT_REQ, pdn_disconnect_req) # Receive UE_DEACTIVATE_BER_REQ response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_DEACTIVATE_BER_REQ.value) print("******************* Received deactivate eps bearer context" " request") # Send DeactDedicatedBearerAccept deactv_bearer_req = response.cast(s1ap_types.UeDeActvBearCtxtReq_t) self._s1ap_wrapper.sendDeactDedicatedBearerAccept( ue_id, deactv_bearer_req.bearerId) 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_multi_enb_paging_request(self): """ Multi Enb + attach 1 UE + UE enters into idle mode + paging + service req + detach """ """ Note: Before execution of this test case, make sure that following steps are correct 1. Configure same plmn and tac in both MME and s1ap tester 2. How to configure plmn and tac in MME: a. Set mcc and mnc in gateway.mconfig for mme service b. Set tac in gateway.mconfig for mme service c. Restart MME service 3. How to configure plmn and tac in s1ap tester, a. For multi-eNB test case, configure plmn and tac from test case. In each multi-eNB test case, set plmn, plmn length and tac in enb_list b. For single eNB test case, configure plmn and tac in nbAppCfg.txt """ # column is an enb parameter, row is number of enbs """ Cell Id, Tac, EnbType, PLMN Id, PLMN length """ enb_list = [ (1, 1, 1, "00101", 5), (2, 1, 1, "00101", 5), (3, 1, 1, "00101", 5), (4, 1, 1, "00101", 5), (5, 1, 1, "00101", 5), ] 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_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(30): 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_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._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_mobile_reachability_tmr_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) 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) time_slept = 0 while time_slept < 660: time.sleep(10) time_slept += 10 print("*********** Slept for", time_slept, "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, )