Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to get valid IPs from an IP Range?

How to get valid IPs from an IP Range?

Scheduled Pinned Locked Moved C#
csharpquestionvisual-studiosysadminhelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bigmacrox
    wrote on last edited by
    #1

    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.

    T 1 Reply Last reply
    0
    • B bigmacrox

      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.

      T Offline
      T Offline
      tylerl
      wrote on last edited by
      #2

      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.

      B 1 Reply Last reply
      0
      • T tylerl

        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.

        B Offline
        B Offline
        bigmacrox
        wrote on last edited by
        #3

        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.

        M 1 Reply Last reply
        0
        • B bigmacrox

          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.

          M Offline
          M Offline
          Mike Dimmick
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups