Browse Source

Simplify assigning final packet/inject times.

dustin.born 7 years ago
parent
commit
9429b6ebae
1 changed files with 3 additions and 10 deletions
  1. 3 10
      code/Attack/MembersMgmtCommAttack.py

+ 3 - 10
code/Attack/MembersMgmtCommAttack.py

@@ -160,14 +160,11 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
         # Setup (initial) parameters for packet creation loop
         BUFFER_SIZE = 1000
         pkt_gen = PacketGenerator()
-        file_timestamp_prv = messages[0].time
-        pcap_timestamp = self.get_param_value(Param.INJECT_AT_TIMESTAMP)
         padding = self.get_param_value(Param.PACKET_PADDING)
         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)
-        duration = 0
         path_attack_pcap = None
 
         msg_packet_mapping = MessageMapping(messages)
@@ -182,12 +179,8 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
             port_src, port_dst = msg.src["Port"], msg.dst["Port"]
             ttl = msg.src["TTL"]
 
-            # update timestamps and duration
-            file_timestamp = msg.time
-            file_time_delta = file_timestamp - file_timestamp_prv
-            pcap_timestamp += file_time_delta
-            duration += file_time_delta
-            file_timestamp_prv = file_timestamp
+            # update duration
+            duration = msg.time - messages[0].time
 
             # if total number of packets has been sent or the attack duration has been exceeded, stop
             if ((limit_packetcount is not None and total_pkts >= limit_packetcount) or 
@@ -204,7 +197,7 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
                 port_src=port_src, port_dst=port_dst, message_type=msg.type, neighborlist_entries=nl_size)
             PaddingGenerator.add_padding(packet, padding,True, True)
 
-            packet.time = pcap_timestamp
+            packet.time = msg.time
             packets.append(packet)
             msg_packet_mapping.map_message(msg, packet)
             total_pkts += 1