工具:SharpPcap 4.2.0
vs工程:控制台应用程序
关于C#抓包,我只找到SharpPcap 这个dll,相关的资料不多,而且都是挺老的,所以就顺手记一下自己的代码,给有同样需求的人一个参考吧。
当然,代码可能存在问题,请见谅。
一、获取连接设备
// 获取连接列表
CaptureDeviceList devices = CaptureDeviceList.Instance;
// 无连接
if (devices.Count < 1)
{
Console.WriteLine(No devices were found on this machine);
return;