Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
4.67/5 (3 votes)
See more: , +
I want to measure the bandwidth usage of different users in a windows system. Windows server enables multiple users to access the server at a time. So is there a way I can measure the bandwidth usage on a per user basis?

Thanks in advance!
Posted
Updated 4-Jun-11 3:13am
v2
Comments
Kim Togo 4-Jun-11 5:27am    
Interesting question. My 5 for that.
rahuldas14 4-Jun-11 5:52am    
I need this for a project. Is there a way by which we can check the intercepted packets if they belong to a certain user?

Kim already said it and I do agree that this is a most interesting question and I will give my two cents as I perceive the picture.
First point I want you to clear for us: How strict is the requirement of bandwidth measurement? I need to elaborate on how I see this small detail. Measuring true bandwidth usage would involve keeping track of all current transfers of all users in a specified time interval. To have some reasonable update interval the measurement interval will have to be a certain TBD length. Counting the sizes of all transfers in such an interval is not trivial as some transmissions will have started before the start of the measurement interval and some transmissions will end after the measurement interval has already ended.

That means figuring out how much data was actually transfered during that time interval is quite convoluted. Why, I hear you say now, don't I just measure each user in his own time interval, so that all transmissions will start and end in that interval?

The reason is twofold:
  1. One user can have many parallel data transfers so it might even be possible that a measurement interval would have to extend to the whole session period.
  2. The second reason is that having a fixed measurement interval for all users will give you better statistics. The total bandwidth measurement for all users can only be given correctly if all user tranfers are measured during one and the same interval.

Second point worth thinking about is how exactly do you define user? Is user in your terminology a client that is using a connection to you server with his windows account? Or is it just the client PC identified by its IP. Then again you could be talking about certain applications that are using your server.

Please change your question to reflect your exact requirements.

Best regards,

-MRB
 
Share this answer
 
v4
Comments
Espen Harlinn 5-Jun-11 6:51am    
Good points, my 5
Manfred Rudolf Bihy 5-Jun-11 7:52am    
Thanks Espen!
Sergey Alexandrovich Kryukov 5-Jun-11 16:12pm    
Good points, my 5, too.
--SA
Kim Togo 17-Jun-11 2:07am    
Good answer. My 5+
You can get quite a lot of the information for Manfreds' solution be leveraging Windows Management Instrumentation[^]

The Win32 Classes[^] provides access to information about network adapters and performance counters.


You'll also find some articles about WMI[^] here on CodeProject.

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 5-Jun-11 16:12pm    
Good references, my 5. (I forgot to vote, just did it. Tricky problem, by the way.)
--SA
Espen Harlinn 7-Jun-11 11:00am    
Thank you, SAKryukov!
thatraja 10-Jun-11 2:15am    
Fortunately I found this, Thanks Espen, 5!
Espen Harlinn 10-Jun-11 8:31am    
Thank you, thatraja
Kim Togo 17-Jun-11 2:08am    
Good approach. My 5.
If you want to measure all bandwidth on the LAN, you'd have to somehow get the info from a box (router) that supports that type of monitoring and that is serving as your LAN's gateway to the internet. You could do this by simply using the WebClient object to log onto your router/gateway box and analyze the returned HTML (assuming said box/router has a web interface).

If you just want it for the machine you're on, you can use WMI as Espen has already suggested.
 
Share this answer
 
Comments
Espen Harlinn 5-Jun-11 9:46am    
WMI also works quite well when you want to access the information for other computers on the network. When you only want to work with the local computer you might prefer using the .Net API for the performance counters directly - as in this article: http://www.codeproject.com/KB/dotnet/perfcounter.aspx

While using http to rettrive the information from "intelligent" switches and routers works quite well - my 5 btw - there is also SNMP, and the option to use something like Net-SNMP http://www.net-snmp.org/
#realJSOP 5-Jun-11 10:18am    
I have a mixed topology and can't use WMI on the Linux or BSD boxes. For me, the best route is to try to get the info from a gateway/router if possible.
Espen Harlinn 5-Jun-11 16:35pm    
Fair enough, now as I understood OPs question, he was only looking at windows based computers; so I just wanted to point out that WMI allows him to access other computers too. Well, keep up the good work :)
Sergey Alexandrovich Kryukov 5-Jun-11 16:12pm    
Good advice, a 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900