8

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.

Joseph Lisee
  • 3,439
  • 26
  • 21

2 Answers2

5

This article may be useful:

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

Brian McFarland
  • 9,052
  • 6
  • 38
  • 56
  • 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. – Joseph Lisee Sep 16 '11 at 20:52
3

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.

Steve-o
  • 12,678
  • 2
  • 41
  • 60
  • That would definitely help, but unfortunately I am running a very old kernel (2.6.27), so I cannot use that. – Joseph Lisee Sep 26 '11 at 22:01
  • 1
    You can patch it in, I did for [2.6.24](http://code.google.com/p/openpgm/downloads/detail?name=linux-image-2.6.24-26-server_2.6.24-26.64_amd64.deb&can=4&q=), but admin overheads, etc. – Steve-o Sep 27 '11 at 15:18
  • 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? – Joseph Lisee Sep 27 '11 at 16:41
  • Still have the [patch](http://code.google.com/p/openpgm/downloads/detail?name=linux-2.6.24-recvmmsg.patch&can=4&q=#makechanges) too, I took it from the LKML post. – Steve-o Sep 27 '11 at 16:49