java jNetPcap 与 Jpcap
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3623681/
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
jNetPcap vs Jpcap
提问by Gilbeg
wondering any of you can give me a bit of comments + insights please. In term of performance, which one should I use, jNetPcap or Jpcap?
想知道你们中的任何人都可以给我一些评论+见解。在性能方面,我应该使用哪个,jNetPcap 还是 Jpcap?
Thanks!
谢谢!
回答by posicks
The referenced post contains an admittedly biased opinion by the owner of the jNetPcap project. It is hardly a reliable source for a true comparison.
引用的帖子包含 jNetPcap 项目所有者公认的偏见意见。它几乎不是真正比较的可靠来源。
One difference that is obvious between the two projects is that jNetPcap uses JNI for access to native code. PCap4j (http://www.pcap4j.org/) uses JNA for access to native code and a "com.sun" JNA compatibility library (https://github.com/twall/jna).
两个项目之间明显的一个区别是 jNetPcap 使用 JNI 来访问本机代码。PCap4j ( http://www.pcap4j.org/) 使用 JNA 来访问本机代码和“com.sun”JNA 兼容性库 ( https://github.com/twall/jna)。
Also, the latest version of jNetPcap does not build on Mac OSX and the patch file that was posted to the support forums does not work, even if manually applied. PCap4j run on Mac OSX if the instructions at http://tomute.hateblo.jp/entry/2013/01/27/003209are followed; for PCap4J 1.3.0 you must replace the JNA 3.3.0 library with the newer versions JNA 4.1.0.
此外,最新版本的 jNetPcap 不是在 Mac OSX 上构建的,即使手动应用,发布到支持论坛的补丁文件也不起作用。如果遵循http://tomute.hateblo.jp/entry/2013/01/27/003209中的说明,则 PCap4j 在 Mac OSX 上运行;对于 PCap4J 1.3.0,您必须用较新版本的 JNA 4.1.0 替换 JNA 3.3.0 库。
The following command line is an example for PCap4j 1.3.0 on Mac OSX 10.9.5: sudo java -cp pcap4j-core-1.3.0.jar:pcap4j-packetfactory-static-1.3.0.jar:./libs/jna-4.1.0.jar:./libs/slf4j-api-1.7.10.jar:./libs/slf4j-nop-1.7.10.jar:pcap4j-sample-1.3.0.jar -Dorg.pcap4j.core.pcapLibName=libpcap.dylib -Dorg.pcap4j.sample.Loop.count=2 org.pcap4j.sample.Loop icmp
以下命令行是 Mac OSX 10.9.5 上 PCap4j 1.3.0 的示例: sudo java -cp pcap4j-core-1.3.0.jar:pcap4j-packetfactory-static-1.3.0.jar:./libs/jna -4.1.0.jar:./libs/slf4j-api-1.7.10.jar:./libs/slf4j-nop-1.7.10.jar:pcap4j-sample-1.3.0.jar -Dorg.pcap4j.core .pcapLibName=libpcap.dylib -Dorg.pcap4j.sample.Loop.count=2 org.pcap4j.sample.Loop icmp
回答by user403295
回答by Anubhav Nandan
I researched it and found three Java wrapper libraries for pcap: jpcap, jNetPcap, and Jpcap. But both jpcap and jNetPcap were unsuitable for SNeO because they seemed to be designed for mainly capturing packets and not to be useful for making and sending packets so much. On the other hand, Jpcap looked useful for making and sending packets. But it had a defect in capturing ICMP packets and its development seemed to be stopped long ago. That's why Pcap4j.
我研究了它,发现了三个用于 pcap 的 Java 包装器库:jpcap、jNetPcap 和 Jpcap。但是 jpcap 和 jNetPcap 都不适合 SNeO,因为它们似乎主要用于捕获数据包,而对制作和发送数据包没有太大用处。另一方面,Jpcap 看起来对制作和发送数据包很有用。但是它在捕获ICMP数据包方面存在缺陷,并且它的开发似乎很久以前就停止了。这就是为什么 Pcap4j。

