如何在Windows中使用.net测量带宽? [英] How can I measure bandwidth using .net in windows?

查看:96
本文介绍了如何在Windows中使用.net测量带宽?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想测量Windows系统中不同用户的带宽使用情况. Windows服务器使多个用户可以一次访问该服务器.那么,有什么方法可以衡量每个用户的带宽使用情况吗?

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!

推荐答案

Kim已经说过了,我也同意这是一个最有趣的问题,我会花两分钱来理解图片. br/> 首先,我想让您为我们澄清一下:带宽测量的要求有多严格?我需要详细说明如何看待这个小细节.测量真实带宽使用情况将涉及在指定的时间间隔内跟踪所有用户的所有当前传输.为了具有一些合理的更新间隔,测量间隔将必须是特定的TBD长度.在这样的时间间隔内计算所有传输的大小并非易事,因为有些传输将在测量间隔开始之前开始,而有些传输将在测量间隔结束之后结束.

这意味着弄清楚在该时间间隔内实际传输了多少数据是非常复杂的.为什么,我现在听到您说的是,为什么我不只是在每个用户的时间间隔内对其进行测量,以便所有传输都将在该时间间隔内开始和结束?

原因是双重的:
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. 一个用户可以进行许多并行数据传输,因此测量间隔甚至可能必须延长到整个会话周期.
  2. 第二个原因是测量值固定所有用户的时间间隔将为您提供更好的统计信息.只有在一个相同的时间间隔内测量所有用户传输,才能正确给出所有用户的总带宽测量.


值得考虑的第二点是您如何精确定义用户?用您的术语来说,用户是使用Windows帐户与您的服务器建立连接的客户端吗?还是仅仅是由其IP标识的客户端PC.再说一次,您可能正在谈论正在使用服务器的某些应用程序.

请更改您的问题以反映您的确切要求.

最好的问候,

-MRB


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


利用 ^ ]

Win32类 [有关WMI的一些文章 [ ^ ]在CodeProject上.

最好的问候
Espen Harlinn
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


如果要测量LAN上的所有带宽,则必须以某种方式从支持这种监视类型且正在提供服务的盒子(路由器)中获取信息.作为您局域网访问Internet的网关.您可以通过简单地使用WebClient对象登录到路由器/网关框中并分析返回的HTML来做到这一点(假设所述框/路由器具有Web界面).

如果只想在运行的计算机上使用它,则可以按照Espen的建议使用WMI.
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.


这篇关于如何在Windows中使用.net测量带宽?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