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
Here's a couple of possibilities:
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...
You could cheat this easily:
What do you think?
Hope this helps, Best regards, Tom.
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.
Some possibilities:
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.