Beispiel #1
0
    def _handle_ue_ho_response(self, vbs, hdr, event, ho):
        """Handle an incoming UE_HO_RESPONSE message.
        Args:
            ho, a UE_HO_RESPONSE message
        Returns:
            None
        """

        addr = hex_to_ether(ho.origin_eNB)
        origin_vbs = RUNTIME.vbses[addr]
        ue = RUNTIME.find_ue_by_rnti(ho.origin_rnti, ho.origin_pci, origin_vbs)

        if event.op == EP_OPERATION_SUCCESS:

            # UE was removed from source eNB
            if ue.is_ho_in_progress_removing():
                ue.set_ho_in_progress_adding()
                return

            # UE was added to target eNB
            if ue.is_ho_in_progress_adding():
                ue._cell = vbs.get_cell_by_pci(hdr.cellid)
                ue.rnti = ho.target_rnti
                ue.set_active()
                return

        self.log.error("Error while performing handover")
        RUNTIME.remove_ue(ue.ue_id)
Beispiel #2
0
    def _handle_ue_report_response(self, vbs, hdr, event, ue_report):
        """Handle an incoming UE_REPORT message.
        Args:
            hello, a UE_REPORT message
        Returns:
            None
        """

        incoming = []

        for ue in ue_report.ues:

            if RUNTIME.find_ue_by_rnti(ue.rnti, ue.pci, vbs):
                continue

            plmn_id = PLMNID(ue.plmn_id[1:].hex())
            tenant = RUNTIME.load_tenant_by_plmn_id(plmn_id)

            if not tenant:
                self.log.info("Unable to find PLMN id %s", plmn_id)
                continue

            if vbs.addr not in tenant.vbses:
                self.log.info("VBS %s not in PLMN id %s", vbs.addr, plmn_id)
                continue

            cell = vbs.get_cell_by_pci(ue.pci)

            if not cell:
                self.log.info("PCI %u not found", u.pci)
                continue

            if ue.imsi != 0:
                ue_id = uuid.uuid5(uuid.NAMESPACE_DNS, str(ue.imsi))
            else:
                ue_id = uuid.uuid4()

            ue = UE(ue_id, ue.imsi, ue.rnti, cell, plmn_id, tenant)
            ue.set_active()

            RUNTIME.ues[ue.ue_id] = ue
            tenant.ues[ue.ue_id] = ue

            incoming.append(ue.ue_id)

            self.server.send_ue_join_message_to_self(ue)

        # check for leaving UEs
        for ue_id in list(RUNTIME.ues.keys()):
            if RUNTIME.ues[ue_id].vbs != vbs:
                continue
            if not RUNTIME.ues[ue_id].is_active():
                self.log.info("Handover in progress for %u, ignoring", ue_id)
                continue
            if ue_id not in incoming:
                RUNTIME.remove_ue(ue_id)
    def _handle_ue_ho_response(self, vbs, hdr, event, ho):
        """Handle an incoming UE_HO_RESPONSE message.

        If event.op is set to EP_OPERATION_SUCCESS, then the handover has been
        successfully performed and the origin_eNB, origin_pci, origin_rnti, and
        target_rnti are all set to their correct values. This message is always
        sent by the TARGET eNB.

        If event.op is set to EP_OPERATION_FAIL it means that the HO failed. In
        this case only the origin_eNB, origin_pci, and origin_rnti fields are
        filled. This message is always sent by the SOURCE eNB.

        Args:
            ho, a UE_HO_RESPONSE message
        Returns:
            None
        """

        origin_enbid = EtherAddress(ho.origin_enbid[2:8])

        if origin_enbid not in RUNTIME.vbses:
            self.log.warning("HO response from unknown VBS %s", RUNTIME.vbses)
            return

        origin_vbs = RUNTIME.vbses[origin_enbid]

        ue = RUNTIME.find_ue_by_rnti(ho.origin_rnti, ho.origin_pci, origin_vbs)

        if not ue:
            self.log.warning("Unable to find UE rnti %u pci %u vbs %s",
                             ho.origin_rnti, ho.origin_pci, origin_vbs)
            return

        ue.handle_ue_handover_response(origin_vbs, self.vbs, ho.origin_rnti,
                                       ho.target_rnti, ho.origin_pci,
                                       hdr.cellid, event.opcode)
    def _handle_ue_report_response(self, vbs, hdr, event, msg):
        """Handle an incoming UE_REPORT message.
        Args:
            hello, a UE_REPORT message
        Returns:
            None
        """

        for raw_entry in msg.options:

            if raw_entry.type not in UE_REPORT_TYPES:
                self.log.warning("Unknown options %u", raw_entry.raw_entry)
                continue

            prop = UE_REPORT_TYPES[raw_entry.type].name
            option = UE_REPORT_TYPES[raw_entry.type].parse(raw_entry.data)

            self.log.warning("Processing options %s", prop)

            if raw_entry.type == EP_UE_REPORT_IDENTITY:

                plmn_id = PLMNID(option.plmn_id)
                tenant = RUNTIME.load_tenant_by_plmn_id(plmn_id)

                if not tenant:
                    self.log.info("Unknown tenant %s", plmn_id)
                    continue

                ue = RUNTIME.find_ue_by_rnti(option.rnti, hdr.cellid, vbs)

                # UE already known, update its parameters
                if ue:

                    ue.plmn_id = plmn_id
                    ue.tmsi = option.timsi

                else:

                    cell = vbs.cells[hdr.cellid]
                    ue_id = uuid.uuid4()

                    ue = UE(ue_id, option.rnti, option.imsi, option.timsi,
                            cell, tenant)

                    RUNTIME.ues[ue.ue_id] = ue
                    tenant.ues[ue.ue_id] = ue

                    self.server.send_ue_join_message_to_self(ue)

            elif raw_entry.type == EP_UE_REPORT_STATE:

                ue_id = uuid.uuid4()

                ue = RUNTIME.find_ue_by_rnti(option.rnti, hdr.cellid, vbs)

                if not ue:
                    continue

                try:
                    ue.state = UE_REPORT_STATES[option.state]
                except IOError:
                    self.log.error("Invalid transistion %s -> %s" \
                                    %(ue.state, UE_REPORT_STATES[option.state]))