<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Muhammad Ahmad on Medium]]></title>
        <description><![CDATA[Stories by Muhammad Ahmad on Medium]]></description>
        <link>https://medium.com/@muhammad.ahmad_64324?source=rss-dafd254cff67------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*b5-NJgcde6YFIHSQ</url>
            <title>Stories by Muhammad Ahmad on Medium</title>
            <link>https://medium.com/@muhammad.ahmad_64324?source=rss-dafd254cff67------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 09:23:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@muhammad.ahmad_64324/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A beginner’s guide to Solarflare TCPDirect]]></title>
            <link>https://medium.com/emumba/a-beginners-guide-to-solarflare-tcpdirect-1c590759d18c?source=rss-dafd254cff67------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c590759d18c</guid>
            <category><![CDATA[tcpdirect]]></category>
            <category><![CDATA[socket-programming]]></category>
            <category><![CDATA[solar-flare]]></category>
            <category><![CDATA[zocket]]></category>
            <dc:creator><![CDATA[Muhammad Ahmad]]></dc:creator>
            <pubDate>Fri, 08 May 2020 11:06:13 GMT</pubDate>
            <atom:updated>2020-05-08T11:06:13.100Z</atom:updated>
            <content:encoded><![CDATA[<p>For the past few months, our team has been working on reducing the overall latency of the TCP/IP stack. Solarflare’s OpenOnload based kernel bypass gives a significant performance boost over the kernel. Using that, we were able to achieve 1800ns UDP to TCP round trip with our application in it but this wasn’t enough. After some research, we found out that TCPDirect claims a further performance boost of around 300–350ns, so we decided to test it out. Although there is a manual available for TCPDirect, there isn’t any significant, easy to understand help available to port conventional sockets to TCPdirect “zockets”.</p><p>After a lot of exploration and experimentation, I have come out to a cheat sheet to convert a conventional socket-based application to TCPDirect’s “<em>zockets”.</em></p><h3>Initial Setup</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mgwD89_FeNkO1J0axfg4KQ.png" /><figcaption>Initial Setup</figcaption></figure><p>To get started with TCPDirect, you have to do the following initializations</p><ol><li>Add the required libraries.</li><li>Call<em> zf_init(). </em>It<em> </em>initializes the TCPDirect.</li><li>Set the optional properties of TCP/IP stack in the <em>“Attr” </em>structure e.g buffer size or interface. This attribute will be used in the next step and later on while initializing the zockets.</li><li>Allocate the stack. One stack can handle a maximum of 64 zockets. If you want to open more zockets you have to create more stacks.</li></ol><p>Unlike conventional UDP socket, which provides the leverage of sending and receiving UDP packets through the same socket, you must have two different zockets for sending and receiving in TCPDirect.</p><h3>UDP Receive</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fXXGTizN6K-H5-W3HneIYQ.png" /><figcaption>UDP Receive</figcaption></figure><p>To set up a receive zocket, you need to perform the following steps.</p><ol><li>Set up a UDP receive zocket using stack and attribute structures used in the initialization step.</li><li>Bind to the address you want to listen, here <em>ai_local</em> is <em>addrinfo</em> type structure.</li><li>Call <em>zf_reactor_perform()</em> to check if any packet is received.</li><li>Use <em>zfur_zc_recv()</em> to receive the packet, if the packet is available in the previous step.</li><li>As it is a zero-copy receive, free the <em>sk-buff</em> after utilizing the data.</li></ol><h3>UDP Send</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*boi8PHwg0BnqcF8qYJrYbQ.png" /><figcaption>UDP Send</figcaption></figure><p>To send a UDP packet, do the following steps</p><ol><li>Set up a UDP send zocket using stack and attribute structures used in the initialization step. Give remote and local addresses in <em>ai_local</em> and <em>ai_remote</em>, which are <em>addrinfo</em> type structures.</li><li>Send packet using <em>zfut_send_single()</em>.</li></ol><h3>TCP Send Receive</h3><p>Unlike UDP, the same zocket can be used to send and receive packets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nmkZQ-b30vINwk5TMOF3FQ.png" /></figure><ol><li>Set up a TCP zocket using stack and attribute structures used in the initialization step.</li><li>Connect to the remote server using <em>zft_connect, </em>here <em>ai_remote</em> is <em>addrinfo</em> type structure.</li><li>Send a packet using <em>zft_send_single().</em></li><li>Start listening to the port to receive packets.</li><li>Use <em>zftl_accept()</em> to check if a connection is accepted or not.</li><li>Frequently call <em>zf-reactor_perform()</em> to check for any received event or packet. This is a very critical function, as it also handles some non-user-visible events like sending the ACK or retransmitting the packet.</li><li>Use <em>zft_zc_rect() </em>to receive a packet.</li><li>As it is a zero-copy receive, free the <em>sk-buff</em> after utilizing the data.</li></ol><h3>Final words</h3><p>TCPDirect APIs are a bit different from the kernel APIs but they can be easily mapped. A small effort in changing them can result in a significant performance boost of about 300–350ns in your latency-critical application. Hopefully, this guide will be helpful to get you started with TCPDirect.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c590759d18c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/emumba/a-beginners-guide-to-solarflare-tcpdirect-1c590759d18c">A beginner’s guide to Solarflare TCPDirect</a> was originally published in <a href="https://medium.com/emumba">Emumba</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>