9

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.

To capture ARP reply, I know I can use jpcap so that part is solved.

Thanks

beyonddc
  • 1,246
  • 3
  • 13
  • 26
  • can you be more explicit by what you mean "within java application". a java app can always execute some external command, calling another tool to do it. java libraries have pretty much the same possibilities as "standard java". – eis Feb 01 '13 at 15:58
  • 1
    I apologize, I am looking for a API solution, not executing external command such as arping. – beyonddc Feb 01 '13 at 16:05
  • See http://stackoverflow.com/questions/1238963/query-arp-cache-to-get-mac-id – maerics Feb 01 '13 at 16:06
  • 1
    It might help if you would explain what it is you are really trying to do - I am guessing you want the MAC address of the remote machine. That is only possible if you're on the same subnet - if you are working across a router, then ARP will tell you the hardware address of the router, not the machine. It's how networks work... – Floris Feb 01 '13 at 16:09

3 Answers3

3

As you've stated, the Java standard library does not provide a low level enough networking API to send an ARP request.

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 this sample for how to send an ARP request.

natbob1
  • 308
  • 1
  • 11
2

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.

Based on googling, there seems to be arping in kraken pcap which is in Java. See about Kraken.

There's also jpcap as well that's used for the purpose.

eis
  • 51,991
  • 13
  • 150
  • 199
-1

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

DangerDan
  • 519
  • 2
  • 13
  • It may not completely be native but there are APIs and here is the link for it: http://yuba.stanford.edu/vns/clack/instructor/rip.html#apis – grepit Feb 01 '13 at 21:32
  • 'Due to security concerns' is just guesswork unless you can cite a source. The fact is that it just isn't present. Netiher are ICMP, RARP, ... Your link isn't much help. – user207421 Apr 13 '16 at 00:05