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:
- Does anyone actually know how TCPView does it?
- How do I use GetPerTcpConnectionEStats for the TCP? Or can it even accomplish what I'm suggesting?
- Is there another known alternative that would work for UDP?
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.