def ReadRawFile(filename): # Initialize a 3G/4G monitor src = OfflineReplayer() #src.set_input_path("./diag_log_20190701_032740_93cda9833356d6bc90e05d0f85b3efee_Google-PixelXL_311480.mi2log") src.set_input_path("./" + filename + ".mi2log") logger = MsgLogger() logger.set_decode_format(MsgLogger.XML) logger.set_dump_type(MsgLogger.FILE_ONLY) #logger.save_decoded_msg_as("./test.txt") logger.save_decoded_msg_as("./" + filename + ".txt") logger.set_source(src) # Analyzers lte_pdcp_analyzer = LtePdcpAnalyzer() lte_pdcp_analyzer.set_source(src) lte_rrc_analyzer = LteRrcAnalyzer() lte_rrc_analyzer.set_source(src) # bind with the monitor wcdma_rrc_analyzer = WcdmaRrcAnalyzer() wcdma_rrc_analyzer.set_source(src) # bind with the monitor lte_nas_analyzer = LteNasAnalyzer() lte_nas_analyzer.set_source(src) umts_nas_analyzer = UmtsNasAnalyzer() umts_nas_analyzer.set_source(src) lte_phy_analyzer = LtePhyAnalyzer() lte_phy_analyzer.set_source(src) lte_mac_analyzer = LteMacAnalyzer() lte_mac_analyzer.set_source(src) mm_analyzer = MmAnalyzer() mm_analyzer.set_source(src) lte_measurement_analyzer = LteMeasurementAnalyzer() lte_measurement_analyzer.set_source(src) lte_rlc_analyzer = LteRlcAnalyzer() lte_rlc_analyzer.set_source(src) #modem_Debug_Analyzer = ModemDebugAnalyzer() #modem_Debug_Analyzer.set_source(src) mobility_mngt = MobilityMngt() mobility_mngt.set_source(src) rrc_analyzer = RrcAnalyzer() rrc_analyzer.set_source(src) # Start the monitoring src.run()
def generate_from_mi2log(filepath, output_filepath=None): src = OfflineReplayer() src.set_input_path(filepath) filename = get_filename_from_path(filepath) logger = MsgLogger() logger.set_decode_format(MsgLogger.XML) logger.set_dump_type(MsgLogger.FILE_ONLY) if (output_filepath is not None): op_fp = output_filepath else: op_fp = "./mi2log_xml/" + filename + "_" + datetime.now().strftime( "%H_%M_%S") + '.xml' logger.save_decoded_msg_as(op_fp) logger.set_source(src) # Analyzers lte_rrc_analyzer = LteRrcAnalyzer() lte_rrc_analyzer.set_source(src) # bind with the monitor # wcdma_rrc_analyzer = WcdmaRrcAnalyzer() # wcdma_rrc_analyzer.set_source(src) # bind with the monitor lte_nas_analyzer = LteNasAnalyzer() lte_nas_analyzer.set_source(src) # umts_nas_analyzer = UmtsNasAnalyzer() # umts_nas_analyzer.set_source(src) # lte_phy_analyzer = LtePhyAnalyzer() # lte_phy_analyzer.set_source(src) # lte_mac_analyzer = LteMacAnalyzer() # lte_mac_analyzer.set_source(src) # Start the monitoring src.run() clean_mi2log_xml(op_fp)
def dump_logs(path): logger = MsgLogger() logger.set_decode_format(MsgLogger.XML) logger.set_dump_type(MsgLogger.FILE_ONLY) logger.save_decoded_msg_as(path) logger.set_source(src) lte_rrc_analyzer = LteRrcAnalyzer() lte_rrc_analyzer.set_source(src) wcdma_rrc_analyzer = WcdmaRrcAnalyzer() wcdma_rrc_analyzer.set_source(src) lte_nas_analyzer = LteNasAnalyzer() lte_nas_analyzer.set_source(src) umts_nas_analyzer = UmtsNasAnalyzer() umts_nas_analyzer.set_source(src) lte_phy_analyzer = LtePhyAnalyzer() lte_phy_analyzer.set_source(src) src.run()
LOGMSG = False logmsg_filename = str(os.path.basename(log_file_location).split(".")[0]) + "_log.xml" MSGLOGGER = False if __name__ == "__main__": # Initialize a 3G/4G monitor src = OfflineReplayer() src.set_input_path(log_file_location) #src.enable_log_all() if (MSGLOGGER): logger = MsgLogger() logger.set_decode_format(MsgLogger.XML) logger.set_dump_type(MsgLogger.FILE_ONLY) logger.save_decoded_msg_as(log_folder+"/"+logmsg_filename) logger.set_source(src) # Analyzers lte_rrc_analyzer = LteRrcAnalyzer() lte_rrc_analyzer.set_source(src) # bind with the monitor wcdma_rrc_analyzer = WcdmaRrcAnalyzer() wcdma_rrc_analyzer.set_source(src) # bind with the monitor lte_nas_analyzer = LteNasAnalyzer() lte_nas_analyzer.set_source(src) umts_nas_analyzer = UmtsNasAnalyzer() umts_nas_analyzer.set_source(src) # PDCP
""" # Import MobileInsight modules from mobile_insight.monitor import OfflineReplayer from mobile_insight.analyzer import MsgLogger, LteRrcAnalyzer, WcdmaRrcAnalyzer, LteNasAnalyzer, UmtsNasAnalyzer, LtePhyAnalyzer, LteMacAnalyzer if __name__ == "__main__": # Initialize a 3G/4G monitor src = OfflineReplayer() src.set_input_path("./offline_log_example.mi2log") logger = MsgLogger() logger.set_decode_format(MsgLogger.XML) logger.set_dump_type(MsgLogger.FILE_ONLY) logger.save_decoded_msg_as("./test.txt") logger.set_source(src) # Analyzers lte_rrc_analyzer = LteRrcAnalyzer() lte_rrc_analyzer.set_source(src) # bind with the monitor wcdma_rrc_analyzer = WcdmaRrcAnalyzer() wcdma_rrc_analyzer.set_source(src) # bind with the monitor lte_nas_analyzer = LteNasAnalyzer() lte_nas_analyzer.set_source(src) umts_nas_analyzer = UmtsNasAnalyzer() umts_nas_analyzer.set_source(src)
# src.enable_log("LTE_RRC_MIB_Packet") # src.enable_log("LTE_NAS_EMM_State") # src.enable_log("LTE_NAS_ESM_OTA_Incoming_Packet") # src.enable_log("LTE_NAS_ESM_OTA_Outgoing_Packet") # src.enable_log("LTE_NAS_ESM_State") # src.enable_log("LTE_NAS_EMM_OTA_Outgoing_Packet") # src.enable_log("LTE_NAS_EMM_OTA_Incoming_Packet") # src.enable_log("UMTS_NAS_GMM_State") # src.enable_log("UMTS_NAS_MM_REG_State") # src.enable_log("UMTS_NAS_OTA_Packet") # src.enable_log("UMTS_NAS_MM_State") # src.enable_log("WCDMA_RRC_OTA_Packet") # src.enable_log("WCDMA_RRC_Serv_Cell_Info") # This enables all supported logs src.enable_log_all() # Save the monitoring results as an offline log src.save_log_as("./test-all.mi2log") #Dump the messages to std I/O. Comment it if it is not needed. dumper = MsgLogger() dumper.set_source(src) #save the messages (decoded) in a file. Formats are XML, JSON or plain text. Comment if not needed dumper.set_decoding(MsgLogger.XML) dumper.set_dump_type(5) dumper.save_decoded_msg_as("./test-rrc-nas-decoded.xml") #Start the monitoring src.run()
# Initialize the 3G/4G monitor for offline analysis. It "replays" the log previously captured path_to_mi2log = './' mi_files = [pos_mi for pos_mi in os.listdir(path_to_mi2log) if pos_mi.endswith('.mi2log')] for index,mi_file in enumerate(mi_files): src = OfflineReplayer() src.set_input_path(mi_file) # Save the decoded messages extracted from the log logger = MsgLogger() logger.set_decode_format(MsgLogger.XML) logger.set_dump_type(MsgLogger.FILE_ONLY) logger.save_decoded_msg_as("./%s.xml" %mi_file) logger.set_source(src) #Analyzers. Use them according to technology in your logs # RRC analyzer for both LTE and UMTS src.enable_log_all() # lte_rrc_analyzer.set_source(src) #bind with the monitor # lte_nas_analyzer = LteNasAnalyzer() # lte_nas_analyzer.set_source(src) # umts_nas_analyzer = UmtsNasAnalyzer() # umts_nas_analyzer.set_source(src) # wcdma_rrc_analyzer = WcdmaRrcAnalyzer() # wcdma_rrc_analyzer.set_source(src) #bind with the monitor