Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Interner Time Server - access from Fortran?

Philip_Muir
Beginner
633 Views

Does anyone know of a routine, and how to implement it, that will allow a Fortran program (using Intel Visual Fortran XE compiler) to read current time from an Internet Time Server?
..thanks,
...Phil.

0 Kudos
5 Replies
Steven_L_Intel1
Employee
633 Views

Since Windows can synchronize with NTP servers, why go through all that trouble and not just ask the system for the time?  I've done some Google searching and the protocol is a bit complex, with pretty much everyone recommending to let the OS handle it.

0 Kudos
andrew_4619
Honored Contributor II
633 Views

Steve point is a valid one. There is a windows tool w32tm.exe you could run that with some options and send the data to a file you can then read.... An example command and output is below.

w32tm /stripchart /computer:us.pool.ntp.org /dataonly /samples:5 > times.txt

Tracking us.pool.ntp.org [38.229.71.1:123].
Collecting 5 samples.
The current time is 09-Sep-16 6:08:37 PM.

18:08:37, +00.0673459s

18:08:39, +00.0669157s

18:08:41, +00.0678203s

18:08:43, +00.0684916s

18:08:45, +00.0669230s

 

0 Kudos
Philip_Muir
Beginner
633 Views

Thanks Steve & Andrew - that specific solution (w32tm) hadn't occurred to me.

What I'm trying to do is prevent users from winding back their operating system clock to circumvent an expired software licence. The one weakness of using the w32tm solution is that a clued-up user could write their own w32tm and place their exe in the path (earlier than the official windows tool) to output a suitable backdated time and thus circumvent the licence expiry date.

My thinking was (is?) that obtaining the internet time wholly within the Fortran code is going to be considerably more secure than relying on an external program to do it. However from your answers I'm suspecting this may be more difficult than I had imagined.

...thanks,
...Phil.

0 Kudos
Steven_L_Intel1
Employee
633 Views

Ah, the old roll-your-own-license-manager trick! The unscrupulous user could just redefine DNS for the NTP server of choice to be a fake one that delivers the wrong time. I think there are better ways of dealing with this, such as storing current UTC with a secure hash and watching for rollbacks. Or use any of a number of available licensing managers that can do this for you.

0 Kudos
andrew_4619
Honored Contributor II
633 Views

All security measures can be circumvented if someone is prepared to make enough effort and if you just use internet time does the application not work if the computer of 'offline'? You can look at clock rewind from saved time, internet time, date stamp on system resources (drivers, updates etc)....

0 Kudos
Reply