2

I have a requirement to monitor the client system connected to a LAN Network. If a system gets connected to a LAN , i need to get a notification and if a system gets disconnected from LAN, i need to get a notification.

Currently i am pinging the systems continuously in a C# code and getting the things done.

Drawbacks :-

1.I hard coded the system names to ping.

2.If the client is not reachable/ not in LAN / Host not found, the ping method waits for a period and throws exception.

3.So to to do this in Background, i perform this function in a thread.

4.Calling that thread inside a timer.

What is the best way to achieve this ?

ESSENCE

Some event , it should notify on new incoming connections, 
connection which is getting lost from LAN. This event should run async, monitor 
continuously.

I am using Windows Application (WPF) , C#.

M.Babcock
  • 18,753
  • 6
  • 54
  • 84
shanmugharaj
  • 3,814
  • 7
  • 42
  • 70
  • Your attempts appear to be monitoring external to the machine being disconnected. Is that a limitation in your environment, or is it possible to install something on the monitored machine to track when it thinks it loses network connectivity? – M.Babcock Dec 02 '13 at 05:03
  • Have you considered checking your machine ARP table? http://stackoverflow.com/questions/13492134/find-all-ip-address-in-a-network – Kye Dec 02 '13 at 05:05
  • I have 30 systems in a LAN. In one i need to run my code, (all machines are Windows 7). A service should run continuously in server (acting) and notify conected/disconnected state of client systems. We can even run a service in client to do so. – shanmugharaj Dec 02 '13 at 05:06
  • Can you connect to the networks router and request the information? – Kye Dec 02 '13 at 05:06
  • yes we can do that. But its on need basis to check info and get it.I need a service kind of thing which should automatically monitor and notify once the application turns on kye. – shanmugharaj Dec 02 '13 at 05:08

1 Answers1

2

Assuming you don't want to install an agent on all the PCs you want to monitor, the best thing to do would be to follow this process:

  1. Look for any ARP Announce packet you receive. Add the IP address to the list of devices to monitor on the network and alert on it coming up.
  2. Run a heartbeat on all IP addresses you have recorded.
    1. Perform a fast ping (Don't wait more than 10ms).
    2. If it doesn't respond, alert and remove it from the monitor list.
S.Richmond
  • 11,412
  • 6
  • 39
  • 57