瀏覽代碼

Fix computation of relative PCAP time

Before this, when a packet was injected right at the start of the
original PCAP, the relative PCAP time in the mapping was wrong as
it was based on the timestamp of the first packet contained in the
original PCAP. Now, the computation is correctly based on the
minimum timestamp of the first original and first injected packet.
dustin.born 6 年之前
父節點
當前提交
ff2f3f259f
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      code/ID2TLib/Botnet/MessageMapping.py

+ 3 - 1
code/ID2TLib/Botnet/MessageMapping.py

@@ -17,7 +17,9 @@ class MessageMapping:
         self.messages = messages
         self.id_to_packet = {}
         ts_date_format = "%Y-%m-%d %H:%M:%S.%f"
-        self.pcap_start_dt = datetime.datetime.strptime(pcap_start_timestamp_str, ts_date_format)
+        first_msg_dt = datetime.datetime.fromtimestamp(min(messages, key=lambda msg: msg.time).time)
+        orig_pcap_start_dt = datetime.datetime.strptime(pcap_start_timestamp_str, ts_date_format)
+        self.pcap_start_dt = min(first_msg_dt, orig_pcap_start_dt)
 
     def map_message(self, message, packet):
         self.id_to_packet[message.msg_id] = packet