From 1eefe1581d95aa34490bc245e25268d0670657ad Mon Sep 17 00:00:00 2001 From: Michael Vrable Date: Wed, 9 Mar 2011 22:15:41 -0800 Subject: [PATCH] Track inter-request delay in TCP analysis When analyzing TCP connections, track the time the connection goes idle (between the end of one request and start of the next). --- parsetrace/analyze-tcp.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/parsetrace/analyze-tcp.py b/parsetrace/analyze-tcp.py index d050d08..fb58b6a 100755 --- a/parsetrace/analyze-tcp.py +++ b/parsetrace/analyze-tcp.py @@ -91,7 +91,7 @@ def split_trace(packets, predicate, before=True): if len(segment) > 0: yield segment -def analyze_get(packets): +def analyze_get(packets, prev_time = None): packets = iter(packets) p = packets.next() @@ -152,10 +152,15 @@ def analyze_get(packets): tot_bytes = max(tot_bytes, bytenr) #print "Transferred %d bytes in %s seconds, initial response after %s" % (tot_bytes, last_ts - start_ts, resp_ts - start_ts) + if prev_time is not None: + prev_delay = start_ts - prev_time + else: + prev_delay = 0 return {'bytes': tot_bytes, 'start_latency': resp_ts - start_ts, 'finish_latency': last_ts - start_ts, - 'interpacket_times': spacings} + 'interpacket_times': spacings, + 'delay_from_previous': prev_delay} if __name__ == '__main__': for f in sys.argv[1:]: @@ -165,6 +170,7 @@ if __name__ == '__main__': def request_start(p): return p.direction > 0 and p.datalen > 0 result_list = [] + prev_time = None for s in split_trace(conn.packets, request_start): s = list(s) if False: @@ -177,9 +183,10 @@ if __name__ == '__main__': #print p #if p.direction > 0 and p.datalen > 0: #print "Request:", repr(p.data) - results = analyze_get(s) + results = analyze_get(s, prev_time) if results is not None: result_list.append(results) + prev_time = s[-1].ts #print "====" print dump_data(result_list) -- 2.20.1