0

how can I get the information of computer that is connected to my computer? it's computer name and it's IP address.. I am using C# as my Programming Language

I am using cross cable to connect the two computer.

  • 3
    Can you describe in more detail exactly how the other computer is connected to yours? Ethernet? How would you imagine distinguishing *that* computer from all the *other* reachable computers? Are they on the same subnet? How is the other computer announcing itself to yours? – Michael Petrotta Sep 30 '12 at 06:08
  • the computer is connected to me using cross cable... I just changed it's IP address as 192.168.0.1 and my computer is using 192.168.0.2 – goldrogerluffy Sep 30 '12 at 06:11
  • You might find [nmap](http://nmap.org/) of use. – Michael Petrotta Sep 30 '12 at 06:14
  • Related: http://stackoverflow.com/questions/2557551/how-get-list-of-local-network-computers/2562302 – Theraot Sep 30 '12 at 06:49

1 Answers1

2

The first thing you should know is that when you connect something to an Ethernet network, crossover cable or not, the devices on this network aren't required to actually send anything. There is no message that says "Oh hi, I'm a new to this network, care to introduce me to the neighbors?"

That being said, there is usually a flurry of activity when a device is connected. On most networks, there is something called a DHCP server that sends out configuration, such as IP address, netmask, DNS server addresses, etc. Again, it isn't required that this is the configuration. Many devices are manually configured and don't use DHCP. Networks in general are not required to use DHCP. But, it is a good start.

What you need to do is a bit of packet sniffing. Basically, write software to listen for all packets coming across your network interface, and filter out for the packets you are interested in. There is a .NET wrapper for Winpcap, which is a packet capture driver for Windows. This should get you started.

Listen for packets set to the Ethernet broadcast (FF:FF:FF:FF:FF:FF). On an IP network, you can use ARP to get the IP address of that host.

Windows network information is also sent via broadcast, if that interests you.

To get an idea of what you're looking for, download Wireshark and take a look.

Brad
  • 159,648
  • 54
  • 349
  • 530