Re: zero-copy udp

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Dec 3, 2007, at 6:08 PM, Stephen Hemminger wrote:

Yes, doing UDP in user space is trivial.

I agree, implementing UDP is easy.


Also I'm unclear how this gets rid of the buffer copy between the kernel and user
space.

It hands you the data direct from the kernel in mmap ring.
By mmap I'm assuming you mean a memory mapped file. I'm unclear how that
helps.
You can access data directly from receive ring.

Ok, I think I found the documentation on what you are referring to:
http://pusa.uv.es/~ulisses/packet_mmap/

So it looks like I can use setsockkkopt to create a ring buffer to my specifications. Then I can mmap the buffer into user space (that was a big surprise to me because
I thought mmap was only for files)
For receiving I check tpacket_hdr.tpstatus at the start of each frame for TP_STATUS_USER
which lets me know that the packet is ready for reading.
To indicate that a frame is available for receiving I clear that same status field.

This all sounds awesome. I was afraid if I had to implement this myself I would have to do it as a kernel module. So being able to stay in user space makes me very happy. :-)

WRITES
=======
However, it is unclear if this mechanism works for writes. I suppose it isn't really required if I'm building the entire packet as long as there is a way to know when the tx is done
so I know that the tx buffer is available for reuse.


ARP
====
Am I responsible for getting the MAC destination address of the packets I'm sending? Since PF_PACKET isn't an IPv4 packet I'm assuming it isn't going to be done
for me automatically.
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux