diff --git a/ex3/figures/FFT_packets_uIPs.png b/ex3/figures/FFT_packets_uIPs.png new file mode 100644 index 0000000..5e083f1 Binary files /dev/null and b/ex3/figures/FFT_packets_uIPs.png differ diff --git a/ex3/figures/tcp_packets_uIPs_timeseries.png b/ex3/figures/tcp_packets_uIPs_timeseries.png new file mode 100644 index 0000000..0a1de7d Binary files /dev/null and b/ex3/figures/tcp_packets_uIPs_timeseries.png differ diff --git a/ex3/rep-20.py b/ex3/rep-20.py index 70be47e..a9a62f1 100644 --- a/ex3/rep-20.py +++ b/ex3/rep-20.py @@ -4,6 +4,9 @@ import numpy as np import matplotlib.pyplot as plt import math as m 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() #return number of elements in p6_pkts list 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)] #set amp. values in the y-axis and specify the limit 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) #find max index and value 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 x = k[1:m.floor(n_2/2)] #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) #find max index and value 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 #set y-axis label 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 - 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) + +# 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()