|
@@ -1257,6 +1257,71 @@ class Statistics:
|
|
|
else:
|
|
|
print("Error plot protocol: No protocol values found!")
|
|
|
|
|
|
+ def plot_avgtime_between_comm_interval(file_ending: str):
|
|
|
+ """
|
|
|
+ Plots the exchanged packets per connection as horizontal bar plot.
|
|
|
+ Included are 'half-open' connections, where only one packet is exchanged.
|
|
|
+ Note: there may be cutoff problems within the plot if there is to little data.
|
|
|
+
|
|
|
+ :param file_ending: The file extension for the output file containing the plot
|
|
|
+ :return: A filepath to the file containing the created plot
|
|
|
+ """
|
|
|
+ plt.gcf().clear()
|
|
|
+ result = self.stats_db._process_user_defined_query(
|
|
|
+ "SELECT ipAddressA, portA, ipAddressB, portB, avgTimeBetweenIntervals FROM comm_interval_statistics")
|
|
|
+
|
|
|
+ if (result):
|
|
|
+ graphy, graphx = [], []
|
|
|
+
|
|
|
+ result = sorted(result, key=lambda row: row[4])
|
|
|
+
|
|
|
+
|
|
|
+ for i, row in enumerate(result):
|
|
|
+ addr1, addr2 = "%s:%d" % (row[0], row[1]), "%s:%d" % (row[2], row[3])
|
|
|
+
|
|
|
+ len_max = max(len(addr1), len(addr2))
|
|
|
+ addr1 = addr1.ljust(len_max)
|
|
|
+ addr2 = addr2.ljust(len_max)
|
|
|
+
|
|
|
+ graphy.append("%s\n%s" % (addr1, addr2))
|
|
|
+ graphx.append(row[4])
|
|
|
+
|
|
|
+
|
|
|
+ dist_mult_height, dist_mult_width = 0.55, 0.07
|
|
|
+ plt_height, plt_width = len(graphy) * dist_mult_height, max(graphx) * dist_mult_width
|
|
|
+ title_distance = 1 + 0.012*52.8/plt_height
|
|
|
+
|
|
|
+
|
|
|
+ fig, ax = plt.subplots()
|
|
|
+ ax.xaxis.tick_top()
|
|
|
+ ax.xaxis.set_label_position("top")
|
|
|
+
|
|
|
+
|
|
|
+ plt.title("Average time between communication intervals in seconds", y=title_distance)
|
|
|
+ plt.xlabel('Average time between intervals')
|
|
|
+ plt.ylabel('Connection')
|
|
|
+ width = 0.5
|
|
|
+ plt.grid(True)
|
|
|
+ plt.gca().margins(y=0)
|
|
|
+ plt.gcf().set_size_inches(plt_width, plt_height)
|
|
|
+
|
|
|
+
|
|
|
+ plt.barh(range(len(graphy)), graphx, width, align='center', linewidth=1, color='red', edgecolor='red')
|
|
|
+
|
|
|
+ plt.yticks(range(len(graphy)), graphy)
|
|
|
+
|
|
|
+ try:
|
|
|
+ plt.tight_layout(pad=4)
|
|
|
+ except ValueError:
|
|
|
+ pass
|
|
|
+
|
|
|
+
|
|
|
+ out = self.pcap_filepath.replace('.pcap', '_plot-Avg Time Between Communication Intervals Distribution' + file_ending)
|
|
|
+ plt.savefig(out, dpi=500)
|
|
|
+ return out
|
|
|
+ else:
|
|
|
+ print("Error plot protocol: No protocol values found!")
|
|
|
+
|
|
|
|
|
|
ttl_out_path = plot_ttl('.' + format)
|
|
|
mss_out_path = plot_mss('.' + format)
|
|
@@ -1277,6 +1342,7 @@ class Statistics:
|
|
|
plot_out_degree = plot_out_degree('.' + format)
|
|
|
plot_in_degree = plot_in_degree('.' + format)
|
|
|
plot_avgpkts_per_comm_interval_out = plot_avgpkts_per_comm_interval('.' + format)
|
|
|
+ plot_avgtime_between_comm_interval_out = plot_avgtime_between_comm_interval('.' + format)
|
|
|
|
|
|
|
|
|
|