def test_tau_ta_updating_connected_mode(self): """Attach 2 UEs. 1. For the 1st UE, send tracking area update(TAU) request in UL NAS transport with EPS Update Type=TA Updating and active flag set to false 2. For the 2nd UE, send tracking area update(TAU) request in UL NAS transport with EPS Update Type=TA Updating and active flag set to true """ num_ues = 2 wait_for_s1_context_rel = False self._s1ap_wrapper.configUEDevice(num_ues) ue_ids = [] # Attach for _ in range(num_ues): req = self._s1ap_wrapper.ue_req ue_id = req.ue_id self._s1ap_wrapper.s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, id_type=s1ap_types.TFW_MID_TYPE_GUTI, ) ue_ids.append(req.ue_id) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Add delay to ensure that S1APTester sends Attach Complete time.sleep(0.5) active_flag = [False, True] for i in range(num_ues): print( "************************* Sending Tracking Area Update ", "request for UE id ", ue_ids[i], ) tau_req = s1ap_types.ueTauReq_t() tau_req.ue_Id = ue_ids[i] tau_req.type = s1ap_types.Eps_Updt_Type.TFW_TA_UPDATING.value tau_req.Actv_flag = active_flag[i] tau_req.ueMtmsi.pres = False self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_TAU_REQ, tau_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEquals( response.msg_type, s1ap_types.tfwCmd.UE_TAU_ACCEPT_IND.value, ) tau_acc = response.cast(s1ap_types.ueTauAccept_t) print( "************************* Received Tracking Area Update ", "accept for UE id ", tau_acc.ue_Id, ) # Detach for ue in ue_ids: print( "************************* Running UE detach (switch-off) for ", "UE id ", ue, ) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, wait_for_s1_context_rel, )
def test_attach_active_tau_with_combined_tala_update_reattach(self): """This test case validates reattach after active combined TAU reject: 1. End-to-end attach with attach type COMBINED_EPS_IMSI_ATTACH 2. Send active TAU request (Combined TALA update) 3. Receive TAU reject (Combined TALA update not supported) 4. Retry end-to-end combined EPS IMSI attach to verify if UE context was released properly after combined TAU reject """ self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id print( "************************* Running End to End attach for UE id ", ue_id, ) # Now actually complete the attach self._s1ap_wrapper._s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, eps_type=s1ap_types.TFW_EPS_ATTACH_TYPE_COMB_EPS_IMSI_ATTACH, ) # Wait for EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Delay to ensure S1APTester sends attach complete before sending UE # context release time.sleep(0.5) print( "************************* Sending UE context release request ", "for UE id ", ue_id, ) # Send UE context release request to move UE to idle mode req = s1ap_types.ueCntxtRelReq_t() req.ue_Id = ue_id req.cause.causeVal = gpp_types.CauseRadioNetwork.USER_INACTIVITY.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, req) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value) print( "************************* Received UE context release indication") print( "************************* Sending active TAU request (Combined " "TALA update) for UE id ", ue_id, ) # Send active TAU request with combined TALA update as update type req = s1ap_types.ueTauReq_t() req.ue_Id = ue_id req.type = s1ap_types.Eps_Updt_Type.TFW_COMB_TALA_UPDATING.value req.Actv_flag = True req.ueMtmsi.pres = False self._s1ap_wrapper.s1_util.issue_cmd(s1ap_types.tfwCmd.UE_TAU_REQ, req) # Waiting for TAU Reject Indication -Combined TALA update not supported response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_TAU_REJECT_IND.value) print("************************* Received Tracking Area Update Reject " "Indication") response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value) print( "************************* Received UE context release indication") print( "************************* Running End to End attach to verify if " "UE context was released properly after combined TAU reject for " "UE id ", ue_id, ) # Now actually complete the attach self._s1ap_wrapper._s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, eps_type=s1ap_types.TFW_EPS_ATTACH_TYPE_COMB_EPS_IMSI_ATTACH, ) # Wait for EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() print("************************* Running UE detach 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)
def test_tau_ta_updating(self): """Attach 2 UEs. Move the UEs to idle mode. 1. For the 1st UE, send tracking area update(TAU) with EPS Update Type=TA Updating and active flag set to true 2. For the 2nd UE, send tracking area update(TAU) with EPS Update Type=TA Updating and active flag set to false """ num_ues = 2 wait_for_s1_context_rel = False self._s1ap_wrapper.configUEDevice(num_ues) ue_ids = [] # Attach for _ in range(num_ues): req = self._s1ap_wrapper.ue_req ue_id = req.ue_id self._s1ap_wrapper.s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, id_type=s1ap_types.TFW_MID_TYPE_GUTI, ) ue_ids.append(req.ue_id) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Add delay to ensure that S1APTester sends Attach Complete time.sleep(0.5) # Move the UEs to idle state for ue in ue_ids: print( "************************* Sending UE context release request ", "for UE id ", ue, ) # Send UE context release request to move UE to idle mode cntxt_rel_req = s1ap_types.ueCntxtRelReq_t() cntxt_rel_req.ue_Id = ue cntxt_rel_req.cause.causeVal = ( gpp_types.CauseRadioNetwork.USER_INACTIVITY.value) self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, cntxt_rel_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) # For the 1st UE, send TAU with Eps_Updt_Type # TA_UPDATING and active flag set to true print( "************************* Sending Tracking Area Update ", "request for UE id ", ue_ids[0], ) tau_req = s1ap_types.ueTauReq_t() tau_req.ue_Id = ue_ids[0] tau_req.type = s1ap_types.Eps_Updt_Type.TFW_TA_UPDATING.value tau_req.Actv_flag = True tau_req.ueMtmsi.pres = False self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_TAU_REQ, tau_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEquals( response.msg_type, s1ap_types.tfwCmd.UE_TAU_ACCEPT_IND.value, ) tau_acc = response.cast(s1ap_types.ueTauAccept_t) print( "************************* Received Tracking Area Update ", "accept for UE id ", tau_acc.ue_Id, ) # For the 2nd UE, send TAU with Eps_Updt_Type # TA_UPDATING and active flag set to false print( "************************* Sending Tracking Area Update ", "request for UE id ", ue_ids[1], ) tau_req = s1ap_types.ueTauReq_t() tau_req.ue_Id = ue_ids[1] tau_req.type = s1ap_types.Eps_Updt_Type.TFW_TA_UPDATING.value tau_req.Actv_flag = False tau_req.ueMtmsi.pres = False self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_TAU_REQ, tau_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEquals( response.msg_type, s1ap_types.tfwCmd.UE_TAU_ACCEPT_IND.value, ) tau_acc = response.cast(s1ap_types.ueTauAccept_t) print( "************************* Received Tracking Area Update ", "accept for UE id ", tau_acc.ue_Id, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) for ue in ue_ids: print( "************************* Running UE detach (switch-off) for ", "UE id ", ue, ) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, wait_for_s1_context_rel, )
def test_eps_bearer_context_status_multi_ded_bearer_deact(self): """Attach a single UE. Create 2 secondary PDNs and add 2 dedicated bearers to each of the secondary PDNs. Send EPS bearer context status IE in TAU request with all default bearer i.e. bearer ids 5,6 and 9 as active and dedicated bearers 7,8,10 and 11 as inactive. Set active flag to false. """ num_ue = 1 num_pdns = 2 sec_ip = [] flow_list = [] wait_for_s1_context_rel = False self._s1ap_wrapper.configUEDevice(num_ue) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id # APN of the secondary PDN ims = { "apn_name": "ims", # APN-name "qci": 5, # qci "priority": 15, # priority "pre_cap": 0, # preemption-capability "pre_vul": 0, # preemption-vulnerability "mbr_ul": 200000000, # MBR UL "mbr_dl": 100000000, # MBR DL } internet = { "apn_name": "internet", # APN-name "qci": 9, # qci "priority": 15, # priority "pre_cap": 0, # preemption-capability "pre_vul": 0, # preemption-vulnerability "mbr_ul": 250000000, # MBR UL "mbr_dl": 150000000, # MBR DL } # APN list to be configured apn_list = [ims, internet] self._s1ap_wrapper.configAPN( "IMSI" + "".join([str(i) for i in req.imsi]), apn_list, ) print( "************************* Running End to End attach for UE id ", ue_id, ) # Attach attach = self._s1ap_wrapper.s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) addr = attach.esmInfo.pAddr.addrInfo default_ip = ipaddress.ip_address(bytes(addr[:4])) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # APNs of the secondary PDNs apn = ["ims", "internet"] for i in range(num_pdns): # Send PDN Connectivity Request self._s1ap_wrapper.sendPdnConnectivityReq(ue_id, apn[i]) # Receive PDN CONN RSP/Activate default EPS bearer context request response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_PDN_CONN_RSP_IND.value, ) act_def_bearer_req = response.cast(s1ap_types.uePdnConRsp_t) print( "********************** Sending Activate default EPS bearer " "context accept for UE id ", ue_id, ) print( "********************** Added default bearer with " "bearer id", act_def_bearer_req.m.pdnInfo.epsBearerId, ) addr = act_def_bearer_req.m.pdnInfo.pAddr.addrInfo sec_ip.append(ipaddress.ip_address(bytes(addr[:4]))) # Add dedicated bearer for the default bearers print( "********************** Adding 1st dedicated bearer to IMSI", "".join([str(i) for i in req.imsi]), ) # Create default flow list flow_list.append(self._spgw_util.create_default_ipv4_flows()) self._spgw_util.create_bearer( "IMSI" + "".join([str(i) for i in req.imsi]), act_def_bearer_req.m.pdnInfo.epsBearerId, flow_list[i], ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_ACT_DED_BER_REQ.value, ) act_ded_ber_ctxt_req = response.cast( s1ap_types.UeActDedBearCtxtReq_t, ) self._s1ap_wrapper.sendActDedicatedBearerAccept( ue_id, act_ded_ber_ctxt_req.bearerId, ) # Create 2nd dedicated bearer print( "********************** Adding 2nd dedicated bearer to IMSI", "".join([str(i) for i in req.imsi]), ) flow_list.append(self._spgw_util.create_default_ipv4_flows()) self._spgw_util.create_bearer( "IMSI" + "".join([str(i) for i in req.imsi]), act_def_bearer_req.m.pdnInfo.epsBearerId, flow_list[i], ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_ACT_DED_BER_REQ.value, ) act_ded_ber_ctxt_req = response.cast( s1ap_types.UeActDedBearCtxtReq_t, ) self._s1ap_wrapper.sendActDedicatedBearerAccept( ue_id, act_ded_ber_ctxt_req.bearerId, ) print("Sleeping for 5 seconds") time.sleep(5) # Verify if flow rules are created for i in range(num_pdns): dl_flow_rules = { default_ip: [], sec_ip[i]: [flow_list[i]], } # 1 UL flow is created per bearer num_ul_flows = 7 self._s1ap_wrapper.s1_util.verify_flow_rules( num_ul_flows, dl_flow_rules, ) print( "************************* Sending UE context release request ", "for UE id ", ue_id, ) # Send UE context release request to move UE to idle mode cntxt_rel_req = s1ap_types.ueCntxtRelReq_t() cntxt_rel_req.ue_Id = ue_id cntxt_rel_req.cause.causeVal = ( gpp_types.CauseRadioNetwork.USER_INACTIVITY.value) self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, cntxt_rel_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) print(" Sleeping for 2 seconds") time.sleep(2) print( "************************* Sending Tracking Area Update ", "request for UE id ", ue_id, ) tau_req = s1ap_types.ueTauReq_t() tau_req.ue_Id = ue_id tau_req.type = s1ap_types.Eps_Updt_Type.TFW_TA_UPDATING.value tau_req.Actv_flag = True # Set default bearers 5,6 and 9 as active and # dedicated bearers 7,8,10 and 11 as inactive # epsBearerCtxSts IE is 16 bits # Ref: 3gpp 24.301 sec-9.9.2.1 tau_req.epsBearerCtxSts = 0x260 tau_req.ueMtmsi.pres = False self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_TAU_REQ, tau_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEquals( response.msg_type, s1ap_types.tfwCmd.UE_TAU_ACCEPT_IND.value, ) tau_acc = response.cast(s1ap_types.ueTauAccept_t) print( "************************* Received Tracking Area Update ", "accept for UE id ", tau_acc.ue_Id, ) # Verify if flow rules are created for i in range(num_pdns): dl_flow_rules = { default_ip: [], sec_ip[i]: [], } # 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( "************************* Running UE detach (switch-off) for ", "UE id ", ue_id, ) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue_id, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, wait_for_s1_context_rel, ) print("Sleeping for 5 seconds") time.sleep(5) # Verify that all UL/DL flows are deleted self._s1ap_wrapper.s1_util.verify_flow_rules_deletion()
def test_tau_periodic_active(self): """ Attach a single UE and send active period tracking area updates (TAU)""" num_taus = 4 tau_period = 0.5 # seconds between TAU updates self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id print( "************************* Running End to End attach for UE id ", ue_id, ) # Now actually complete the attach self._s1ap_wrapper.s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, id_type=s1ap_types.TFW_MID_TYPE_GUTI, ) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Add delay to ensure that S1APTester sends Attach Complete before # UE context release request message. time.sleep(0.5) print( "************************* Sending UE context release request ", "for UE id ", ue_id, ) # Send UE context release request to move UE to idle mode req = s1ap_types.ueCntxtRelReq_t() req.ue_Id = ue_id req.cause.causeVal = gpp_types.CauseRadioNetwork.USER_INACTIVITY.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) for _ in range(num_taus): timer = threading.Timer(tau_period, lambda: None) timer.start() timer.join() print( "************************* Sending Tracking Area Update ", "request for UE id ", ue_id, ) # Send UE context release request to move UE to idle mode req = s1ap_types.ueTauReq_t() req.ue_Id = ue_id req.type = s1ap_types.Eps_Updt_Type.TFW_PERIODIC_UPDATING.value req.Actv_flag = True req.ueMtmsi.pres = False self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_TAU_REQ, req, ) response = self._s1ap_wrapper.s1_util.get_response() if s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value == response.msg_type: response = self._s1ap_wrapper.s1_util.get_response() self.assertEquals( response.msg_type, s1ap_types.tfwCmd.UE_TAU_ACCEPT_IND.value, ) print( "************************* Sending UE context release ", "request for UE id ", ue_id, ) # Send UE context release request to move UE to idle mode req = s1ap_types.ueCntxtRelReq_t() req.ue_Id = ue_id req.cause.causeVal = gpp_types.CauseRadioNetwork.USER_INACTIVITY.value self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) else: self.assertEquals( response.msg_type, s1ap_types.tfwCmd.UE_TAU_REJECT_IND.value, ) print( "************************* Running UE detach (switch-off) for ", "UE id ", ue_id, ) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue_id, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, False, )
def test_tau_ta_updating_reject(self): """Attach a UE. Move the UE to idle mode. Send tracking area update(TAU)request with TAC=55 MME sends TAU reject as the tac is not configured in mme.conf """ num_ues = 1 wait_for_s1_context_rel = False self._s1ap_wrapper.configUEDevice(num_ues) # Attach req = self._s1ap_wrapper.ue_req ue_id = req.ue_id self._s1ap_wrapper.s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, id_type=s1ap_types.TFW_MID_TYPE_GUTI, ) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Add delay to ensure that S1APTester sends Attach Complete time.sleep(0.5) # Configure TAC=5 in s1aptester config_tai = s1ap_types.nbConfigTai_t() config_tai.ue_Id = req.ue_id config_tai.tac = 55 self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.ENB_CONFIG_TAI, config_tai, ) print( "************************* Sending ENB_CONFIG_TAI ", "for UE id ", req.ue_id, ) # Move the UE to idle state print( "************************* Sending UE context release request ", "for UE id ", req.ue_id, ) cntxt_rel_req = s1ap_types.ueCntxtRelReq_t() cntxt_rel_req.ue_Id = req.ue_id cntxt_rel_req.cause.causeVal = ( gpp_types.CauseRadioNetwork.USER_INACTIVITY.value ) self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, cntxt_rel_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) print( "************************* Sending Tracking Area Update ", "request for UE id ", req.ue_id, ) tau_req = s1ap_types.ueTauReq_t() tau_req.ue_Id = req.ue_id tau_req.type = s1ap_types.Eps_Updt_Type.TFW_TA_UPDATING.value tau_req.Actv_flag = False tau_req.ueMtmsi.pres = False self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_TAU_REQ, tau_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEquals( response.msg_type, s1ap_types.tfwCmd.UE_TAU_REJECT_IND.value, ) tau_rej = response.cast(s1ap_types.ueTauRejInd_t) print( "************************* Received Tracking Area Update ", "reject for UE id ", tau_rej.ue_Id, ) print("************************* Sleeping for 2 seconds") time.sleep(2) print( "************************* Running UE detach (switch-off) for ", "UE id ", req.ue_id, ) # Now detach the UE self._s1ap_wrapper.s1_util.detach( req.ue_id, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, wait_for_s1_context_rel, )
def test_tau_mixed_partial_lists(self): """Attach 3 UEs. Move the UEs to idle mode. Send tracking area update(TAU)request with TACs belonging to different partial TAI lists """ num_ues = 3 ue_ids = [] tac = [1, 20, 45] wait_for_s1_context_rel = False self._s1ap_wrapper.configUEDevice(num_ues) # Attach for _ in range(num_ues): req = self._s1ap_wrapper.ue_req self._s1ap_wrapper.s1_util.attach( req.ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) ue_ids.append(req.ue_id) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() # Add delay to ensure that S1APTester sends Attach Complete time.sleep(0.5) for i in range(num_ues): # Configure tacs in s1aptester config_tai = s1ap_types.nbConfigTai_t() config_tai.ue_Id = ue_ids[i] config_tai.tac = tac[i] self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.ENB_CONFIG_TAI, config_tai, ) print( "************************* Sending ENB_CONFIG_TAI ", "for UE id ", ue_ids[i], ) # Move the UE to idle state print( "************************* Sending UE context release request ", "for UE id ", ue_ids[i], ) cntxt_rel_req = s1ap_types.ueCntxtRelReq_t() cntxt_rel_req.ue_Id = ue_ids[i] cntxt_rel_req.cause.causeVal = ( gpp_types.CauseRadioNetwork.USER_INACTIVITY.value) self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_CNTXT_REL_REQUEST, cntxt_rel_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) print( "************************* Sending Tracking Area Update ", "request for UE id ", ue_ids[i], ) tau_req = s1ap_types.ueTauReq_t() tau_req.ue_Id = ue_ids[i] tau_req.type = s1ap_types.Eps_Updt_Type.TFW_TA_UPDATING.value tau_req.Actv_flag = False tau_req.ueMtmsi.pres = False self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_TAU_REQ, tau_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_TAU_ACCEPT_IND.value, ) tau_acc = response.cast(s1ap_types.ueTauAccept_t) print( "************************* Received Tracking Area Update ", "accept for UE id ", tau_acc.ue_Id, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) print("************************* Sleeping for 2 seconds") time.sleep(2) for ue in ue_ids: print( "************************* Running UE detach (switch-off) for ", "UE id ", ue, ) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, wait_for_s1_context_rel, )