Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>On receiver data is being decoded and subtract with new <code>[NSDate date]</code></p> </blockquote> <p>That's the problem. It has nothing to do with the iOS version installed on the device: in general, if your timestamps are produced by different computers, you cannot subtract them, and expect any kind of precision to come out of it, because the device clocks are not synchronized enough to measure network latency, because of <a href="http://en.wikipedia.org/wiki/Clock_skew#On_a_network" rel="nofollow">clock skew</a>.</p> <p>Consider this simplistic example: let's say the clocks on computers Alice and Bob are 10 seconds apart: when Alice's clock shows 12:00:00, Bob's clock shows 12:00:10.</p> <p>Alice sends Bob its timestamp, which says 14:23:06. It takes the package one second to reach Bob, now Bob sees 14:23:17 when the package arrives. If Bob simply subtracts Alice's timestamp from his own, he would conclude that the package took 11 seconds to reach it.</p> <p>If Bob sends Alice his timestamp now - let's say it's 14:23:18, Alice would receive it one second later, which by Alice's clock would be 14:23:09. Now Alice would conclude that the package took -9 (yes, <em>negative nine!</em>) seconds to reach it, which makes no sense at all.</p> <p>Fortunately, if it is fair to assume that the latency is the same on both legs of the round-trip, you can measure the latency by factoring out the clock skew. The idea is to obtain two pairs of timestamps constructed in such a way that the clock skew is a factor in both pairs, but the sign of the skew is opposite.</p> <p>Consider the timestamps from the above example:</p> <pre><code>A1=14:23:06 B1=14:23:17 B2=14:23:18 A2=14:23:09 </code></pre> <p>Each pair, A1-B1 and B2-A2, contain the skew, but in the first pair the skew is positive, while in the second pair it is negative. <strong>Hence, if you average the two time differences, you would end up with your roundtrip delay</strong>.</p> <pre><code>((B1-A1)+(A2-B2)) / 2 = (11 + -9) / 2 = 2 / 2 = 1 second </code></pre> <p>This should be enough for you to implement a simple program for measuring the roundtrip latency in your system.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload