Official repository - Fully managed, cross platform (Windows, Mac, Linux) .NET library for capturing packets
Fully managed, cross platform (Windows, Mac, Linux) .NET library for capturing packets from live and file based devices
The official SharpPcap repository.
For packet dissection and creation, see Packet.Net.
On Linux, support for libpcap
On Windows, support for:
On all platforms:
NativeLibrary support
.NET Core 3 and .NET Framework support
See the Examples folder for a range of full example projects using SharpPcap
var devices = CaptureDeviceList.Instance;
foreach (var dev in devices)
Console.WriteLine("{0}\n", dev.ToString());
void Device_OnPacketArrival(object s, PacketCapture e)
{
Console.WriteLine(e.Packet);
}
using var device = LibPcapLiveDeviceList.Instance[0];
device.Open();
device.OnPacketArrival += Device_OnPacketArrival;
device.StartCapture();
void Device_OnPacketArrival(object s, PacketCapture e)
{
Console.WriteLine(e.Packet);
}
using var device = new CaptureFileReaderDevice("filename.pcap");
device.Open();
device.OnPacketArrival += Device_OnPacketArrival;
device.Capture();
using var device = new CaptureFileWriterDevice("somefilename.pcap", System.IO.FileMode.Open);
var bytes = new byte[] { 1, 2, 3, 4 };
device.Write(bytes);
We have support for a number of CI systems for a few reasons:
SharpPcap is released via nuget
SharpPcap is where it is today because of a number of developers who have provided improvements and fixes and users that have provided helpful feedback through issues and feature requests.
We are especially appreciative of a number of projects we build upon (as SharpPcap is a C# wrapper):
We hope that you'll find the 6.x api to be cleaner and easier to use.
6.0 brings a number of cleanups that have resulted in API breakage for 5.x users.
To aid with the migration from 5.x to 6.0 here is a list of some of the changes you'll have to make to your SharpPcap usage.
The examples are also a great resource as they show working examples using the latest API.