What's the best way to retrieve raw packets from the kernel?
a) use libpcap
Overhead: a little bit worse than the best of any of the other options?
b) use af_packet, and call recvfrom or recvmsg myself for each packet
Overhead: one full memcpy of the packet body and one
system call per packet.
c) enable CONFIG_PACKET_MMAP, use PACKET_RX_RING, and read packets from an mmap'd ring buffer
Overhead: kernel does a full memcpy of the packet body to get it
into the ring buffer, and my program does another to get it out.
If I understand it right, b costs one memcpy and one recv, and c costs
two memcpys. Which one wins?
I guess I should benchmark these alternatives myself, but before I do,
does anyone know of a good place to look for this info? Maybe
I'm reinventing the wheel here.
Thanks,
Dan
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/