소스 검색

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