Who Is On My Network?
A Software How-To In C#

Ever feeling a bit paranoid and wonder just what or who is connected to your network??? I do, that's why I decided to do a little fun programming and came up with Communication Manager.

A little program to find all valid IP's being used and identify what they are. I was surprised when I first ran it, I had no idea it would pick up so many things. Good news is, all connections were valid.

Quake USA Communication Manager

The program is made very simple utilizing the System.Net library, specifically Sockets, DNS, and Network Information. The program starts by obtaining the host name and associated IP’s from System.Net.Dns (Domain Naming Service) and determines whether the IP’s are v6 or v4.

Some other fun stuff, all the active ports are obtained using System.IO.Ports.SerialPort.GetPortNames(), network interfaces are processed (see below), and even though it has little to do with communication/networking; the active drives are listed out using System.IO.DriveInfo.GetDrives().

The real fun comes from processing the active IP’s on the network. This is where you can find out if anyone is hacked into your network. The program uses the base IP address the first three sets of numbers from the IP (i.e. 000.000.000.xxx where xxx equals 0 thru 255) and runs a loop for all the possible IP’s, except for the hosts IP. Each IP is pinged for status reply: positive reply denotes active IP. System.Net.NetworkInformation.Ping() is utilized for this purpose.

All active IP’s are captured and queried for the connection information which is held within the valid reply. The other piece of information you need is obtained by using System.Net.Dns.GetHostEntry(IP address).HostName. It really comes down to just processing information. For example, to process all the network interfaces:

NetworkInterface[] niNetInterface = NetworkInterface.GetAllNetworkInterfaces();

Now you just go through the retrieved list and process the information for each network interface. Information such as Description, Interface Type, Physical Address, Bytes received and sent, etc…

Other items of interest if someone is learning C#, the application is WPF, a timer is created and utilized, formatting for drive sizes, updating control data sources. This is a Visual Studio 2010 version project, but you will have no trouble porting it to a more recent version of Visual Studio if you need to. It is straight forward and commented. The project source code can be found here: ComMgr
Enjoy!

End Of Line Man!