network time synchronisation in java


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: network time synchronisation in java

  1. #1
    Join Date
    Jun 2004
    Posts
    3

    network time synchronisation in java

    Hi everyone! I hope someone can help me with this problem.

    I need to synchronize two network clients in time so that they can execute a command at an exact point in time.

    * FIRST: An algorithmic approach
    I have tried to solve this problem by sending packets between the two clients, but it seems to be theoretically impossible. Anyone with a solution here.

    * SECOND: Using network time protocol (in java?)
    The second approach I come up with is using some sort of network time protocol. I have no experience of this and can not find anything of employing it with javas standard packets (I donīt want to use third party packets in the first run). Anyone with some experience on this issue.

    I use the udp protocol for data transfer between the clients and need an accurancy of <= 10 ms. Can it be achieved (with java)?


    /Anders Persson (bossebo)

  2. #2
    Join Date
    Feb 2004
    Posts
    808
    what you propose is nearly impossible in any language.. you can get close but true synchrony will be near impossible, as the computer clocks are not guaranteed to be in sync even 1 second after true-syncronisation

    can you tell a little more about why you need this precision
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

  3. #3
    Join Date
    Jun 2004
    Posts
    3
    Well, its a real time application between network-clients and therefore synchronisation in time could help compensate for absolute and relative network-latencies.

  4. #4
    Join Date
    Jun 2004
    Posts
    3
    as the computer clocks are not guaranteed to be in sync even 1 second after true-syncronisation
    It is not a problem for me to send sync information every second or less...

    I will try to rephrase the question:

    Is there any way to synchronize two clients that are better than do a "ping" with my present time, and inform the client that his time should be mySentTime+(ping/2) when the ping reached him. That is, we are asuming that the ping package took equal amount of time to reach the client as to get back.

  5. #5
    Join Date
    Feb 2004
    Posts
    808
    resolution of latency is generally not considered; it is left to the user to compensate.. experiments have been attempted in games like quake, but it becomes irritating after a ertain level of compensation.. it is perfectly feasible for a server to remember where players were up to 10 seconds ago, but how many people would appreciate running down a corridor then suddenly dying because a modem user with a lag of 800ms, shot them 800ms ago..

    what if they killed someone else in the meantime?


    with latency, it a case of you-snooze-you-lose..

    however, your method is the current accepted method of synchronising two PCs. for more info and algorithms, look up how NTP works..
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center