使用 C# 监控 Internet 连接
我想监控我的路由器以查看当前正在下载的内容以及启动它的应用程序/软件
,谁是执行此操作的用户
以及用户占用的下载速度
我获得了无线连接和路由器所需的所有凭据
在 C# 中是否有类似的想法?
想法
I want to monitor my router to see what is currently being downloaded
and what application/Software that initiate it
, who is the user
doing this and download speed
that user occupy
i got all credential needed for both my wireless connection and the router
any head start for sth like that in C#?
the idea
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先:您知道您的路由器可以做到这一点吗?我见过的大多数路由器都不具备这种级别的流量理解和管理能力。
如果您的路由器有,则通常可以通过以下两种方式之一来获取此类数据:
1) 通过 HTTP 接口(受密码保护)
或者
2) 通过 SNMP 接口
要检索适当的 HTTP URL,您只需像获取任何其他网页一样获取它即可。尝试类似:http://www.csharp-station.com/HowTo/HttpWebFetch。 ASPX
要检索 SNMP 设置,有很多选项;试试这个问题:What SNMP library for .NET make traps ,设置还是变得简单?
但是,很可能您的路由器实际上不会提供此信息。
因此,编辑:如果您的路由器不支持侧链,并且不支持 SNMP 或类似的统计信息,那么您不能在一般意义上执行此操作。
您可以启动一个 Linux 机器作为机器的网关,并使用 NAT 会话统计信息来监控这一点。实现此目的的方法是拥有两个网络接口(逻辑或物理),其中一个从调制解调器获取 IP,另一个是无线网络的默认网关。打开 IP 转发和伪装 (NAT) 以及无线网络端的 DHCP 服务器。现在,您可以使用 iptables 查看活动的 NAT 会话以及已传输的数据量。您还可以使用数据包过滤器来获取更具体的信息。
另外,如果您知道哪台计算机正在执行下载并且正在运行 Windows,则可以使用 WMI(“perfmon.exe”来绘制此图)来查看实际计算机上传输了多少数据。
First of all: Do you even know that your router can do this? Most routers I've seen do not have this level of traffic understanding and management.
If your router does, then there is one of two ways that such data is generally made available:
1) Through a HTTP interface (password protected)
or
2) Through an SNMP interface
To retrieve the appropriate HTTP URL, you simply get it as you would any other web page. Try something like: http://www.csharp-station.com/HowTo/HttpWebFetch.aspx
To retrieve the SNMP settings, there are many options; try this question: What SNMP library for .NET makes traps, sets or gets simple?
However, most likely, your router will not actually have this information available.
So, edit: If your router doesn't support side-chaining, and doesn't support SNMP or similar statistics, then you can't do this in the general sense.
You could spin up a Linux box as the gateway for the machines, and use NAT session statistics to monitor this. The way to do this is to have two network interfaces (logical or physical), one of which gets an IP from your modem, and the other which is the default gateway for the wireless network. Turn on IP forwarding and masquerading (NAT) as well as a DHCP server for the wireless network side. Now, you can use iptables to look at active NAT sessions and how much data has been transferred. You can also use packet filters for more specific information.
Also, if you know which machine is doing the downloading, and are running Windows, you can use WMI ("perfmon.exe" to plot this) to see how much data is being transfered on the actual machine.