tag:blogger.com,1999:blog-8406272111392859047.post6461904767848298995..comments2024-01-25T20:07:43.330-08:00Comments on Linux Unleashed: Raw socket, Packet socket and Zero copy networking in Linuxyusuf@linuxhttp://www.blogger.com/profile/11945824423731733759noreply@blogger.comBlogger14125tag:blogger.com,1999:blog-8406272111392859047.post-85179921114592455322018-02-02T10:46:39.462-08:002018-02-02T10:46:39.462-08:00Thanks alot Yusuf, really the expalnation are very...Thanks alot Yusuf, really the expalnation are very crystal clearAnonymoushttps://www.blogger.com/profile/10936020221167250415noreply@blogger.comtag:blogger.com,1999:blog-8406272111392859047.post-46776069469472790442016-11-08T03:53:32.328-08:002016-11-08T03:53:32.328-08:00Hey Yusuf, Thanks for this amazing article. Helped...Hey Yusuf, Thanks for this amazing article. Helped me understand a lot of stuff. geek_jihttps://www.blogger.com/profile/07840940206690818190noreply@blogger.comtag:blogger.com,1999:blog-8406272111392859047.post-69697018201795557952016-03-22T11:53:40.717-07:002016-03-22T11:53:40.717-07:00I have worked on PF_RING for quite sometime as par...I have worked on PF_RING for quite sometime as part of network monitoring solutions. At the time, was not aware that AF_PACKET existed for the same purpose that almost seems to provide the same functionality as PF_RING.<br /><br />There are a couple of doubts however:<br />1. Are there any test results to prove which one is better in performance ? Assume PACKET_MMAP is enabled<br />2. To use PACKET_MMAP, kernel has to be compiled with this flag. PF_RING does not require a kernel compile, just a kernel module compile. That makes it&#39;s more easy to use than AF_PACKET. Any drawback though ?<br />3. Setting BPF filters in PF_RING was simple, just enter the string containing the BPF expression and call the API. In AF_PACKET seems more complex to do<br /><br /><br /><br /><br />Athif Abdul Azizhttps://www.blogger.com/profile/04162991784332223445noreply@blogger.comtag:blogger.com,1999:blog-8406272111392859047.post-8906976824232389722016-03-08T01:40:34.242-08:002016-03-08T01:40:34.242-08:00I want zero copy code any one have it ?? I want zero copy code any one have it ??<br />Anonymoushttps://www.blogger.com/profile/12302569527748723239noreply@blogger.comtag:blogger.com,1999:blog-8406272111392859047.post-52896783332459009072014-03-07T11:17:32.092-08:002014-03-07T11:17:32.092-08:00Nice post and really informative. Is there any way...Nice post and really informative. Is there any way to filter pf_packets? Perhaps ebtables or is it a fact that packet socket cant be filtered at all?Anonymoushttps://www.blogger.com/profile/14567243199017733558noreply@blogger.comtag:blogger.com,1999:blog-8406272111392859047.post-73393076492306263312013-08-15T13:14:18.990-07:002013-08-15T13:14:18.990-07:00What&#39;s about joins to specific multicast group...What&#39;s about joins to specific multicast groups?<br />I have tried this (setsockopt() succeeds) but no joins established.<br /><br />Can you share your experience?<br /><br />Thanks in advance.<br />RegardsAnonymoushttps://www.blogger.com/profile/04194716468624506014noreply@blogger.comtag:blogger.com,1999:blog-8406272111392859047.post-78276325727157095902013-07-21T09:51:11.507-07:002013-07-21T09:51:11.507-07:00hi this is a nice article...i am in need of help i...hi this is a nice article...i am in need of help in designing a zero copy ftp client and server using C in linuxjovidsilvahttps://www.blogger.com/profile/10799001372794743302noreply@blogger.comtag:blogger.com,1999:blog-8406272111392859047.post-79116783082863784632013-07-04T00:45:09.265-07:002013-07-04T00:45:09.265-07:00Excellent article. Thanks. Excellent article. Thanks.<br />Anandhttps://www.blogger.com/profile/00704835243197514149noreply@blogger.comtag:blogger.com,1999:blog-8406272111392859047.post-91737847546016988902013-06-04T00:46:43.178-07:002013-06-04T00:46:43.178-07:00Great article! Thanks for posting it... However, ...Great article! Thanks for posting it...<br /><br />However, I have a big issue when trying to implement a zero-copy socket following the instructions that you provide. The problem comes when I try to call twice to &quot;setsockopt()&quot; using the same socket, in order to get, with the first call, access to the TX_RING and, with the second one, access to the RX_RING (or viceversa). The first call to setsockopt() always works fine (either for accessing the TX_RING or the RX_RING), but the second call to setsockopt() always returns an error (-16 in accordance with perror(), i.e., EBUSY kernel signal). I could access both RINGS using TWO DIFFERENT SOCKETS, one for TX_RING and a different one for RX_RING.<br /><br />Is this the normal approach or am I doing anything wrong?Anonymoushttps://www.blogger.com/profile/02778212182471607516noreply@blogger.comtag:blogger.com,1999:blog-8406272111392859047.post-9229735977752808962011-02-18T07:02:20.771-08:002011-02-18T07:02:20.771-08:00I m trying to implement a very light weight protoc...I m trying to implement a very light weight protocol for transferring files between nodes in a cluster system.<br />I m using Zero copy concept as described above. The problem is that i m facing packet losses. I just want to add reliability to it without using any retransmission scheme. Is it Possible??<br /><br />I have tried to map a larger buffer on receiver side to prevent packet loss..<br />Please HELP!!!!<br /><br />ThanksUnknownhttps://www.blogger.com/profile/10513992207682436941noreply@blogger.comtag:blogger.com,1999:blog-8406272111392859047.post-18373902798984604132011-02-02T02:30:45.401-08:002011-02-02T02:30:45.401-08:00Steven sorry for very late reply, Yes PF_RING used...Steven sorry for very late reply, Yes PF_RING used for so called Zero Copy :-)yusuf@linuxhttps://www.blogger.com/profile/11945824423731733759noreply@blogger.comtag:blogger.com,1999:blog-8406272111392859047.post-85654343141119914582010-12-23T17:47:42.251-08:002010-12-23T17:47:42.251-08:00Great Article! In reference to Zero Copy, is this...Great Article!<br /><br />In reference to Zero Copy, is this what is used by PF_RING?Unknownhttps://www.blogger.com/profile/05144268656455119928noreply@blogger.comtag:blogger.com,1999:blog-8406272111392859047.post-58252239985959519392010-12-06T08:18:26.022-08:002010-12-06T08:18:26.022-08:00HI Jeff, Thanks for pointing this out, Yes you ar...HI Jeff,<br /><br />Thanks for pointing this out, Yes you are right inside the kernel its not zero copy and even if the packet can be dma directly to skb, still it requires 1 copy to pkt_rx_ring, but i wrote this article from user point of view ,for users the most time consuming copy is from the kernel to user memory and it is the major bottleneck for real-time protocols at application layer, With this feature we avoid this most expensive copy and that&#39;s the reason i call it zero copy.yusuf@linuxhttps://www.blogger.com/profile/11945824423731733759noreply@blogger.comtag:blogger.com,1999:blog-8406272111392859047.post-38849916728343113622010-12-04T18:59:20.894-08:002010-12-04T18:59:20.894-08:00Regarding zero-copy, it&#39;s not. PF_PACKET is d...Regarding zero-copy, it&#39;s not.<br /><br />PF_PACKET is designed for more efficient bandwidth handling in network sniffers by removing the need for vigorous read/write system calls (as you noted). It works by installing an *additional* protocol handler on target network devices, meaning data packets will also be delivered to any other existing protocol handler (ETH_P_IP aka PF_INET) sockets in other applications (security issue). Furthermore, the NIC driver is unaware of the PF_PACKET framework and the kernel doesn&#39;t abstract skb memory allocation enough that the driver can DMA data directly into the PACKET_RX_RING. The NIC just allocates a random skb (and possibly DMAs data to it to avoid a copy), then passes the skb to the protocol handlers. If you review the PF_PACKET protocol handler implementation when a PACKET_RX_RING is installed, specifically net/packet/af_packet.c:tpacket_rcv(), you will notice that the protocol handler uses skb_copy_bits() to *copy* the data from the NIC allocated skb to the PACKET_RX_RING.<br /><br />In order to achieve true zero copy using PF_PACKET, the NIC driver would need to be able to allocate skb&#39;s where the data segment was part of the PACKET_RX_RING naturally. It&#39;s probably not worth the effort to use DMA to copy an *already* allocated skb to the ring because it would inject latency into a framework designed for efficient sniffing, doing more harm than good.Jeff Venable, Sr.https://www.blogger.com/profile/03114605162292966231noreply@blogger.com