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 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

Step 3: Ping 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.326 ms

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

Step 4: Run command set date 2024-04-22 12:00:00 at DUT0 and expect this output: Step 5: Run command set date ntp 10.100.0.100 at DUT0 and check if output does not contain the following tokens:

skipping this server
Show output
sntp 4.2.8p12@1.3728-o (1)
2024-04-22 12:00:01.153003 (+0000) +105829.509952 +/- 70560.954144 10.100.0.100 s4 no-leap

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

Mon
Show output
Tue Apr 23 17:23:51 UTC 2024

Step 7: Run command set date hwclock from-system debug at DUT0 and expect this output:

Show output
hwclock from util-linux 2.33.1
System Time: 1713893031.683551
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1713893030 seconds after 1969
Last calibration done at 1713893030 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 - 1713893031.685681 is too far past 1713893031.500000 (0.185681 > 0.001000)
1713893032.500000 is close enough to 1713893032.500000 (0.000000 < 0.002000)
Set RTC to 1713893032 (1713893031 + 1; refsystime = 1713893031.000000)
Setting Hardware Clock to 17:23:52 = 1713893032 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 1713893031 0.000000
1713893031
UTC

Step 8: Run command set date hwclock to-system debug at DUT0 and expect this output:

Show output
hwclock from util-linux 2.33.1
System Time: 1713893032.555338
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1713893031 seconds after 1969
Last calibration done at 1713893031 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: 2024/04/23 17:23:53
Hw clock time : 2024/04/23 17:23:53 = 1713893033 seconds since 1969
Time since last adjustment is 2 seconds
Calculated Hardware Clock drift is 0.000000 seconds
Calling settimeofday(1713893033.000000, 0)

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

Mon
Show output
Tue Apr 23 17:23:53 UTC 2024

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 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

Step 3: Ping 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.602 ms

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

Step 4: Run command set date 2024-04-22 12:00:00 at DUT0 and expect this output: Step 5: Run command set date ntp 10.100.0.100 at DUT0 and check if output does not contain the following tokens:

skipping this server
Show output
sntp 4.2.8p12@1.3728-o (1)
2024-04-22 12:00:01.147644 (+0000) +105838.479481 +/- 70566.933830 10.100.0.100 s4 no-leap

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

Mon
Show output
Tue Apr 23 17:24:00 UTC 2024

Step 7: Run command set date hwclock from-system update-drift debug at DUT0 and expect this output:

Show output
hwclock from util-linux 2.33.1
System Time: 1713893040.653957
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1713893039 seconds after 1969
Last calibration done at 1713893039 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: 2024/04/23 17:24:01
Hw clock time : 2024/04/23 17:24:01 = 1713893041 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
1713893041.500000 is close enough to 1713893041.500000 (0.000000 < 0.001000)
Set RTC to 1713893041 (1713893041 + 0; refsystime = 1713893041.000000)
Setting Hardware Clock to 17:24:01 = 1713893041 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 1713893041 0.000000
1713893041
UTC

Step 8: Run command set date hwclock to-system debug at DUT0 and expect this output:

Show output
hwclock from util-linux 2.33.1
System Time: 1713893041.558733
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1713893041 seconds after 1969
Last calibration done at 1713893041 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: 2024/04/23 17:24:02
Hw clock time : 2024/04/23 17:24:02 = 1713893042 seconds since 1969
Time since last adjustment is 1 second
Calculated Hardware Clock drift is 0.000000 seconds
Calling settimeofday(1713893042.000000, 0)

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

Mon
Show output
Tue Apr 23 17:24:02 UTC 2024