summaryrefslogtreecommitdiffstats
path: root/prog/icmpft/fft.py
blob: d39244a8d4c76d211c8f081428be29acf22aad32 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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()