Quellcode durchsuchen

Use deque for efficiency

dustin.born vor 7 Jahren
Ursprung
Commit
0cf8b7dc93
1 geänderte Dateien mit 2 neuen und 2 gelöschten Zeilen
  1. 2 2
      code/Attack/MembersMgmtCommAttack.py

+ 2 - 2
code/Attack/MembersMgmtCommAttack.py

@@ -1,4 +1,5 @@
 from random import randint
+from collections import deque
 
 from Attack import BaseAttack
 from Attack.AttackParameters import Parameter as Param
@@ -64,12 +65,11 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
 
         # Setup initial parameters for packet creation
         BUFFER_SIZE = 1000
-
         id_to_ip_mapper = MappingIPGenerator()
         file_timestamp_prv = float(comm_entries[0]["Time"])
         pcap_timestamp = self.get_param_value(Param.INJECT_AT_TIMESTAMP)
         duration = 0
-        packets = []
+        packets = deque(maxlen=BUFFER_SIZE)
         total_pkts = 0
         limit_packetcount = self.get_param_value(Param.PACKETS_LIMIT)
         limit_duration = self.get_param_value(Param.ATTACK_DURATION)