2011-02-14 81 views
4

我想問我怎麼能得到一些應用程序,如流媒體等使用的互聯網金額我想在C#中使用一個程序,我不怎麼開始它....給一些建議感謝互聯網在每個應用程序中的使用

+0

你的意思是你想測量給定應用程序的帶寬使用情況嗎? – 2011-02-14 13:36:18

回答

0

試試這個:How to calculate network bandwidth speed in c#

編輯

現在我明白這個問題最好嘗試尋找其他this SO質疑

+0

該文章指定了如何顯示整個計算機(或者網絡接口)的帶寬數據,而不是單個應用程序。 – 2011-02-14 13:41:39

3

作爲一個起點,我會看看WinSock API。您可能會找到一種按流程提取交通信息的方法。 如果您想查看整個網絡的使用情況,我會使用性能監控工具。我發現這個例子從一個web search

private static void ShowNetworkTraffic() 
{ 
    PerformanceCounterCategory performanceCounterCategory = new PerformanceCounterCategory("Network Interface"); 
    string instance = performanceCounterCategory.GetInstanceNames()[0]; // 1st NIC ! 
    PerformanceCounter performanceCounterSent = new PerformanceCounter("Network Interface", "Bytes Sent/sec", instance); 
    PerformanceCounter performanceCounterReceived = new PerformanceCounter("Network Interface", "Bytes Received/sec", instance); 

    for (int i = 0; i < 10; i++) 
    { 
     Console.WriteLine("bytes sent: {0}k\tbytes received: {1}k", performanceCounterSent.NextValue()/1024, performanceCounterReceived.NextValue()/1024); 
     Thread.Sleep(500); 
     } 
} 
1

據我所知,存在以測量每個應用程序的網絡帶寬的標準方法。用標準方法得到的最多的是netstatperfmon。計算每個應用程序度量標準的唯一方法是編寫NDIS篩選器驅動程序,或使用現有的篩選器驅動程序(如WinPcap)。但是這兩種方式都需要在每臺目標機器上安裝驅動程序。

相關問題