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 6905935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:14:43+00:00 2026-05-27T08:14:43+00:00

I am reading a single data item from a UDP port. It’s essential that

  • 0

I am reading a single data item from a UDP port. It’s essential that this read be the lowest latency possible. At present I’m reading via the boost::asio library’s async_receive_from method. Does anyone know the kind of latency I will experience between the packet arriving at the network card, and the callback method being invoked in my user code?

Boost is a very good library, but quite generic, is there a lower latency alternative?

All opinions on writing low-latency UDP network programs are very welcome.

EDIT: Another question, is there a relatively feasible way to estimate the latency that I’m experiencing between NIC and user mode?

  • 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-27T08:14:44+00:00Added an answer on May 27, 2026 at 8:14 am

    Your latency will vary, but it will be far from the best you can get. Here are few things that will stand in your way to the better latency:

    Boost.ASIO

    1. It constantly allocates/deallocates memory to store “state” in order to invoke a callback function associated with your read operation.
    2. It does unnecessary mutex locking/unlocking in order to support a broken mix of async and sync approaches.
    3. The worst, it constantly adds and removes event descriptors from the underlying notification mechanism.

    All in all, asio is a good library for high-level application developers, but it comes with a big price tag and a lot of CPU cycle eating gremlins. Another alternative is libevent, it is a lot better, but still aims to support many notification mechanisms and be platform-independent. Nothing can beat native mechanisms, i.e. epoll.

    Other things

    1. UDP stack. It doesn’t do a very good job for latency sensitive applications. One of the most popular solutions is OpenOnload. It by-passes the stack and works directly with your NIC.
    2. Scheduler. By default, scheduler is optimized for throughput and not latency. You will have to tweak and tune your OS in order to make it latency oriented. Linux, for example, has a lot of “rt” patches for that purpose.
    3. Watch out not to sleep. Once your process is sleeping, you will never get a good wakeup latency compared to constantly burning CPU and waiting for a packet to arrive.
    4. Interference with other IRQs, processes etc.

    I cannot tell you exact numbers, but assuming that you won’t be getting a lot of traffic, using Boost and a regular Linux kernel, with a regular hardware, your latency will range somewhere between ~50 microseconds to ~100 milliseconds. It will improve a bit as you get more data, and after some point start dropping, and will always be ranging. I’d say that if you are OK with those numbers, don’t bother optimizing.

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

Sidebar

Related Questions

I am trying to solve this problem. I am reading data from csv fiile
I'm looking at solutions to a problem that involves reading keyed data from more
I know that reading from a single object across multiple threads is safe in
Is there a way of reading one single character from the user input? For
I am using a TStream to read binary data (thanks to this post: How
After reading this question I started to wonder: is it possible to have a
I'm looking into reading single bits from memory (RAM, harddisk). My understanding was, one
I want to verify that a generated class (single entity or collection) from an
I have a file mmap'd read-only/shared, with multiple threads/processes reading the data concurrently. A
I'm reading an XML file that looks like this: <?xml version=1.0 encoding=utf-8?> <VehicleList> <Vehicle>

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.