Is zero-copy UDP packing receiving possibly on Linux?
Asked Answered
H

2

9

I would like to have UDP packets copied directly from the ethernet adapter into my userspace buffer

Some details on my setup:

I am receiving data from a pair of gigabit ethernet cameras. Combined I am receiving 28800 UDP packets per second (1 packet per line * 30FPS * 2 cameras * 480 lines). There is no way for me to switch to jumbo frames, and I am already looking into tuning driver level interrupts for reduced CPU utilization. What I am after here is reducing the number of times I am copying this ~40MB/s data stream.

This is the best source I have found on this, but I was hoping there was a more complete reference or proof that such an approach worked out in practice.

Harrisharrisburg answered 16/9, 2011 at 20:24 Comment(0)
N
6

This article may be useful:

http://yusufonlinux.blogspot.com/2010/11/data-link-access-and-zero-copy.html

Northman answered 16/9, 2011 at 20:42 Comment(1)
Thansk! That article looks to be pretty close. In comments it says that the kernel still performs a copy from the driver to the shared ring buffer. I will have to investigate to see if this actually reduces copies, compared to a standard recv call.Harrisharrisburg
K
4

Your best avenues are recvmmsg and increasing RX interrupt coalescing.

http://lwn.net/Articles/334532/

You can move lower and match how Wireshark/tcpdump operate but it becomes futile to attempt any serious processing above it having to decode everything yourself.

At only 30,000 packets per second I wouldn't worry too much about copying packets, those problems arise when dealing with 3,000,000 messages per second.

Koy answered 16/9, 2011 at 21:41 Comment(4)
That would definitely help, but unfortunately I am running a very old kernel (2.6.27), so I cannot use that.Harrisharrisburg
You can patch it in, I did for 2.6.24, but admin overheads, etc.Koy
Actually that might be possible, we already patch in support for a specific device, and changing just that one thing require much less verification time then changing the entire kernel. Which git changesets did you patch in?Harrisharrisburg
Still have the patch too, I took it from the LKML post.Koy

© 2022 - 2024 — McMap. All rights reserved.