如何使用毫秒时间戳将十六进制转储导入 Wireshark?

How to import hex dump into Wireshark with millisecond timestamps?

我正在尝试将文本十六进制转储导入带有毫秒时间戳的 wireshark。

I've read this page about how to do it, but it's not clear to me how to get millisecond timestamp granularity.

这是我的示例十六进制转储:

0.111
000000 00 e0 1e a7 05 6f 00 10 ........
000008 5a a0 b9 12 08 00 46 00 ........
000010 03 68 00 00 00 00 0a 2e ........
000018 ee 33 0f 19 08 7f 0f 19 ........
000020 03 80 94 04 00 00 10 01 ........
000028 16 a2 0a 00 03 50 00 0c ........
000030 01 01 0f 19 03 80 11 01 ........

1.222
000000 00 e0 1e a7 05 6f 00 10 ........
000008 5a a0 b9 12 08 00 46 00 ........
000010 03 68 00 00 00 00 0a 2e ........
000018 ee 33 0f 19 08 7f 0f 19 ........
000020 03 80 94 04 00 00 10 01 ........
000028 16 a2 0a 00 03 50 00 0c ........
000030 01 01 0f 19 03 80 11 01 ........

3.333
000000 00 e0 1e a7 05 6f 00 10 ........
000008 5a a0 b9 12 08 00 46 00 ........
000010 03 68 00 00 00 00 0a 2e ........
000018 ee 33 0f 19 08 7f 0f 19 ........
000020 03 80 94 04 00 00 10 01 ........
000028 16 a2 0a 00 03 50 00 0c ........
000030 01 01 0f 19 03 80 11 01 ........

如果我在导入时输入“%S”作为 Date/Time 格式,我可以获得第二个粒度,这很好 - 但第二个之后的所有内容都被截断了,所以我没有得到实际的毫秒数。 (纳秒也不错,但我会满足于毫秒。)

有什么想法吗?谢谢!

这是不可能的,因为 wireshark 使用 strptime(3) 来解析时间戳,而 strptime(3) 不支持 milliseconds/fractions.

更新 1:

一种可能的解决方案是使用 wireshark 支持的 Lua api 编写自定义解析器。更多关于 here.

如 Wireshark 发行版中 text2pcap 的文档所述,如果您想要亚秒级时间戳,则需要在格式字符串中包含尾随 "period"。例如。 %H:%M:%S. 也会在 Wireshark UI 中正确解析 10:15:14.5476。在你的情况下 %S. 应该有效。

来自 text2pcap 帮助:

-t <timefmt> treat the text before the packet as a date/time code; the specified argument is a format string of the sort supported by strptime.
Example: The time 10:15:14.5476 has the format code %H:%M:%S.

NOTE: The subsecond component delimiter, '.', must be given, but no pattern is required; the remaining number is assumed to be fractions of a second.

NOTE: Date/time fields from the current date/time are used as the default for unspecified fields.