Browse Source

when -t Flag used, then Entropy plot will be printed

Roey Regev 6 years ago
parent
commit
49eb1958e5
3 changed files with 13 additions and 10 deletions
  1. 4 2
      code/CLI.py
  2. 3 3
      code/ID2TLib/Controller.py
  3. 6 5
      code/ID2TLib/Statistics.py

+ 4 - 2
code/CLI.py

@@ -67,7 +67,6 @@ class CLI(object):
         # Attack arguments
         parser.add_argument('-a', '--attack', metavar="ATTACK", action='append',
                                        help='injects ATTACK into a PCAP file.', nargs='+')
-
         # Parse arguments
         self.args = parser.parse_args(args)
 
@@ -140,7 +139,10 @@ class CLI(object):
 
         # Create statistics plots
         if self.args.plot is not None:
-            controller.create_statistics_plot(self.args.plot)
+            doEntropy = False
+            if self.args.extraTests:
+                doEntropy = True
+            controller.create_statistics_plot(self.args.plot, doEntropy)
 
         # Check random seed
         if not isinstance(self.args.randomSeed, list):

+ 3 - 3
code/ID2TLib/Controller.py

@@ -251,12 +251,12 @@ class Controller:
         readline.set_history_length(1000)
         readline.write_history_file(history_file)
 
-    def create_statistics_plot(self, params: str):
+    def create_statistics_plot(self, params: str, entropy: bool):
         """
         Plots the statistics to a file by using the given customization parameters.
         """
         if params is not None and params[0] is not None:
             params_dict = dict([z.split("=") for z in params])
-            self.statistics.plot_statistics(format=params_dict['format'])
+            self.statistics.plot_statistics(entropy = entropy, format=params_dict['format'])
         else:
-            self.statistics.plot_statistics()
+            self.statistics.plot_statistics(entropy = entropy)

+ 6 - 5
code/ID2TLib/Statistics.py

@@ -635,7 +635,7 @@ class Statistics:
         return sd
 
 
-    def plot_statistics(self, format: str = 'pdf'): #'png'
+    def plot_statistics(self,entropy : int , format: str = 'pdf'): #'png'
         """
         Plots the statistics associated with the dataset.
         :param format: The format to be used to save the statistics diagrams.
@@ -973,10 +973,11 @@ class Statistics:
         win_out_path = plot_win('.' + format)
         protocol_out_path = plot_protocol('.' + format)
         plot_interval_pktCount = plot_interval_pktCount('.' + format)
-        plot_interval_ip_src_ent = plot_interval_ip_src_ent('.' + format)
-        plot_interval_ip_dst_ent = plot_interval_ip_dst_ent('.' + format)
-        plot_interval_ip_src_cum_ent = plot_interval_ip_src_cum_ent('.' + format)
-        plot_interval_ip_dst_cum_ent = plot_interval_ip_dst_cum_ent('.' + format)
+        if entropy:
+            plot_interval_ip_src_ent = plot_interval_ip_src_ent('.' + format)
+            plot_interval_ip_dst_ent = plot_interval_ip_dst_ent('.' + format)
+            plot_interval_ip_src_cum_ent = plot_interval_ip_src_cum_ent('.' + format)
+            plot_interval_ip_dst_cum_ent = plot_interval_ip_dst_cum_ent('.' + format)
         plot_interval_new_ip = plot_interval_new_ip('.' + format)
         plot_interval_new_port = plot_interval_new_port('.' + format)
         plot_interval_new_ttl = plot_interval_new_ttl('.' + format)