I need to determine per-process network usage statistics similar to what TCPView can do.
Example http://img513.imageshack.us/img513/861/6601f15814544055a590e26.png
So before you shoot me for posting a duplicate of this question, or this question, I would like to point out that neither of those have a thorough answer that could help me actually do this.
I've been doing research, and there are clearly many ways to list out active connections and their associated processes, whether this be with netstat or other windows API's like IpHlpAPI.dll.
Now, from what Google'ing I've done, I have not found much - except for these vague terms: GetPerTcpConnectionEStats and GetPerTcp6ConnectionEStats. Presumably for TCP over IPv4 and IPv6 respectively. Now where I was reading its supposedly able to do what I need to do. However, that still leaves out UDP. And those are also not available on XP systems, which TCPViewer works on.
I would be satisfied with using those for TCP, but the problem is, I can't seem to find any examples of how to use them from C#.
So I guess it all boils down to these few questions:
The whole point of this is to see the independent bandwidth usage of the processes themselves. Not calculate the total system bandwidth usage.
Thanks in advance for any and all answers.
I spent a bit of time trying to figure out how I'd do something similar (latency vs bandwidth) but have had to give up due to a lack of time to invest. I thought I'd add my findings here in the hope we eventually get an answer.
You'll obviously need to use PInvoke and I'm afraid the specifics are far beyond my experience with it.
This Wrapper Library on CodeProject uses AllocateAndGetTcpExTableFromStack which only works on Windows XP and Server 2003. It still doesn't get you bandwidth though sorry.
The closest information I could find as a starting point (for Vista/Server 2008 or newer) is an example on pinvoke.net for GetExtendedTcpTable.
The tool PInvoke Interop Assistant might help determine how to call the unmanaged code.
If I were to keep trying this I'd try to figure out the following:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With