Created
December 2, 2015 10:31
-
-
Save david-lshift/8e813c43e96a0e7062d9 to your computer and use it in GitHub Desktop.
Calculate prefetch deficit from Wireshark text export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
for arg in sys.argv[1:]: | |
acktimes = [] | |
prefetch = 0 | |
for line in open(arg).readlines(): | |
tokens = line.split() | |
n, time, src, dest, protocol, length = tokens[0:6] | |
summary = ' '.join(tokens[6:]) | |
acks = summary.count('Basic.Ack') | |
if acks: | |
acktimes.extend([float(time)] * acks) | |
prefetch = prefetch - acks | |
deliveries = summary.count('Basic.Deliver') | |
if deliveries: | |
prefetch = prefetch + deliveries | |
acktimes = acktimes[deliveries:] | |
if deliveries or acks: | |
time = float(time) | |
if len(acktimes): | |
latency = time - min(acktimes) | |
else: | |
latency = 0 | |
print "{}\t{}\t{}\t{}\t{}".format(n, time, latency, prefetch, len(acktimes)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This should really write two separate files - one for the deficit and one for the latency. Also, I need to include TCP acks, one for each direction, so you can see when the recipient is blocking.