Jump to content

how to use a time server ?


jennico
 Share

Recommended Posts

does anyone know how to get and use data from a time server ?

and which time server to ask ?

and how to do that without losing synchronization by delay ?

maybe someone can provide an example script ?

would be amazing to know.

thx

j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

This may be to simplistic, but from a command prompt:

net time /setsntp:{Server Address}, where {Server Address} is your selection, as shown below:

Server Address Location (IP Address)

time-a.nist.gov NIST, Gaithersburg, Maryland 129.6.15.28

time-b.nist.gov NIST, Gaithersburg, Maryland 129.6.15.29

time-a.timefreq.bldrdoc.gov NIST, Boulder, Colorado 132.163.4.101

time-b.timefreq.bldrdoc.gov NIST, Boulder, Colorado 132.163.4.102

time-c.timefreq.bldrdoc.gov NIST, Boulder, Colorado 132.163.4.103

utcnist.colorado.edu University of Colorado, Boulder 128.138.140.44

time.nist.gov NCAR, Boulder, Colorado 192.43.244.18

time-nw.nist.gov Microsoft, Redmond, Washington 131.107.1.10

nist1.datum.com Datum, San Jose, California 66.243.43.21

nist1.dc.glassey.com Abovenet, Virginia 216.200.93.8

nist1.ny.glassey.com Abovenet, New York City 208.184.49.9

nist1.sj.glassey.com Abovenet, San Jose, California 207.126.103.204

nist1.aol-ca.truetime.com TrueTime, AOL facility, Sunnyvale, CA 207.200.81.113

nist1.aol-va.truetime.com TrueTime, AOL facility, Virginia 205.188.185.33

Above from this document: http://tf.nist.gov/service/pdf/win2000xp.pdf

other info: http://tf.nist.gov/general/pdf/1383.pdf

this from MS: http://technet.microsoft.com/en-us/library/cc779145.aspx

and TechRepublic: http://articles.techrepublic.com.com/5100-...11-1055067.html

http://blogs.techrepublic.com.com/window-o...;tag=rbxccnbtr1

I have every confidence that you know much better than I how to implement all this in AutoIt.

Hope this is of some use,

-Mike

Edited by mdwerne
Link to comment
Share on other sites

The reply from mdwerne will synchronize the system clock but, as far as I know, there is no NET TIME command that will simply return the value.

It's also impossible to get network time from any server without some synchro delay. Of course the trick here is to find the NTP server that gives the fastest return time which is usually (not always) the closest server to your system.

Another list of time servers can be found here

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

thanks first, i DO NOT want to update my system time. i want to implement this in a script.

i would like to return a data string from the NTP (or whatever) and be able to interprete this correctly.

so i think i need the command and then a simple instruction how to use the returned string.

i think, someone here must have done that before.

j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

well, more simple: maybe anyone knows a website that simply displays and updates an official time every second, so that i could extract the data from the html script ?

j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

the syncro delay might be calculable from the call and response time, maybe.

j.

okay, it would be a workaround update the system time and then pick it into the script....

but must be working directly, i guess, somehow.

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

the syncro delay might be calculable from the call and response time, maybe.

j.

okay, it would be a workaround update the system time and then pick it into the script....

but must be working directly, i guess, somehow.

There is more technical information in the links above...but in response to your last request.

http://www.time.gov/

-Mike

Edited by mdwerne
Link to comment
Share on other sites

yes, i know this site, but the time is displayed thru a java aplet, so it's not possible to read out of the html.

the html is very interesting though:

// get the computer's date
  var Thisdate = new Date();
  // convert to NIST date, using offset calculated in ClientNISTDelta
  ThisMilliseconds =  Thisdate.getTime() + ClientNISTDelta;

  document.images['xearth'].src = xearthSrc(ThisMilliseconds);

  setTimeout("updatexearthImage()", 10000);
}

function xearthSrc(ThisMilliseconds) {

var ssue = ThisMilliseconds / 1000;
var TWOPI = 2 * Math.PI;
var EpochStart = 631065600;
var DaysSinceEpoch = (ssue - EpochStart) / (24*3600);

var RadsPerDay = TWOPI / 365.242191;

var Epsilon_g = 279.403303 * (TWOPI / 360);
var OmegaBar_g = 282.768422 * (TWOPI / 360);
var Eccentricity = 0.016713;

var MeanObliquity = 23.440592 * (TWOPI / 360);

//Compute lambda = sun_ecliptic_longitude(ssue)
//Begin sun_ecliptic_longitude
  var D = DaysSinceEpoch;
  var N = RadsPerDay * D;
  N = N % TWOPI;
  if (N < 0) N += TWOPI;

  var M_sun = N + Epsilon_g - OmegaBar_g;
  if (M_sun < 0) M_sun += TWOPI;

  //Compute var E = solve_keplers_equation(M_sun);
  //Begin solve_keplers_equation
    var E = M_sun;
    var delta;
    while (1) {
      delta = E - (Eccentricity*Math.sin(E)) - M_sun;
      if (Math.abs(delta) <= 1E-10) break;
      E -= delta / (1 - (Eccentricity*Math.cos(E)));
    }
  //End solve_keplers_equation

  var lambda = OmegaBar_g + (2 * Math.atan(Math.sqrt((1+Eccentricity) / (1-Eccentricity)) * Math.tan(E/2)));
//End sun_ecliptic_longitude


//Compute ecliptic_to_equatorial(lambda, 0.0, alpha, delta)
  var sin_e = Math.sin(MeanObliquity);
  var cos_e = Math.cos(MeanObliquity);
  var alpha = Math.atan2(Math.sin(lambda)*cos_e, Math.cos(lambda));
  var delta = Math.asin(sin_e*Math.sin(lambda));
//End ecliptic_to_equatorial

//Compute GST(ssue)
  //Compute JD = julian_date(year, month, day)
    var TmpDate = new Date(ThisMilliseconds);
    var OffsetMilliseconds = ThisMilliseconds; //+ (60000*TmpDate.getTimezoneOffset());
    var ThisDate = new Date(OffsetMilliseconds);
    var y = ThisDate.getYear();
      if (y < 1000) y += 1900;
    var m = ThisDate.getMonth() + 1;
    var z = ThisDate.getDate();
    
//  if ((m==1) || (m==2)) {
//    y -= 1;
//    m += 12; }

    var A = y / 100;
    var B = 2 - A + (A/4);
    var C = 365.25 * y;
    var D = 30.6001 * (m+1);

    var JD = B + C + D + z + 1720994.5;
  //End julian_date

  var T = (JD - 2451545) / 36525;
  var T0 = ((((T + 2.5862E-5) * T) + 2400.051336) * T) + 6.697374558;

  T0 = T0 % 24;
  if (T0 < 0) T0 += 24;

  var UT = ThisDate.getHours() + ((ThisDate.getMinutes() + (ThisDate.getSeconds() / 60)) / 60);
 
  T0 += UT * 1.002737909;
  T0 = T0 % 24;
  if (T0 < 0) T0 += 24;
//End GST

var tmp = alpha - ((TWOPI/24)*T0);
while (tmp < -Math.PI) {tmp += TWOPI;};
while (tmp > Math.PI) {tmp -= TWOPI;};

var lon = tmp * (360/TWOPI);
var lat = delta * (360/TWOPI);

//Generate the path of the appropriate xearth image

//lon is even
lon = Math.round(lon);
//if (lon & 1 != 0) {
if (lon % 2 != 0) {
  if (lon > 0) {
    lon -= 1;
    }
  else {
    lon += 1;
    }
  }
  
  // force even for mozilla 4.01-4.05
  // Consolidate lines, 4/5/01 - PRF
  lon = Math.round(lon/2) * 2;
  
if (lon <= -181) lon = -180;
if (lon >= 181) lon = 180;

//lat is odd
lat = Math.round(lat);
//if (lat & 1 == 0) {
if (lat % 2 == 0) {
  if (lat > 0) {
    lat -= 1;
    }
  else {
    lat += 1;
    }
  }
  
  // force odd for mozilla 4.01-4.05
  // Fixed broken algorithm, 4/5/01 - PRF
  lat =  (Math.round(lat/2 - 1) * 2) + 1;
  
  
if (lat <= -24) lat = -23;
if (lat >= 24) lat = 23;

var latStr; var lonStr;
if (lat < 0) 
  latStr = (-lat) + "S";
else 
  latStr = lat + "N";

if (lon < 0) 
  lonStr = (-lon) + "S";
else 
  lonStr = lon + "N";

lots of math and your pc gets scanned !!!

j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

just thinking loudly...

the time server is

internet address of server named time_a.timefreq.bldrdoc.gov

cp="132.163.4.101";

others are

char *serv_ip[NUMSRV]= {"64.236.96.53" ,/*nist1.aol-va.truetime.com*/

"128.138.140.44" ,/*utcnist.colorado.edu*/

"207.200.81.113" ,/*nist1.aol-ca.truetime.com*/

"216.200.93.8" ,/*nist1-dc.glassey.com*/

"63.149.208.50" ,/*nist1.datum.com*/

"208.184.49.9" ,/*nist1-ny.glassey.com*/

"207.126.103.204",/*nist1-sj.glassey.com*/

"129.6.15.28" ,/*time-a.nist.gov*/

"129.6.15.29" ,/*time-b.nist.gov*/

"132.163.4.101" ,/*time-a.timefreq.bldrdoc.gov*/

"132.163.4.102" ,/*time-b.timefreq.bldrdoc.gov*/

"132.163.4.103" ,/*time-c.timefreq.bldrdoc.gov*/

"192.43.244.18" ,/*time.nist.gov*/

"131.107.1.10" ,/*time-nw.nist.gov*/

"utcnist.colorado.edu"/*DNS entry =128.138.140.44*/

printf("\n Time message received:");

printf("\n D L");

printf("\n MJD YY MM DD HH MM SS ST S H Adv.");

printf("%s\n",buf);

The server will respond to a "daytime" request with a text string

giving the date as a Modified Julian Day number and as a civil date and

the Universal Coordinated Time (formerly called GMT). The message also

contains advance notice for the transitions to and from Daylight Saving

Time (using the US transition dates) and for leap seconds. The response

can be parsed to set the time on your machine with an uncertainty that is

determined primary by the variability in the transmission time across

the internet path which is typically about 0.1 seconds or less.

let's try it out..
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

Here's a quick and dirty way to query the time server:

#include <IE.au3> 

;http://tf.nist.gov/timefreq/service/time-servers.html
;nist1-sj.WiTime.net
$server = "64.125.78.85"

$oIE = _IECreate("http://" & $server & ":13", 0, 0, 1, -1)
$read = _IEBodyReadText($oIE)

$time = StringSplit($read, " ")
$stime = StringSplit($time[3], ":")
;convert from UTC to PST
$nhr = StringTrimLeft($stime[1], 1)
If $nhr < 9 Then
    $nhr = 24 + $nhr
EndIf
$hr = $nhr - 8
MsgBox(0, "?", $hr & ":" & $stime[2] & ":" & $stime[3])

You may want to use TimerDiff to adjust the results to compensate for the delay. Hope this helps.

Edited by dillonlim
Link to comment
Share on other sites

YES !!!!! THX !!!! :mellow::(:);) this is what i was looking for !

where did you find the IP ? been looking anywhere.

i think this is a secret, no ?

j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...