Jelajahi Sumber

Merge branch 'develop' of https://git.tk.informatik.tu-darmstadt.de/leon.boeck/ID2T-toolkit-BotnetTraffic into develop

Denis Waßmann 6 tahun lalu
induk
melakukan
81b0e20c85
1 mengubah file dengan 17 tambahan dan 17 penghapusan
  1. 17 17
      code/ID2TLib/Statistics.py

+ 17 - 17
code/ID2TLib/Statistics.py

@@ -1060,7 +1060,7 @@ class Statistics:
             graphy = list(range(len(graphx)))
             plt.barh(graphy, graphx, width, align='center', linewidth=1, color='red', edgecolor='red')
             plt.yticks(graphy, labels)
-            out = self.pcap_filepath.replace('.pcap', '_in_degree' + file_ending)
+            out = self.pcap_filepath.replace('.pcap', '_plot-In Degree of an IP' + file_ending)
             plt.tight_layout()
             plt.savefig(out,dpi=500)
 
@@ -1113,7 +1113,7 @@ class Statistics:
             graphy = list(range(len(graphx)))
             plt.barh(graphy, graphx, width, align='center', linewidth=1, color='red', edgecolor='red')
             plt.yticks(graphy, labels)
-            out = self.pcap_filepath.replace('.pcap', '_out_degree' + file_ending)
+            out = self.pcap_filepath.replace('.pcap', '_plot-Out Degree of an IP' + file_ending)
             plt.tight_layout()
             plt.savefig(out,dpi=500)
 
@@ -1166,7 +1166,7 @@ class Statistics:
             graphy = list(range(len(graphx)))
             plt.barh(graphy, graphx, width, align='center', linewidth=1, color='red', edgecolor='red')
             plt.yticks(graphy, labels)
-            out = self.pcap_filepath.replace('.pcap', '_overall_degree' + file_ending)
+            out = self.pcap_filepath.replace('.pcap', '_plot-Overall Degree of an IP' + file_ending)
             plt.tight_layout()
             plt.savefig(out,dpi=500)
             return out
@@ -1363,7 +1363,7 @@ class Statistics:
 
             # set additional plot parameters
             plt.title(title)
-            plt.ylabel("Number of connections")
+            plt.ylabel("Relative frequency of connections")
             plt.xlabel(label)
             width = 0.5
             plt.grid(True)
@@ -1374,11 +1374,11 @@ class Statistics:
             for i in range(0, 11):
                 bins.append(i * max_val/10)
 
-            # comment out and set weights to normalize
-            # weights = numpy.ones_like(result)/float(len(result))
+            # set weights normalize histogram
+            weights = numpy.ones_like(result)/float(len(result))
 
             # plot the above data, first use plain numbers as graphy to maintain sorting
-            plt.hist(result, bins=bins, color='red', edgecolor='red', align="mid", rwidth=0.5)
+            plt.hist(result, bins=bins, weights=weights, color='red', edgecolor='red', align="mid", rwidth=0.5)
             plt.xticks(bins)
 
             # save created figure
@@ -1409,7 +1409,7 @@ class Statistics:
 
             # set additional plot parameters
             plt.title(title)
-            plt.ylabel("Number of IPs")
+            plt.ylabel("Relative frequency of IPs")
             plt.xlabel(label)
             width = 0.5
             plt.grid(True)
@@ -1420,11 +1420,11 @@ class Statistics:
             for i in range(0, 11):
                 bins.append(int(i * max_val/10))
 
-            # comment out and set weights to normalize
-            # weights = numpy.ones_like(result)/float(len(result))
+            # set weights normalize histogram
+            weights = numpy.ones_like(result)/float(len(result))
 
             # plot the above data, first use plain numbers as graphy to maintain sorting
-            plt.hist(result, bins=bins, color='red', edgecolor='red', align="mid", rwidth=0.5)
+            plt.hist(result, bins=bins, weights=weights, color='red', edgecolor='red', align="mid", rwidth=0.5)
             plt.xticks(bins)
 
             # save created figure
@@ -1432,6 +1432,12 @@ class Statistics:
             plt.savefig(out, dpi=500)
             return out    
 
+        plot_hist_indegree_out = plot_histogram_degree("inDegree", "Histogram - Ingoing degree per IP Address", 
+            "Ingoing degree", "_plot-Histogram Ingoing Degree per IP" + format)
+        plot_hist_outdegree_out = plot_histogram_degree("outDegree", "Histogram - Outgoing degree per IP Address", 
+            "Outgoing degree", "_plot-Histogram Outgoing Degree per IP" + format)
+        plot_hist_overalldegree_out = plot_histogram_degree("overallDegree", "Histogram - Overall degree per IP Address", 
+            "Overall degree", "_plot-Histogram Overall Degree per IP" + format)
         ttl_out_path = plot_ttl('.' + format)
         mss_out_path = plot_mss('.' + format)
         win_out_path = plot_win('.' + format)
@@ -1465,12 +1471,6 @@ class Statistics:
             "Average interval time", "_plot-Histogram Avg Interval Time per Connection" + "." + format)
         plot_hist_total_comm_duration_out = plot_comm_histogram("totalConversationDuration", "Histogram - Total communication duration in seconds",
             "Duration", "_plot-Histogram Communication Duration per Connection" + "." + format)
-        # plot_hist_indegree_out = plot_histogram_degree("inDegree", "Histogram - Ingoing degree per IP Address", 
-        #     "Ingoing degree", "_plot-Histogram Ingoing Degree per IP" + format)
-        # plot_hist_outdegree_out = plot_histogram_degree("outDegree", "Histogram - Outgoing degree per IP Address", 
-        #     "Outgoing degree", "_plot-Histogram Outgoing Degree per IP" + format)
-        # plot_hist_overalldegree_out = plot_histogram_degree("overallDegree", "Histogram - Overall degree per IP Address", 
-        #     "Overall degree", "_plot-Histogram Overall Degree per IP" + format)
 
         ## Time consuming plot
         # port_out_path = plot_port('.' + format)