监控过程中的网络使用? [英] Monitor a process's network usage?

查看:118
本文介绍了监控过程中的网络使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有在C#或C / C ++和放大器的方法; Win32的监视某一进程的网络使用(如果没有申请,而你明明建)?我想监视仅1过程像一个小时左右,然后返回通过仅处理中使用的字节数,例如LimeWire的例如

Is there a way in C# or C/C++ & Win32 to monitor a certain process's network usage (Without that application being built by you obviously)? I would like to monitor just 1 process for like an hour or so, then return the bytes used by only that process, such as limewire for example.

这可能吗?我知道,在Windows的netstat -e会告诉你发送/接收的字节总数,但这是所有进程。

Is it possible? I know netstat -e on windows will tell you total bytes sent/received, but that is for all processes.

编辑:如果我无法回报只是一个进程的使用,我怎样才能获得通过整个系统的发送/接收的字节数?与netstat显示器除了我只想整数。

edit: If i can't return just one processes usage, how can i get the bytes sent/received by the entire system? as netstat displays except i just want the integers.

例如:


netstat -e

                           Received            Sent

Bytes                    2111568926      1133174989
Unicast packets             3016480         2711006
Non-unicast packets            3122            1100
Discards                          0               0
Errors                            0               0
Unknown protocols                 0

我只是想获得2变量,如REC = 2111568926送= 1133174989

I just want to get 2 variables, like rec = 2111568926 and sent = 1133174989

推荐答案

这是可能的,但如果我没有记错,你必须创建一个网络驱动程序来过滤所有网络流量,比计算出哪个进程所创建的流

It's possible, but if I'm not mistaken you'll have to create a network driver to filter all network traffic and than figure out which process created the traffic.

微软有一个免费的应用程序为它所谓的 Microsoft网络监视器3.2 (<一个href=\"http://www.microsoft.com/downloads/details.aspx?FamilyID=f4db40af-1e08-4a21-a26b-ec2f4dc4190d&DisplayLang=en\"相对=nofollow>下载)。根据发行说明它也有一个API来使用。

Microsoft has an free application for it called Microsoft Network Monitor 3.2 (download). According to the release notes it also has an api to use.

网络监视器API:创建您自己的
  应用程序捕获,分析和
  分析网络流量!

Network Monitor API: Create your own applications that capture, parse and analyze network traffic!

这里是博客文章有关这些API的

在我看来,你应该使用这个API(或其他API,如WinPcap的)来过滤流量,而不是写自己的设备驱动程序。

In my opinion you should use this API (or another API such as WinPcap) to filter the traffic instead of writing your own device driver.

这篇关于监控过程中的网络使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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