Detect all networked devices' types in a home network
I would like to write a software running in a networked device, i.e. PC. It can automatically detect the other network devices' types. For example, it can detect there is a PS3,开发者_Go百科 a Wii, an IPad running in the same network. Any ideas? Thanks,
You have two problems: first, detecting that a device is connected to your network and at 192.168.1.x
. Second, somehow detecting what that device is.
The first is easy-ish to accomplish: there's discovery protocols like UPnP and Bonjour. However, in a home networking scenario, the easiest and most reliable way to get a list of connected devices is probably to pull the DHCP reservations from your router. You might have to scrape data from the router's HTML-based management interface—hacky as that may be—but it would work. (If you're using .NET, consider the HTML Agility Pack to accomplish this.)
Once you have a list of IP addresses of connected devices, your next problem is to figure out what each device actually is. This will be more challenging. Some possibilities:
- You may be able to use the MAC address to help detect the device's vendor. (Here's a list.)
- If you're using UPnP, you can ask the device what it is.
- Use IP fingerprinting to determine what the device is.
Couple thoughts. The broadcast IP address - 255.255.255.255 is where devices talk and say "here I am". Should be able to listen to this and find ip addresses and more. Second, if devices are assigned an IP address by a DHCP client (obviously) you can usually find a list on the dhcp device. Devices often have names, this is a higher level protocol, like windows SMB, that you may have to interface with in order to get that information.
精彩评论