views:

96

answers:

3

Hi

I'm currently working on a .NET Cybercafe management program and would like to calculate the amount of data downloaded from the Internet by each computer in the Cybercafe, since users have to pay for their download amount.

I believe there has to be some sort of API in Windows to give me this. Where should I look?

Thanks everyone.

+1  A: 

I'd use some built for purpose solution. Google 'cybercafe management software' - there are tons of results:

e.g.: www.handycafe.com/

UpTheCreek
Yup, the question as phrased is proggramming-related, but _it shouldn't have been_.
MSalters
Of course, he might be trying to create a cybercafe management system for profit, in which case my answer isn't very helpful! (appart from perhaps highligting the fact that it's a crowded market) But if he's trying to run a cybercafe (and create his own solution for it) then that's how I'd go.
UpTheCreek
There are many clues in my question suggesting I'm 'creating' a Cybercafe management system.
TheAgent
+2  A: 

I just found System.Net.NetworkInformation namespace and wrote following code:

NetworkInterface[] networkInterfaces = 
    NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface ni in networkInterfaces)
{
    IPv4InterfaceStatistics stats = ni.GetIPv4Statistics();
    IPInterfaceProperties props = ni.GetIPProperties();
    Console.WriteLine("{0} ({1:#,##0.00}Mb/s, {2})",
        ni.Name, ni.Speed / 1024D / 1024D, ni.OperationalStatus);
    Console.WriteLine("\t{0}", ni.Description);

    Console.WriteLine("\t{0:#,##0.00}Mb sent, {1:#,##0.00}Mb received",
        stats.BytesSent / 1024D / 1024D, stats.BytesReceived / 1024D / 1024D);
    Console.WriteLine();
}

I got this output:

Local Area Connection 2 (953,67Mb/s, Up)
        Realtek RTL8169/8110 Family PCI Gigabit Ethernet NIC (NDIS 6.0)
        1.906,92Mb sent, 483,77Mb received

Local Area Connection 3 (9,54Mb/s, Down)
        D-Link DFE-520TX PCI Fast Ethernet Adapter
        0,00Mb sent, 0,00Mb received

Loopback Pseudo-Interface 1 (1.024,00Mb/s, Up)
        Software Loopback Interface 1
        0,00Mb sent, 0,00Mb received

HTH

Rubens Farias
This is very good; however, is there a way I can differentiate data sent and received from the Internet and local network traffic?
TheAgent
+1  A: 

You can also read the performance counters on the system. See PerformanceCounter class in .NET. For a list of available performance counters on your machine. Start->Run Perfmon -> Do "Add Counters" to see the ones available.

RichAmberale