コード例 #1
0
    def test_attach_detach(self):
        """ attach/detach + dedicated bearer activation reject test with a
            single UE """
        num_ues = 1
        detach_type = [
            s1ap_types.ueDetachType_t.UE_NORMAL_DETACH.value,
            s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value,
        ]
        wait_for_s1 = [True, False]
        self._s1ap_wrapper.configUEDevice(num_ues)

        for i 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()

            time.sleep(5)
            print(
                "********************** Adding dedicated bearer to IMSI",
                "".join([str(i) for i in req.imsi]),
            )
            self._spgw_util.create_bearer(
                "IMSI" + "".join([str(i) for i in req.imsi]), 5)

            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)
            ded_bearer_rej = s1ap_types.UeActDedBearCtxtRej_t()
            ded_bearer_rej.ue_Id = req.ue_id
            ded_bearer_rej.bearerId = act_ded_ber_ctxt_req.bearerId
            # Send Bearer Activation Reject
            self._s1ap_wrapper._s1_util.issue_cmd(
                s1ap_types.tfwCmd.UE_ACT_DED_BER_REJ, ded_bearer_rej)

            time.sleep(5)
            print(
                "********************** Running UE detach for UE id ",
                req.ue_id,
            )
            # Now detach the UE
            self._s1ap_wrapper.s1_util.detach(req.ue_id, detach_type[i],
                                              wait_for_s1[i])
コード例 #2
0
    def test_attach_detach_rar_activation_reject(self):
        """Attach/detach + rar + dedicated bearer activation reject test
        with a single UE"""
        num_ues = 1
        self._s1ap_wrapper.configUEDevice(num_ues)

        req = self._s1ap_wrapper.ue_req
        print(
            "********************** Running End to End attach for UE id",
            req.ue_id,
        )
        # Now actually complete the attach
        self._s1ap_wrapper._s1_util.attach(
            req.ue_id,
            s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST,
            s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND,
            s1ap_types.ueAttachAccept_t,
        )

        # Wait for EMM Information from MME
        self._s1ap_wrapper._s1_util.receive_emm_info()

        # UL Flow description #1
        ul_flow1 = {
            "ip_proto": FlowMatch.IPPROTO_TCP,  # Protocol Type
            "direction": FlowMatch.UPLINK,  # Direction
        }
        # DL Flow description #1
        dl_flow1 = {
            "ip_proto": FlowMatch.IPPROTO_TCP,  # Protocol Type
            "direction": FlowMatch.DOWNLINK,  # Direction
        }
        # Flow list to be configured
        flow_list = [
            ul_flow1,
            dl_flow1,
        ]
        # QoS
        qos = {
            "qci": 5,  # qci value [1 to 9]
            "priority": 15,  # 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
        }

        policy_id = "ims-voice"

        time.sleep(5)
        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_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_ctxt_req = response.cast(
            s1ap_types.UeActDedBearCtxtReq_t,
        )
        print(
            "********************** Received Activate Dedicated Bearer Request",
        )
        time.sleep(15)

        # The T3485 timer expires in 8 seconds, leading to re-transmission of
        # Dedicated Bearer Activation Request message.
        # Handling re-transmitted Dedicated Bearer Activation Request
        response = self._s1ap_wrapper.s1_util.get_response()
        self.assertEqual(
            response.msg_type,
            s1ap_types.tfwCmd.UE_ACT_DED_BER_REQ.value,
        )
        print(
            "********************** Ignoring re-transmitted Dedicated Bearer "
            "Activation Request",
        )

        print(
            "********************** Sending Activate Dedicated Bearer Reject",
        )
        # Send Bearer Activation Reject
        ded_bearer_rej = s1ap_types.UeActDedBearCtxtRej_t()
        ded_bearer_rej.ue_Id = req.ue_id
        ded_bearer_rej.bearerId = act_ded_ber_ctxt_req.bearerId
        self._s1ap_wrapper._s1_util.issue_cmd(
            s1ap_types.tfwCmd.UE_ACT_DED_BER_REJ,
            ded_bearer_rej,
        )

        time.sleep(15)
        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,
        )
    def test_attach_detach_dedicated_activation_reject(self):
        """attach/detach + dedicated bearer activation reject test with a
        single UE
        """
        num_ues = 1
        detach_type = [
            s1ap_types.ueDetachType_t.UE_NORMAL_DETACH.value,
            s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value,
        ]
        wait_for_s1 = [True, False]
        self._s1ap_wrapper.configUEDevice(num_ues)

        for i 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
            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]))

            # Wait on EMM Information from MME
            self._s1ap_wrapper._s1_util.receive_emm_info()

            print("Sleeping for 5 seconds")
            time.sleep(5)
            print(
                "********************** Adding dedicated bearer to IMSI",
                "".join([str(i) for i in req.imsi]),
            )
            # Create default flow list
            flow_list = self._spgw_util.create_default_ipv4_flows()
            self._spgw_util.create_bearer(
                "IMSI" + "".join([str(i) for i in req.imsi]),
                attach.esmInfo.epsBearerId,
                flow_list,
            )

            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,
            )
            ded_bearer_rej = s1ap_types.UeActDedBearCtxtRej_t()
            ded_bearer_rej.ue_Id = req.ue_id
            ded_bearer_rej.bearerId = act_ded_ber_ctxt_req.bearerId
            # Send Bearer Activation Reject
            self._s1ap_wrapper._s1_util.issue_cmd(
                s1ap_types.tfwCmd.UE_ACT_DED_BER_REJ, ded_bearer_rej,
            )
            print(
                "Sent UE_ACT_DED_BER_REJ for bearer id",
                ded_bearer_rej.bearerId,
            )

            print("Sleeping for 5 seconds")
            time.sleep(5)
            # Dedicated bearer creation failed as UE sent UE_ACT_DED_BER_REJ
            # flow rule should not be created for the dedicated bearer
            dl_flow_rules = {
                default_ip: [],
            }
            # 1 UL flow for default bearer
            num_ul_flows = 1
            self._s1ap_wrapper.s1_util.verify_flow_rules(
                num_ul_flows, dl_flow_rules,
            )

            print(
                "********************** Running UE detach for UE id ",
                req.ue_id,
            )
            # Now detach the UE
            self._s1ap_wrapper.s1_util.detach(
                req.ue_id, detach_type[i], wait_for_s1[i],
            )