我希望获得有关网卡的已发送和已接收数据包计数(IP级别:包括TCP,UDP等)的统计信息。
如何从Windows查询该信息?
答案 0 :(得分:0)
WMI。
不容易在C#中使用,但可能。
所需课程的文档位于
答案 1 :(得分:0)
首先你有
using System.Net.NetworkInformation;
接下来你有:
var iFaceArr = NetworkInterface.GetAllNetworkInterfaces();
NetworkInterface iface = iFaceArr[0];
IPv4InterfaceStatistics iFaceStats = iface.GetIPv4Statistics();
然后你有这些变量:
iFaceStats.UnicastPacketsReceived;
iFaceStats.UnicastPacketsSent;
iFaceStats.NonUnicastPacketsReceived;
iFaceStats.NonUnicastPacketsSent;
答案 2 :(得分:-1)
您可以查看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).
请注意,必须在您的系统上安装winpcap驱动程序。