java 有没有办法通过Java发送ARP请求?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14650089/
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
Is there a way to send ARP request via Java?
提问by beyonddc
Is there a way to send ARP request within a Java application? I know that ARP is sitting a layer under TCP and UDP therefore by default Java couldn't send ARP request. I am just wondering is there any 3rd party Java library that will allow you to send ARP request.
有没有办法在 Java 应用程序中发送 ARP 请求?我知道 ARP 位于 TCP 和 UDP 之下,因此默认情况下 Java 无法发送 ARP 请求。我只是想知道是否有任何 3rd 方 Java 库可以让您发送 ARP 请求。
To capture ARP reply, I know I can use jpcap so that part is solved.
要捕获 ARP 回复,我知道我可以使用 jpcap 以便解决该部分。
Thanks
谢谢
回答by eis
A java app can always execute some external command, calling another tool to do it. I'm not sure what you mean by "standard java" though.
Java 应用程序总是可以执行一些外部命令,调用另一个工具来执行它。不过,我不确定您所说的“标准 Java”是什么意思。
Based on googling, there seems to be arpingin kraken pcapwhich is in Java. See about Kraken.
基于谷歌搜索,在 Java中的kraken pcap 中似乎有arping。参见Kraken。
There's also jpcapas well that's used for the purpose.
还有用于此目的的jpcap。
回答by natbob1
As you've stated, the Java standard library does not provide a low level enough networking API to send an ARP request.
正如您所说,Java 标准库没有提供足够低级别的网络 API 来发送 ARP 请求。
The pcap4j
provides Java bindings for libpcap / winpcap and thus can be used to send an ARP request. Information on the library can be found on their homepage. See thissample for how to send an ARP request.
该pcap4j
对的libpcap / winpcap的提供Java绑定,从而可用于发送ARP请求。关于图书馆的信息可以在他们的主页上找到。有关如何发送 ARP 请求,请参阅此示例。
回答by DangerDan
No, not in native Java (I'm guessing this is due to security concerns). It can be done although it does require the use of C++/C native code libraries and JNI programming. https://forums.oracle.com/forums/thread.jspa?threadID=1690617
不,不是在本机 Java 中(我猜这是由于安全问题)。虽然它确实需要使用 C++/C 本机代码库和 JNI 编程,但它可以完成。https://forums.oracle.com/forums/thread.jspa?threadID=1690617