I am attempting to programmatically determine in VB .Net 4.5 if a specific device is attached to my LAN so I can take actions depending on whether it is On or Off.
Since the LAN uses DHCP for address assignment, there is no guarantee what the IP address will be, thus (using a reverse lookup routine I created) I check the arp cache to see if the device is there. If it is then I open a socket to communicate with it.
But if there is no arp cache entry then I know that the device is either turned off, or an arp cache timeout has occurred for the device. If a timeout has cleared the entry, then I'd like to try to determine that, so I can use the device, by sending a general ARP "WHO HAS" Broadcast and see if I get an answer.
Since I only have its MAC address I want to send an ARP "Who has" broadcast to force a cache refresh, then delay 30 seconds and try the arp lookup again.
So. Long story short, I have two issues . . .
1) The construction of the ARP packet uses the last two fields as Target MAC and Target IP. The broadcasts I have trapped all have the IP field filled in and the MAC field with all 00 bytes. I am hoping I can turn that around and use 00 bytes for the IP and the MAC for the lost target. If that is not possible, then there is no need to answer question 2, unless there is a way to do it not discussed in this question.
2) How can I send a pure raw packet [VB .Net 4.5]? This (I believe) is the complete message I need to send . . .
ff ff ff ff ff ff f4 6d 04 ef e1 06 08 06 00 01 08 00 00 01 f4 6d 04 ef e1 06 c0 a8 01 5a 88 53 95 86 a0 1f 00 00 00 00
I have not been able to find a method to send that packet. Specifically what VB code is required to define,open, and use the socketsend?
Much thanks. The answer to this will make my day. Been at it for two weeks and dozens of forums, without an answer.
:-(