public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* is CONFIG_PACKET_MMAP always a win?
@ 2002-02-22  1:51 Dan Kegel
  2002-02-22  2:33 ` Alan Cox
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Dan Kegel @ 2002-02-22  1:51 UTC (permalink / raw)
  To: linux-kernel@vger.kernel.org; +Cc: Zach Brown

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2002-02-23  0:11 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-02-22  1:51 is CONFIG_PACKET_MMAP always a win? Dan Kegel
2002-02-22  2:33 ` Alan Cox
2002-02-22  5:59 ` David S. Miller
2002-02-22  6:45   ` Ben Greear
2002-02-22  8:37     ` Gianni Tedesco
2002-02-22  7:04   ` Dan Kegel
2002-02-22 14:04     ` Maciej W. Rozycki
2002-02-22 18:09 ` Jamie Lokier
2002-02-22 18:40   ` Alan Cox
2002-02-22 19:04     ` Jamie Lokier
2002-02-22 19:57       ` Alan Cox
2002-02-22 21:44         ` Mike Fedyk
2002-02-23  0:24           ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox