运行于windows平台,使用图形图像界面进行交互,界面风格良好,操作简单快捷。本软件依靠SharpPcap插件,这个是一个.NET 环境下的网络包捕获框架,基于著名的 pcap/WinPcap 库开发。private void loadDevice()
{
try
{
// 获取网卡方法
foreach (var i in CaptureDeviceList.Instance)
{
comDeviceList.Items.Add(i.Description); //在combox中添加
}
if (comDeviceList.Items.Count > 0)
{
comDeviceList.SelectedIndex = 0;//自动选中第一个
}
else
{
MessageBox.Show("没有发现网卡!");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
}
//选择网卡
private void comDeviceList_SelectedIndexChanged(object sender, EventArgs e)
{
device = CaptureDeviceList.Instance[comDeviceList.SelectedIndex];
}
/// <summary>
/// 启动网卡
/// </summary>
private void Start()
{
if (device == null || device.Started)
return;
bufferList = new List<RawCapture>();
Clear();//清理原有的数据
isStartAnalyzer = true;
StartAnalyzer();//启动分析线程
try
{
device.OnPacketArrival = new PacketArrivalEventHandler(device_OnPacketArrival);
//默认使用混杂模式,超时 1000
device.Open(devMode, readTimeOut);
device.Filter = comFilter.Text;
/*****zhaoym*******/
//string filter = "ip and tcp";
//device.Filter = filter;
/*****zhaoym*******/
device.StartCapture();
UIConfig(true);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
UIConfig(false);
}
}
评论