Add plots for rep-20
This commit is contained in:
parent
d0105475ea
commit
b32c5e60f6
BIN
ex3/figures/FFT_packets_uIPs.png
Normal file
BIN
ex3/figures/FFT_packets_uIPs.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 260 KiB |
BIN
ex3/figures/tcp_packets_uIPs_timeseries.png
Normal file
BIN
ex3/figures/tcp_packets_uIPs_timeseries.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 156 KiB |
@ -4,6 +4,9 @@ import numpy as np
|
|||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import math as m
|
import math as m
|
||||||
dataset = pd.read_csv('csv/team13_protocol.csv').fillna(0)
|
dataset = pd.read_csv('csv/team13_protocol.csv').fillna(0)
|
||||||
|
dataset['timestamp'] = pd.to_datetime(dataset['timestamp'], unit='s')
|
||||||
|
dataset = dataset.set_index('timestamp')
|
||||||
|
print(dataset)
|
||||||
p6_pkts = dataset['6 · # Packets'].tolist()
|
p6_pkts = dataset['6 · # Packets'].tolist()
|
||||||
#return number of elements in p6_pkts list
|
#return number of elements in p6_pkts list
|
||||||
n = len(p6_pkts)
|
n = len(p6_pkts)
|
||||||
@ -18,6 +21,9 @@ k = range(0,n-1) #creates an array from 0 to n-1
|
|||||||
x = k[1:m.floor(n/2)]
|
x = k[1:m.floor(n/2)]
|
||||||
#set amp. values in the y-axis and specify the limit
|
#set amp. values in the y-axis and specify the limit
|
||||||
y = pkt_amp[1:m.floor(n/2)]
|
y = pkt_amp[1:m.floor(n/2)]
|
||||||
|
plt.figure(figsize=(20,10))
|
||||||
|
plt.tight_layout(h_pad=0.5)
|
||||||
|
plt.subplot(2, 1, 1)
|
||||||
plt.stem(x, y)
|
plt.stem(x, y)
|
||||||
#find max index and value
|
#find max index and value
|
||||||
max_k = np.flip(np.argsort(pkt_amp[1:m.floor(n/2)]))[0]
|
max_k = np.flip(np.argsort(pkt_amp[1:m.floor(n/2)]))[0]
|
||||||
@ -45,7 +51,8 @@ k = range(0,n_2-1) #creates an array from 0 to n-1
|
|||||||
#set k values in the x-axis and specify the limit
|
#set k values in the x-axis and specify the limit
|
||||||
x = k[1:m.floor(n_2/2)]
|
x = k[1:m.floor(n_2/2)]
|
||||||
#set amp. values in the y-axis and specify the limit
|
#set amp. values in the y-axis and specify the limit
|
||||||
y = pkt_amp[1:m.floor(n/2)]
|
y = uIPs_amp[1:m.floor(n/2)]
|
||||||
|
plt.subplot(2, 1, 2)
|
||||||
plt.stem(x, y)
|
plt.stem(x, y)
|
||||||
#find max index and value
|
#find max index and value
|
||||||
max_k = np.flip(np.argsort(uIPs_amp[1:m.floor(n_2/2)]))[0]
|
max_k = np.flip(np.argsort(uIPs_amp[1:m.floor(n_2/2)]))[0]
|
||||||
@ -54,8 +61,19 @@ plt.xlim(1, m.floor(n_2/2))
|
|||||||
plt.xlabel('k') #sets x-axis label
|
plt.xlabel('k') #sets x-axis label
|
||||||
#set y-axis label
|
#set y-axis label
|
||||||
plt.ylabel('Amplitude [millions of unique source IPs]')
|
plt.ylabel('Amplitude [millions of unique source IPs]')
|
||||||
plt.title('Amp. Spectrum for unique source IPs') #displays title
|
plt.title('Amp. Spectrum for #unique source IPs') #displays title
|
||||||
|
plt.show()
|
||||||
|
|
||||||
print('TCP #uIPs/hour - FFT max value: ', round(max_amp / 1000000, 2))
|
print('TCP #uIPs/hour - FFT max value: ', round(max_amp / 1000000, 2))
|
||||||
print('TCP #uIPs/hour - k of FFT max value: ', np.where(uIPs_amp == max_amp))
|
print('TCP #uIPs/hour - k of FFT max value: ', np.where(uIPs_amp == max_amp))
|
||||||
print('TCP #uIPs/hour - period of k corresponding to FFT max value: ', n_2 / 31)
|
print('TCP #uIPs/hour - period of k corresponding to FFT max value: ', n_2 / 31)
|
||||||
|
|
||||||
|
# Plot TCP #pkts/hour and TCP #uIPs/hour timeseries
|
||||||
|
plt.figure(figsize=(20,10))
|
||||||
|
plt.tight_layout(h_pad=2)
|
||||||
|
plt.subplot(2, 1, 1)
|
||||||
|
dataset['6 · # Packets'].plot(xlabel='', ylabel='Number of TCP Packets', title='Number of TCP Packets over Time')
|
||||||
|
|
||||||
|
plt.subplot(2, 1, 2)
|
||||||
|
dataset['6 · # Unique Source IPs'].plot(xlabel='Time', ylabel='Number of Unique TCP Source IPs', title='Number of Unique TCP Source IPs over Time')
|
||||||
|
plt.show()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user