05-23-2011 01:09 AM
Hi Everyone,
I would like to know how do i detect device connected over ethernet by using labVIEW?
My require is:
I have to develop a code which detect any device connected to ethernet port.(The external device which is connected to ethernet port may be anything)
I would like to get the IP of the device connected to my ethernet port using labVIEW.
It will be really grateful if anyone can help me to resolve this.
05-23-2011 09:39 AM
This is a nontrivial application and there are many things involved. First and foremost LabVIEW would have to be sniffing all the data going over the port. There are some examples of using the Wireshark libraries to do this but none of them go into enough depth for what you are looking for.
In addition to this and probably much more problematic is that you need access to all of the data on that port. Today's switches automatically filter the data that will be sent on a single port so if your monitoring PC is connected to one port it will not see any data on the other ports. Some managed switches allow you to mirror the data from one port to another but this requires that you have administration rights on the switch and you have permission to do this on the network you are working. Alternatively you can use a hub connected to the port you wish to monitor. The problem there is that hubs are difficult to find these days and they generally aren't cheap because the supply is very low. There are dedicated test devices designed specifically for passively tapping into an Ethernet connection but these are much more expensive. These start at about the 1K mark. There are some "how to's" on the internet which describe how you can make your own passive tap. These are not always reliable though and can impact the data on the line.
What is your purpose for doing this?
05-23-2011 11:56 AM
HI Mark,
First of all thankyou for your response..
I am in a process of developing an ethernet manager as my project work wherein I will first of get all devices IP which are connected to network.
Then I try to communicate with each device .
My cRIO will be connected over ethernet which intern will be connected over switch.
Thats why I am looking to get all IP.
05-23-2011 01:26 PM
If you have control over all of the devices it would probably be better to implement some type of a discovery protocol. Your manager would broadcast a discovery packet and the devices (at least those that are aware of the discovery packet) would reply with all the necessary information the manager needs.
If you simply sniff the network, learn addresses and start trying to talk to them you may run into issues with the IT staff that maintains the network. This is not an issue if you are in full control of the network but if there is an IT group managing things you may run into some resistance.
05-23-2011 11:31 PM
Hi Mark,
For the devices who are known to me I can always brodcast a message to see who all are there as u said correctly.
But I am getting stuck for the Unknown device who are getting connected over Ethernet.How do I find them..Is there any command which all devices responds to.. who all are connected over ethernet...
05-24-2011 10:14 AM
A brute force method which is commonly used is to send a ping packet to every IP address in the subnet(s) you are interested in. This is not guaranteed to work since some devices will not reply to ICMP ping packets for security reasons. Another approach which again guaranteed to work and will more likely find fewer devices would be to send a SNMP request for the system description (1.3.6.1.2.1.1.1.0) . If a device supports SNMP they will generally respond to this request.
Many devices, especially network infrastructure devices, will not be easily managed. They will have security enabled to limit access to them. Part of this security will be to limit what types of communications they will accept and who they will talk to. Simply finding an IP address active on a network will not provide you with too much information about the type of device it is and how you may communicate with it. There are lots of network protocols out there and many devices have very specific ones they use. A general purpose network manager that can find and communicate with anything on the network is a daunting task and one that most likely will not be possible to implement. At best you will be able to find a subset of devices. As I mentioned even the most basic ping packet will not guarantee you will find everything.
I'm not trying to rain on your parade but trying to let you know that you are trying to accomplish something that will most likely impossible to actually do. Probably the most effective way, but not very practical, to at least find eveything would be to implement a port scanner that would exhaustively go through every IP address in your desired range and attempt to establish a connection on every TCP port (you could stop once you get a response). If a device is on the network it more than likely will communicate on at least one TCP port. All this would tell you though is that there is a device at that IP address that communicates using port x. However, as I cautioned before this type of activity will very quickly get the attention of the network staff managing the network you do this on.
05-25-2011 02:49 AM
Mark has done a great job in explaining the difficulties in what you want to do. But basically what you describe wanting to do is simply impossible. It would be the equivalent of teaching a device or software to develop almost parapsychologic capabilities.