Commit 8228e1cf authored by Joanne Hugé's avatar Joanne Hugé

Update code related to PTP and sync measure

Add ptp scripts
Fix PTP script
Update scripts, add shuttle A20 measure
Set DMA latency target for server
Update phc2sys
Use CLOCK_REALTIME in server
parent ea156ea4
......@@ -600,8 +600,6 @@ class MeasureSet:
while len(lines) > 0:
measure_set = {}
measure_set['props_type'] = 'histogram'
measure_set['units'] = ['us']
measure_set['props'] = [[]]
measure_set['metadata'] = {}
measure_set['metadata']['lost_packets'] = 0
......@@ -625,7 +623,7 @@ class MeasureSet:
measure_set['props_names'] = ['Packet round trip time']
elif "Shuttle-A20" in line:
measure_set['measure_type'] = 'shuttle_a20_signal_jitter'
measure_set['props_names'] = ['Shuttle controlled A20 signal output jitter']
measure_set['props_names'] = ['edge jitter', 'period jitter']
elif "Shuttle" in line:
measure_set['measure_type'] = 'shuttle_signal_jitter'
measure_set['props_names'] = ['Shuttle signal output jitter']
......@@ -635,34 +633,38 @@ class MeasureSet:
break
i+=1
measure_set['props'] = [[] for x in measure_set['props_names']]
measure_set['units'] = ['us' for x in measure_set['props_names']]
lines = lines[i+1:]
i = 0
for line in lines:
if line[0] == '#':
break
j, x = parse.parse('{:d} {:d}', line)
measure_set['props'][0].append(x)
i+=1
for prop_i in range(len(measure_set['props_names'])):
lines = lines[i:]
i = 0
for line in lines:
if line[0] == '#':
break
j, x = parse.parse('{:d} {:d}', line)
measure_set['props'][prop_i].append(x)
i+=1
for line in lines:
if ': ' not in line:
break
s,v = line.split(": ")
lines = lines[i:]
i = 0
if "Duration" in s:
measure_set['metadata']['duration'] = v[:-1]
if "High kernel latencies" in s or "Invalid parameters" in s or "Missed deadlines" in s or "Lost packets" in s:
measure_set['metadata']['lost_packets'] += int(v)
i+=1
for line in lines:
if ': ' not in line:
break
s,v = line.split(": ")
measure_set['metadata']['lost_packets'] = str(measure_set['metadata']['lost_packets'])
if "Duration" in s:
measure_set['metadata']['duration'] = v[:-1]
if "High kernel latencies" in s or "Invalid parameters" in s or "Missed deadlines" in s or "Lost packets" in s:
measure_set['metadata']['lost_packets'] += int(v)
i+=1
lines = lines[i:]
lines = lines[i:]
measure_set['metadata']['lost_packets'] = str(measure_set['metadata']['lost_packets'])
data['measure_sets'].append(measure_set)
if measure_set['measure_type'] == 'cyclictest_wake-up_latency':
......
......@@ -67,19 +67,6 @@ no, 62h51, 1000us (226318412) | 0.0000us | 586.0000us | 268.5267
![alt text](measures/graphs/packet_jitterPacket jitter.png "packet_jitter Graph")
### shuttle_a20_signal_jitter results
Two A20 boards are connected end to end with an ethernet cable to a shuttle. All devices are synchronized with PTP. The shuttle sends packets containing timestamps to the boards, and the boards emit a signal at the given timestamp. A logic analyzer measures the variation difference between the signals of the two boards.
**Common test metadata:** Device: A20, Linux kernel version: 5.6, Task priority: 98, Interval: 1000us, Boot Parameters: isolcpus,rcu_nocbs,irqaffinity, ETF qdisc delta: None, Device and processor load: None, Test duration: 0h20, Speed (Mb/s): 1000, ETF offset: 500us, Packet route: E2E, qdisc: pfifo_fast, Client device: A20, XDP: no
Minimum | Maximum | Average | Standard deviation | Lost packets
----------------------------------------------- | ----------------------------------------------- | ----------------------------------------------- | ----------------------------------------------- | ------------
**Shuttle controlled A20 signal output jitter** | **Shuttle controlled A20 signal output jitter** | **Shuttle controlled A20 signal output jitter** | **Shuttle controlled A20 signal output jitter** |
0.0000us | 267.0000us | 7.7268us | 10.8222us | 0
![alt text](measures/graphs/shuttle_a20_signal_jitterShuttle controlled A20 signal output jitter.png "shuttle_a20_signal_jitter Graph")
### ping_interval results
Ping RTT from A20 to shuttle, with fixed interval
......@@ -94,4 +81,19 @@ Minimum | Maximum | Average | Standard deviation | Lost packets
![alt text](measures/graphs/ping_intervalping RTT.png "ping_interval Graph")
### shuttle_a20_signal_jitter results
Two A20 boards are connected end to end with an ethernet cable to a shuttle. All devices are synchronized with PTP. The shuttle sends packets containing timestamps to the boards, and the boards emit a signal at the given timestamp. A logic analyzer measures the variation difference between the signals of the two boards.
**Common test metadata:** Device: A20, Linux kernel version: 5.6, Task priority: 98, Interval: 1000us, Boot Parameters: isolcpus,rcu_nocbs,irqaffinity, ETF qdisc delta: None, Device and processor load: None, Test duration: 0h20, Speed (Mb/s): 1000, ETF offset: 500us, Packet route: E2E, qdisc: pfifo_fast, Client device: A20, XDP: no
Minimum | Maximum | Average | Standard deviation | Lost packets
------------------------------- | ------------------------------- | ------------------------------- | ------------------------------- | ------------
**edge jitter - period jitter** | **edge jitter - period jitter** | **edge jitter - period jitter** | **edge jitter - period jitter** |
0.0000us - 595.0000us | 216.0000us - 1432.0000us | 6.8536us - 999.5032us | 8.4292us - 45.7510us | 0
![alt text](measures/graphs/shuttle_a20_signal_jitteredge jitter.png "shuttle_a20_signal_jitter Graph")
![alt text](measures/graphs/shuttle_a20_signal_jitterperiod jitter.png "shuttle_a20_signal_jitter Graph")
{"cyclictest_wake-up_latency": {"ids": [3, 5], "next_id": 6}, "shuttle_signal_jitter": {"ids": [0], "next_id": 1}, "packet_jitter": {"ids": [0, 1, 2, 3, 4], "next_id": 5}, "shuttle_a20_signal_jitter": {"ids": [0], "next_id": 1}, "ping_interval": {"ids": [0], "next_id": 1}}
\ No newline at end of file
{"cyclictest_wake-up_latency": {"ids": [3, 5], "next_id": 6}, "shuttle_signal_jitter": {"ids": [0], "next_id": 1}, "packet_jitter": {"ids": [0, 1, 2, 3, 4], "next_id": 5}, "ping_interval": {"ids": [0], "next_id": 1}, "shuttle_a20_signal_jitter": {"ids": [0], "next_id": 1}}
\ No newline at end of file
{"measure_sets": [{"measure_type": "shuttle_a20_signal_jitter", "props_names": ["Shuttle controlled A20 signal output jitter"], "units": ["us"], "middle": 0, "props": [[258505, 195333, 118392, 79731, 61293, 45493, 35536, 30341, 28019, 26919, 25720, 23666, 21502, 18477, 16918, 14558, 10645, 8642, 7483, 6855, 6522, 6657, 7143, 7313, 7330, 7843, 8273, 8717, 9194, 9671, 9264, 7450, 5695, 4831, 4959, 5468, 6431, 6231, 5967, 6196, 5874, 4927, 3818, 2493, 1999, 1617, 1235, 1135, 557, 177, 102, 69, 68, 51, 40, 44, 41, 41, 29, 30, 33, 33, 32, 31, 26, 22, 23, 12, 19, 16, 14, 17, 7, 8, 12, 7, 4, 5, 3, 1, 1, 2, 2, 2, 0, 1, 0, 2, 0, 1, 1, 1, 0, 1, 1, 2, 1, 2, 0, 1, 0, 3, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 1, 2, 1, 2, 0, 1, 1, 1, 1, 0, 1, 1, 0, 2, 1, 0, 1, 0, 1, 1, 2, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 5, 2, 5, 1, 2, 3, 0, 2, 4, 1, 2, 2, 2, 3, 4, 5, 0, 2, 7, 3, 0, 4, 2, 3, 0, 1, 2, 2, 2, 0, 0, 3, 3, 1, 1, 0, 0, 4, 2, 0, 2, 1, 2, 1, 0, 0, 1, 2, 0, 3, 2, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1]], "props_type": "histogram", "metadata": {"dev": "A20", "ker": "5.6", "prio": "98", "i": "1000us", "boot_p": "isolcpus,rcu_nocbs,irqaffinity", "delta": "None", "load": "None", "duration": "0h20", "speed": "1000", "etf_offset": "500us", "route": "E2E", "qdisc": "pfifo_fast", "client": "A20", "XDP": "no", "lost_packets": "0"}}]}
\ No newline at end of file
{"measure_sets": [{"measure_type": "shuttle_a20_signal_jitter", "props_names": ["edge jitter", "period jitter"], "units": ["us", "us"], "middle": 0, "props": [[185988, 159565, 131040, 105630, 84946, 69601, 58997, 47575, 38698, 31479, 25823, 22278, 19474, 17443, 15489, 14020, 13090, 12852, 13110, 12467, 11645, 11115, 10499, 10170,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 2, 2, 11, 13, 14, 16, 20, 30, 53, 45, 60, 53, 67, 69, 92, 123, 110, 116, 111, 123, 122, 109, 105, 110, 135, 151, 135, 140, 153, 172, 185, 208, 294, 381, 436, 529, 674, 810, 985, 1161, 1380, 1378, 1287, 1101, 892, 689, 548, 375, 286, 219, 185, 148, 130, 149, 154, 214, 238, 252, 258, 201, 171, 114, 82, 56, 30, 27, 12, 10, 15, 12, 16, 10, 11, 8, 10, 9, 7, 4, 4, 1, 5, 6, 5, 3, 3, 3, 4, 2, 5, 1, 1, 4, 1, 1, 3, 0, 1, 4, 3, 3, 3, 2, 3, 6, 0, 3, 3, 0, 0, 1, 0, 1, 1, 2, 3, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 2, 2, 0, 0, 0, 0, 1, 1, 3, 1, 1, 0, 2, 0, 2, 2, 1, 0, 3, 1, 1, 0, 2, 3, 1, 1, 4, 0, 1, 1, 4, 2, 3, 0, 4, 2, 1, 1, 2, 1, 1, 2, 1, 1, 0, 0, 1, 0, 2, 1, 2, 3, 1, 2, 1, 2, 0, 0, 0, 2, 2, 1, 1, 2, 0, 4, 4, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 2, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 2, 0, 0, 1, 1, 1, 1, 0, 0, 1, 2, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 2, 3, 0, 2, 1, 1, 1, 1, 0, 2, 0, 2, 3, 6, 12, 15, 17, 20, 33, 23, 36, 43, 40, 46, 59, 64, 71, 48, 77, 82, 114, 131, 206, 235, 266, 302, 334, 396, 426, 507, 655, 867, 1177, 1507, 1944, 2616, 3813, 6001, 15433, 47814, 65637, 54264, 69074, 35775, 32209, 194152, 730676, 627419, 135556, 19622, 21715, 66558, 48547, 52999, 66239, 26121, 7598, 4081, 3350, 2662, 2026, 1665, 1427, 1220, 972, 782, 645, 537, 451, 384, 340, 313, 247, 219, 179, 133, 129, 105, 79, 53, 52, 27, 14, 25, 18, 25, 29, 22, 35, 23, 17, 21, 11, 13, 11, 2, 9, 1, 2, 3, 2, 0, 3, 0, 0, 1, 0, 4, 0, 0, 1, 0, 0, 4, 2, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 0, 1, 2, 2, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1, 1, 1, 0, 0, 2, 2, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 2, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 4, 3, 3, 3, 1, 0, 0, 1, 0, 2, 3, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 2, 0, 0, 0, 1, 0, 0, 2, 2, 1, 1, 0, 2, 2, 1, 1, 4, 4, 1, 1, 3, 2, 1, 2, 1, 1, 3, 0, 0, 3, 0, 0, 2, 1, 0, 0, 2, 3, 1, 0, 1, 0, 0, 0, 0, 0, 2, 1, 1, 1, 1, 4, 0, 0, 1, 0, 0, 1, 0, 2, 1, 1, 0, 2, 0, 1, 2, 2, 1, 0, 0, 0, 0, 1, 1, 0, 1, 3, 1, 1, 1, 2, 0, 1, 1, 3, 5, 2, 2, 3, 6, 3, 2, 5, 0, 3, 3, 2, 4, 3, 2, 3, 3, 5, 5, 5, 4, 3, 4, 4, 5, 5, 4, 8, 8, 6, 14, 7, 12, 14, 21, 17, 16, 24, 26, 34, 48, 75, 106, 149, 195, 238, 271, 261, 227, 194, 166, 141, 163, 234, 247, 306, 409, 602, 783, 927, 1100, 1229, 1142, 1122, 988, 767, 649, 649, 564, 511, 481, 375, 323, 250, 220, 206, 186, 142, 152, 120, 112, 117, 121, 133, 110, 125, 109, 117, 106, 86, 91, 61, 55, 73, 34, 46, 42, 26, 25, 20, 19, 7, 14, 7, 7, 2, 1, 0, 2, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]], "props_type": "histogram", "metadata": {"dev": "A20", "ker": "5.6", "prio": "98", "i": "1000us", "boot_p": "isolcpus,rcu_nocbs,irqaffinity", "delta": "None", "load": "None", "duration": "0h20", "speed": "1000", "etf_offset": "500us", "route": "E2E", "qdisc": "pfifo_fast", "client": "A20", "XDP": "no", "lost_packets": "0"}}]}
\ No newline at end of file
......@@ -118,45 +118,6 @@ static void help(char *argv[]) {
argv[0]);
}
/* Latency trick
* if the file /dev/cpu_dma_latency exists,
* open it and write a zero into it. This will tell
* the power management system not to transition to
* a high cstate (in fact, the system acts like idle=poll)
* When the fd to /dev/cpu_dma_latency is closed, the behavior
* goes back to the system default.
*
* Documentation/power/pm_qos_interface.txt
*/
static void set_latency_target(void) {
struct stat s;
int err;
errno = 0;
err = stat("/dev/cpu_dma_latency", &s);
if (err == -1) {
error(EXIT_FAILURE, errno, "WARN: stat /dev/cpu_dma_latency failed");
return;
}
errno = 0;
latency_target_fd = open("/dev/cpu_dma_latency", O_RDWR);
if (latency_target_fd == -1) {
error(EXIT_FAILURE, errno, "WARN: open /dev/cpu_dma_latency");
return;
}
errno = 0;
err = write(latency_target_fd, &latency_target_value, 4);
if (err < 1) {
error(EXIT_FAILURE, errno, "# error setting cpu_dma_latency to %d!",
latency_target_value);
close(latency_target_fd);
return;
}
printf("# /dev/cpu_dma_latency set to %dus\n", latency_target_value);
}
/*
* Real-time thread:
* - Sends packets at a regular intervall
......
......@@ -22,6 +22,45 @@ struct timespec uint_to_ts(uint64_t t) {
return ts;
}
/* Latency trick
* if the file /dev/cpu_dma_latency exists,
* open it and write a zero into it. This will tell
* the power management system not to transition to
* a high cstate (in fact, the system acts like idle=poll)
* When the fd to /dev/cpu_dma_latency is closed, the behavior
* goes back to the system default.
*
* Documentation/power/pm_qos_interface.txt
*/
void set_latency_target(void) {
struct stat s;
int err;
errno = 0;
err = stat("/dev/cpu_dma_latency", &s);
if (err == -1) {
error(EXIT_FAILURE, errno, "WARN: stat /dev/cpu_dma_latency failed");
return;
}
errno = 0;
latency_target_fd = open("/dev/cpu_dma_latency", O_RDWR);
if (latency_target_fd == -1) {
error(EXIT_FAILURE, errno, "WARN: open /dev/cpu_dma_latency");
return;
}
errno = 0;
err = write(latency_target_fd, &latency_target_value, 4);
if (err < 1) {
error(EXIT_FAILURE, errno, "# error setting cpu_dma_latency to %d!",
latency_target_value);
close(latency_target_fd);
return;
}
printf("# /dev/cpu_dma_latency set to %dus\n", latency_target_value);
}
void add_ns(struct timespec *t, uint64_t ns) {
t->tv_nsec += ns;
......
......@@ -43,6 +43,7 @@ struct timespec uint_to_ts(uint64_t t);
void add_ns(struct timespec *t, uint64_t ns);
uint64_t calcdiff_ns(struct timespec t1, struct timespec t2);
void set_latency_target(void);
void init_signals(void (*_sighand)(int));
int _min_(int a, int b);
......
......@@ -162,7 +162,7 @@ static void *tsn_thread(void *p) {
else
recv_xdp_packet();
clock_gettime(CLOCK_MONOTONIC, &current);
clock_gettime(CLOCK_REALTIME, &current);
recv_xdp_cleanup();
// Emit signal
......@@ -285,6 +285,8 @@ int main(int argc, char *argv[]) {
// Process bash options
process_options(argc, argv);
set_latency_target();
ingress_params.use_timestamps = enable_timestamps;
ingress_params.interval = thread_params.interval;
......
#!/bin/bash
usage() {
cat << ENDUSAGE
Usage: $0 [-h] -l | [-s SEC -m MSEC -u USEC -n NSEC]
-h Show help
-l Loop
-s SEC Add offset in seconds
-m MSEC Add offset in milliseconds
-u USEC Add offset in microseconds
-n NSEC Add offset in nanoseconds
ENDUSAGE
1>&2;
exit 1;
}
offset=0
while getopts "hls:m:u:n:" opt; do
case "${opt}" in
h )
usage
;;
l )
loop=1
;;
s )
new_offset=$((OPTARG * 1000000000))
offset+=$((offset + new_offset))
;;
m )
new_offset=$((OPTARG * 1000000))
offset+=$((offset + new_offset))
;;
u )
new_offset=$((OPTARG * 1000))
offset+=$((offset + new_offset))
;;
n )
new_offset=${OPTARG}
offset+=$((offset + new_offset))
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
script_dir=$(dirname $(realpath $0))
cd $script_dir/../gettime/build;
make > /dev/null;
if [ -n "$loop" ]; then
./gettime -r -i 100000;
else
ptp_time=$(./gettime -r -q)
echo $((ptp_time + offset));
fi
......@@ -3,7 +3,7 @@
usage() {
cat << ENDUSAGE
Usage: $0 [-h] BOARD1_HOSTNAME BOARD2_HOSTNAME
Kills all processes started by test-board-synchro (ptp4l, client, server)
Kills all processes started by test-board-synchro (clients and servers)
-h Show help
ENDUSAGE
1>&2;
......@@ -27,12 +27,7 @@ shift $((OPTIND-1))
board1=$1
board2=$2
killall ptp4l;
killall phc2sys;
killall client;
killall run-client;
./sudossh $board1 "killall ptp4l";
./sudossh $board1 "killall server";
./sudossh $board2 "killall ptp4l";
./sudossh $board2 "killall server";
......@@ -59,6 +59,8 @@ def parseToggles(filename):
lines = [l for l in f]
lines = lines[3:]
values = [ parseLine(l) for l in lines]
values_c1 = []
values_c2 = []
# If both signals happenned at the same, they get merged at export
# We don't want this, so here we undo this merge
......@@ -68,10 +70,19 @@ def parseToggles(filename):
(t, c1, c2) = values[i]
if c1 != pc1 and c2 != pc2:
values.insert(i, (t, c1, c2))
values_c1.append(t)
values_c2.append(t)
i += 1
elif c1 != pc1:
values_c1.append(t)
elif c2 != pc2:
values_c2.append(t)
(pt, pc1, pc2) = values[i]
i += 1
periods_c1 = [values_c1[i] - values_c1[i-1] for i in range(1, len(values_c1))]
periods_c2 = [values_c2[i] - values_c2[i-1] for i in range(1, len(values_c2))]
values = [ t for (t, *x) in values]
deltas = []
......@@ -87,7 +98,7 @@ def parseToggles(filename):
exit()
deltas.append(values[i] - values[i-1])
return deltas
return (deltas, periods_c1, periods_c2)
print("IO error")
exit()
......@@ -121,16 +132,17 @@ def parse_args():
args = parser.parse_args()
if args.t is not None:
print("# Shuttle-A20 synchronization histogram")
filename = args.t[0]
deltas = parseToggles(filename)
(deltas, periods_c1, periods_c2) = parseToggles(filename)
print("# Shuttle-A20 synchronization signal jitter histogram")
generateHistogram(deltas)
generateHistogram(periods_c1 + periods_c2)
if args.p is not None:
filename = args.p[0]
print("# Shuttle synchronization histogram")
deltas = parsePulses(filename)
generateHistogram(deltas)
generateHistogram(deltas)
parse_args()
......@@ -74,5 +74,6 @@ log=ptp4l_${interface}_log
if [ -n "$reset" ]; then
killall ptp4l;
fi
echo "ptp4l $opts --step_threshold=1 -m &> ~/$log &";
ptp4l $opts --step_threshold=1 -m &> ~/$log &
echo "chrt -f 98 ptp4l $opts --step_threshold=1 -m &> ~/$log &";
chrt -f 97 ptp4l $opts --step_threshold=1 -m &> ~/$log &
#!/bin/bash
script_dir=$(dirname $(realpath $0))
usage() {
cat << ENDUSAGE
Usage: $0 [-h]
-h Show help
ENDUSAGE
1>&2;
exit 1;
}
while getopts "h" opt; do
case "${opt}" in
h )
usage
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
# Run phc2sys
chrt -f 95 phc2sys -m -c /dev/ptp0 -s CLOCK_REALTIME -w &> ~/phc2sys_sys_log &
chrt -f 95 phc2sys -m -c /dev/ptp1 -s CLOCK_REALTIME -w &> ~/phc2sys_sys_log &
#!/bin/bash
script_dir=$(dirname $(realpath $0))
usage() {
cat << ENDUSAGE
Usage: $0 [-h] [-s] BOARD1_HOSTNAME BOARD2_HOSTNAME
-h Show help
-s Use software timestampings
BOARD_HOSTNAME Uses /etc/hosts to find the IP address associated to the hostname
ENDUSAGE
1>&2;
exit 1;
}
while getopts "hs" opt; do
case "${opt}" in
h )
usage
;;
s )
software_ts=1
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
if [ $# -ne 2 ]; then
usage
fi
board1=$1
board2=$2
# Run linux-ptp
echo "Starting ptp4l on master";
killall ptp4l;
if [ -n "$software_ts" ]; then
$script_dir/run-ptp4l -i enp1s0;
$script_dir/run-ptp4l -i enp2s0;
else
$script_dir/run-ptp4l -i enp1s0 -H;
$script_dir/run-ptp4l -i enp2s0 -H;
fi
echo "Starting ptp4l on slaves";
$script_dir/sudossh $board1 "killall ptp4l";
$script_dir/sudossh $board2 "killall ptp4l";
$script_dir/sudossh $board1 "run-ptp4l -s";
$script_dir/sudossh $board2 "run-ptp4l -s";
......@@ -4,11 +4,11 @@ script_dir=$(dirname $(realpath $0))
usage() {
cat << ENDUSAGE
Usage: $0 [-h] [-i USEC -c USEC -s] [-T] BOARD1_HOSTNAME BOARD2_HOSTNAME
Usage: $0 [-h] [-i USEC -c USEC -t MSEC] [-T] BOARD1_HOSTNAME BOARD2_HOSTNAME
-h Show help
-i USEC Specify which interval to use in client
-c USEC Specify which offset to use for the timestamp in the packet
-s Use software timestampings
-t MSEC Set the start timestamp offset
-T Enable tracing on the boards
BOARD_HOSTNAME Uses /etc/hosts to find the IP address associated to the hostname
ENDUSAGE
......@@ -17,10 +17,11 @@ ENDUSAGE
exit 1;
}
interval=4000000
interval=500000
server_opts=""
ts_offset=6000
while getopts "hc:i:o:rsT" opt; do
while getopts "hc:i:o:rt:T" opt; do
case "${opt}" in
h )
usage
......@@ -31,8 +32,8 @@ while getopts "hc:i:o:rsT" opt; do
c )
delay=${OPTARG}
;;
s )
software_ts=1
t )
ts_offset=${OPTARG}
;;
T )
enable_tracing=1
......@@ -52,75 +53,21 @@ fi
board1=$1
board2=$2
# Setup irqs
ksoftirq1_pid=$(ps -eL -o pid,cmd | grep "ksoftirqd/1" | awk '{ print $1 }' | head -n1)
ksoftirq2_pid=$(ps -eL -o pid,cmd | grep "ksoftirqd/2" | awk '{ print $1 }' | head -n1)
# Set high priority for ksoftirq deamons
chrt -f -p 97 $ksoftirq1_pid;
chrt -f -p 97 $ksoftirq2_pid;
# Run linux-ptp
echo "Starting ptp4l on master";
killall ptp4l;
if [ -n "$software_ts" ]; then
$script_dir/run-ptp4l -i enp1s0;
$script_dir/run-ptp4l -i enp2s0;
else
$script_dir/run-ptp4l -i enp1s0 -H;
$script_dir/run-ptp4l -i enp2s0 -H;
fi
echo "Starting ptp4l on slaves";
$script_dir/sudossh $board1 "killall ptp4l";
$script_dir/sudossh $board2 "killall ptp4l";
$script_dir/sudossh $board1 "run-ptp4l -s";
$script_dir/sudossh $board2 "run-ptp4l -s";
echo "Waiting for ptp to take effect...";
sleep 30;
# Run phc2sys
#phc2sys -arrm &> ~/phc2sys1_log&
#phc2sys -arrm &> ~/phc2sys2log&
$script_dir/run-phc2sys -i enp1s0;
$script_dir/run-phc2sys -i enp2s0;
echo "Waiting for phc2sys to take effect...";
sleep 20;
echo "Start servers on slave";
$script_dir/sudossh $board1 "setup_irqs";
$script_dir/sudossh $board2 "setup_irqs";
$script_dir/sudossh $board1 "killall server";
$script_dir/sudossh $board2 "killall server";
if [ -n "$enable_tracing" ]; then
server_opts+=" -T $((interval*2)) -E \"-e irq -e sched -e net -e napi -e gpio\" -B 100000"
fi
./sudossh $board1 "killall server";
./sudossh $board2 "killall server";
killall client;
killall run-client;
$script_dir/exec-ssh-nohup $board1 "run-server -c $server_opts";
$script_dir/exec-ssh-nohup $board2 "run-server -c $server_opts";
cd $script_dir/../gettime/build;
make;
time=$(./gettime -r -q)
echo "CLOCK_REALTIME time is $time";
time=$((time + 10000000000))
ts=$($script_dir/get-ptp-time -m $ts_offset)
echo "Timestamp: $ts";
echo "Start clients on master";
cd $script_dir;
......@@ -129,5 +76,8 @@ if [ -z "$delay" ]; then
delay=$((interval / 2))
fi
$script_dir/run-client -a 1 -q -i $interval -p -I enp1s0 -c $delay -s $time $board1 &> client_enp1s0_log&
$script_dir/run-client -a 2 -q -i $interval -p -I enp2s0 -c $delay -s $time $board2 &> client_enp2s0_log&
echo "$script_dir/run-client -a 1 -q -i $interval -p -I enp1s0 -c $delay -s $ts $board1 &> client_enp1s0_log&";
echo "$script_dir/run-client -a 2 -q -i $interval -p -I enp2s0 -c $delay -s $ts $board2 &> client_enp2s0_log&";
$script_dir/run-client -a 1 -q -i $interval -p -I enp1s0 -c $delay -s $ts $board1 &> client_enp1s0_log&
$script_dir/run-client -a 2 -q -i $interval -p -I enp2s0 -c $delay -s $ts $board2 &> client_enp2s0_log&
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment