mobile-insight / mobileinsight-core

Mobile Network Intelligence Made Easy -- MobileInsight core functionalities
http://www.mobileinsight.net
Other
105 stars 80 forks source link

lte_phy_analyzer in callback_pucch records = log_item['Records'] KeyError: 'Records' #61

Open patrick-ucr opened 5 years ago

patrick-ucr commented 5 years ago

Hi,

Description

I use MI v3.4 to collect logs from Android phone (OnePlus 5T with Android 7.1) and use latest desktop mobileinsight-core to analyze the data. However, when I add lte_phy_analyzer, I receive this error message

Code and Logs

src = OfflineReplayer()
src.set_input_path(log_filename)
lte_phy_analyzer = LtePhyAnalyzer()
lte_phy_analyzer.set_source(src)
src.run()
(MI)Unknown LTE PHY PUCCH Tx Report version: 121
Traceback (most recent call last):
  File "build/bdist.linux-x86_64/egg/mobile_insight/monitor/offline_replayer.py", line 205, in run
    self.send(event)
  File "build/bdist.linux-x86_64/egg/mobile_insight/element.py", line 108, in send
    map(G, self.to_list)
  File "build/bdist.linux-x86_64/egg/mobile_insight/element.py", line 107, in G
    def G(module): return module.recv(self, event)
  File "build/bdist.linux-x86_64/egg/mobile_insight/analyzer/analyzer.py", line 231, in recv
    map(G, self.source_callback)
  File "build/bdist.linux-x86_64/egg/mobile_insight/analyzer/analyzer.py", line 227, in G
    def G(f): return f(event)
  File "build/bdist.linux-x86_64/egg/mobile_insight/analyzer/lte_phy_analyzer.py", line 364, in __msg_callback
    self.callback_pucch(msg)
  File "build/bdist.linux-x86_64/egg/mobile_insight/analyzer/lte_phy_analyzer.py", line 120, in callback_pucch
    records = log_item['Records']
KeyError: 'Records'
harpreet-s commented 5 years ago

I ma facing same issue, seems new version 121 needs to be defined , I have added print command to the log , there is no key word Records.

(MI)Unknown LTE PHY PUCCH Tx Report version: 121 {'timestamp': datetime.datetime(2019, 7, 25, 11, 14, 46, 731432), 'type_id': 'LTE_PHY_PUCCH_Tx_Report', 'Version': 121, 'log_msg_len': 56} Traceback (most recent call last): File "build/bdist.linux-aarch64/egg/mobile_insight/monitor/offline_replayer.py", line 205, in run self.send(event) File "build/bdist.linux-aarch64/egg/mobile_insight/element.py", line 108, in send map(G, self.to_list) File "build/bdist.linux-aarch64/egg/mobile_insight/element.py", line 107, in G def G(module): return module.recv(self, event) File "build/bdist.linux-aarch64/egg/mobile_insight/analyzer/analyzer.py", line 231, in recv map(G, self.source_callback) File "build/bdist.linux-aarch64/egg/mobile_insight/analyzer/analyzer.py", line 227, in G def G(f): return f(event) File "build/bdist.linux-aarch64/egg/mobile_insight/analyzer/lte_phy_analyzer.py", line 366, in __msg_callback self.callback_pucch(msg) File "build/bdist.linux-aarch64/egg/mobile_insight/analyzer/lte_phy_analyzer.py", line 122, in callback_pucch records = log_item['Records'] KeyError: 'Records'

Kpodov commented 5 years ago

Hello,

I faced the same issue as well. Here's what I did to pass around it:

  1. I uninstalled the current version of MobileInsight (sudo ./uninstall.sh)
  2. Then I modified this file: mobileinsight-core/mobile_insight/analyzer/lte_phy_analyzer.py

    • Look for these 2 functions: callback_pucchand callback_pusch_tx
    • Put the content of the functions in a try/except block like so:
 def callback_pusch_tx(self, msg):
    """
    Dump PUSCH power measurement information
    :param msg: raw LTE_PHY_PUSCH_Tx_Report packet
    :return:
    """

    try:  
        log_item = msg.data.decode()
        timestamp = str(log_item['timestamp'])

        # print log_item
        records = log_item['Records']

        # TODO: Extract PUSCH tx power information and add broadcast to it

        for record in records:
        #     print record
            pusch_tx_power = record['PUSCH Tx Power (dBm)']
            bcast_dict = {}
            bcast_dict['tx power'] = pusch_tx_power
            bcast_dict['timestamp'] = timestamp
            self.broadcast_info("PUSCH_TX_POWER", bcast_dict)
            self.log_info("PUSCH_TX_POWER: " + str(bcast_dict))

    except:
            print('callback_pusch_tx() failed here')

def callback_pucch(self, msg):
    """
    Dump PUCCH scheduling request information
    :param msg: raw LTE_PHY_PUCCH_Tx_Report packet
    :return:
    """
    try:
        log_item = msg.data.decode()
        records = log_item['Records']
        timestamp = str(log_item['timestamp'])

        for record in records:
            pucch_tx_power = record['PUCCH Tx Power (dBm)']
            bcast_dict = {}
            bcast_dict['tx power'] = pucch_tx_power
            bcast_dict['timestamp'] = timestamp
            self.broadcast_info("PUCCH_TX_POWER", bcast_dict)
            self.log_info("PUCCH_TX_POWER: " + str(bcast_dict))
            uciformat = record['Format']
            if uciformat == 'Format 1':
                self.init_flag = True
                self.rb_slot1 = record['Start RB Slot 0']
                self.rb_slot2 = record['Start RB Slot 1']
                self.sr_sfn = record['Current SFN SF'] % 10  # subframenumber
                sr_dict = {}
                sr_dict['timestamp'] = timestamp
                sr_dict['fn and subfn'] = record['Current SFN SF']
                self.broadcast_info("SR_EVENT", sr_dict)
                self.log_info("SR_EVENT: " + str(sr_dict))
            elif uciformat == 'Format 1B' or uciformat == 'Format 1A':
                # TODO: reset init_flag for new logs
                if self.init_flag:
                    if int(record['Start RB Slot 1']) == self.rb_slot2 and int(record['Start RB Slot 0']) == self.rb_slot1 \
                            and record['Current SFN SF'] % 10 == self.sr_sfn:
                        sr_dict = {}
                        sr_dict['timestamp'] = timestamp
                        sr_dict['fn and subfn'] = record['Current SFN SF']
                        self.broadcast_info("SR_EVENT", sr_dict)
                        self.log_info("SR_EVENT: " + str(sr_dict))
            elif uciformat == "Format 3":
                # TODO: Deal with SR event in format 3
                pass

    except:
        pass
  1. Finally, reinstall Mobile Insight.

Hope this helps...