Kaynağa Gözat

add temporal efficiency test for DDoSAttack

Jens Keim 6 yıl önce
ebeveyn
işleme
76ab75d3fa
2 değiştirilmiş dosya ile 21 ekleme ve 0 silme
  1. 9 0
      code/ID2TLib/TestLibrary.py
  2. 12 0
      code/Test/efficiency_testing.py

+ 9 - 0
code/ID2TLib/TestLibrary.py

@@ -124,3 +124,12 @@ def get_attacker_config(ip_source_list, ipAddress: str):
 
     return next_port, ttl
 
+
+def write_attack_pcap(self, packets: list, append_flag: bool = False, destination_path: str = None):
+    """
+    temporal efficiency test patch for write_attack_pcap (Attack.BaseAttack.py)
+
+    :return: The path to a dummy pcap file.
+    """
+    os.system("cp " + test_pcap + " " + test_resource_dir + "dummy.pcap")
+    return test_resource_dir + 'dummy.pcap'

+ 12 - 0
code/Test/efficiency_testing.py

@@ -54,3 +54,15 @@ class EfficiencyTests(Test.ID2TAttackTest):
 
     def test_SalityBotnet_10_000(self):
         self.temporal_efficiency_test([['SalityBotnet']], time_limit=15, factor=10000)
+
+    @mock.patch('Attack.BaseAttack.BaseAttack.write_attack_pcap', side_effect=Lib.write_attack_pcap)
+    def test_DDoS_10_000(self, mock_write_attack_pcap):
+        # TODO: update attack args, when DDoS gets refactored
+        self.temporal_efficiency_test([['DDoSAttack', 'attackers.count=100', 'packets.per-second=95',
+                                        'attack.duration=150']], time_limit=15, factor=10000)
+
+    @mock.patch('Attack.BaseAttack.BaseAttack.write_attack_pcap', side_effect=Lib.write_attack_pcap)
+    def test_DDoS_100_000(self, mock_write_attack_pcap):
+        # TODO: update attack args, when DDoS gets refactored
+        self.temporal_efficiency_test([['DDoSAttack', 'attackers.count=1000', 'packets.per-second=950',
+                                        'attack.duration=300']], time_limit=150, factor=100000)