def test_scalability_attach_detach_multi_ue(self): """Basic attach and detach for 1024 UEs This testcase is a reference testcase for handling configurations for supporting large number of UEs. """ ue_ids = [] num_ues = 1024 self._s1ap_wrapper.configUEDevice(num_ues) # The inactivity timers for UEs attached in the beginning starts getting # expired before all the UEs could be attached. Increasing UE inactivity # timer to 60 min (3600000 ms) to allow all the UEs to get attached and # detached properly print("Setting the inactivity timer value to 60 mins") config_data = s1ap_types.FwNbConfigReq_t() config_data.inactvTmrVal_pr.pres = True config_data.inactvTmrVal_pr.val = 3600000 self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.ENB_INACTV_TMR_CFG, config_data, ) time.sleep(0.5) 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 for EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() ue_ids.append(req.ue_id) 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, ) # Reset the inactivity timer value to default 2 mins (120000 ms) print("Resetting the inactivity timer value to default value (2 mins)") config_data = s1ap_types.FwNbConfigReq_t() config_data.inactvTmrVal_pr.pres = True config_data.inactvTmrVal_pr.val = 120000 self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.ENB_INACTV_TMR_CFG, config_data, ) time.sleep(0.5)
def test_s1setup_incorrect_tac(self): """S1 Setup Request with incorrect TAC value """ print("************************* Enb tester configuration") req = s1ap_types.FwNbConfigReq_t() req.cellId_pr.pres = True req.cellId_pr.cell_id = 10 req.tac_pr.pres = True req.tac_pr.tac = 0 print("************************* Sending ENB configuration Request") assert self._s1_util.issue_cmd(s1ap_types.tfwCmd.ENB_CONFIG, req) == 0 response = self._s1_util.get_response() assert response.msg_type == s1ap_types.tfwCmd.ENB_CONFIG_CONFIRM.value res = response.cast(s1ap_types.FwNbConfigCfm_t) assert res.status == s1ap_types.CfgStatus.CFG_DONE.value print("************************* Sending S1-Setup Request") req = None assert (self._s1_util.issue_cmd(s1ap_types.tfwCmd.ENB_S1_SETUP_REQ, req) == 0) response = self._s1_util.get_response() assert response.msg_type == s1ap_types.tfwCmd.ENB_S1_SETUP_RESP.value res = response.cast(s1ap_types.FwNbS1setupRsp_t) assert res.res == s1ap_types.S1_setp_Result.S1_SETUP_FAILED.value
def test_s1setup_failure_incorrect_plmn(self): """S1 Setup with incorrect plmn ID""" print("************************* Enb tester configuration") req = s1ap_types.FwNbConfigReq_t() req.cellId_pr.pres = True req.cellId_pr.cell_id = 10 req.plmnId_pr.pres = True # Convert PLMN to ASCII character array of MCC and MNC digits # For 5 digit PLMN add \0 in the end, e.g., "00101\0" req.plmnId_pr.plmn_id = (ctypes.c_ubyte * 6).from_buffer_copy( bytearray(b"333333"), ) print("************************* Sending ENB configuration Request") assert self._s1_util.issue_cmd(s1ap_types.tfwCmd.ENB_CONFIG, req) == 0 response = self._s1_util.get_response() assert response.msg_type == s1ap_types.tfwCmd.ENB_CONFIG_CONFIRM.value res = response.cast(s1ap_types.FwNbConfigCfm_t) assert res.status == s1ap_types.CfgStatus.CFG_DONE.value print("************************* Sending S1-setup Request") req = None assert (self._s1_util.issue_cmd(s1ap_types.tfwCmd.ENB_S1_SETUP_REQ, req) == 0) response = self._s1_util.get_response() assert response.msg_type == s1ap_types.tfwCmd.ENB_S1_SETUP_RESP.value res = response.cast(s1ap_types.FwNbS1setupRsp_t) assert res.res == s1ap_types.S1_setp_Result.S1_SETUP_FAILED.value
class TestS1SetupFailureIncorrectPlmn(unittest.TestCase): """ S1 Setup with incorrect plmn ID """ s1ap_utils._s1_util = S1ApUtil() print("************************* Enb tester config") req = s1ap_types.FwNbConfigReq_t() req.cellId_pr.pres = True req.cellId_pr.cell_id = 10 req.plmnId_pr.pres = True req.plmnId_pr.plmn_id[0] = 3 req.plmnId_pr.plmn_id[1] = 3 req.plmnId_pr.plmn_id[2] = 3 req.plmnId_pr.plmn_id[3] = 3 req.plmnId_pr.plmn_id[4] = 3 req.plmnId_pr.plmn_id[5] = 3 assert (s1ap_utils._s1_util.issue_cmd(s1ap_types.tfwCmd.ENB_CONFIG, req) == 0) response = s1ap_utils._s1_util.get_response() assert (response.msg_type == s1ap_types.tfwCmd.ENB_CONFIG_CONFIRM.value) res = response.cast(s1ap_types.FwNbConfigCfm_t) assert (res.status == s1ap_types.CfgStatus.CFG_DONE.value) assert (s1ap_utils._s1_util.issue_cmd(s1ap_types.tfwCmd.ENB_S1_SETUP_REQ, req) == 0) response = s1ap_utils._s1_util.get_response() assert (response.msg_type == s1ap_types.tfwCmd.ENB_S1_SETUP_RESP.value)
def test_s1setup_secondary_plmn(self): """ S1 Setup with multiple bPLMN IDs, the second being valid. """ print("************************* Enb tester configuration") req = s1ap_types.FwNbConfigReq_t() req.cellId_pr.pres = True req.cellId_pr.cell_id = 1 req.plmnId_pr.pres = True req.plmnId_pr.plmn_id = (ctypes.c_ubyte * 6).from_buffer_copy( bytearray(b"333333"), ) req.suppTAs.pres = True req.suppTAs.numTAs = 1 req.suppTAs.suppTA[0].tac = 1 req.suppTAs.suppTA[0].bPlmnList.numBPlmns = 2 # 333333 - invalid MCC/MNC req.suppTAs.suppTA[0].bPlmnList.bPlmn[0].numMncDigits = 3 req.suppTAs.suppTA[0].bPlmnList.bPlmn[0].mcc = (ctypes.c_ubyte * 3).from_buffer_copy( bytearray(b"\x03\x03\x03"), ) req.suppTAs.suppTA[0].bPlmnList.bPlmn[0].mnc = (ctypes.c_ubyte * 3).from_buffer_copy( bytearray(b"\x03\x03\x03"), ) # 00101 - Valid MCC/MNC req.suppTAs.suppTA[0].bPlmnList.bPlmn[1].numMncDigits = 2 req.suppTAs.suppTA[0].bPlmnList.bPlmn[1].mcc = (ctypes.c_ubyte * 3).from_buffer_copy( bytearray(b"\x00\x00\x01"), ) req.suppTAs.suppTA[0].bPlmnList.bPlmn[1].mnc = (ctypes.c_ubyte * 3).from_buffer_copy( bytearray(b"\x00\x01\x00"), ) print("************************* Sending ENB configuration Request") assert self._s1_util.issue_cmd(s1ap_types.tfwCmd.ENB_CONFIG, req) == 0 response = self._s1_util.get_response() assert response.msg_type == s1ap_types.tfwCmd.ENB_CONFIG_CONFIRM.value res = response.cast(s1ap_types.FwNbConfigCfm_t) assert res.status == s1ap_types.CfgStatus.CFG_DONE.value print("************************* Sending S1-setup Request") req = None assert ( self._s1_util.issue_cmd(s1ap_types.tfwCmd.ENB_S1_SETUP_REQ, req) == 0 ) response = self._s1_util.get_response() assert response.msg_type == s1ap_types.tfwCmd.ENB_S1_SETUP_RESP.value res = response.cast(s1ap_types.FwNbS1setupRsp_t) assert res.res == s1ap_types.S1_setp_Result.S1_SETUP_SUCCESS.value
def _enBConfig(self): """Helper to configure the eNB""" # Using exaggerated prints makes the stdout easier to read. print("************************* Enb tester config") req = s1ap_types.FwNbConfigReq_t() req.cellId_pr.pres = True req.cellId_pr.cell_id = 10 assert self._s1_util.issue_cmd(s1ap_types.tfwCmd.ENB_CONFIG, req) == 0 response = self._s1_util.get_response() assert response.msg_type == s1ap_types.tfwCmd.ENB_CONFIG_CONFIRM.value res = response.cast(s1ap_types.FwNbConfigCfm_t) assert res.status == s1ap_types.CfgStatus.CFG_DONE.value
class TestS1SetupFailureIncorrectTac(unittest.TestCase): """S1 Setup Request with incorrect TAC value """ s1ap_utils._s1_util = S1ApUtil() print("************************* Enb tester config") req = s1ap_types.FwNbConfigReq_t() req.cellId_pr.pres = True req.cellId_pr.cell_id = 10 req.tac_pr.pres = True req.tac_pr.tac = 0 assert (s1ap_utils._s1_util.issue_cmd(s1ap_types.tfwCmd.ENB_CONFIG, req) == 0) response = s1ap_utils._s1_util.get_response() assert (response.msg_type == s1ap_types.tfwCmd.ENB_CONFIG_CONFIRM.value) res = response.cast(s1ap_types.FwNbConfigCfm_t) assert (res.status == s1ap_types.CfgStatus.CFG_DONE.value) req = None assert (s1ap_utils._s1_util.issue_cmd(s1ap_types.tfwCmd.ENB_S1_SETUP_REQ, req) == 0) response = s1ap_utils._s1_util.get_response() assert (response.msg_type == s1ap_types.tfwCmd.ENB_S1_SETUP_RESP.value)
def test_attach_and_mme_restart_loop_detach_and_mme_restart_loop_multi_ue( self, ): """ Multi UE attach-detach with MME restart. Steps to be followed: 1-Attach 2-MmeRestart + wait for 30 seconds 3-Repeat step 1 and 2 in loop for all UEs 4-Detach 5-MmeRestart + wait for 30 seconds 6-Repeat step 4 and 5 in loop for all UEs """ num_ues = 32 detach_type = [ s1ap_types.ueDetachType_t.UE_NORMAL_DETACH.value, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, ] detach_type_str = ["NORMAL", "SWITCHOFF"] self._s1ap_wrapper.configUEDevice(num_ues) # The inactivity timers for UEs attached in the beginning starts getting # expired before all the UEs could be attached. Increasing UE inactivity # timer to 15 min (900000 ms) to allow all the UEs to get attached and # detached properly config_data = s1ap_types.FwNbConfigReq_t() config_data.inactvTmrVal_pr.pres = True config_data.inactvTmrVal_pr.val = 900000 self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.ENB_INACTV_TMR_CFG, config_data, ) time.sleep(0.5) 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) 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) for ue in ue_ids: # Now detach the UE random.seed(time.clock()) index = random.randint(0, 1) print( "************************* Running UE detach for UE id ", ue, "(Detach type: " + detach_type_str[index] + ")", ) self._s1ap_wrapper.s1_util.detach(ue, detach_type[index]) 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)