I want to get statistics about sent and received packet counts (IP level : including TCP, UDP, etc) of a network card.
How can I query that information from windows?
I want to get statistics about sent and received packet counts (IP level : including TCP, UDP, etc) of a network card.
How can I query that information from windows?
WMI.
Not easy to use from C#, but possible.
Documentation for the needed class is at
First you have
using System.Net.NetworkInformation;
Next you have:
var iFaceArr = NetworkInterface.GetAllNetworkInterfaces();
NetworkInterface iface = iFaceArr[0];
IPv4InterfaceStatistics iFaceStats = iface.GetIPv4Statistics();
Then you have these variables:
iFaceStats.UnicastPacketsReceived;
iFaceStats.UnicastPacketsSent;
iFaceStats.NonUnicastPacketsReceived;
iFaceStats.NonUnicastPacketsSent;
You can take a look at Pcap.Net.
Getting the list of Live Devices on the local host. Reading packets from Live Devices (Network Devices) and Offline Devices (Files) using the different WinPcap methods. Receiving statistics on the entire capture. Receiving statistics of packets instead of the full packets. Using different sampling methods. Applying Berkley Packet Filters. Sending packets to Live Devices directly or using WinPcap's send queues. Dumping packets to Pcap files. Using Enumerables to receive packets (and LINQ).
Note that winpcap driver will have to be installed on your system.