Rtc

This scenario shows how to configure NTP client/server authentication.

../../../../_images/client.svg

Test RTC Synchronization

Description

Checks that RTC is working properly on machines that have an RTC device.

Scenario

Step 1: Set the following configuration in DUT1 :

set interfaces ethernet eth0 address 10.100.0.100/24
set protocols static route 0.0.0.0/0 next-hop 10.100.0.50
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
set system ntp master prefer
set system ntp master stratum 3

Step 2: Set the following configuration in DUT0 :

set interfaces ethernet eth0 address 10.100.0.50/24
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 3: Ping the IP address 10.100.0.100 from DUT0:

admin@DUT0$ ping 10.100.0.100 count 1 size 56 timeout 1
Show output
PING 10.100.0.100 (10.100.0.100) 56(84) bytes of data.
64 bytes from 10.100.0.100: icmp_seq=1 ttl=64 time=0.581 ms

--- 10.100.0.100 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.581/0.581/0.581/0.000 ms

Step 4: Run the command set date 2026-05-18 12:00:00 on DUT0 and expect no output.

Step 5: Run the command set date ntp 10.100.0.100 on DUT0 and check whether the output does not contain the following tokens:

skipping this server
Show output
Date was successfully updated!

Step 6: Run the command show date on DUT0 and check whether the output does not contain the following tokens:

Mon
Show output
Tue 19 May 2026 15:30:50 +00:00

Step 7: Run the command set date hwclock from-system debug on DUT0 and expect the following output:

Show output
hwclock from util-linux 2.38.1
System Time: 1779204650.657552
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1779204650 seconds after 1969
Last calibration done at 1779204650 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
RTC type: 'rtc_cmos'
Using delay: 0.500000 seconds
missed it - 1779204650.657776 is too far past 1779204650.500000 (0.157776 > 0.001000)
1779204651.500000 is close enough to 1779204651.500000 (0.000000 < 0.002000)
Set RTC to 1779204651 (1779204650 + 1; refsystime = 1779204650.000000)
Setting Hardware Clock to 15:30:51 = 1779204651 seconds since 1969
ioctl(RTC_SET_TIME) was successful.
Not adjusting drift factor because the --update-drift option was not used.
New /etc/adjtime data:
0.000000 1779204650 0.000000
1779204650
UTC

Step 8: Run the command set date hwclock to-system debug on DUT0 and expect the following output:

Show output
hwclock from util-linux 2.38.1
System Time: 1779204651.559187
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1779204650 seconds after 1969
Last calibration done at 1779204650 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
...got clock tick
Time read from Hardware Clock: 2026/05/19 15:30:52
Hw clock time : 2026/05/19 15:30:52 = 1779204652 seconds since 1969
Time since last adjustment is 2 seconds
Calculated Hardware Clock drift is 0.000000 seconds
Calling settimeofday(NULL, 0) to lock the warp_clock function.
Calling settimeofday(1779204652.000000, NULL) to set the System time.

Step 9: Run the command show date on DUT0 and check whether the output does not contain the following tokens:

Mon
Show output
Tue 19 May 2026 15:30:52 +00:00

Test RTC Synchronization With Drift

Description

Tests that RTC is working properly on machines that have an RTC device (while adjusting the drift too).

Scenario

Step 1: Set the following configuration in DUT1 :

set interfaces ethernet eth0 address 10.100.0.100/24
set protocols static route 0.0.0.0/0 next-hop 10.100.0.50
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
set system ntp master prefer
set system ntp master stratum 3

Step 2: Set the following configuration in DUT0 :

set interfaces ethernet eth0 address 10.100.0.50/24
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 3: Ping the IP address 10.100.0.100 from DUT0:

admin@DUT0$ ping 10.100.0.100 count 1 size 56 timeout 1
Show output
PING 10.100.0.100 (10.100.0.100) 56(84) bytes of data.
64 bytes from 10.100.0.100: icmp_seq=1 ttl=64 time=0.381 ms

--- 10.100.0.100 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.381/0.381/0.381/0.000 ms

Step 4: Run the command set date 2026-05-18 12:00:00 on DUT0 and expect no output.

Step 5: Run the command set date ntp 10.100.0.100 on DUT0 and check whether the output does not contain the following tokens:

skipping this server
Show output
Date was successfully updated!

Step 6: Run the command show date on DUT0 and check whether the output does not contain the following tokens:

Mon
Show output
Tue 19 May 2026 15:30:59 +00:00

Step 7: Run the command set date hwclock from-system update-drift debug on DUT0 and expect the following output:

Show output
hwclock from util-linux 2.38.1
System Time: 1779204659.661715
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1779204658 seconds after 1969
Last calibration done at 1779204658 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
...got clock tick
Time read from Hardware Clock: 2026/05/19 15:31:00
Hw clock time : 2026/05/19 15:31:00 = 1779204660 seconds since 1969
Time since last adjustment is 2 seconds
Calculated Hardware Clock drift is 0.000000 seconds
RTC type: 'rtc_cmos'
Using delay: 0.500000 seconds
1779204660.500000 is close enough to 1779204660.500000 (0.000000 < 0.001000)
Set RTC to 1779204660 (1779204660 + 0; refsystime = 1779204660.000000)
Setting Hardware Clock to 15:31:00 = 1779204660 seconds since 1969
ioctl(RTC_SET_TIME) was successful.
Not adjusting drift factor because it has been less than four hours since the last calibration.
New /etc/adjtime data:
0.000000 1779204660 0.000000
1779204660
UTC

Step 8: Run the command set date hwclock to-system debug on DUT0 and expect the following output:

Show output
hwclock from util-linux 2.38.1
System Time: 1779204660.557995
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1779204660 seconds after 1969
Last calibration done at 1779204660 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
...got clock tick
Time read from Hardware Clock: 2026/05/19 15:31:01
Hw clock time : 2026/05/19 15:31:01 = 1779204661 seconds since 1969
Time since last adjustment is 1 second
Calculated Hardware Clock drift is 0.000000 seconds
Calling settimeofday(NULL, 0) to lock the warp_clock function.
Calling settimeofday(1779204661.000000, NULL) to set the System time.

Step 9: Run the command show date on DUT0 and check whether the output does not contain the following tokens:

Mon
Show output
Tue 19 May 2026 15:31:01 +00:00