简体   繁体   English

监视连接到网络的客户端

[英]Monitoring clients connected to a network

I have a requirement to monitor the client system connected to a LAN Network. 我需要监视连接到LAN网络的客户端系统。 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. 如果系统连接到LAN,我需要获取通知;如果系统与LAN断开连接,则需要获取通知。

Currently i am pinging the systems continuously in a C# code and getting the things done. 目前,我正在用C#代码连续ping系统并完成工作。

Drawbacks :- 缺点 :-

1.I hard coded the system names to ping. 1.我将系统名称硬编码为ping。

2.If the client is not reachable/ not in LAN / Host not found, the ping method waits for a period and throws exception. 2.如果客户端无法访问/不在局域网中/找不到主机,则ping方法将等待一段时间并引发异常。

3.So to to do this in Background, i perform this function in a thread. 3.因此,要在后台执行此操作,我需要在一个线程中执行此功能。

4.Calling that thread inside a timer. 4.在计时器中调用该线程。

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#. 我正在使用Windows应用程序(WPF)和C#。

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: 假设您不想在要监视的所有PC上安装代理,那么最好的办法就是遵循以下过程:

  1. Look for any ARP Announce packet you receive. 查找您收到的任何ARP通告包。 Add the IP address to the list of devices to monitor on the network and alert on it coming up. 将IP地址添加到要在网络上监视的设备列表中,并在出现该警告时发出警报。
  2. Run a heartbeat on all IP addresses you have recorded. 对您记录的所有IP地址运行心跳。
    1. Perform a fast ping (Don't wait more than 10ms). 执行快速ping(不要等待超过10ms)。
    2. If it doesn't respond, alert and remove it from the monitor list. 如果它没有响应,请发出警报并将其从监视器列表中删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM