PcapDotNet/Pcap.Net

Avoid the service's buffer

Closed this issue · 4 comments

berjk commented

Firstly hello to all,
There is my issue. When i try to capture a packet with count very fast, the system buffers it.
I use this method : communicator.ReceivePackets(64, PacketHandler); every time PacketHandler method receives packet, i process it and it is quite longer than receving process. So when PacketHandler method finishes its process, it gets the buffered packets from memory. What i want is getting current the data on ethernet. But i couldnt find a way to break buffer, this package should provide a flag to break buffering.

If you want change packet content before it reach application layer, try https://github.com/basil00/Divert https://github.com/TechnikEmpire/Divert.Net, there limitation that Divert not support change mac and vlan.

berjk commented

Actually i dont want to change content of any of packets. When communicator receives a packet, it calls my packet handler method. My handler method is little bit slow. When packets start to come very fast, my handler method gets old buffered data, not the new coming data. I want to avoid this issue. i want my method to take the new data on ethernet, not the ones on the queue.

Is it important to finish processing a packet before grabbing the next packet? Or, can you grab a packet while one is being processed?

You should process the packets fast.
You can put them in container quickly and handle the next packet.
Your slow processing should always take the latest packet inserted in the container instead of relying on Pcap.Net to bring it the latest packet.
Please ask questions using Pcap.Net Q&A Group.