def test_attach_detach_multienb_multiue(self):
        """ Multi Enb Multi UE attach detach """

        num_of_enbs = 5
        # column is a enb parameter,  row is a number of enbs
        """            Cell Id,   Tac, EnbType, PLMN Id """
        enb_list = list([[1, 1, 1, "001010"], [2, 1, 1, "001010"],
                         [3, 1, 1, "001010"], [4, 1, 1, "001010"],
                         [5, 1, 1, "001010"]])

        assert (num_of_enbs == len(enb_list)), "Number of enbs configured"
        "not equal to enbs in the list!!!"

        self._s1ap_wrapper.multiEnbConfig(num_of_enbs, 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 = 5
        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)

        # Trigger eNB Reset
        # Add delay to ensure S1APTester sends attach complete before sending
        # eNB Reset Request
        time.sleep(0.5)

        print("************************* Sending eNB Reset Request")
        reset_req = s1ap_types.ResetReq()
        reset_req.rstType = s1ap_types.resetType.COMPLETE_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.completeRst = s1ap_types.CompleteReset()
        reset_req.r.completeRst.enbId = 2
        self._s1ap_wrapper.s1_util.issue_cmd(s1ap_types.tfwCmd.RESET_REQ,
                                             reset_req)
        response = self._s1ap_wrapper.s1_util.get_response()
        self.assertEqual(response.msg_type, s1ap_types.tfwCmd.RESET_ACK.value)

        time.sleep(1)
        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)
    def test_enb_complete_reset(self):
        """ENB Complete Reset:

        1) Attach 32 UEs
        2) Send complete reset
        3) 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()

        # Trigger eNB Reset
        # Add delay to ensure S1APTester sends attach complete before sending
        # eNB Reset Request
        time.sleep(0.5)

        print("************************* Sending eNB Reset Request")
        reset_req = s1ap_types.ResetReq()
        reset_req.rstType = s1ap_types.resetType.COMPLETE_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.completeRst = s1ap_types.CompleteReset()
        self._s1ap_wrapper.s1_util.issue_cmd(
            s1ap_types.tfwCmd.RESET_REQ,
            reset_req,
        )
        response = self._s1ap_wrapper.s1_util.get_response()
        self.assertEqual(response.msg_type, s1ap_types.tfwCmd.RESET_ACK.value)

        # Sleep for 3 seconds to ensure that MME has cleaned up all S1 state
        # before proceeding
        time.sleep(3)
        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,
                wait_for_s1_ctxt_release=True,
            )
Beispiel #3
0
 def test_enb_partial_reset(self):
     """ attach 32 UEs """
     ue_ids = []
     num_ues = 1
     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()
     # Trigger eNB Reset
     # Add delay to ensure S1APTester sends attach partial before sending
     # eNB Reset Request
     time.sleep(0.5)
     print("************************* Sending eNB Partial Reset Request")
     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 = num_ues
     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[indx]
         print(
             "Reset_req.r.partialRst.ueS1apIdPairList[indx].ueId",
             reset_req.r.partialRst.ueS1apIdPairList[indx].ueId,
             indx,
         )
     print("ue_ids", ue_ids)
     self._s1ap_wrapper.s1_util.issue_cmd(s1ap_types.tfwCmd.RESET_REQ,
                                          reset_req)
     response = self._s1ap_wrapper.s1_util.get_response()
     self.assertEqual(response.msg_type, s1ap_types.tfwCmd.RESET_ACK.value)
     # Sleep for 3 seconds to ensure that MME has cleaned up all S1 state
     # before proceeding
     time.sleep(3)
     # Trigger detach request
     for ue in ue_ids:
         print("************************* Calling detach for UE id ", ue)
         # self._s1ap_wrapper.s1_util.detach(
         #    ue, detach_type, wait_for_s1)
         self._s1ap_wrapper.s1_util.detach(
             ue, s1ap_types.ueDetachType_t.UE_NORMAL_DETACH.value, True)
    def test_enb_complete_reset(self):
        """ attach 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()

        # Trigger eNB Reset
        # Add delay to ensure S1APTester sends attach complete before sending
        # eNB Reset Request
        time.sleep(0.5)

        print("************************* Sending eNB Reset Request")
        reset_req = s1ap_types.ResetReq()
        reset_req.rstType = s1ap_types.resetType.COMPLETE_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.u = s1ap_types.U()
        reset_req.u.completeRst = s1ap_types.CompleteReset()
        self._s1ap_wrapper.s1_util.issue_cmd(
            s1ap_types.tfwCmd.RESET_REQ, reset_req)
        response = self._s1ap_wrapper.s1_util.get_response()
        self.assertEqual(
            response.msg_type, s1ap_types.tfwCmd.RESET_ACK.value)

        # Note - S1APTester is not sending detach after receiving reset.
        # Reported the issue to S1APTester team.
        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)
Beispiel #5
0
    def test_enb_partial_reset(self):
        """ attach 32 UEs """
        ue_ids = []
        num_ues = 1
        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,
            )
            # Trigger Attach Request with PDN_Type = IPv4v6
            attach_req = s1ap_types.ueAttachRequest_t()
            sec_ctxt = s1ap_types.TFW_CREATE_NEW_SECURITY_CONTEXT
            id_type = s1ap_types.TFW_MID_TYPE_IMSI
            eps_type = s1ap_types.TFW_EPS_ATTACH_TYPE_EPS_ATTACH
            pdn_type = s1ap_types.pdn_Type()
            pdn_type.pres = True
            # Set PDN TYPE to IPv4V6 i.e. 3. IPV4 is equal to 1
            # IPV6 is equal to 2 in value
            pdn_type.pdn_type = 1
            attach_req.ue_Id = req.ue_id
            attach_req.mIdType = id_type
            attach_req.epsAttachType = eps_type
            attach_req.useOldSecCtxt = sec_ctxt
            attach_req.pdnType_pr = pdn_type

            print("********Triggering Attach Request with PND Type IPv4 test")

            self._s1ap_wrapper._s1_util.issue_cmd(
                s1ap_types.tfwCmd.UE_ATTACH_REQUEST,
                attach_req,
            )
            response = self._s1ap_wrapper.s1_util.get_response()
            self.assertEqual(
                response.msg_type,
                s1ap_types.tfwCmd.UE_AUTH_REQ_IND.value,
            )

            # Trigger Authentication Response
            auth_res = s1ap_types.ueAuthResp_t()
            auth_res.ue_Id = req.ue_id
            sqnRecvd = s1ap_types.ueSqnRcvd_t()
            sqnRecvd.pres = 0
            auth_res.sqnRcvd = sqnRecvd
            self._s1ap_wrapper._s1_util.issue_cmd(
                s1ap_types.tfwCmd.UE_AUTH_RESP,
                auth_res,
            )
            response = self._s1ap_wrapper.s1_util.get_response()
            self.assertEqual(
                response.msg_type,
                s1ap_types.tfwCmd.UE_SEC_MOD_CMD_IND.value,
            )

            # Trigger Security Mode Complete
            sec_mode_complete = s1ap_types.ueSecModeComplete_t()
            sec_mode_complete.ue_Id = req.ue_id
            self._s1ap_wrapper._s1_util.issue_cmd(
                s1ap_types.tfwCmd.UE_SEC_MOD_COMPLETE,
                sec_mode_complete,
            )

            response = self._s1ap_wrapper.s1_util.get_response()
            self.assertEqual(
                response.msg_type,
                s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value,
            )

            response = self._s1ap_wrapper.s1_util.get_response()
            print("response message type for ATTTACH ACC", response.msg_type)
            print("acc", s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND.value)
            self.assertEqual(
                response.msg_type,
                s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND.value,
            )
            ue_ids.append(req.ue_id)

        # Trigger eNB Reset
        # Add delay to ensure S1APTester sends attach partial before sending
        # eNB Reset Request
        time.sleep(0.5)
        print("************************* Sending eNB Partial Reset Request")
        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 = num_ues
        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[indx]
            print(
                "Reset_req.r.partialRst.ueS1apIdPairList[indx].ueId",
                reset_req.r.partialRst.ueS1apIdPairList[indx].ueId,
                indx,
            )
        print("ue_ids", ue_ids)
        self._s1ap_wrapper.s1_util.issue_cmd(
            s1ap_types.tfwCmd.RESET_REQ,
            reset_req,
        )
        response1 = self._s1ap_wrapper.s1_util.get_response()
        print("response1 message type", response1.msg_type)
        self.assertEqual(response1.msg_type, s1ap_types.tfwCmd.RESET_ACK.value)
        # Trigger detach request
        """time.sleep(0.5)
    def test_enb_partial_reset_multi_ue(self):
        """ENB Partial Reset for multiple UEs:
        1) Attach 32 UEs
        2) Send partial reset for a random subset of the attached UEs
        3) 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.time())
        reset_ue_count = random.randint(1, num_ues)
        random.seed(time.time())
        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,
        )
        response = self._s1ap_wrapper.s1_util.get_response()
        self.assertEqual(response.msg_type, s1ap_types.tfwCmd.RESET_ACK.value)

        # Sleep for 3 seconds to ensure that MME has cleaned up all S1 state
        # before proceeding
        time.sleep(3)
        # 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_multiple_enb_partial_reset(self):
        """ attach 32 UEs """
        num_of_enbs = 5
        # column is a enb parameter,  row is a number of enbs
        """            Cell Id,   Tac, EnbType, PLMN Id """
        enb_list = list([[1, 1, 1, "001010"], [2, 1, 1, "001010"],
                         [3, 1, 1, "001010"], [4, 1, 1, "001010"],
                         [5, 1, 1, "001010"]])

        assert (num_of_enbs == len(enb_list)), "Number of enbs configured"
        "not equal to enbs in the list!!!"

        self._s1ap_wrapper.multiEnbConfig(num_of_enbs, enb_list)

        time.sleep(2)

        ue_ids = []
        num_ues = 1

        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()
        # Trigger eNB Reset
        # Add delay to ensure S1APTester sends attach partial before sending
        # eNB Reset Request
        time.sleep(0.5)
        print("************************* Sending eNB Partial Reset Request")
        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.u = s1ap_types.U()
        reset_req.u.partialRst = s1ap_types.PartialReset()
        reset_req.u.partialRst.numOfConn = num_ues
        reset_req.u.partialRst.ueIdLst = (ctypes.c_ubyte *
                                          reset_req.u.partialRst.numOfConn)()
        for indx in range(reset_req.u.partialRst.numOfConn):
            reset_req.u.partialRst.ueIdLst[indx] = ue_ids[indx]
            print(
                "Reset_req.u.partialRst.ueIdLst[indx]",
                reset_req.u.partialRst.ueIdLst[indx],
                indx,
            )
        print("ue_ids", ue_ids)
        self._s1ap_wrapper.s1_util.issue_cmd(s1ap_types.tfwCmd.RESET_REQ,
                                             reset_req)
        response = self._s1ap_wrapper.s1_util.get_response()
        self.assertEqual(response.msg_type, s1ap_types.tfwCmd.RESET_ACK.value)
        # Trigger detach request
        for ue in ue_ids:
            print("************************* Calling detach for UE id ", ue)
            # self._s1ap_wrapper.s1_util.detach(
            #    ue, detach_type, wait_for_s1)
            self._s1ap_wrapper.s1_util.detach(
                ue, s1ap_types.ueDetachType_t.UE_NORMAL_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,
            )
