C#获得网络连接信息 IPGlobalProperties
原文:
C#获得网络连接信息 IPGlobalProperties
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄
IPGlobalProperties 提供有关本地计算机的网络连接的信息。
SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。此类提供有关本地计算机的网络接口和网络连接的配置和统计信息 可以获取本机TCP UDP 丢包 发包等数据。
此类提供的信息与 IP Helper API 函数提供的信息相似。有关 IP Helper 的信息,请参见 MSDN Library 中的文档。
1 //得到本机Internet协议IPV4的统计数据; 2 IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); 3 IPGlobalStatistics ipstat = properties.GetIPv4GlobalStatistics(); 4 Console.WriteLine(" Inbound Packet Data:"); 5 Console.WriteLine(" Received ............................ : {0}",ipstat.ReceivedPackets); 6 Console.WriteLine(" Forwarded ........................... : {0}",ipstat.ReceivedPacketsForwarded); 7 Console.WriteLine(" Delivered ........................... : {0}",ipstat.ReceivedPacketsDelivered); 8 Console.WriteLine(" Discarded ........................... : {0}",ipstat.ReceivedPacketsDiscarded);
https://msdn.microsoft.com/zh-cn/library/system.net.networkinformation.ipglobalproperties%28v=vs.110%29.aspx

更多精彩