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