Beispiel #9
0
    def test_enb_partial_reset_with_unknown_ue_s1ap_ids(self):
        """ENB Partial Reset with unknown UE S1AP Id:

        1) Attach 1 UE
        2) Send partial reset for 1 UE with unknown UE S1AP Id
        3) Detach the UEs
        """
        ue_ids = []
        num_ues = 1
        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()
        # Trigger eNB Reset
        # Add delay to ensure S1APTester sends attach complete before sending
        # eNB Reset Request
        time.sleep(0.5)
        print("************************* Sending eNB Partial Reset Request")
        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 = num_ues
        reset_req.r.partialRst.ueS1apIdPairList = (
            (s1ap_types.UeS1apIdPair) * reset_req.r.partialRst.numOfConn)()
        random_inc_val = 20
        for indx in range(reset_req.r.partialRst.numOfConn):
            reset_req.r.partialRst.ueS1apIdPairList[indx].ueId = ue_ids[indx]
            # Known Issue: If enbUeS1apId is changed, Detach Request is not
            # sent from S1APTester. Due to other high priority tasks, working
            # on this issue is de-prioritized. After the issue gets resolved,
            # uncomment the following code to set unknown enbUeS1apId

            # reset_req.r.partialRst.ueS1apIdPairList[indx].enbUeS1apId = (
            #     ue_ids[indx] + random_inc_val
            # )
            reset_req.r.partialRst.ueS1apIdPairList[indx].mmeUeS1apId = (
                ue_ids[indx] + random_inc_val)
            print(
                "Reset_req.r.partialRst.ueS1apIdPairList[",
                indx,
                "].ueId:",
                reset_req.r.partialRst.ueS1apIdPairList[indx].ueId,
                ", enbUeS1apId:",
                reset_req.r.partialRst.ueS1apIdPairList[indx].enbUeS1apId,
                ", mmeUeS1apId:",
                reset_req.r.partialRst.ueS1apIdPairList[indx].mmeUeS1apId,
            )
        self._s1ap_wrapper.s1_util.issue_cmd(
            s1ap_types.tfwCmd.RESET_REQ,
            reset_req,
        )
        response = self._s1ap_wrapper.s1_util.get_response()
        self.assertEqual(response.msg_type, s1ap_types.tfwCmd.RESET_ACK.value)

        # Sleep for 3 seconds to ensure that MME has cleaned up all S1 state
        # before proceeding
        time.sleep(3)
        # 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,
                wait_for_s1_ctxt_release=True,
            )
    def test_multiple_enb_partial_reset(self):
        """ Multi eNB + attach 1 UE + s1ap partial reset + 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 = []
        num_ues = 1

        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()
        # Trigger eNB Reset
        # Add delay to ensure S1APTester sends attach partial before sending
        # eNB Reset Request
        time.sleep(0.5)
        print("************************* Sending eNB Partial Reset Request")
        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 = num_ues
        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[indx]
            print(
                "Reset_req.r.partialRst.ueS1apIdPairList[indx].ueId",
                reset_req.r.partialRst.ueS1apIdPairList[indx].ueId,
                indx,
            )
        print("ue_ids", ue_ids)
        self._s1ap_wrapper.s1_util.issue_cmd(
            s1ap_types.tfwCmd.RESET_REQ,
            reset_req,
        )
        response = self._s1ap_wrapper.s1_util.get_response()
        self.assertEqual(response.msg_type, s1ap_types.tfwCmd.RESET_ACK.value)
        # Trigger detach request
        for ue in ue_ids:
            print("************************* Calling detach for UE id ", ue)
            # self._s1ap_wrapper.s1_util.detach(
            #    ue, detach_type, wait_for_s1)
            self._s1ap_wrapper.s1_util.detach(
                ue,
                s1ap_types.ueDetachType_t.UE_NORMAL_DETACH.value,
                True,
            )
Beispiel #11
0
    def test_attach_detach_multienb_multiue_complete_reset(self):
        """ Multi Enb Multi UE attach detach + complete reset """

        """ 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 = 5
        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)

        # Trigger eNB Reset
        # Add delay to ensure S1APTester sends attach complete before sending
        # eNB Reset Request
        time.sleep(0.5)

        print("************************* Sending eNB Reset Request")
        reset_req = s1ap_types.ResetReq()
        reset_req.rstType = s1ap_types.resetType.COMPLETE_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.completeRst = s1ap_types.CompleteReset()
        reset_req.r.completeRst.enbId = 2
        self._s1ap_wrapper.s1_util.issue_cmd(
            s1ap_types.tfwCmd.RESET_REQ, reset_req)
        response = self._s1ap_wrapper.s1_util.get_response()
        self.assertEqual(
            response.msg_type, s1ap_types.tfwCmd.RESET_ACK.value)

        time.sleep(1)
        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)
    def test_enb_partial_reset_con_dereg(self):
        """Test ENB partial reset with 1 UE while UE is connected and
        de-registered
        """
        ue_ids = []
        num_ues = 1
        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,
            )
            # Trigger Attach Request with PDN_Type = IPv4v6
            attach_req = s1ap_types.ueAttachRequest_t()
            sec_ctxt = s1ap_types.TFW_CREATE_NEW_SECURITY_CONTEXT
            id_type = s1ap_types.TFW_MID_TYPE_IMSI
            eps_type = s1ap_types.TFW_EPS_ATTACH_TYPE_EPS_ATTACH
            pdn_type = s1ap_types.pdn_Type()
            pdn_type.pres = True
            # Set PDN TYPE to IPv4V6 i.e. 3. IPV4 is equal to 1
            # IPV6 is equal to 2 in value
            pdn_type.pdn_type = 1
            attach_req.ue_Id = req.ue_id
            attach_req.mIdType = id_type
            attach_req.epsAttachType = eps_type
            attach_req.useOldSecCtxt = sec_ctxt
            attach_req.pdnType_pr = pdn_type

            print(
                "************************* Triggering Attach Request with PDN "
                "Type IPv4 test", )

            self._s1ap_wrapper._s1_util.issue_cmd(
                s1ap_types.tfwCmd.UE_ATTACH_REQUEST,
                attach_req,
            )
            response = self._s1ap_wrapper.s1_util.get_response()
            self.assertEqual(
                response.msg_type,
                s1ap_types.tfwCmd.UE_AUTH_REQ_IND.value,
            )

            # Trigger Authentication Response
            auth_res = s1ap_types.ueAuthResp_t()
            auth_res.ue_Id = req.ue_id
            sqn_recvd = s1ap_types.ueSqnRcvd_t()
            sqn_recvd.pres = 0
            auth_res.sqnRcvd = sqn_recvd
            self._s1ap_wrapper._s1_util.issue_cmd(
                s1ap_types.tfwCmd.UE_AUTH_RESP,
                auth_res,
            )
            response = self._s1ap_wrapper.s1_util.get_response()
            self.assertEqual(
                response.msg_type,
                s1ap_types.tfwCmd.UE_SEC_MOD_CMD_IND.value,
            )

            # Trigger Security Mode Complete
            sec_mode_complete = s1ap_types.ueSecModeComplete_t()
            sec_mode_complete.ue_Id = req.ue_id
            self._s1ap_wrapper._s1_util.issue_cmd(
                s1ap_types.tfwCmd.UE_SEC_MOD_COMPLETE,
                sec_mode_complete,
            )

            # Receive initial context setup and attach accept indication
            response = (self._s1ap_wrapper._s1_util.
                        receive_initial_ctxt_setup_and_attach_accept())
            attach_acc = response.cast(s1ap_types.ueAttachAccept_t)
            print(
                "********************** Received attach accept for UE Id:",
                attach_acc.ue_Id,
            )
            ue_ids.append(req.ue_id)

        # Trigger eNB Reset
        # Add delay to ensure S1APTester sends attach complete before sending
        # eNB Reset Request
        time.sleep(0.5)
        print("************************* Sending eNB Partial Reset Request")
        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 = num_ues
        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[indx]
            print(
                "Reset_req.r.partialRst.ueS1apIdPairList[",
                indx,
                "].ueId",
                reset_req.r.partialRst.ueS1apIdPairList[indx].ueId,
            )
        self._s1ap_wrapper.s1_util.issue_cmd(
            s1ap_types.tfwCmd.RESET_REQ,
            reset_req,
        )
        response = self._s1ap_wrapper.s1_util.get_response()
        self.assertEqual(response.msg_type, s1ap_types.tfwCmd.RESET_ACK.value)
Beispiel #13
0
    def test_enb_partial_reset(self):
        """ attach 32 UEs """
        ue_ids = []
        num_ues = 1
        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()
        # Trigger eNB Reset
        # Add delay to ensure S1APTester sends attach partial before sending
        # eNB Reset Request
        time.sleep(0.5)
        print("************************* Sending eNB Partial Reset Request")
        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 = num_ues
        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[indx]
            '''Known Issue: if enbUeS1apId is getting changed, Detach Request is
             not sent from s1ap tester.
             Due to other high priority tasks, working on this issue is de-prioritized
            '''

            #reset_req.r.partialRst.ueS1apIdPairList[indx].enbUeS1apId = ue_ids[indx] + 20
            reset_req.r.partialRst.ueS1apIdPairList[
                indx].mmeUeS1apId = ue_ids[indx] + 20
            print(
                "Reset_req.r.partialRst.ueS1apIdPairList[indx].ueId"
                " enbUeS1apId: mmeUeS1apId:",
                reset_req.r.partialRst.ueS1apIdPairList[indx].ueId, indx,
                reset_req.r.partialRst.ueS1apIdPairList[indx].enbUeS1apId,
                reset_req.r.partialRst.ueS1apIdPairList[indx].mmeUeS1apId)
        print("ue_ids", ue_ids)
        self._s1ap_wrapper.s1_util.issue_cmd(s1ap_types.tfwCmd.RESET_REQ,
                                             reset_req)
        response = self._s1ap_wrapper.s1_util.get_response()
        self.assertEqual(response.msg_type, s1ap_types.tfwCmd.RESET_ACK.value)
        # Trigger detach request
        for ue in ue_ids:
            print("************************* Calling detach for UE id ", ue)
            # self._s1ap_wrapper.s1_util.detach(
            #    ue, detach_type, wait_for_s1)
            self._s1ap_wrapper.s1_util.detach(
                ue, s1ap_types.ueDetachType_t.UE_NORMAL_DETACH.value, True)