summaryrefslogtreecommitdiffstats
path: root/test/simulation/142-ntpoverptp
blob: 2996dc0e8daa5f311a32c5844f9b494c36b4e77e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
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