X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=extract_from_tshark.py;h=5704a975bbf891678e75533a2d435b52a597969d;hb=38e85fbaaea37e40593772f1867aaae3eafb9bae;hp=a66b5562e1ed1b232677c03fcb0813906d2206c3;hpb=32b88ddd2697216d75d11b0e90f3b94c1caf6282;p=pingpong.git diff --git a/extract_from_tshark.py b/extract_from_tshark.py index a66b556..5704a97 100644 --- a/extract_from_tshark.py +++ b/extract_from_tshark.py @@ -36,6 +36,11 @@ json_key_frame_comment = json_key_frame + ".comment" json_key_frame_ts = json_key_frame + ".time_epoch" +JSON_KEY_ETH = "eth" +JSON_KEY_ETH_SRC = "eth.src" +JSON_KEY_ETH_DST = "eth.dst" + + def make_unique(key, dct): counter = 0 unique_key = key @@ -100,6 +105,13 @@ def change_file(fpath): new_packet["dst_ip"] = layers[json_key_ip][json_key_ip + ".dst"] new_packet["dst_port"] = int(layers[json_key_tcp][json_key_tcp + ".dstport"]) + # JV: Also include src so we can see what device initiates the traffic + new_packet["src_ip"] = layers[json_key_ip][json_key_ip + ".src"] + new_packet["src_port"] = int(layers[json_key_tcp][json_key_tcp + ".srcport"]) + #JV: Also include eth soure/destination info so that we can map traffic to physical device using MAC + new_packet[JSON_KEY_ETH_SRC] = layers[JSON_KEY_ETH][JSON_KEY_ETH_SRC] + new_packet[JSON_KEY_ETH_DST] = layers[JSON_KEY_ETH][JSON_KEY_ETH_DST] + # Go through all HTTP fields and extract the ones that are needed http_data = layers[json_key_http] for http_key in http_data: @@ -149,17 +161,6 @@ def change_file(fpath): new_packet["ts"] = layers[json_key_frame][json_key_frame_ts] - # Now extract and parse the packet comment - if (json_key_pkt_comment not in layers or - json_key_frame_comment not in layers[json_key_pkt_comment]): - print "WARNING: no packet comment found!" + frame_num - continue - - comment = layers[json_key_pkt_comment][json_key_frame_comment] - comment_data = json.loads(comment) - for key in comment_data: - new_packet[str(key)] = str(comment_data[key]) - # Create a unique key for each packet to keep consistent with ReCon # Also good in case packets end up in different files data[str(uuid.uuid4())] = new_packet