diff options
Diffstat (limited to 'prog/icmpft/fft.py')
-rwxr-xr-x | prog/icmpft/fft.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/prog/icmpft/fft.py b/prog/icmpft/fft.py new file mode 100755 index 0000000..d39244a --- /dev/null +++ b/prog/icmpft/fft.py @@ -0,0 +1,23 @@ +#!/usr/bin/python3 +from sys import stdin +from struct import unpack +profile = stdin.buffer.read() +hosts = {} +for resp in [profile[i:i+32] for i in range(0, len(profile), 32)]: + ssec, snsec, rsec, rusec = unpack("!LLLL", resp[0:16]) + ipaddr = resp[16:32] + if ipaddr not in hosts: + hosts[ipaddr] = {} + stime = ssec*1000000000+snsec + rtime = rsec*1000000000+rusec + hosts[ipaddr][stime] = rtime-stime +from numpy.fft import rfft +import numpy as np +import matplotlib +matplotlib.use("GTK3Cairo") +from matplotlib import pyplot as plt +for host in hosts: + N = 10 + fft = np.convolve(np.absolute(rfft(list(hosts[host].values()))), np.ones(N)/N, mode='valid') + plt.plot(list(range(len(fft))), fft) + plt.show() |