summaryrefslogtreecommitdiffstats
path: root/prog/icmpft/fft.py
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2023-12-09 15:03:53 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2023-12-09 15:03:53 +0100
commitf29ba4fc0a9525ffd38d712d751aa22c0714377e (patch)
treefeee18d851ce3f028aa543f8d1cb746ce6c796b3 /prog/icmpft/fft.py
parentaoc9 (diff)
parentMerge branch 'master' of ssh://ni/var/lib/git/sijanec/r (diff)
downloadr-f29ba4fc0a9525ffd38d712d751aa22c0714377e.tar
r-f29ba4fc0a9525ffd38d712d751aa22c0714377e.tar.gz
r-f29ba4fc0a9525ffd38d712d751aa22c0714377e.tar.bz2
r-f29ba4fc0a9525ffd38d712d751aa22c0714377e.tar.lz
r-f29ba4fc0a9525ffd38d712d751aa22c0714377e.tar.xz
r-f29ba4fc0a9525ffd38d712d751aa22c0714377e.tar.zst
r-f29ba4fc0a9525ffd38d712d751aa22c0714377e.zip
Diffstat (limited to 'prog/icmpft/fft.py')
-rwxr-xr-xprog/icmpft/fft.py23
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()