Skip to content

Instantly share code, notes, and snippets.

@david-lshift
Created December 2, 2015 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save david-lshift/8e813c43e96a0e7062d9 to your computer and use it in GitHub Desktop.
Save david-lshift/8e813c43e96a0e7062d9 to your computer and use it in GitHub Desktop.
Calculate prefetch deficit from Wireshark text export
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))
@david-lshift
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment