Java PCAP 文件解析器库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26978618/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 10:59:29  来源:igfitidea点击:

Java PCAP file parser library

javapcap

提问by Amir Rossert

I'm looking for a fast way to parse PCAP file packets.

我正在寻找一种解析 PCAP 文件包的快速方法。

I'm currently using jNetPcaplike so:

我目前正在使用jNetPcap,如下所示:

Pcap pcap = Pcap.openOffline(file, errbuf);
pcap.loop(10, jpacketHandler, "jNetPcap rocks!");

But it is pretty slow, is there any other good Java libraries that can parse PCAP files?

但是它很慢,有没有其他好的Java库可以解析PCAP文件?

采纳答案by Alexandro González

Just stumbled upon pcap parsing task in Java and found a pcap parser in Kaitai Struct. Surprisingly, it turns out to be blazing fast — probably because it's not a wrapper over C pcap library, but just a raw parser instead. My average results (on the same box, of course) are as following:

刚刚在 Java 中偶然发现了 pcap 解析任务,并在 Kaitai Struct 中找到了一个pcap 解析器。令人惊讶的是,结果证明它非常快——可能是因为它不是 C pcap 库的包装器,而只是一个原始解析器。我的平均结果(当然是在同一个盒子上)如下:

  • jpcap - 10,301 pps
  • jnetpcap - 15,148 pps
  • pcap.ksy in Kaitai Struct - 121,176 pps
  • jpcap - 10,301 页
  • jnetpcap - 15,148 页
  • 开泰结构中的 pcap.ksy - 121,176 pps

So, if you don't need capturing, I wholeheartedly recommend trying out Kaitai Struct parser.

所以,如果你不需要capture,我衷心推荐你尝试 Kaitai Struct 解析器。

回答by Vishnu

jNetPcapis the most stable and well written wrapper. Its better than JPcap see thisfor comparison details. And i don't have a comparison details for pcap4jto evaluate.

jNetPcap是最稳定、写得最好的包装器。它比 JPcap 更好,请参阅以获取比较详细信息。而且我没有要评估的pcap4j的比较详细信息。