简体   繁体   中英

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
any head start for sth like that in 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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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