Monitoring data in/out of the computer via vb.net

后端 未结 6 1773
半阙折子戏
半阙折子戏 2021-01-16 20:29

I want to create a bandwidth meter for Windows using vb.net, but I cannot seem to find anything in the .net framework for monitoring the amount of data in or out. I want to

相关标签:
6条回答
  • 2021-01-16 20:31

    Here's a couple of possibilities:

    • WMI - http://msdn.microsoft.com/en-us/library/aa394340(VS.85).aspx
    • Performance Counters /Logs and Alerts - http://msdn.microsoft.com/en-us/library/bb509354(VS.85).aspx
    0 讨论(0)
  • 2021-01-16 20:33

    You need to go down to driver level and monitor your ethernet device and count up the bytes coming and out.

    It'll involve P/Invoke I'm pretty sure. Don't think it's that simple...

    0 讨论(0)
  • 2021-01-16 20:33

    You could cheat this easily:

    1. Create a process using cmd.exe
    2. Call the command `netstat -e 10' (for 10 seconds)
    3. Pipe the output back to your application as an input stream
    4. Parse the input stream
    5. If the user decides to quit the program send a ctrl-c break sequence to the process.

    What do you think?

    Hope this helps, Best regards, Tom.

    0 讨论(0)
  • 2021-01-16 20:42

    There are several performance counters that give you basic numbers on throughput on the network interface card. Start by taking a look at them with Perfmon.exe, you'll see their category, name and instance name. Those same numbers are available with the .NET PerformanceCounter class.

    Using them to measure bandwidth is a rather tricky, you are more likely to measure the bandwidth of the server you are talking to, combined with the dozen or so routers that pipe the IP message to your machine.

    0 讨论(0)
  • 2021-01-16 20:49

    Some possibilities:

    • WinPCap - Will not give you application, however
    • LSP - Loaded as a DLL into any process that uses Winsock. Gives you everyhting you would want to monitor traffic per-application, but is not simple to write.
    • WMI - Aggregate totals per network interface: http://msdn.microsoft.com/en-us/library/aa394293(VS.85).aspx
    0 讨论(0)
  • 2021-01-16 20:51

    Your best bet is to use performance counters or WMI and do sampling at a frequency that is comfortable for you. IF you are trying to get something similar to the byte counts on the network card properties those counters are in the performance counter set.

    If you are trying to also measure all devices (USB, etc) you will probably need to write your own customer drivers to intercept data transfer events.

    0 讨论(0)
提交回复
热议问题