Linux raw socket (layer2) - best strategy -
context:
I'm thinking about the best method of the process I'm packing nic to the app.
I have 4 processes running and Ethernet is receiving packets from NICT.
They run pf_packet sockets so they can get 2 layers.
The problem is that they all have to filter the packets.
There is no race conditions because the filtering port is done by. An app is interested in a unique port.
Question:
Is there any way to filter out all packets to avoid every app? Having a core for the filter and contacting the packet with the right app reduces the reference switch cost.
Is it possible to put a custom packet in a defined RX queue in accordance with custom ports? In this way my app will ensure that these packets are specially for them.
What's the best way?
If you do not want to use BPF and libpcap, then you might want to use the Linux socket filter It will filter the packet in the kernel space before handing over your packet sockets.
Use some syntax examples, BSD BPF man page or Google / duckduckgo
But I also suggest that, if your app performance is important, then you can use prototype and separate - To measure different options, Libpcap).
Comments
Post a Comment