PcapPlusPlus
PcapPlusPlus copied to clipboard
RawPacketsVector concurrent
Hi. I would like to thank you for this nice library, it's much more simpler and C++ish than npcap or libpcap.
I would like to ask a question. Is there any way of making the Async capture with a vector thread concurrent without changing the library code?
thanks for the kind words :)
Could you please clarify your question? what do you mean by async capture with a vector thread?
Sorry. What I meant is if there is a way of making "Asynchronous packet capture using a packet list (vector)" thread safe.
I want to capture packets and process them at the same time (without stopping the capture). It would be nicer if I can process a bunch of packets at the same time instead of processing one by one. Hence, I would like to use the "Asynchronous packet capture using a packet list (vector)" capture mode of your library.
That being said, I have (at least) two threads trying to use the same pcpp::RawPacketsVector, so I was wondering if there is a way of making it thread safe. Or do you have any other suggestion?
Thanks for clarifying your question. If I understand your ask, you're currently using the API:
PcapLiveDevice::startCapture(RawPacketVector& capturedPacketsVector)
And you're looking for a way to start using the packets in the RawPacketVector
before stopping the capture.
Unfortunately RawPacketVector
(which is based on std::vector
) is not thread safe so this may not work. But it's should be pretty easy to make it thread safe by adding a locking mechanism to that class. Please let me know what you think
Thanks for your reply. I'll work on that.
Thanks. Please create a PR once you're done and I'll review and merge it
hi @KevinSmild please let me know if you have the time to work on this
@gx740 what do you think about this?
@seladb If it helps, i want to work on this issue and create PR if done.
Sure @jafar75 you're more than welcome! Please go for it, thank you!
To be honest, I don't think this is something worth investigating. I'll close this issue