kb:driver_software:driver_software_for_windows:meinberg_time_adjustment_service:monitoring_the_status_of_the_meinberg_time_adjustment_service

Monitoring the Status of the Meinberg Time Adjustment Service

The time adjustment service which ships with the Meinberg Driver Software for Windows doesn't log status changes of the reference clock etc. directly to a text file but generates log entries in the Windows application event log, which can be viewed using eventvwr.exe program shipped with Windows. However, the message text and event codes may vary with the version of the driver software, thus evaluation of the event log entries is not a reliable way to monitor time synchronization. Also, log entries are only generated whenever a status changes, so here's another approach to check the current status at any time.

To verify that the Windows system time is adjusted properly by the Meinberg Time Adjustment service there are several conditions that have to be checked:

  • The time adjustment service has to be active. If it's not active, it's unable to adjust the Windows system time, and no further information can be retrieved from it. API calls trying to retrieve detailed information from the service when the service is not active will return an error.
  • If the time service is active, the clock which provides the reference time needs to be “connected”. If the reference clock is an external device connected via a serial interface, or USB, the cable may have been disconnected, so the service might be unable to read the reference time from the device. However, a PCI card should always be “connected”.
  • If the reference clock is connected, the clock also needs to be synchronized to its time source. If it is not synchronized, the clock may be rejected by the time adjustment service since the service doesn't know if the time of the reference clock is really accurate, or not. If the reference clock device is not connected, status information will obviously not be available, and an API call attempting to retrieve the status will fail with an error.

So only if all 3 conditions are met you can be sure the Windows system time is adjusted properly, and if one step fails, it makes no sense to try the subsequent steps.


There is an example command line program called mbgdmpst available which uses some Meinberg API calls to retrieve the current status information, and dumps the status to a text file:

Just run

mbgdmpst status.txt

to dump the status information to a text file called status.txt.

If the time adjustment service is active, and the clock is connected, and the clock is synchronized, the status.txt file will contain information as shown below:

[Info]
About=Meinberg Time Adjustment Status Dumper v1.1

[Output]
SvcTimeAdjustmentActive=1
SvcRefTimeAccessible=1
RefTimeNotSynchronized=0
RefDaylightSavingEnabled=1
RefSyncAfterReset=1
RefDaylightChangeAnnounced=0
RefIsUtc=0
RefLeapSecondAnnounced=0
RefTimeSetManually=0
RefTimeInvalid=0

I.e., the first 3 lines of the [Output] section contain the information on the 3 conditions mentioned above. The remaining lines contain additional status information of the clock device. In the example above everything is OK.

If the time adjustment service is not active, no detailed information is available, so the status.txt file contains the following lines in this case:

[Info]
About=Meinberg Time Adjustment Status Dumper v1.1

[Output]
SvcTimeAdjustmentActive=0
SvcRefTimeAccessible=
RefTimeNotSynchronized=
RefDaylightSavingEnabled=
RefSyncAfterReset=
RefDaylightChangeAnnounced=
RefIsUtc=
RefLeapSecondAnnounced=
RefTimeSetManually=
RefTimeInvalid=

In the example output above, the only real information is that the time adjustment service is not active. In the subsequent lines, there are no values behind the '=' to indicate that the information is not available, which is because the time adjustment service is not running.

3rd party programs can simply just call the mbgdmpst program periodically, and parse the output file.

The source code of the mbgdmpst program can be found in the C sample code section of the Meinberg SDK for Windows, which is available via the Meinberg web site:

The API calls used to retrieve the status information are provided by the mbgsvcio DLL which is shipped as part of the Meinberg driver software package for Windows.

:!: Please note that a few years ago there were some cases reported where a handle leak occurred at least under Windows Server 2008 and Windows XP if an application was running continuously and used the mbgsvcio API calls repeatedly. This happened even though the API functions were implemented according to the specs provided by Microsoft, and a specific reason for this problem could not be identified. Anyway, if a 3rd party application calls mbgdmpst periodically to monitor the time synchronization status then there is no handle leak since all handles are freed whenever mbgdmpst has done its job and terminates.


Martin Burnicki martin.burnicki@meinberg.de 2019-10-15

  • kb/driver_software/driver_software_for_windows/meinberg_time_adjustment_service/monitoring_the_status_of_the_meinberg_time_adjustment_service.txt
  • Last modified: 2020-09-21 12:45
  • by 127.0.0.1