Quellcode durchsuchen

improved calculation of external communication delay + added warnings

Marcel vor 6 Jahren
Ursprung
Commit
613bb107e6
1 geänderte Dateien mit 26 neuen und 4 gelöschten Zeilen
  1. 26 4
      code/ID2TLib/Statistics.py

+ 26 - 4
code/ID2TLib/Statistics.py

@@ -570,6 +570,8 @@ class Statistics:
             # calculate avg local and external delay by summing up the respective delays and dividing them by the number of conversations
             avg_delay_external = 0.0
             avg_delay_local = 0.0
+            default_ext = False
+            default_local = False
 
             if(local_conv):
                 for conv in local_conv:
@@ -577,7 +579,8 @@ class Statistics:
                 avg_delay_local = (avg_delay_local/len(local_conv)) * 0.001 #ms
             else:
                 # no local conversations in statistics found
-                avg_delay_local = 0.06
+                avg_delay_local = 0.055
+                default_local = True
 
             if(external_conv):
                 for conv in external_conv:
@@ -585,11 +588,30 @@ class Statistics:
                 avg_delay_external = (avg_delay_external/len(external_conv)) * 0.001 #ms
             else:
                 # no external conversations in statistics found
-                avg_delay_external = 0.15
+                avg_delay_external = 0.09
+                default_ext = True
         else:
             #if no statistics were found, use these numbers
-            avg_delay_external = 0.15
-            avg_delay_local = 0.06
+            avg_delay_external = 0.09
+            avg_delay_local = 0.055
+            default_ext = True
+            default_local = True
+
+        # check whether delay numbers are consistent
+        if avg_delay_local > avg_delay_external:
+            avg_delay_external = avg_delay_local*1.2
+
+        # print information, that (default) values are used, that are not collected from the Input PCAP
+        if default_ext or default_local:
+            if default_ext and default_local:
+                print("Warning: Could not collect average delays for local or external communication, using following values:")
+            elif default_ext:
+                print("Warning: Could not collect average delays for external communication, using following values:")
+            elif default_local:
+                print("Warning: Could not collect average delays for local communication, using following values:")
+            print("Avg delay of external communication: {0}s,  Avg delay of local communication: {1}s".format(avg_delay_external, avg_delay_local))
+            
+
         return avg_delay_local, avg_delay_external
 
     def get_filtered_degree(self, degree_type: str):