Open georg-jung opened 4 years ago
This is correct, as stated in the readme.
I did not find a good way of reliably sending ARP requests on Linux/BSD systems. If you know how to do it properly, I'd be happy to know! :)
You are right, a PlatformNotSupportedException would be much better.
Seems like the easiest way involves parsing commandline outputs from arp
or arping
, which aren't available everywhere (i.e. in my default WSL installation without apt get
ting arping). A good starting point regarding this seems to be https://github.com/Kiphaz/PureActive/blob/master/src/PureActive.Network.Services.ArpService/ArpService.cs. Either way this doesn't feel like a good solution.
It's doable using https://github.com/chmorgan/sharppcap/blob/master/SharpPcap/ARP.cs too but this requires a dependency to non-managed code. While it's possibly better then parsing stdout it doesn't seem optimal either...
If I'm not mistaking, it also requires the OS to have PCAP installed.
See https://github.com/georg-jung/LinuxArpLookupDemo This is workaround-ish too but possibly the best option if one wants to get arp working on linux. Doesn't have prerequisits or dependencies.
Note that this doesn't work on WSL (1, seems like it will on 2), but thats a thing of WSL.
Possible that this requires root though - the machine I tested with just has a root user.
Edit: Reading does work as a non-root user on a debian I just tried and it seems to work on android too
One could use Linux' raw socket to send the ARP packet directly: https://gist.github.com/austinmarton/1922600
However, it requires root as well.
Yeah I've seen this. Raw sockets on linux require root, on windows they are completely unsupported. One way around is pcap. But the solution I linked works without root and without calling external processes. It is even kind of truly async.
Actually I think this method works quite well and has reasonable drawbacks - the unnecessary ping. If one wanted to not use a ping one could obviously try to connect to some port via TCP or send a UDP packet too. I liked the ping option most.
On the plus side we get linux + android support, a real async method and don't take dependencies. I created https://github.com/georg-jung/ArpLookup to support the arp-only use case. Feel free to integrate my code if you like to.
The linux lookup looks promising. If it's still ok for you, I'd integrate the linux lookup into the library.
Sure!
Trying to execute them on linux results in the following exception:
While I understand why this is the case it might be nice to provide a different solution for non-windows platforms or at least throwing a platform not supported exception.