Commit 6c434118 authored by gauthier's avatar gauthier
Browse files

handle not existing msc log file

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7194 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 53585b0a
...@@ -9,8 +9,8 @@ import subprocess ...@@ -9,8 +9,8 @@ import subprocess
import re import re
import socket import socket
import datetime import datetime
import os.path
from datetime import date from datetime import date
import os, errno
MSCGEN_OUTPUT_TYPE = "png" MSCGEN_OUTPUT_TYPE = "png"
MAX_MESSAGES_PER_PAGE = 36 MAX_MESSAGES_PER_PAGE = 36
...@@ -69,6 +69,8 @@ def parse_oai_log_files(): ...@@ -69,6 +69,8 @@ def parse_oai_log_files():
global g_final_display_order_list global g_final_display_order_list
#open TXT file that contain OAI filtered traces for mscgen #open TXT file that contain OAI filtered traces for mscgen
filenames = [ filenames = [
'/tmp/openair.msc.ip_ue.log',
'/tmp/openair.msc.ip_enb.log',
'/tmp/openair.msc.nas_ue.log', '/tmp/openair.msc.nas_ue.log',
'/tmp/openair.msc.pdcp_ue.log', '/tmp/openair.msc.pdcp_ue.log',
'/tmp/openair.msc.rrc_ue.log', '/tmp/openair.msc.rrc_ue.log',
...@@ -87,82 +89,87 @@ def parse_oai_log_files(): ...@@ -87,82 +89,87 @@ def parse_oai_log_files():
'/tmp/openair.msc.s1ap_mme.log'] '/tmp/openair.msc.s1ap_mme.log']
for filename in filenames: for filename in filenames:
fhandle = open(filename, 'r') try:
fcontent = fhandle.read() fhandle = open(filename, 'r')
fhandle.close() fcontent = fhandle.read()
fhandle.close()
# split file content in lines
lines = fcontent.splitlines() # split file content in lines
for line in lines: lines = fcontent.splitlines()
if line.strip() != "": for line in lines:
print ("INPUT LINE: %s " % line) if line.strip() != "":
partition = line.split(' ',3) print ("INPUT LINE: %s " % line)
event_id = int(partition[0]) partition = line.split(' ',3)
event_type = partition[1] event_id = int(partition[0])
entity_id = int(partition[2]) event_type = partition[1]
if MSC_NEW_STR == event_type: entity_id = int(partition[2])
entity_name = partition[3] if MSC_NEW_STR == event_type:
if len(g_proto_names) <= entity_id: entity_name = partition[3]
for i in range(len(g_proto_names),(entity_id +1)): if len(g_proto_names) <= entity_id:
g_proto_names.append("NotDeclared") for i in range(len(g_proto_names),(entity_id +1)):
g_proto_names[entity_id] = entity_name g_proto_names.append("NotDeclared")
g_proto_names[entity_id] = entity_name
# if line is a trace of a message between 2 protocol entities or layers
elif MSC_MSG_STR == event_type: # if line is a trace of a message between 2 protocol entities or layers
print ("partition[3]:%s" % partition[3]) elif MSC_MSG_STR == event_type:
sub_partition = partition[3].split(' ',4) print ("partition[3]:%s" % partition[3])
arrow = sub_partition[0] sub_partition = partition[3].split(' ',4)
entity2_id = int(sub_partition[1]) arrow = sub_partition[0]
mac = int(sub_partition[2]) entity2_id = int(sub_partition[1])
time = sub_partition[3] mac = int(sub_partition[2])
message = sub_partition[4] time = sub_partition[3]
Message = {} message = sub_partition[4]
Message['mac'] = mac Message = {}
Message['time'] = time Message['mac'] = mac
Message['message'] = message Message['time'] = time
Message['line_color'] = g_display_color[entity_id] Message['message'] = message
Message['text_color'] = g_display_color[entity_id] Message['line_color'] = g_display_color[entity_id]
if arrow == '<-': Message['text_color'] = g_display_color[entity_id]
Message['type'] = "rx" if arrow == '<-':
Message['tx'] = entity2_id Message['type'] = "rx"
Message['rx'] = entity_id Message['tx'] = entity2_id
Message['discarded'] = False Message['rx'] = entity_id
g_messages[event_id] = Message Message['discarded'] = False
elif arrow == '->': g_messages[event_id] = Message
Message['type'] = "tx" elif arrow == '->':
Message['tx'] = entity_id Message['type'] = "tx"
Message['rx'] = entity2_id Message['tx'] = entity_id
Message['discarded'] = False Message['rx'] = entity2_id
g_messages[event_id] = Message Message['discarded'] = False
elif arrow == 'x-': g_messages[event_id] = Message
Message['type'] = "rx" elif arrow == 'x-':
Message['tx'] = entity2_id Message['type'] = "rx"
Message['rx'] = entity_id Message['tx'] = entity2_id
Message['discarded'] = True Message['rx'] = entity_id
g_messages[event_id] = Message Message['discarded'] = True
elif arrow == '-x': g_messages[event_id] = Message
Message['type'] = "tx" elif arrow == '-x':
Message['tx'] = entity_id Message['type'] = "tx"
Message['rx'] = entity2_id Message['tx'] = entity_id
Message['discarded'] = True Message['rx'] = entity2_id
g_messages[event_id] = Message Message['discarded'] = True
g_messages[event_id] = Message
elif MSC_BOX_STR == event_type:
sub_partition = partition[3].split(' ',1) elif MSC_BOX_STR == event_type:
time = sub_partition[0] sub_partition = partition[3].split(' ',1)
message = sub_partition[1] time = sub_partition[0]
Message = {} message = sub_partition[1]
Message['type'] = "box" Message = {}
Message['tx'] = entity_id Message['type'] = "box"
Message['rx'] = entity_id Message['tx'] = entity_id
Message['discarded'] = False Message['rx'] = entity_id
Message['time'] = time Message['discarded'] = False
Message['message'] = message Message['time'] = time
Message['line_color'] = g_display_color[entity_id] Message['message'] = message
Message['text_color'] = g_display_color[entity_id] Message['line_color'] = g_display_color[entity_id]
g_messages[event_id] = Message Message['text_color'] = g_display_color[entity_id]
g_messages[event_id] = Message
except IOError, e:
print 'errno:', ioex.errno
print 'err code:', errno.errorcode[ioex.errno]
print 'err message:', os.strerror(ioex.errno)
#print("------------------------------------") #print("------------------------------------")
#print (" %s " % ( g_messages ) ) #print (" %s " % ( g_messages ) )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment