Boost logo

Boost Users :

Subject: [Boost-users] [asio] async udp socket latency
From: Andrew Hundt (athundt_at_[hidden])
Date: 2015-07-02 03:12:25


I'm having difficulty with latency when running an async asio udp socket. I
don't have the same problems with an identical application that uses
synchronous udp. I'm communicating with a physical device which permits a
maximum 5ms latency for each UDP packet, and I'm currently getting a
latency of 8ms with a std dev of 0.065ms which is surprisingly precise.

I'm on Mac OS X 10.10.4 with Xcode 6.3.2 (6D2105).

Here are some of the key details about this problem:

   - Sync UDP test program
      - works, staying under 5ms latency 100% of the time for over an hour
      - Code
         - main file KukaFRIClientDataTest.cpp
         <https://github.com/ahundt/grl/blob/master/test/KukaFRIClientDataTest.cpp>
         - UDP socket communication class KukaFriClientData.hpp
         <https://github.com/ahundt/grl/blob/master/include/grl/KukaFriClientData.hpp>
      - Key lines
         - calls socket.receive_from() then socket.send() at the lowest
         level.
         - receive_from call
         <https://github.com/ahundt/grl/blob/master/include/grl/KukaFriClientData.hpp#L161>
         - send call
         <https://github.com/ahundt/grl/blob/master/include/grl/KukaFriClientData.hpp#L175>

   - Async UDP test program
      - buggy, 8ms w/ 0.065 ms std dev, continuously high latency
      - Code
         - main file KukaFRITest.cpp
         <https://github.com/ahundt/grl/blob/master/test/KukaFRITest.cpp>
         - High level wrapper class KukaFRIThreadSeparator.hpp
         <https://github.com/ahundt/grl/blob/master/include/grl/KukaFRIThreadSeparator.hpp>
         - Low level wrapper class KukaFRI.hpp
         <https://github.com/ahundt/grl/blob/master/include/grl/KukaFRI.hpp>
         .
      - Key lines
         - calls socket_.async_receive_from() then that handler calls
         socket_.async_send_to(), which calls the final callback with the
         results.
         - async_receive_from call
         <https://github.com/ahundt/grl/blob/master/include/grl/KukaFRI.hpp#L374>
         - async_send_to_call
         <https://github.com/ahundt/grl/blob/master/include/grl/KukaFRI.hpp#L432>

Does anyone have insight into why this latency issue may be occurring in
the Async UDP version? Thanks.

Cheers!
Andrew Hundt



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net