tags:

views:

232

answers:

7

I'm trying to confirm a user a unplugged my embedded device from a network before performing some maintenance. I'm considering "ping"ing all IP address on my sub-net, but that sounds crude. Is there a broadcast/ARP method that might work better?

+2  A: 

You can try a broadcast ping (this is from linux):

ping -b 255.255.255.255

Another option is to download Nmap and do a ping-scan.

bmdhacks
+1  A: 

You could use nmap. It's still crude, but at least it's using a tool designed to do it so you don't have to spend time on it.

jj33
A: 

If you can't get reliable link state information from your Ethernet device (which most chipsets should support these days, BTW...), sending an ARP request for each IP on your local subnet is a decent substitute. The overhead is minimal, and as soon as you get a single response, you can be sure you're still connected to a network.

The only possible problem I see here, is that if your device is on a /8 subnet, it can take quite a while to loop through all 4294967296 possible IPs. So, you may want to consider some optimization, such as only sending ARP requests for your default gateway, as well as all IPs currently in your ARP table.

mdb
Thanks! Any pointers on how to programmatically send an ARP in linux?
Jeff
A: 

If there's a peer you know you were connected to recently you could try pinging or arping that first. That could cut down on the traffic you're generating.

Andrew Queisser
A: 

you could also run tcpdump -n to see what's active on the network too.

mike511
A: 

Not receiving any responses to ICMP pings or ARP requests is not a 100% guarantee that there's no network connection. For instances, there might be devices on the network that are firewalled off.

EDIT: May be you could access some lower-level information on your embedded device to check whether the network interface has its link up without actually sending any data.

Alexander
A: 

Is there any chance that your device supports UPnP or Bonjour? Beside of the low-level protocols your should also have a look at these protocols which support some kind of plug-&-Play functionality. A UPnP device for example sends a message on the LAN before it is switched off (though, this doesn't help if it is just removed by unplugging it...).

akr