Ntp Client

Test suite to check NTP client using VRF, PBR, authentication and RTC synchronization

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

Test NTP Service

Description

DUT0 is configured to obtain time information from a static configured NTP server

Scenario

Step 1: Set the following configuration in DUT1:

set interfaces ethernet eth0 address 10.215.200.100/24
set protocols static route 0.0.0.0/0 next-hop 10.215.200.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.215.200.50/24

Step 3: Ping IP address 10.215.200.100 from DUT0:

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

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

Step 4: Run command set date 2023-12-12 12:00:00 at DUT0 and expect this output: Step 5: Run command set date ntp 10.215.200.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)
2023-12-12 12:00:00.136174 (+0000) +51061.056126 +/- 34048.651593 10.215.200.100 s4 no-leap

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

Tue
Show output
Wed Dec 13 02:11:01 UTC 2023

Step 7: Run command set date 2023-12-12 12:00:00 at DUT0 and expect this output: Step 8: Run command system ntp status at DUT0 and check if output contains the following tokens:

NTP is not running
Show output
NTP is not running

Step 9: Set the following configuration in DUT0:

set system ntp server address 10.215.200.100 max-poll 4
set system ntp server address 10.215.200.100 min-poll 3

Step 10: Run command system ntp status at DUT0 and check if output contains the following tokens:

10.215.200.100
Show output
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 10.215.200.100  .INIT.          16 u    -    8    0    0.000    0.000   0.000

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

Tue
Show output
Wed Dec 13 02:11:11 UTC 2023

Test NTP Service Specific VRF

Description

DUT0 is configured to obtain time information from an NTP server via VRF (Virtual Routing and Forwarding).

Scenario

Step 1: Set the following configuration in DUT1:

set interfaces ethernet eth0 address 10.215.200.100/24
set protocols static route 0.0.0.0/0 next-hop 10.215.200.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.215.200.50/24
set interfaces ethernet eth0 vrf WAN
set system vrf WAN

Step 3: Ping IP address 10.215.200.100 from DUT0:

admin@DUT0$ ping 10.215.200.100 vrf WAN count 1 size 56 timeout 1
Show output
ping: Warning: source address might be selected on device other than WAN.
PING 10.215.200.100 (10.215.200.100) from 10.215.200.50 WAN: 56(84) bytes of data.
64 bytes from 10.215.200.100: icmp_seq=1 ttl=64 time=0.714 ms

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

Step 4: Run command set date 2023-12-12 12:00:00 at DUT0 and expect this output: Step 5: Run command set date ntp 10.215.200.100 vrf WAN at DUT0 and expect this output:

Show output
sntp 4.2.8p12@1.3728-o (1)
2023-12-12 12:00:00.124826 (+0000) +51081.412030 +/- 34062.222196 10.215.200.100 s4 no-leap

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

Tue
Show output
Wed Dec 13 02:11:22 UTC 2023

Step 7: Run command set date 2023-12-12 12:00:00 at DUT0 and expect this output: Step 8: Set the following configuration in DUT0:

set system ntp server address 10.215.200.100 max-poll 4
set system ntp server address 10.215.200.100 min-poll 3
set system ntp server address 10.215.200.100 local-vrf WAN
set system ntp server address 10.215.200.100 local-address 10.215.200.50

Step 9: Run command system ntp status at DUT0 and check if output contains the following tokens:

10.215.200.100
Show output
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 10.215.200.100  .INIT.          16 u    -    8    0    0.000    0.000   0.000

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

Tue
Show output
Wed Dec 13 02:11:32 UTC 2023

Test NTP Service Specific VRF and PBR

Description

Simple test to check NTP service using a specific VRF and PBR (Policy Based Routing).

Scenario

Step 1: Run command set date 2023-12-12 12:00:00 at DUT0 and expect this output: Step 2: Set the following configuration in DUT1:

set interfaces ethernet eth0 address 10.215.200.100/24
set protocols static route 0.0.0.0/0 next-hop 10.215.200.50
set system ntp master prefer
set system ntp master stratum 3

Step 3: Set the following configuration in DUT0:

set interfaces ethernet eth0 address 10.215.200.50/24
set interfaces ethernet eth0 vrf WAN
set system vrf WAN
set interfaces dummy dum0 address 192.168.0.1/24
set interfaces dummy dum0 vrf LAN
set interfaces ethernet eth0 traffic policy in LOCVRF_POL
set traffic policy LOCVRF_POL rule 1 set vrf LAN
set traffic policy LOCVRF_POL rule 1 selector LOCVRF_SEL
set traffic selector LOCVRF_SEL rule 1 protocol udp
set protocols vrf LAN static route 0.0.0.0/0 interface eth0
set system vrf LAN
set system ntp server address 10.215.200.100 max-poll 4
set system ntp server address 10.215.200.100 min-poll 3
set system ntp server address 10.215.200.100 local-vrf LAN
set system ntp server address 10.215.200.100 local-interface dum0

Step 4: Ping IP address 10.215.200.100 from DUT0:

admin@DUT0$ ping 10.215.200.100 vrf WAN count 1 size 56 timeout 1
Show output
ping: Warning: source address might be selected on device other than WAN.
PING 10.215.200.100 (10.215.200.100) from 10.215.200.50 WAN: 56(84) bytes of data.
64 bytes from 10.215.200.100: icmp_seq=1 ttl=64 time=0.592 ms

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

