lkml.org 
[lkml]   [2002]   [Feb]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectis CONFIG_PACKET_MMAP always a win?
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/

\
 
 \ /
  Last update: 2005-03-22 13:24    [W:0.072 / U:0.404 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site