mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-04 07:45:07 -05:00
ntp: add client support for network correction
If the network correction is known for both the request and response, and their sum is not larger that the measured peer delay, allowing the transparent clocks to be running up to 100 ppm faster than the client's clock, apply the corrections to the NTP offset and peer delay. Don't correct the root delay to not change the estimated maximum error.
This commit is contained in:
@@ -114,7 +114,7 @@ limit=1
|
||||
for chronyc_conf in \
|
||||
"accheck 1.2.3.4" \
|
||||
"add peer 10.0.0.0 minpoll 2 maxpoll 6" \
|
||||
"add server 10.0.0.0 minpoll 6 maxpoll 10 iburst burst key 1 certset 2 maxdelay 1e-3 maxdelayratio 10.0 maxdelaydevratio 10.0 maxdelayquant 0.5 mindelay 1e-4 asymmetry 0.5 offset 1e-5 minsamples 6 maxsamples 6 filter 3 offline auto_offline prefer noselect trust require xleave polltarget 20 port 123 presend 7 minstratum 3 version 4 nts ntsport 4460 copy extfield F323" \
|
||||
"add server 10.0.0.0 minpoll 6 maxpoll 10 iburst burst key 1 certset 2 maxdelay 1e-3 maxdelayratio 10.0 maxdelaydevratio 10.0 maxdelayquant 0.5 mindelay 1e-4 asymmetry 0.5 offset 1e-5 minsamples 6 maxsamples 6 filter 3 offline auto_offline prefer noselect trust require xleave polltarget 20 port 123 presend 7 minstratum 3 version 4 nts ntsport 4460 copy extfield F323 extfield F324" \
|
||||
"add server node1.net1.clk" \
|
||||
"allow 1.2.3.4" \
|
||||
"allow 1.2" \
|
||||
|
||||
106
test/simulation/142-ntpoverptp
Executable file
106
test/simulation/142-ntpoverptp
Executable file
@@ -0,0 +1,106 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
. ./test.common
|
||||
|
||||
test_start "NTP over PTP"
|
||||
|
||||
# Block communication between 3 and 1
|
||||
base_delay="(+ 1e-4 (* -1 (equal 0.1 from 3) (equal 0.1 to 1)))"
|
||||
|
||||
cat > tmp/peer.keys <<-EOF
|
||||
1 MD5 1234567890
|
||||
EOF
|
||||
|
||||
clients=2
|
||||
peers=2
|
||||
max_sync_time=420
|
||||
|
||||
server_conf="
|
||||
ptpport 319"
|
||||
client_conf="
|
||||
ptpport 319
|
||||
authselectmode ignore
|
||||
keyfile tmp/peer.keys"
|
||||
client_server_options="minpoll 6 maxpoll 6 port 319"
|
||||
client_peer_options="minpoll 6 maxpoll 6 port 319 key 1"
|
||||
|
||||
run_test || test_fail
|
||||
check_chronyd_exit || test_fail
|
||||
check_source_selection || test_fail
|
||||
check_sync || test_fail
|
||||
|
||||
check_file_messages " 2 1 .* 319 319 1 96 " 150 160 \
|
||||
log.packets || test_fail
|
||||
check_file_messages " 1 2 .* 319 319 1 96 " 150 160 \
|
||||
log.packets || test_fail
|
||||
check_file_messages " 2 3 .* 319 319 1 116 " 150 160 \
|
||||
log.packets || test_fail
|
||||
check_file_messages " 3 2 .* 319 319 1 116 " 150 160 \
|
||||
log.packets || test_fail
|
||||
|
||||
check_config_h 'HAVE_LINUX_TIMESTAMPING 1' || test_skip
|
||||
|
||||
export CLKNETSIM_TIMESTAMPING=2
|
||||
export CLKNETSIM_LINK_SPEED=100
|
||||
|
||||
client_server_options+=" extfield F324 minpoll 0 maxpoll 0"
|
||||
client_peer_options+=" extfield F324 minpoll 0 maxpoll 0 maxdelaydevratio 1e6"
|
||||
server_conf+="
|
||||
clockprecision 1e-9
|
||||
hwtimestamp eth0"
|
||||
client_conf+="
|
||||
clockprecision 1e-9
|
||||
hwtimestamp eth0"
|
||||
delay_correction="(+ delay (* -8e-8 (+ length 46)))"
|
||||
wander=1e-9
|
||||
limit=1000
|
||||
freq_offset=-1e-4
|
||||
min_sync_time=5
|
||||
max_sync_time=20
|
||||
time_max_limit=1e-7
|
||||
time_rms_limit=2e-8
|
||||
freq_max_limit=1e-7
|
||||
freq_rms_limit=5e-8
|
||||
client_chronyd_options="-d"
|
||||
|
||||
run_test || test_fail
|
||||
check_chronyd_exit || test_fail
|
||||
check_source_selection || test_fail
|
||||
check_sync || test_fail
|
||||
|
||||
if check_config_h 'FEAT_DEBUG 1'; then
|
||||
check_log_messages "apply_net_correction.*Applied" 900 2100 || test_fail
|
||||
check_log_messages "apply_net_correction.*Invalid" 0 4 || test_fail
|
||||
fi
|
||||
|
||||
client_server_options+=" xleave"
|
||||
client_peer_options+=" xleave"
|
||||
|
||||
run_test || test_fail
|
||||
check_chronyd_exit || test_fail
|
||||
check_source_selection || test_fail
|
||||
check_sync || test_fail
|
||||
|
||||
if check_config_h 'FEAT_DEBUG 1'; then
|
||||
check_log_messages "apply_net_correction.*Applied" 900 2100 || test_fail
|
||||
check_log_messages "apply_net_correction.*Invalid" 0 4 || test_fail
|
||||
|
||||
freq_offset=0.0
|
||||
delay_correction="(+ -1.0e-9 (* 1.0001 delay))"
|
||||
|
||||
run_test || test_fail
|
||||
check_chronyd_exit || test_fail
|
||||
|
||||
check_log_messages "apply_net_correction.*Applied" 350 1400 || test_fail
|
||||
check_log_messages "apply_net_correction.*Invalid" 350 1400 || test_fail
|
||||
|
||||
server_conf="ptpport 319"
|
||||
client_conf="ptpport 319"
|
||||
|
||||
run_test || test_fail
|
||||
check_chronyd_exit || test_fail
|
||||
|
||||
check_log_messages "apply_net_correction.*Applied" 0 0 || test_fail
|
||||
fi
|
||||
|
||||
test_pass
|
||||
@@ -1,41 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
. ./test.common
|
||||
|
||||
test_start "PTP port"
|
||||
|
||||
# Block communication between 3 and 1
|
||||
base_delay="(+ 1e-4 (* -1 (equal 0.1 from 3) (equal 0.1 to 1)))"
|
||||
|
||||
cat > tmp/peer.keys <<-EOF
|
||||
1 MD5 1234567890
|
||||
EOF
|
||||
|
||||
clients=2
|
||||
peers=2
|
||||
max_sync_time=420
|
||||
|
||||
server_conf="
|
||||
ptpport 319"
|
||||
client_conf="
|
||||
ptpport 319
|
||||
authselectmode ignore
|
||||
keyfile tmp/peer.keys"
|
||||
client_server_options="minpoll 6 maxpoll 6 port 319"
|
||||
client_peer_options="minpoll 6 maxpoll 6 port 319 key 1"
|
||||
|
||||
run_test || test_fail
|
||||
check_chronyd_exit || test_fail
|
||||
check_source_selection || test_fail
|
||||
check_sync || test_fail
|
||||
|
||||
check_file_messages " 2 1 .* 319 319 1 96 " 150 160 \
|
||||
log.packets || test_fail
|
||||
check_file_messages " 1 2 .* 319 319 1 96 " 150 160 \
|
||||
log.packets || test_fail
|
||||
check_file_messages " 2 3 .* 319 319 1 116 " 150 160 \
|
||||
log.packets || test_fail
|
||||
check_file_messages " 3 2 .* 319 319 1 116 " 150 160 \
|
||||
log.packets || test_fail
|
||||
|
||||
test_pass
|
||||
@@ -31,6 +31,7 @@ default_primary_time_offset=0.0
|
||||
default_time_offset=1e-1
|
||||
default_freq_offset=1e-4
|
||||
default_base_delay=1e-4
|
||||
default_delay_correction=""
|
||||
default_jitter=1e-4
|
||||
default_jitter_asymmetry=0.0
|
||||
default_wander=1e-9
|
||||
@@ -460,6 +461,10 @@ run_test() {
|
||||
for j in $(seq 1 $nodes); do
|
||||
echo "node${i}_delay${j} = $(get_delay_expr up)"
|
||||
echo "node${j}_delay${i} = $(get_delay_expr down)"
|
||||
if [ -n "$delay_correction" ]; then
|
||||
echo "node${i}_delay_correction${j} = $delay_correction"
|
||||
echo "node${j}_delay_correction${i} = $delay_correction"
|
||||
fi
|
||||
done
|
||||
done > tmp/conf
|
||||
|
||||
|
||||
Reference in New Issue
Block a user