Difference between revisions of "OpenIGTLink/Timestamp"

From NAMIC Wiki
Jump to: navigation, search
Line 2: Line 2:
  
  
NTP4 Timestamp is defined by [http://www.faqs.org/rfcs/rfc2030.html RFC 2030] and [http://www.faqs.org/rfcs/rfc1305.html RFC 1305]. (See "3. NTP Timestamp Format")
+
'''Big Endian format:''' bits numbered in big-endian fashion from 0 starting at the left, or high-order, position.
  
'''Big Endian format:''' NTP data are specified as integer or fixed-point
+
'''Seconds and fraction of seconds:''' timestamps are represented as a 64-bit unsigned
quantities, with bits numbered in big-endian fashion from 0 starting
+
fixed-point number, in seconds relative to 00:00:00 January 1, 1970, UTC. The
at the left, or high-order, position.
+
integer part is in the first 32 bits (Unix-style timestamp) and the fraction part in the
 
 
'''Seconds and fraction of seconds:''' NTP timestamps are represented as a 64-bit unsigned
 
fixed-point number, in seconds relative to 0h on 1 January 1900. The
 
integer part is in the first 32 bits and the fraction part in the
 
 
last 32 bits. In the fraction part, the non-significant low order can
 
last 32 bits. In the fraction part, the non-significant low order can
 
be set to 0.
 
be set to 0.
  
'''Convention:''' Note that, since some time in 1968 (second 2,147,483,648) the most
+
'''Wrap around:''' The first 32-bit field will overflow some time in 2106 (second 4,294,967,296)
significant bit (bit 0 of the integer part) has been set and that the
 
64-bit field will overflow some time in 2036 (second 4,294,967,296).
 
There will exist a 232-picosecond interval, henceforth ignored, every
 
136 years when the 64-bit field will be 0, which by convention is
 
interpreted as an invalid or unavailable timestamp.
 
 
 
If bit 0 is set, the UTC time is in the range 1968-2036 and UTC time
 
is reckoned from 0h 0m 0s UTC on 1 January 1900.  If bit 0 is not
 
set, the time is in the range 2036-2104 and UTC time is calculated
 
from 6h 28m 16s UTC on 7 February 2036.  Note that when calculating
 
the correspondence, 2000 is a leap year and leap seconds are not
 
included in the reckoning.
 
 
 
'''Precision:''' 200 picoseconds
 
 
 
'''Wrap around:''' in year 2104
 
  
 
== Obtaining timestamp ==
 
== Obtaining timestamp ==
 +
* '''Linux''' / '''Mac''': [http://www.hmug.org/man/3/ftime.php ftime()]
 +
* '''Windows''': [http://msdn2.microsoft.com/en-us/library/z54t9z5f(VS.71).aspx ftime()] - 10 ms resolution
 +
** '''Old Timestamp''' - 1 sec resoultion: Now, [http://msdn2.microsoft.com/en-us/library/1f4c8f33.aspx Time], Timer
 +
** '''System time''' - 10 msec resolution: GetTickCount, [http://msdn2.microsoft.com/en-us/library/ms724411.aspx GetTickCount64] or [http://msdn2.microsoft.com/en-us/library/ms713418(VS.85).aspx timeGetTime()]
 +
** '''Highres''' - hardware dependent: [http://msdn2.microsoft.com/en-us/library/ms644904.aspx QueryPerformanceCounter] (Intel IA32 instruction: [http://www.intel.com/design/pentium4/manuals/245471.htm RDTSC])
  
Intel IA32 instruction [http://www.intel.com/design/pentium4/manuals/245471.htm RDTSC]
+
== Time synchronization ==
* '''Windows:''' Use [http://msdn2.microsoft.com/en-us/library/ms644904.aspx QueryPerformanceCounter()] or [http://msdn2.microsoft.com/en-us/library/ms713418(VS.85).aspx timeGetTime()] (10ms)
+
Two solutions:
 +
# Install NTP on all devices
 +
# Compute timestamp differences (local NTP can be used)
  
== Calibrating the counters ==
+
== Resources ==
# Install NTP or compute timestamp differences
+
* NTP4 Timestamp: [http://www.faqs.org/rfcs/rfc2030.html RFC 2030] and [http://www.faqs.org/rfcs/rfc1305.html RFC 1305]. (See "3. NTP Timestamp Format")
# Calibrate timestamp (counter) - real time difference
+
* [http://www.lochan.org/2005/keith-cl/useful/win32time.html Obtaining Accurate Timestamps under Windows XP]

Revision as of 18:02, 10 January 2008

Home < OpenIGTLink < Timestamp

<< OpenIGTLink


Big Endian format: bits numbered in big-endian fashion from 0 starting at the left, or high-order, position.

Seconds and fraction of seconds: timestamps are represented as a 64-bit unsigned fixed-point number, in seconds relative to 00:00:00 January 1, 1970, UTC. The integer part is in the first 32 bits (Unix-style timestamp) and the fraction part in the last 32 bits. In the fraction part, the non-significant low order can be set to 0.

Wrap around: The first 32-bit field will overflow some time in 2106 (second 4,294,967,296)

Obtaining timestamp

Time synchronization

Two solutions:

  1. Install NTP on all devices
  2. Compute timestamp differences (local NTP can be used)

Resources