|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.cometd.server.ext.TimesyncExtension
public class TimesyncExtension
Timesync extension (server side).
With each handshake or connect, the extension sends timestamps within the
ext field like: {ext:{timesync:{tc:12345567890,l:23,o:4567},...},...}
where:
A cometd server that supports timesync, can respond with an ext
field like: {ext:{timesync:{tc:12345567890,ts:1234567900,p:123,a:3},...},...}
where:
If the client and server clocks were in sync, then network lag could
be calculated with (ts-tc)
. But the client clock is not in sync and
the calculated offset o must be applied to calculate the lag as seen
by the server: (ts-(tc+o))
.
The accuracy of the offset o may now be calculated as the difference
between the real lag measured by the client (see below) and the
lag calculated on the server that is based on o. Thus the
accuracy a is (l-(ts-(tc+o))
On receipt of the response, the client is able to use current time to determine the total trip time, from which p is subtracted to determine an approximate two way network traversal time. The measured accuracy is used to adjust the assumption that the network is symmetric for traversal time, so:
These calculated lag and offset are sent with the next meta message and the accuracy is again measured by the server. Thus the calculated o will iteratively be improved by application of the calculated a.
A cometd server that measures a low a that is within an accuracy target may decide not to send a timesync ext response, as the offset is already accurately determined.
Constructor Summary | |
---|---|
TimesyncExtension()
|
Method Summary | |
---|---|
int |
getAccuracyTarget()
timesync responses are not set if the measured accuracy is less than the accuracyTarget. |
Message |
rcv(Client from,
Message message)
|
Message |
rcvMeta(Client from,
Message message)
|
Message |
send(Client from,
Message message)
|
Message |
sendMeta(Client from,
Message message)
|
void |
setAccuracyTarget(int target)
timesync responses are not set if the measured accuracy is less than the accuracyTarget. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TimesyncExtension()
Method Detail |
---|
public int getAccuracyTarget()
public void setAccuracyTarget(int target)
target
- accuracy target in mspublic Message rcv(Client from, Message message)
rcv
in interface Extension
public Message rcvMeta(Client from, Message message)
rcvMeta
in interface Extension
public Message send(Client from, Message message)
send
in interface Extension
public Message sendMeta(Client from, Message message)
sendMeta
in interface Extension
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |