How to get valid IPs from an IP Range?
-
I wanted to know if given an ip range, i.e 192.168.1.0-192.168.0.255, how do I find out which IPs are actual machines connected to the LAN without having to ping each IP? Even if I ping each IP, I wouldn't know if a timed out IP is an actual machine connected the network but offline or if the IP doesn't even exist on the LAN. If anyone has used the program Look@Lan, they would know that when you input an IP range it automatically figures out which IPs are valid and discards the ones that don't exist on the LAN. How do I accomplish this using C#? I'm using Visual Studio .NET 2005 with framework 2.0. I would appreciate any help or advice. Thanks.
-
I wanted to know if given an ip range, i.e 192.168.1.0-192.168.0.255, how do I find out which IPs are actual machines connected to the LAN without having to ping each IP? Even if I ping each IP, I wouldn't know if a timed out IP is an actual machine connected the network but offline or if the IP doesn't even exist on the LAN. If anyone has used the program Look@Lan, they would know that when you input an IP range it automatically figures out which IPs are valid and discards the ones that don't exist on the LAN. How do I accomplish this using C#? I'm using Visual Studio .NET 2005 with framework 2.0. I would appreciate any help or advice. Thanks.
There's really two questions you seem to be confusing here. The first is "which IPs are valid within a range", and "which IPs are used by computers". The first question can be solved mathematically, but it won't tell you anything about your actual network. The second question can only be solved by sending a ping or ARP packet out for each address, and checking for a response. Whether a machine is disconnected or simply nonexistant really is the same thing as far as network is concerned, so there's no way (or reason) to differentiate between the two. If you want to know which addresses within a range of IPs have computers associated, ping each one. It's tedious, but it's the only way. You'll obvously only want to scan a small range of addresses, or you'll be at it for hours.
-
There's really two questions you seem to be confusing here. The first is "which IPs are valid within a range", and "which IPs are used by computers". The first question can be solved mathematically, but it won't tell you anything about your actual network. The second question can only be solved by sending a ping or ARP packet out for each address, and checking for a response. Whether a machine is disconnected or simply nonexistant really is the same thing as far as network is concerned, so there's no way (or reason) to differentiate between the two. If you want to know which addresses within a range of IPs have computers associated, ping each one. It's tedious, but it's the only way. You'll obvously only want to scan a small range of addresses, or you'll be at it for hours.
Thx for the reply tylerl. I was hoping there was some other way to find out which IPs are used by computers besides pinging each one. I don't know if you have used Look@Lan, but somehow it figures out which IPs are used by computers and which IPs just don't exist. I've tried looking around the net for the program's source code but even though its free, the source code is unavailable. I've also looked at quite a few ping applications in c# but they still can't differentiate between an IP that is being used by a computer or one that doesn't exist on the network. They just send a packet and check for a reply. If you can think of anything else, please don't hesitate to reply back. Thanks again.
-
Thx for the reply tylerl. I was hoping there was some other way to find out which IPs are used by computers besides pinging each one. I don't know if you have used Look@Lan, but somehow it figures out which IPs are used by computers and which IPs just don't exist. I've tried looking around the net for the program's source code but even though its free, the source code is unavailable. I've also looked at quite a few ping applications in c# but they still can't differentiate between an IP that is being used by a computer or one that doesn't exist on the network. They just send a packet and check for a reply. If you can think of anything else, please don't hesitate to reply back. Thanks again.
Pinging is no longer much help. Unless you turn on the File Sharing exception for Windows Firewall in XP SP2, or otherwise open port 445, Windows Firewall will reject ICMP Echo Request packets sent by
ping
, by default. You can enable them if required. You'll find that most other software firewalls will do the same. If you need to determine whether you can connect to a network service, just try to connect to it. If you're trying to do a site survey you're probably out of luck. Stability. What an interesting concept. -- Chris Maunder