When analyzing TCP connections, track the time the connection goes idle
(between the end of one request and start of the next).
if len(segment) > 0:
yield segment
if len(segment) > 0:
yield segment
-def analyze_get(packets):
+def analyze_get(packets, prev_time = None):
packets = iter(packets)
p = packets.next()
packets = iter(packets)
p = packets.next()
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)
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,
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:]:
if __name__ == '__main__':
for f in sys.argv[1:]:
def request_start(p):
return p.direction > 0 and p.datalen > 0
result_list = []
def request_start(p):
return p.direction > 0 and p.datalen > 0
result_list = []
for s in split_trace(conn.packets, request_start):
s = list(s)
if False:
for s in split_trace(conn.packets, request_start):
s = list(s)
if False:
#print p
#if p.direction > 0 and p.datalen > 0:
#print "Request:", repr(p.data)
#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)
if results is not None:
result_list.append(results)
#print "===="
print dump_data(result_list)
#print "===="
print dump_data(result_list)