• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Measuring latency
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Measuring latency


  • Subject: Re: Measuring latency
  • From: Peter Sichel <email@hidden>
  • Date: Mon, 20 Oct 2008 16:50:14 -0400

On Oct 19, 2008, at 2:22 AM, Liwei wrote:

I need to have a way to measure latency in my application. My idea is
to send a "ping" message, take note of the current time and when the
return message arrives, find out how much time has elapsed to get the
round trip time and divide by two. This may not be terribly accurate
but should be sufficient for my use.

In my experience,

  gettimeofday(&tp, &tzp);

works pretty well and is the underlying UNIX standard which makes
it convenient for comparing to other system references.

A bigger issue is distinguishing the round trip time of your
ping response versus the latency of when your process gets scheduled.
To resolve this you'll need to use the SO_TIMESTAMP option on your
socket and read the kernel timestamp of when the packet arrived as
ancillary data.  The BSD kernel uses the same timeval structure
as gettimeofday().

This is covered in Steven's "UNIX Network Programming" (and others).

- Peter Sichel
  Sustainable Softworks


_______________________________________________ Do not post admin requests to the list. They will be ignored. Macnetworkprog mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Measuring latency
      • From: Quinn <email@hidden>
References: 
 >Measuring latency (From: Liwei <email@hidden>)

  • Prev by Date: Not listen to your own broadcast
  • Next by Date: CFNetwork isn't sending If-None-Match: headers
  • Previous by thread: Re: Measuring latency
  • Next by thread: Re: Measuring latency
  • Index(es):
    • Date
    • Thread