Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pcap.net vs Sharppcap

I just want to listen a network device, capture packets and write the packets to a dummy file. Also i need to filter packets while listening so ill only write packets which passes the filter. I need to do these on .net c#. These are my requirements. So which one should i use? High transfer rate and minimum packet loss is really important. Thanks for reading.

like image 854
Emre Erisgen Avatar asked Jul 11 '11 13:07

Emre Erisgen


People also ask

What is SharpPcap?

SharpPcap is a cross-platform(Windows, Mac, Linux) packet capture framework for the . NET environment. It provides an API for capturing, injecting, analyzing and building packets using any . NET language such as C# and VB.NET. Product.

What is the value of pcap?

PCAP is always a valuable resource to analyze any file and monitor the network traffic. Packet collection is a tool which will allow you to collect the network traffic and translate the format in which human can read it. There are uncountable reasons behind PCAP to use the monitor network.

What is the purpose of pcap library?

The packet capture library (pcap) is a portable framework for low-level network monitoring that uses the standard pcap format. The pcap library comprises multiple applications, including those for network statistics collection, security monitoring, and network debugging.


2 Answers

As the author of SharpPcap I can say that you'll be able to perform all of those operations with the library. Performance was a critical design goal.

Packet.Net has a range of packets that it can parse and is the library bundled along with SharpPcap for packet dissection and generation. It's architecture does lazy evaluation anywhere it is possible in order to be as fast as possible.

Performance is tricky, especially because network packet capture is often a lower priority task for an operating system. The faster your application handles the packet the more packets can be handled without drops. I've been able to capture 3MB/s of packets without any drops. I haven't tried it at higher data rates or written extensive tests to generate and capture data in order to evaluate performance. Tests and real world results are welcome data points to be added to the documentation and website though.

like image 116
Chris Morgan Avatar answered Sep 21 '22 00:09

Chris Morgan


The entire functionality is available in Pcap.Net.

Pcap.Net uses C++/CLI to wrap WinPcap, which is considered more efficient than PInvoke.

The packet library in Pcap.Net is quite big and complex packets can be parsed and created. This includes recursive layers like IP over IP. Parsing of each layer is done lazily and only when you need it.

For your needs, I see only benefits of using Pcap.Net over SharpPcap.

like image 29
brickner Avatar answered Sep 20 '22 00:09

brickner