0

On a local network I'm sending a WOL (Wake-On-LAN) packet using sendto to the target MAC address. The code for that works without any problems and the target machine is turned on correctly. The problem is, that I don't know if the target machine has a LAN cable attached or not. If it's not attached, then the whole process fails. Unfortunately, sendto is unidirectional, so I don't know if my magic packet arrived.

I'm wondering about the best and fastest way to find out if WOL succeeded or not. Waiting for the device to boot up completely so I find out get and ping its IP address takes way too long.

Is there a way to "ping" a MAC address, i.e. get some sort of Layer-2-reply?

I need this solution for a Delphi application, but if you have a solution for a different language at hand you're welcome to post that as well. Thank you!

CodeX
  • 717
  • 7
  • 23
  • Refer [this questions answer by RRUZ](http://stackoverflow.com/questions/10178173/network-infrastructure-discovery) – pn098 Mar 09 '17 at 13:13
  • This may be helpful: [Can one ping a NIC by MAC](http://unix.stackexchange.com/questions/86165/can-one-ping-a-nic-by-mac) – Dave Olson Mar 09 '17 at 13:19
  • @pn098: The linked topic refers to ARP which doesn't work without an IP. Dave: I've read about "arping", but it's a Linux tool and in my understanding it just retrieves the IP from the provided MAC address and pings the IP then. – CodeX Mar 09 '17 at 13:29
  • That post also refers to this: [ThomasHabets/arping](https://github.com/ThomasHabets/arping) – Dave Olson Mar 09 '17 at 13:30
  • @DaveOlson, what are you tryng to tell me? I found arping before posting this question and in my understanding it does not really ping a MAC, but uses ARP to get the IP for a MAC and pings that then. Quote: "Arping when pinging a MAC relies on the host to answer a broadcast ping (icmp echo request) properly". ICMP requires IP. Tell me if I'm mistaken or if I didn't get your point. – CodeX Mar 09 '17 at 13:38
  • I trying to tell you that there might be a solution there. From the readme: "Example uses, If some box is dumping non-IP (like IPX) garbage and you don't know which box it is, you can **ping by MAC** to get the IP and fix the problem." - I haven't looked at the code in any detail (I'm going to now) but maybe there's a way to use the maneuver to get what you want. – Dave Olson Mar 09 '17 at 15:55
  • I think that the best way would be to listen on your network connection for DHCP discovery message that each network device broadcasts to start the process of receiving an IP address from DHCP server. https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol Unfortunately I don't have any code for doing this available. – SilverWarior Mar 09 '17 at 16:23
  • This is an interesting approach that I haven't thought of yet. But in the end it works only for the devices that use DHCP and not a static IP configuration. Also, this doesn't save much time as the DHCP broadcast is only sent when the device finished booting. – CodeX Mar 09 '17 at 17:34
  • @CodeX When I think more about it you are right. Devices probably won't request for IP assignment until they load their OS. – SilverWarior Mar 09 '17 at 18:08
  • 1
    @CodeX Here is another idea that might work. If you configure BIOS on your computers to try booting from network first it might force requesting for IP assignment before loading main OS or at least broadcast some special message to find address of server that provides network booting capabilities. Unfortunately I have no practical experience of using network booting. – SilverWarior Mar 09 '17 at 18:20
  • In my case I need a universal solution without having to modify the target the systems, unfortunately. Otherwise the idea to look at the network-boot-option would definitely be a good idea! – CodeX Mar 09 '17 at 18:25

0 Answers0