简体   繁体   English

使用C#监视Internet连接

[英]Monitor Internet Connection using 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 我想监视我的路由器,看看当前正在downloaded和应用是什么/是软件initiate it ,谁是user这样做的, download speed是用户占用我有需要我的无线连接和路由器都所有凭证
any head start for sth like that in C#? 在C#中有什么领先的机会吗?

the idea 这个主意

替代文字

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 1)通过HTTP接口(受密码保护)或2)通过SNMP接口

To retrieve the appropriate HTTP URL, you simply get it as you would any other web page. 要检索适当的HTTP URL,您只需像获取其他任何网页一样获取它即可。 Try something like: http://www.csharp-station.com/HowTo/HttpWebFetch.aspx To retrieve the SNMP settings, there are many options; 尝试使用类似的方法: http : //www.csharp-station.com/HowTo/HttpWebFetch.aspx要检索SNMP设置,有许多选项;请参阅第144页的『获取SNMP设置』。 try this question: What SNMP library for .NET makes traps, sets or gets simple? 尝试以下问题: .NET的哪个SNMP库使陷阱,设置或变得简单?

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. 因此,请编辑:如果您的路由器不支持侧链,并且不支持SNMP或类似的统计信息,那么一般来讲您就不能这样做。

You could spin up a Linux box as the gateway for the machines, and use NAT session statistics to monitor this. 您可以启动Linux机器作为计算机的网关,并使用NAT会话统计信息进行监视。 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. 这样做的方法是拥有两个网络接口(逻辑或物理),其中一个从调制解调器获取IP,另一个是无线网络的默认网关。 Turn on IP forwarding and masquerading (NAT) as well as a DHCP server for the wireless network side. 为无线网络端打开IP转发和伪装(NAT)以及DHCP服务器。 Now, you can use iptables to look at active NAT sessions and how much data has been transferred. 现在,您可以使用iptables查看活动的NAT会话以及已传输了多少数据。 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. 另外,如果您知道哪台计算机正在执行下载并正在运行Windows,则可以使用WMI(“ perfmon.exe”进行绘制)查看实际计算机上正在传输多少数据。

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

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