Difference between revisions of "OpenIGTLink/Timestamp"
From NAMIC Wiki
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | [[OpenIGTLink | << OpenIGTLink]] | + | [[OpenIGTLink | << OpenIGTLink]] | [[OpenIGTLink/Protocol | Protocol]] |
− | + | '''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 | |
− | |||
− | '''Seconds and fraction of seconds:''' | ||
− | fixed-point number, in seconds relative to | ||
− | 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. | ||
− | ''' | + | '''Wrap around:''' The first 32-bit field will overflow some time in 2106 (second 4,294,967,296) |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Obtaining timestamp == | == Obtaining timestamp == | ||
+ | * [http://www.itk.org/Doxygen34/html/classitk_1_1RealTimeClock.html itk::RealTimeClock] | ||
+ | * '''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]) | ||
− | + | == Time synchronization == | |
− | + | Two solutions: | |
+ | # Install NTP on all devices | ||
+ | # Compute timestamp differences (local NTP can be used) | ||
− | == | + | == Resources == |
− | + | * 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") | |
− | + | * [http://www.lochan.org/2005/keith-cl/useful/win32time.html Obtaining Accurate Timestamps under Windows XP] |
Latest revision as of 21:58, 11 February 2008
Home < OpenIGTLink < Timestamp
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
- itk::RealTimeClock
- Linux / Mac: ftime()
- Windows: ftime() - 10 ms resolution
- Old Timestamp - 1 sec resoultion: Now, Time, Timer
- System time - 10 msec resolution: GetTickCount, GetTickCount64 or timeGetTime()
- Highres - hardware dependent: QueryPerformanceCounter (Intel IA32 instruction: RDTSC)
Time synchronization
Two solutions:
- Install NTP on all devices
- Compute timestamp differences (local NTP can be used)
Resources
- NTP4 Timestamp: RFC 2030 and RFC 1305. (See "3. NTP Timestamp Format")
- Obtaining Accurate Timestamps under Windows XP