16.3.15 Configuring the Clock per DomainParticipant

Connext uses clocks to measure time and generate timestamps.

The middleware uses two clocks: an internal clock and an external clock.

  • The internal clock measures time and handles all timing in the middleware.
  • The external clock is used solely to generate timestamps (such as the source timestamp and the reception timestamp), in addition to providing the time given by the DomainParticipant’s get_current_time() operation (see 16.3.16.2 Getting the Current Time).

16.3.15.1 Available Clocks

Two clock implementations are generally available: the real-time clock and the monotonic clock.

The real-time clock provides the real time of the system. This clock may generally be monotonic, but may not be guaranteed to be so. It is adjustable and may be subject to small and large changes in time. The time obtained from this clock is generally a meaningful time, in that it is the amount of time from a known epoch. For the purposes of clock selection, this clock can be referenced by the names "realtime" or "system"—both names map to the same real-time clock.

The monotonic clock provides times that are monotonic from a clock that is not adjustable. This clock is not subject to changes in the system or realtime clock, which may be adjusted by the user or via time synchronization protocols. However, this clock’s time generally starts from an arbitrary point in time, such as system start-up. Note that the monotonic clock is not available for all architectures. Please see the RTI Connext Core Libraries Platform Notes for the architectures on which it is supported. For the purposes of clock selection, this clock can be referenced by the name "monotonic".

16.3.15.2 Clock Selection Strategy

To configure the clock selection, use the DomainParticipant’s 47.19 PROPERTY QosPolicy (DDS Extension) . Table 16.7 Clock Selection Properties lists the supported properties.

Table 16.7 Clock Selection Properties

Property

Description

dds.clock.external_clock

Comma-delimited list of clocks to use for the external clock, in the order of preference.

Valid clock names are “realtime”, “system”, or “monotonic”.

dds.clock.internal_clock

Comma-delimited list of clocks to use for the internal clock, in the order of preference.

Valid clock names are “realtime”, “system”, or “monotonic”.

By default, both the internal and external clocks use the realtime clock.

If you want your application to be robust to changes in the system time, you may use the monotonic clock as the internal clock, and leave the system clock as the external clock. However, note that this may slightly diminish performance, in that both the send and receive paths may need to get times from both clocks.

Since the monotonic clock is not available on all architectures, you may want to specify "monotonic, realtime" for the internal_clock property (see Table 16.7 Clock Selection Properties). By doing so, the middleware will attempt to use the monotonic clock if it is available, and will fall back to the realtime clock if the monotonic clock is not available.

If you want the application to be robust to changes in the system time, you are not relying on source timestamps, and you want to avoid obtaining times from both clocks, you may use the monotonic clock for both the internal and external clocks.