Che Koi
Che Koi

Reputation: 51

internet usage in every application

i would like to ask how can i get the internet amount that being used by some application like streaming and etc. i would like to make a program using in C# and i don't how can i start it.... give some advice thanks

Upvotes: 4

Views: 2438

Answers (3)

Phill
Phill

Reputation: 1320

As a starting point I'd look at the WinSock API. You may find a way of pulling traffic information on a per process basis. If you want to see total network usage, I'd use the Performance Monitoring tools. I found this example from a 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);
      }
}

Upvotes: 3

Anton Tykhyy
Anton Tykhyy

Reputation: 20066

To the best of my knowledge, there exists no standard method to measure network bandwidth per-application. The most you can get with standard means is essentially what netstat and perfmon show. The only way to calculate per-application metrics is to write an NDIS filter driver, or use an existing filter driver such as WinPcap. But both ways you'll have to install a driver on every target machine.

Upvotes: 1

tzup
tzup

Reputation: 3604

Try this: How to calculate network bandwidth speed in c#

EDIT

Now that I understand the question better try looking at this other SO question

Upvotes: 0

Related Questions