Re: Measuring latency
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