.NET ez 2012-06-04
利用 .Net 抓取電腦的網路流量,程式碼如下:
using System; using System.Net.NetworkInformation; namespace Test { class Program { static void Main(string[] args) { while (true) { IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); IPGlobalStatistics ipstat = properties.GetIPv4GlobalStatistics(); Console.Clear(); Console.WriteLine("接收封包數:" + ipstat.ReceivedPackets); Console.WriteLine("轉發封包數:" + ipstat.ReceivedPacketsForwarded); Console.WriteLine("傳送封包數:" + ipstat.ReceivedPacketsDelivered); Console.WriteLine("丟棄封包數:" + ipstat.ReceivedPacketsDiscarded); System.Threading.Thread.Sleep(1000); } } } }
標籤: .NET
本文章網址:
https://www.ez2o.com/Blog/Post/csharp-Network-Traffic-NIC-Packets
https://www.ez2o.com/Blog/Post/177
https://www.ez2o.com/Blog/Post/csharp-Network-Traffic-NIC-Packets
https://www.ez2o.com/Blog/Post/177