Step 5: Run command system ntp status at DUT0 and check if output contains the following tokens:

10.215.200.100
Show output
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 10.215.200.100  .INIT.          16 u    -    8    0    0.000    0.000   0.000

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

Tue
Show output
Wed Dec 13 02:11:53 UTC 2023

Test RTC Synchronization

Description

Tests 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.215.200.100/24
set protocols static route 0.0.0.0/0 next-hop 10.215.200.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.215.200.50/24

Step 3: Ping IP address 10.215.200.100 from DUT0:

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

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

Step 4: Run command set date 2023-12-12 12:00:00 at DUT0 and expect this output: Step 5: Run command set date ntp 10.215.200.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)
2023-12-12 12:00:00.124275 (+0000) +51123.911962 +/- 34090.555484 10.215.200.100 s4 no-leap

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

Tue
Show output
Wed Dec 13 02:12:05 UTC 2023

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: 1702433525.756307
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1702433524 seconds after 1969
Last calibration done at 1702433524 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 - 1702433525.760484 is too far past 1702433525.500000 (0.260484 > 0.001000)
1702433526.500000 is close enough to 1702433526.500000 (0.000000 < 0.002000)
Set RTC to 1702433526 (1702433525 + 1; refsystime = 1702433525.000000)
Setting Hardware Clock to 02:12:06 = 1702433526 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 1702433525 0.000000
1702433525
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: 1702433526.637378
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1702433525 seconds after 1969
Last calibration done at 1702433525 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: 2023/12/13 02:12:07
Hw clock time : 2023/12/13 02:12:07 = 1702433527 seconds since 1969
Time since last adjustment is 2 seconds
Calculated Hardware Clock drift is 0.000000 seconds
Calling settimeofday(1702433527.000000, 0)

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

Tue
Show output
Wed Dec 13 02:12:07 UTC 2023

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.215.200.100/24
set protocols static route 0.0.0.0/0 next-hop 10.215.200.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.215.200.50/24

Step 3: Ping IP address 10.215.200.100 from DUT0:

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

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

Step 4: Run command set date 2023-12-12 12:00:00 at DUT0 and expect this output: Step 5: Run command set date ntp 10.215.200.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)
2023-12-12 12:00:00.106841 (+0000) +51135.615695 +/- 34098.357973 10.215.200.100 s4 no-leap

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

Tue
Show output
Wed Dec 13 02:12:16 UTC 2023

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: 1702433536.767866
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1702433535 seconds after 1969
Last calibration done at 1702433535 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: 2023/12/13 02:12:17
Hw clock time : 2023/12/13 02:12:17 = 1702433537 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
1702433537.500000 is close enough to 1702433537.500000 (0.000000 < 0.001000)
Set RTC to 1702433537 (1702433537 + 0; refsystime = 1702433537.000000)
Setting Hardware Clock to 02:12:17 = 1702433537 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 1702433537 0.000000
1702433537
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: 1702433537.627548
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1702433537 seconds after 1969
Last calibration done at 1702433537 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: 2023/12/13 02:12:18
Hw clock time : 2023/12/13 02:12:18 = 1702433538 seconds since 1969
Time since last adjustment is 1 second
Calculated Hardware Clock drift is 0.000000 seconds
Calling settimeofday(1702433538.000000, 0)

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

Tue
Show output
Wed Dec 13 02:12:18 UTC 2023

Test NTP Service With Client Authentication Only

Description

DUT0 is configured to use NTP authentication. An NTP server is configured without authentication. Optaining the time should fail due to crypto failure, in which case the test succeeeds.

Scenario

Step 1: Set the following configuration in DUT0:

set interfaces ethernet eth0 address 10.215.200.50/24
set system ntp authentication-key 1 md5 unencryptedKey

Step 2: Set the following configuration in DUT1:

set interfaces ethernet eth0 address 10.215.200.100/24
set protocols static route 0.0.0.0/0 next-hop 10.215.200.50
set system ntp master prefer
set system ntp master stratum 3

Step 3: Run command set date 2023-12-12 12:00:00 at DUT0 and expect this output: Step 4: Run command set date ntp 10.215.200.100 key 1 at DUT0 and check if output contains the following tokens:

Crypto NAK
Show output
sntp 4.2.8p12@1.3728-o (1)
Crypto NAK = 0x00000000 from 10.215.200.100
  CLI Error: Command error

Test NTP Service With Client And Server Authentication

Description

NTP client and NTP server are configured to use the same authentication key. Optaining time information should succeed.

Scenario

Step 1: Set the following configuration in DUT0:

set interfaces ethernet eth0 address 10.215.200.50/24
set system ntp authentication-key 1 md5 unencryptedKey

Step 2: Set the following configuration in DUT1:

set interfaces ethernet eth0 address 10.215.200.100/24
set protocols static route 0.0.0.0/0 next-hop 10.215.200.50
set system ntp master prefer
set system ntp master stratum 3
set system ntp authentication-key 1 md5 unencryptedKey
set system ntp trusted-key 1

Step 3: Run command set date 2023-12-12 12:00:00 at DUT0 and expect this output: Step 4: Run command set date ntp 10.215.200.100 key 1 at DUT0 and expect this output:

Show output
sntp 4.2.8p12@1.3728-o (1)
2023-12-12 12:00:01.253354 (+0000) +51158.470557 +/- 34113.594548 10.215.200.100 s4 no-leap

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

Tue
Show output
Wed Dec 13 02:12:40 UTC 2023