is CONFIG_PACKET_MMAP always a win?

From: Dan Kegel (dank@kegel.com)
Date: Thu Feb 21 2002 - 20:51:20 EST


Newbie gig-ethernet question here.
I'm helping somebody implement a program that needs to process
raw packets as close to wire rate as is possible. We're
using kernel 2.4.16 or so.

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/



This archive was generated by hypermail 2b29 : Sat Feb 23 2002 - 21:00:38 EST