Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7011245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:06:08+00:00 2026-05-27T22:06:08+00:00

Networking is my worst area in operating systems, so forgive me for asking perhaps

  • 0

Networking is my worst area in operating systems, so forgive me for asking perhaps an incomplete question. I’ve been reading about this for a few hours, but it’s kinda swimming in my head. (To me, I feel like chip design is easy compared to figuring out networking protocols.)

I have some networked services that communicate with each other via sockets. Specifically, the sockets are created with fd = socket(PF_INET, SOCK_STREAM, 0);, which automatically gets TCP/IP. I need this as the base case, because these services may be running on separate machines.

But for one project, we’re trying to squeeze all of them into an underpowered embedded ‘appliance’, based on an Atom Z530P, so it seems to me that the memory copy overhead is something we could optimize out. I’ve been reading about that here: data-link-access-and-zero-copy and Linux_packet_mmap and packet_mmap.

For this case, one would create the socket something like this: fd = socket(PF_PACKET, PF_RAW, 0);. And there’s a bunch of other stuff to do, like allocating ring buffers, mmapping them, associating them with the socket, etc. It looks like you’re restricted to using sendto and recvfrom in order to transmit data. As I understand it, since the socket is local, you don’t need a reliable “stream” type socket, so raw sockets is the appropriate interface, and I’m guessing that the ring buffer is used at page granularity, where each packet (or datagram) starts at a page boundary.

Before I spend a huge amount of time trying to investigate this further, I was hoping some helpful individuals might help me with some questions:

  • How much performance benefit should I expect to get here from zero-copy sockets? I think the last I checked, we were moving an maximum of like 40 MB/sec from one process to another and finally to the disk. In the most basic scenario, data moves from the capture process, to the one-to-many process (others can listen in on the stream), to the archiver process that writes to disk. That’s two hops not counting the disk and internal stuff.
  • Does Linux do any of this automatically, optimizing for processes running on the same machine?
  • In any case, I would have listening sockets in TCP ports. Can I use those to make connections between processes yet still be able to use zero-copy? In other words, can I use AF_INET with PF_PACKET?
  • Is PF_PACKET with SOCK_RAW the only valid configuration for zero-copy sockets?
  • Is there any good sample code out there that will use zero-copy with TCP/IP as a fallback?
  • What’s the simplest or best way to detect that the two processes are on the same machine? They know each other’s IP addresses, so I could just compare and use different code paths for each. Is there a simpler way to do this?
  • Can I use write() and read() on a packet-based socket, or are those only valid for streams? (Rewriting how connections are made would be simpler then rewriting ALL of the socket code.)
  • Am I over-complicating things and/or optimizing the wrong thing? OProfiler tells me that most CPU time is spent in two places: (1) zlib, and (2) the kernel, which I can’t profile since I’m using CentOS 6.2, which doesn’t provide a vmlinux. I assume the kernel time is a combination of idle time and data copying and not much else.

Thanks in advance for the help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:06:09+00:00Added an answer on May 27, 2026 at 10:06 pm

    Am I over-complicating things and/or optimizing the wrong thing?

    Possibly. Using PF_PACKET sockets is only for specialized stuff. You probably want to look into

    • sendfile(2)
    • splice(2)

    What’s the simplest or best way to detect that the two processes are
    on the same machine?

    Simply not “forgetting” this information.

    Does Linux do any of this automatically, optimizing for processes
    running on the same machine?

    No, you have to do it yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

some more networking problems. I stumbled into this question: Serialization/Deserialization of a struct to
I am learning Computer Networking this semester, on which I find it quite interesting
So far my networking code works fine, but I'm a bit worried about something
I am looking for networking designs and tricks specific to games. I know about
I run a social networking / blogging website ( http://www.obsidianportal.com ), and currently the
I have a networking Linux application which receives RTP streams from multiple destinations, does
Are there any c++ networking libs that are very useful and robust? and libs
When experiencing networking problems on client machines, I'd like to be able to run
I'm designing a networking framework which uses WSAEventSelect for asynchronous operations. I spawn one
Consider a typical social networking website, which has more or less the following models:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.