From c2d5c387f89687eea72adc0de26917eff6ac11e1 Mon Sep 17 00:00:00 2001 From: Adriana Draghici Date: Fri, 4 Dec 2009 13:11:23 +0000 Subject: [PATCH] Tribler - LogParser - changes for BT_INTERESTED messages. --- log-parser/tribler/LogParser.py | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/log-parser/tribler/LogParser.py b/log-parser/tribler/LogParser.py index 1344e0b..6347846 100644 --- a/log-parser/tribler/LogParser.py +++ b/log-parser/tribler/LogParser.py @@ -15,7 +15,7 @@ import re # the names used by Tribler for the BitTorrent messages msg_types = {"BT_REQUEST_SEND": "new_request", "BT_REQUEST_RECV": "REQUEST(", "BT_CHOKE": "CHOKE from", "BT_UNCHOKE": "UNCHOKE from", "BT_HAVE": "HAVE(", "BT_PIECE": "PIECE(", "BT_BITFIELD": "BITFIELD from", - "BT_CANCEL": "sent cancel"} + "BT_CANCEL": "sent cancel", "BT_INTERESTED": "INTERESTED from"} msg_db_code = {"BT_CHOKE" : 0, "BT_UNCHOKE": 1, "BT_INTERESTED": 2, "BT_NOT_INTERESTED": 3, "BT_HAVE" : 4, "BT_BITFIELD": 5, "BT_REQUEST" : 6, "BT_PIECE": 7, "BT_CANCEL": 8} @@ -83,6 +83,33 @@ def tribler_parse_choke_msg(line): if is_unchoke != -1: return (timestamp, direction, peer_ip, None, msg_db_code["BT_UNCHOKE"], None, None, None, 0) +""" + Parse a line that contains interested messages. + line format: date timestamp connecter: Got INTERESTED from ip +""" + +def tribler_parse_interested_msg(line): + + if line.find(msg_types["BT_INTERESTED"]) == -1: + return None + + line_parts = re.split(" *", line) + timestamp = tribler_parse_timestamp(line_parts[0], line_parts[1]) + + if timestamp == None: + print "Error: invalid date & time format for Connecter." + return None + + nr_parts = len(line_parts) + if nr_parts < 7 : + print "Error: invalid line format for Connecter.", line + return None + + peer_ip = line_parts[nr_parts-1]; + direction = log_msg_dir["RECEIVE"]; + return (timestamp, direction, peer_ip, None, msg_db_code["BT_INTERESTED"], None, None, None, 0) + + """ sample line: 14-11-2009 23:11:13 connecter: Got HAVE( 14 ) from 141.85.37.41 BitTorrent message format: have @@ -104,7 +131,7 @@ def tribler_parse_have_msg(line): return None nr_parts = len(line_parts) - if nr_parts < 8 : + if nr_parts < 9 : print "Error: invalid line format for Connecter.", line return None @@ -205,7 +232,7 @@ def tribler_parse_piece_msg(line): return None nr_parts = len(line_parts) - if nr_parts < 8 : + if nr_parts < 9 : print "Error: invalid line format for Connecter.", line return None -- 2.20.1