Commit faa58445 authored by Joanne Hugé's avatar Joanne Hugé

Remove outdated scripts

parent d771d9ab
...@@ -22,54 +22,3 @@ report the results shared by the real-time thread. ...@@ -22,54 +22,3 @@ report the results shared by the real-time thread.
The real-time thread can be assigned to a CPU and can have it's priority set as The real-time thread can be assigned to a CPU and can have it's priority set as
an option, default is to 98. an option, default is to 98.
## Scripts
- run-server, run-client
Front-end interface to the client and server programs from packet-exchange
Uses create-qdisc to setup qdisc
Can use trace-cmd for tracing
Uses /etc/hosts to find IP address
- run-ptp4l, run-phc2sys, run-cyclictest
Easier interfaces to use ptp4l, phc2sys and cyclictest
- test-board-synchro
This script can be used in a setup with two boards connected to one computer
It will synchronize the computer and the boards with linux ptp, and have the computer send timestamps to the boards at a regular interval.
On receiving these timestamps, the boards will toggle one of their GPIO pins at the given timestamp, and the signals can be measured with an oscilloscope, logic analyzer, microcontroller with input capture etc...
- create-qdisc:
Setups ETF or pfifo_fast qdisc, was written for the lime2 board whose
NIC has only one queue, it should not be used for NIC with multiple RX queues
- packet-histogram-stop, packet-histogram-stop
Can automate measures between two boards using ssh and expect scripts
(Needs to be updated: currently has no documentation, and might be broken)
- sudossh
Execute a command with root privileges on the olimex boards without having to enter the password
- exec-ssh-nohup
Execute a command and fork it so that it can still run after ssh is closed
- txtime-stats.py
Used for parsing for the tcpdump option in run-server
- parse-saleae-measures.py
Used to parse measures from the Saleaea logic analyzer
## Measure analysis
The measure-analysis folder contains an automatically generated report with tables and
graphs of all measures done, which can be found in measure-analysis/measure-report.md
The report is generated by a python script on which json formatted sets of
measures can be imported (it can also parse and import cyclictest output)
The imported sets of measures are then stored in the measure folders, and the report
can then be generated with these measures.
Metadatas are included with the measures, such as the kernel version used, the boot parameters passed, various others parameters specific to the measure, etc... Measures measuring the same propriety are grouped together in tables and graphs, and are identified by their diverging metadatas. This is useful to analyse the effect of specific parameters on the measured propriety.
Report description, metadata description, and measure types description is located into report-info, it is then parsed by the script to generate the report. (The parsing is very sensitive to line breaks)
#!/bin/bash
usage() {
echo "Usage: $0 OPTIONS -c OUTPUT CLIENT_BOARD SERVER_BOARD" 1>&2;
echo " $0 OPTIONS -s OUTPUT [-t] (-p | (-e DELTA -o ETF_OFFSET)) CLIENT_BOARD SERVER_BOARD" 1>&2;
echo " $0 OPTIONS -C OUTPUT [-l]" 1>&2;
echo "OPTIONS: [-h] [-i INTERVAL] -k KERNEL_VERSION" 1>&2;
exit 1;
}
script_dir=$(dirname $(realpath $0))
interval=1000
while getopts "hb:i:c:s:tjpe:o:C:lk:" opt; do
case "${opt}" in
h )
usage
;;
b )
board=${OPTARG}
;;
i )
interval=${OPTARG}
;;
c )
client_histogram=1
output=${OPTARG}
;;
s )
server_histogram=1
output=${OPTARG}
;;
t )
server_timestamps=1
;;
p )
server_pfifo=1
;;
e )
server_etf=1
etf_delta=${OPTARG}
;;
o )
etf_offset=${OPTARG}
;;
C )
cyclictest_histogram=1
output=${OPTARG}
;;
l )
stop_load=1
;;
k )
kernel_version=${OPTARG}
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
if [ -n "$client_histogram" ] || [ -n "$server_histogram" ]; then
if [ $# -ne 2 ]; then
echo "Wrong number of arguments";
usage
else
client_board=$1
server_board=$2
fi
elif [ -n "$cyclictest_histogram" ]; then
if [ $# -ne 1 ]; then
echo "Wrong number of arguments";
usage
else
board=$1
fi
else
echo "You need to choose between client, server or cyclictest histogram";
usage
fi
if [ -n "$client_histogram" ]; then
echo "Killing client ($client_board)...";
ssh -t $client_board "echo olimex | sudo -S killall client";
echo "Killing server ($server_board)...";
ssh -t $server_board "echo olimex | sudo -S killall server";
echo "Copying $output...";
scp $client_board:$output $script_dir/;
cd $script_dir/../measure-analysis;
echo "Writing metadata...";
cat > client_metadata << EndOfMessage
{"ker": "$kernel_version"}
EndOfMessage
./measure-analysis.py -i $script_dir/$output -I client_metadata;
./measure-analysis.py -R;
rm client_metadata;
rm $script_dir/$output;
elif [ -n "$server_histogram" ]; then
echo "Killing server ($server_board)...";
ssh -t $server_board "echo olimex | sudo -S killall server";
echo "Killing client ($client_board)...";
ssh -t $client_board "echo olimex | sudo -S killall client";
echo "Copying $output";
scp $server_board:$output $script_dir/;
cd $script_dir/../measure-analysis;
echo "Writing metadata...";
if [ -n "$server_etf" ]; then
cat > server_metadata << EndOfMessage
{
"ker": "$kernel_version",
"qdisc": "etf",
"etf_offset": "${etf_offset}us",
"delta": "${etf_delta}us"
}
EndOfMessage
else
cat > server_metadata << EndOfMessage
{
"ker": "$kernel_version"
}
EndOfMessage
fi
./measure-analysis.py -i $script_dir/$output -I server_metadata;
./measure-analysis.py -R;
rm server_metadata;
rm $script_dir/$output;
elif [ -n "$cyclictest_histogram" ]; then
echo "Killing cyclictest on $board...";
ssh -t $board "echo olimex | sudo -S killall cyclictest";
if [ -n "$stop_load" ]; then
ssh -t $board "echo olimex | sudo -S killall run-cyclictest";
ssh -t $board "echo olimex | sudo -S killall hackbench";
fi
scp $board:$output $script_dir/;
cd $script_dir/../measure-analysis;
echo "Writing metadata...";
if [ -n "$stop_load" ]; then
cat > cyclictest_metadata << EndOfMessage
{
"ker": "$kernel_version",
"load": "hackbench",
"i": "${interval}us"
}
EndOfMessage
else
cat > cyclictest_metadata << EndOfMessage
{
"ker": "$kernel_version",
"i": "${interval}us"
}
EndOfMessage
fi
./measure-analysis.py -i $script_dir/$output -c -I cyclictest_metadata;
./measure-analysis.py -R;
rm cyclictest_metadata;
rm $script_dir/$output;
fi
#!/bin/bash
usage() {
echo "Usage: $0 [-I if] -e delta -H|-p" 1>&2;
exit 1;
}
tc_opts=""
interface="eth0"
while getopts "he:pHI:" opt; do
case "${opt}" in
h )
usage
;;
e )
delta=${OPTARG}
use_etf=1
;;
p )
use_pfast=1
;;
I )
interface="${OPTARG}"
;;
H )
tc_opts+=" offload on"
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
if [ -z "${use_etf}" ] && [ -z "${use_pfast}" ]; then
usage
fi
if [ -n "${use_etf}" ] && [ -n "${use_pfast}" ]; then
usage
fi
if [ -n "${use_etf}" ]; then
echo "Creating ETF qdisc with delta $delta"
tc qdisc del root dev $interface;
tc qdisc add dev $interface parent root handle 100 prio bands 2 priomap 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1;
tc qdisc add dev $interface parent 100:1 etf clockid CLOCK_TAI delta $delta $tc_opts;
tc qdisc show dev $interface;
elif [ -n "${use_pfast}" ]; then
echo "Creating pfast qdisc"
tc qdisc del root dev $interface;
tc qdisc show;
fi
#!/bin/expect
spawn ssh [lindex $argv 0]
expect "oli@"
send -- "sudo echo\r"
expect "assword"
send -- "olimex\r"
expect "oli@"
send -- "sudo nohup [lindex $argv 1] > /dev/null > [lindex $argv 2] &\r"
expect "stdout\r"
send -- \x03
expect "oli@"
#!/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
#!/bin/bash
usage() {
cat << ENDUSAGE
Usage: $0 [-h]
Kills all processes started by test-board-synchro (clients and servers)
-h Show help
ENDUSAGE
1>&2;
exit 1;
}
while getopts "h" opt; do
case "${opt}" in
h )
usage
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
killall phc2sys;
#!/bin/bash
script_dir=$(dirname $(realpath $0))
usage() {
cat << ENDUSAGE
Usage: $0 [-h] BOARD1_HOSTNAME BOARD2_HOSTNAME
Kills all processes started by test-board-synchro (clients and servers)
-h Show help
BOARD_HOSTNAME Uses /etc/hosts to find the IP address associated to the hostname
ENDUSAGE
1>&2;
exit 1;
}
while getopts "h" opt; do
case "${opt}" in
h )
usage
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
if [ $# -ne 2 ]; then
usage
fi
board1=$1
board2=$2
killall ptp4l;
$script_dir/sudossh $board1 "killall ptp4l";
$script_dir/sudossh $board2 "killall ptp4l";
#!/bin/bash
script_dir=$(dirname $(realpath $0))
usage() {
cat << ENDUSAGE
Usage: $0 [-h] BOARD1_HOSTNAME BOARD2_HOSTNAME
Kills all processes started by test-board-synchro (clients, servers, software-pulse)
-h Show help
BOARD_HOSTNAME Uses /etc/hosts to find the IP address associated to the hostname
ENDUSAGE
1>&2;
exit 1;
}
while getopts "h" opt; do
case "${opt}" in
h )
usage
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
if [ $# -ne 2 ]; then
usage
fi
board1=$1
board2=$2
killall client;
killall run-client;
$script_dir/sudossh $board1 "killall server software-pulse";
$script_dir/sudossh $board2 "killall server software-pulse";
#!/bin/bash
usage() {
cat << ENDUSAGE
Usage: $0 OPTIONS -c CLIENT_BOARD SERVER_BOARD" 1>&2;
$0 OPTIONS -s [-t] (-p | (-e DELTA -o ETF_OFFSET)) CLIENT_BOARD SERVER_BOARD" 1>&2;
$0 OPTIONS -C [-l] BOARD" 1>&2;
OPTIONS: [-h] [-i INTERVAL] [-k KERNEL_VERSION]" 1>&2;
ENDUSAGE
1>&2;
exit 1;
}
script_dir=$(dirname $(realpath $0))
interval=1000
server_opts=""
cyclictest_opts=""
etf_offset=600
kernel_version="5.6-dirty"
while getopts "hi:csCtpe:o:lk:" opt; do
case "${opt}" in
h )
usage
;;
i )
interval=${OPTARG}
;;
c )
client_histogram=1
;;
s )
server_histogram=1
;;
t )
server_opts+=" -t"
;;
p )
server_pfifo=1
;;
e )
server_etf=1
etf_delta=${OPTARG}
;;
o )
etf_offset=${OPTARG}
;;
C )
cyclictest_histogram=1
;;
l )
cyclictest_opts+=" -l"
;;
k )
kernel_version=${OPTARG}
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
stop_opts="-i $interval -k $kernel_version"
if [ -n "$client_histogram" ] || [ -n "$server_histogram" ]; then
if [ $# -ne 2 ]; then
echo "Wrong number of arguments";
usage
else
client_board=$1
server_board=$2
fi
elif [ -n "$cyclictest_histogram" ]; then
if [ $# -ne 1 ]; then
echo "Wrong number of arguments";
usage
else
board=$1
fi
else
echo "You need to choose between client, server or cyclictest histogram";
usage
fi
stop_opt_name=packet-histogram_stop-options
stop_opt_index=0
while [ -f "${stop_opt_name}${stop_opt_index}" ]; do
stop_opt_index=$(( $stop_opt_index + 1 ))
done
stop_opt_filename=${stop_opt_name}${stop_opt_index}
# Client histogram
if [ -n "$client_histogram" ]; then
$script_dir/exec-ssh-nohup $server_board "run-server" server_log;
$script_dir/exec-ssh-nohup $client_board "run-client -p -i $interval -t -g $server_board" client_log;
echo "$stop_opts -c client_i${interval}_pfast -i $interval $client_board $server_board" > $script_dir/${stop_opt_filename};
# Server histogram
elif [ -n "$server_histogram" ]; then
# Server pfifo_fast qdisc histogram
if [ -n "$server_pfifo" ]; then
$script_dir/exec-ssh-nohup $server_board "run-server -g ${interval}$server_opts" server_log;
$script_dir/exec-ssh-nohup $client_board "run-client -p -i $interval $server_board" client_log;
echo "$stop_opts -s server_i${interval} $server_opts -p $client_board $server_board" > $script_dir/${stop_opt_filename};
# Server ETF qdisc histogram
elif [ -n "$server_etf" ]; then
$script_dir/exec-ssh-nohup $server_board "run-server -g ${interval}$server_opts" server_log;
$script_dir/exec-ssh-nohup $client_board "run-client -e $etf_delta -o $etf_offset -i $interval $server_board" client_log;
echo "$stop_opts -s server_i${interval} $server_opts -e $etf_delta -o $etf_offset $client_board $server_board" > $script_dir/${stop_opt_filename};
else
echo "Server histogram requires choosing between pfifo_fast or etf qdisc";
usage
fi
# cyclictest histogram
elif [ -n "$cyclictest_histogram" ]; then
$script_dir/exec-ssh-nohup $board "run-cyclictest -g $cyclictest_opts -i $interval" cyclictest_log;
echo "$stop_opts -C cyclictest_hist $cyclictest_opts $board" > $script_dir/${stop_opt_filename};
fi
#!/bin/bash
usage() {
echo "Usage: $0 STOP_OPTIONS_INDEX" 1>&2;
exit 1;
}
if [ -z "$1" ]; then
usage
fi
script_dir=$(dirname $(realpath $0))
stop_opt_name=packet-histogram_stop-options
stop_opt_index=$1
stop_opt_filename=${stop_opt_name}${stop_opt_index}
echo "$script_dir/_packet-histogram-stop `cat $stop_opt_filename`";
cat_out=`cat $stop_opt_filename`;
echo "cat_out = $cat_out";
$script_dir/_packet-histogram-stop `cat $stop_opt_filename`;
rm $stop_opt_filename
#!/bin/bash
script_dir=$(dirname $(realpath $0))
usage() {
cat << ENDUSAGE
Usage: $0 [-h] QDISC_OPT [CLIENT_OPTS] IF BOARD_HOSTNAME [IF2 BOARD_HOSTNAME2]
-h Show help
QDISC_OPTS: [-e DELTA [-o USEC] -H] [-q]
Which qdisc to use (will call create-qdisc script)
-e DELTA Use ETF (Earlier Txtime First) qdisc with specified delta
(check tc-etf man page for more information)
-o USEC Offset in userspace program to set the timestamp passed to ETF qdisc
-H Use hardware offloading for the ETF qdisc (not all hardware supports this)
-q Setup qdiscs with create-qdisc script
CLIENT_OPTS: -bgt (-c DELAY -s NS | -d TX_BUF_LEN) -i INTERVAL -I if -a CPU [TRACE_OPTS]
Options passed to the C client program (everything here is optional)
-b Measure round trip time
-g Generate histogram of the measures
-t Use SO_TIMESTAMPS to see how much time packet spent in kernel
-c DELAY Send a timestamp in the packet with the specified delay (in us)
(to be used with PTP)
-s NS Specify a CLOCK_REALTIME timestamp at which client should start
(to be used with PTP)
-d TX_BUF_LEN Length of the data sent in the packets
-i USEC Interval at which the RT thread should send packets
-a CPU CPU on which to pin the program
-U Interactive interval change
TRACE_OPTS: -T [-P TRACER -E EVENTS -B SIZE]
Options to trace with trace-cmd until ETF deadline is missed
(see trace-cmd man page and ftrace documentation)
-T Enable ETF tracing
-S THRESHOLD Enable threshold tracing
-P TRACER Which trace to use when tracing: function, function_graph, wakeup etc...
Default: function
-E EVENTS Specify which events to trace (e.g: "-E "-e net -e irq")
Default: irq, sched, net_dev_start_xmit,
net_dev_xmit, net_dev_xmit_timeout
-B SIZE Size of the buffer for each CPU in kilobytes
BOARD_HOSTNAME /etc/hosts is used to find the IP of the given hostname
ENDUSAGE
1>&2;
exit 1;
}
# Default interval
interval=1000
# Default options
interface="eth0"
cpu="1"
client_options="-p 95"
qdisc_options=""
etf_offset=500
tracecmd_events="-e irq -e sched -e net_dev_start_xmit -e net_dev_xmit -e net_dev_xmit_timeout"
tracecmd_opts=""
while getopts "a:bc:d:e:o:ghi:qs:tB:E:I:HP:TS:U:" opt; do
case "${opt}" in
h )
usage
;;
a )
cpu=${OPTARG}
;;
b )
client_options+=" -b"
;;
c )
client_options+=" -c ${OPTARG}"
;;
d )
client_options+=" -d ${OPTARG}"
;;
e )
use_etf=1
delta=$((${OPTARG}*1000))
;;
o )
etf_offset=${OPTARG}
;;
g )
client_options+=" -g"
use_histogram=1
;;
i )
interval=${OPTARG}
;;
p )
use_pfast=1
;;
q )
create_qdisc=1
;;
s )
client_options+=" -s ${OPTARG}"
;;
t )
use_timestamps=1
client_options+=" -t"
;;
B )
tracecmd_opts+=" -m ${OPTARG} -b ${OPTARG}"
;;
E )
tracecmd_events=${OPTARG}
;;
H )
qdisc_options+=" -H"
;;
P )
tracecmd_opts+=" -p ${OPTARG}"
;;
T )
use_tracer=1
client_options+=" -T"
;;
S )
use_tracer=1
client_options+=" -S ${OPTARG}"
;;
U )
client_options+=" -U ${OPTARG}"
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
qdisc_options+=" -I $interface"
client_options+=" -a $cpu"
if [ -z "$1" ] || [ -z "$2" ]; then
usage
fi
board_name=$2
board_ip=$(cat /etc/hosts | grep $board_name | awk '{print $1}')
interface=$1
board2_ip=""
interface2=""
if [ -n "$3" ]; then
if [ -z "$4" ]; then
usage
fi
interface2=$3
board2_name=$4
board2_ip=$(cat /etc/hosts | grep $board2_name | awk '{print $1}')
fi
if [ -z "${use_histogram}" ]; then
client_options+=" -v"
else
if [ -z "${use_timestamps}" ]; then
client_options+=" -t"
fi
output="client_i${interval}"
if [ -n "${use_pfast}" ]; then
output+="_pfast"
else
output+="_etf_${delta}"
fi
fi
if [ -n "${use_etf}" ]; then
client_options+=" -e $etf_offset -q 8"
qdisc_options+=" -e $delta"
else
client_options+=" -q 1"
qdisc_options+=" -p"
fi
client_options+=" -i $interval"
if [ -n "$create_qdisc" ]; then
echo "create-qdisc $qdisc_options";
$script_dir/create-qdisc $qdisc_options;
fi
echo "make client";
cd $script_dir/../packet-exchange/build;
make client;
cd $script_dir;
if [ -n "${use_histogram}" ]; then
echo "client $client_options $interface $board_ip $interface2 $board2_ip > $output;mv $output ~/";
$script_dir/../packet-exchange/build/client $client_options $interface $board_ip $interface2 $board2_ip > $output;
mv $output ~/;
elif [ -n "${use_tracer}" ]; then
echo "trace-cmd record $tracecmd_opts $tracecmd_events ./client $client_options $interface $board_ip $interface2 $board2_ip";
trace-cmd record $tracecmd_opts $tracecmd_events $script_dir/../packet-exchange/build/client $client_options $interface $board_ip $interface2 $board2_ip;
else
echo "client $client_options $interface $board_ip $interface2 $board2_ip";
$script_dir/../packet-exchange/build/client $client_options $interface $board_ip $interface2 $board2_ip;
fi
#!/bin/bash
usage() {
cat << ENDUSAGE
Usage: $0 -hgl -i INTERVAL" 1>&2
-h Show help
-g Generate histogram of the measures
-l Generate artificial load with hackbench
(This will cause heavy lag, program then needs to be stopped with
killall run-cyclictest to prevent hackbench thread to keep
being spawned)
-i INTERVAL Interval passed to cyclictest (see cyclictest man page)
ENDUSAGE
1>&2;
exit 1;
}
interval=1000
cyclictest_opts="-a1 -n -t1 -p98 -mlocakall"
while getopts "hgli:" opt; do
case "${opt}" in
h )
usage
;;
g )
generate_histogram=1
;;
l )
create_load=1
;;
i )
interval=${OPTARG}
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
cyclictest_opts+=" -i $interval"
if [ -n "$create_load" ]; then
while :
do
hackbench
done&
fi
if [ -n "$generate_histogram" ]; then
cyclictest $cyclictest_opts -h 400 -q > cyclictest_hist
else
cyclictest $cyclictest_opts
fi
#!/bin/bash
linuxptp_dir=/home/oli/linuxptp
opts=""
interface="eth0"
usage() {
echo "Usage: $0 [-r -i IF -o OPTS]" 1>&2;
exit 1;
}
while getopts "i:o:r" opt; do
case "${opt}" in
i )
interface=${OPTARG}
;;
o )
opts+=${OPTARG}
;;
r )
reset=1
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
opts+="-s $interface"
log=phc2sys_${interface}_log
if [ -n "$reset" ]; then
killall phc2sys;
fi
echo "phc2sys $opts -c CLOCK_REALTIME --step_threshold=1 --transportSpecific=1 -w -m &> ~/$log &";
phc2sys $opts -c CLOCK_REALTIME --step_threshold=1 --transportSpecific=1 -w -m &> ~/$log &
#!/bin/bash
linuxptp_dir=$HOME/linuxptp
telecom_profile="G.8265.1.cfg"
gPTP_profile="gPTP.cfg"
profile_name="none"
opts=""
interface="eth0"
usage() {
cat << ENDUSAGE
Usage: $0 [-h] [-r -p telecom|gPTP|OTHER -s -H -i IF -o OPTS]
-h Show help
-r Kill all ptp4l programs before
-p Use a linuxptp profile (see in linuxptp/configs)
-s Use slave mode
-H Use hardware timestamping
-i IF Set network interface to be used
-o OPTS Pass additionnal options to linuxptp
ENDUSAGE
1>&2;
exit 1;
}
while getopts "i:o:p:rsH" opt; do
case "${opt}" in
i )
interface=${OPTARG}
;;
H )
hardware_ts=1
opts+=" -H "
;;
o )
opts+=${OPTARG}
;;
p )
profile_name=${OPTARG}
;;
r )
reset=1
;;
s )
opts+=" -s "
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
if [ -z "$hardware_ts" ]; then
opts+=" -S "
fi
opts+="-i $interface"
if [ $profile_name == "none" ]; then
opts+=""
elif [ $profile_name == "telecom" ]; then
opts+=" -f $linuxptp_dir/configs/$telecom_profile "
elif [ $profile_name == "gPTP" ]; then
opts+=" -f $linuxptp_dir/configs/$gPTP_profile "
else
opts+=" -f $profile_name "
fi
log=ptp4l_${interface}_log
if [ -n "$reset" ]; then
killall ptp4l;
fi
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() {
echo "Usage: $0 | " 1>&2;
exit 1;
}
usage() {
cat << ENDUSAGE
Usage: $0 [-h] [-I if] [SERVER] | TCPDUMP [TRACE_OPTS]
-h Show help
SERVER: -bctX -g INTERVAL -a CPU
Options passed to the C server program (everything here is optional)
-b Send back packets for round trip measurements
-c USEC Emit a signal on GPIO at the timestamp given in packet, specify interval
(to be used with -c option in client program)
-C USEC Measure difference between current time and timestamp sent in tx data
-t Use SO_TIMESTAMPS to see how much time packet spent in kernel
-X Use XDP sockets, with libbpf located in \$HOME/libbpf folder
-s NS Specify a CLOCK_REALTIME timestamp at which client should start
(to be used with PTP) (interval needs to be specified with -j)
-j USEC Specify interval (used with -s)
-g USEC Generate histograms for measures with the specified interval
-a CPU CPU on which to pin the program
TCPDUMP: -d NB_PACKETS [-i INTERVAL]
Will use tcpdump to capture the packets and measure jitter
-d NB_PACKETS Use tcpdump to capture given amount of packets
(don't set it too high, it doesn't scale well)
-i USEC Specify which interval was used in the client
Default: 1ms
TRACE_OPTS: -T LATENCY_THRESHOLD [-P TRACER -E XDP_EVENTS]
Trace until latency threshold is met
-T USEC Enable tracing until threshold is met
-Q Enable eth0 IRQ tracing only
-P TRACER Which trace to use when tracing: function, function_graph, wakeup etc...
Default: function
-E EVENTS Specify which events to trace (e.g: "-E "-e net -e irq")
Default: irq, sched, net, napi
-B SIZE Size of the buffer for each CPU in kilobytes
-M Send tracemark when packet is received\n"
-S Send tracemark containing RX SO_TIMESTAMP timestamp\n"
ENDUSAGE
1>&2;
exit 1;
}
# Default options
interface="eth0"
server_options="-p 95"
make_opts=""
ip="10.100.21."
tcpdump_interval=1000000
tracecmd_events="-e irq -e sched -e net -e napi"
tracecmd_opts=""
cpu=1
while getopts "j:a:b:c:C:htx:Xs:d:i:g:I:T:E:P:B:MSQ" opt; do
case "${opt}" in
h )
usage
;;
j )
server_options+=" -i ${OPTARG}"
;;
a )
cpu=${OPTARG}
;;
b )
use_rtt=1
board_name=${OPTARG}
;;
c )
server_options+=" -c -i ${OPTARG}"
;;
C )
server_options+=" -C -i ${OPTARG}"
;;
d )
use_tcpdump=1
nb_packets=${OPTARG}
;;
i )
tcpdump_interval=${OPTARG}
;;
g )
interval=${OPTARG}
server_options+=" -g -i $interval"
use_histogram=1
;;
t )
server_options+=" -t"
;;
x )
server_options+=" -x ${OPTARG}"
make_opts=" -e WITH_XDP=1"
;;
I )
interface="${OPTARG}"
;;
X )
server_options+=" -x "
make_opts=" -e WITH_GIT_XDP=1"
;;
s )
server_options+=" -s ${OPTARG}"
;;
B )
tracecmd_opts+=" -m ${OPTARG} -b ${OPTARG}"
;;
E )
tracecmd_events=${OPTARG}
;;
P )
tracecmd_opts+=" -p ${OPTARG}"
;;
T )
use_tracer=1
server_options+=" -T ${OPTARG}"
;;
M )
server_options+=" -M "
;;
S )
server_options+=" -S "
;;
Q )
use_tracer=1
server_options+=" -T 999999"
tracecmd_events=" -e irq_handler_entry "
tracecmd_filter="irq == 56"
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
server_options+=" -f $interface -a $cpu"
if [ -n "${use_rtt}" ]; then
board_ip=$(cat /etc/hosts | grep $board_name | awk '{print $1}')
server_options+=" -b $board_ip"
fi
if [ -z "${use_histogram}" ]; then
server_options+=" -v"
else
output="server_i${interval}"
fi
if [ -n "${use_tcpdump}" ]; then
echo "tcpdump -c $nb_packets -i $interface -w tmp.pcap -tt --time-stamp-precision=nano udp port 50000";
tcpdump -c $nb_packets -i $interface -w server_stats_tmp.pcap -tt --time-stamp-precision=nano udp port 50000;
echo "tshark -r tmp.pcap --disable-protocol dcp-etsi --disable-protocol dcp-pft -t e -E separator=, -T fields -e frame.number -e frame.time_epoch -e data.data > tmp.out";
tshark -r server_stats_tmp.pcap --disable-protocol dcp-etsi --disable-protocol dcp-pft -t e -E separator=, -T fields -e frame.number -e frame.time_epoch -e data.data > server_stats_tmp.out;
echo "txtime-stats.py -f server_pcap_stats -i $tcpdump_interval";
$script_dir/txtime-stats.py -f server_stats_tmp.out -i $tcpdump_interval;
else
echo "make $make_opts server";
cd $script_dir/../packet-exchange/build;make $make_opts server;cd $script_dir
if [ -n "${use_tracer}" ]; then
if [ -n "${tracecmd_filter}" ]; then
echo "trace-cmd record $tracecmd_opts $tracecmd_events -f \"$tracecmd_filter\" $script_dir/../packet-exchange/build/server $server_options";
trace-cmd record $tracecmd_opts $tracecmd_events -f "$tracecmd_filter" $script_dir/../packet-exchange/build/server $server_options;
else
echo "trace-cmd record $tracecmd_opts $tracecmd_events $script_dir/../packet-exchange/build/server $server_options";
trace-cmd record $tracecmd_opts $tracecmd_events $script_dir/../packet-exchange/build/server $server_options;
fi
elif [ -z "${use_histogram}" ]; then
echo "server $server_options";
$script_dir/../packet-exchange/build/server $server_options;
else
echo "server $server_options > $output; mv $output ~/";
$script_dir/../packet-exchange/build/server $server_options > $output;
mv $output ~/;
fi
fi
#!/bin/bash
script_dir=$(dirname $(realpath $0))
usage () {
cat << ENDUSAGE
Usage: $0 [-h] [-i USEC -g -s -t MSEC] BOARD1_HOSTNAME BOARD2_HOSTNAME
-h Show help
-i USEC Signal period
-g Use GPIO instead of serial
-t MSEC Set the start timestamp offset
-P USEC Do polling to wakeup with specified margin
BOARD_HOSTNAME Uses /etc/hosts to find the IP address associated to the hostname
ENDUSAGE
1>&2;
exit 1;
}
interval=1000
pp_opts=""
ts_offset=6000
while getopts "hi:gt:P:" opt; do
case "$opt" in
h)
usage
;;
i)
interval=${OPTARG}
;;
g)
pulse_opts+=" -g "
;;
t )
ts_offset=${OPTARG}
;;
P )
pulse_opts+=" -P ${OPTARG} "
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
if [ $# -ne 2 ]; then
usage
fi
board1=$1
board2=$2
ts=$($script_dir/get-ptp-time -m $ts_offset)
echo "Timestamp: $ts";
ssh $board1 "cd tsn-measures/software-pulse/build;make";
echo "$script_dir/exec-ssh-nohup $board1 \"tsn-measures/software-pulse/build/software-pulse -a1 -p97 -i $interval $pulse_opts -s $ts\"" server_log;
$script_dir/exec-ssh-nohup $board1 "tsn-measures/software-pulse/build/software-pulse -a1 -p97 -i $interval $pulse_opts -s $ts" server_log;
ssh $board2 "cd tsn-measures/software-pulse/build;make";
echo "$script_dir/exec-ssh-nohup $board2 \"tsn-measures/software-pulse/build/software-pulse -a1 -p97 -i $interval $pulse_opts -s $ts\"" server_log;
$script_dir/exec-ssh-nohup $board2 "tsn-measures/software-pulse/build/software-pulse -a1 -p97 -i $interval $pulse_opts -s $ts" server_log;
#!/bin/bash
script_dir=$(dirname $(realpath $0))
usage() {
cat << ENDUSAGE
Usage: $0 [-h] [-is -c USEC] [-X]
-h Show help
-i Init motors
-s Start servers on olimex boards
-c USEC Specify which offset to use for the timestamp in the packet
-X Use XDP
BOARD_HOSTNAME Uses /etc/hosts to find the IP address associated to the hostname
ENDUSAGE
1>&2;
exit 1;
}
interval=1000
server_opts=""
delay=250
while getopts "hisc:X" opt; do
case "${opt}" in
h )
usage
;;
i )
init_motors=1
;;
s )
start_servers=1
;;
c )
delay=${OPTARG}
;;
X )
server_opts+=" -X "
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
board1="onyx"
board2="slate"
killall client;
killall run-client;
if [ -n "$init_motors" ]; then
$script_dir/sudossh $board1 "motor-scripts/motor-init";
$script_dir/sudossh $board2 "motor-scripts/motor-init";
$script_dir/sudossh $board1 "motor-scripts/motor-cw";
$script_dir/sudossh $board2 "motor-scripts/motor-ccw";
fi
if [ -n "$start_servers" ]; then
$script_dir/sudossh $board1 "killall server";
$script_dir/sudossh $board2 "killall server";
$script_dir/exec-ssh-nohup $board1 "run-server -c $interval $server_opts" server_log;
$script_dir/exec-ssh-nohup $board2 "run-server -c $interval $server_opts" server_log;
sleep 5;
fi
echo "$script_dir/run-client -i 40000 -c $delay -U 100 enp1s0 $board1 enp2s0 $board2";
$script_dir/run-client -i 40000 -c $delay -U 100 enp1s0 $board1 enp2s0 $board2
#!/bin/expect
spawn ssh [lindex $argv 0]
expect "oli@"
send -- "sudo [lindex $argv 1]\r"
expect "assword"
send -- "olimex\r"
expect {
"Do you want to continue?" {
send "Y\r"
exp_continue
}
"oli@" {
exit
}
}
#!/bin/bash
script_dir=$(dirname $(realpath $0))
usage() {
cat << ENDUSAGE
Usage: $0 [-h]
-h Show help
-s use CLOCK_REALTIME as slave (might not work well)
ENDUSAGE
1>&2;
exit 1;
}
while getopts "hs" opt; do
case "${opt}" in
h )
usage
;;
s )
rt_slave=1
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
# Run phc2sys
pmc -u -b 0 -i enp1s0 "SET GRANDMASTER_SETTINGS_NP clockClass 248 clockAccuracy 0xfe offsetScaledLogVariance 0xffff currentUtcOffset 37 leap61 0 leap59 0 currentUtcOffsetValid 1 ptpTimescale 1 timeTraceable 1 frequencyTraceable 0 timeSource 0xa0"
pmc -u -b 0 -i enp2s0 "SET GRANDMASTER_SETTINGS_NP clockClass 248 clockAccuracy 0xfe offsetScaledLogVariance 0xffff currentUtcOffset 37 leap61 0 leap59 0 currentUtcOffsetValid 1 ptpTimescale 1 timeTraceable 1 frequencyTraceable 0 timeSource 0xa0"
if [ -n "$rt_slave" ]; then
chrt -f 95 phc2sys -m -c /dev/ptp0 -s /dev/ptp1 --step_threshold=1 -w &> ~/phc2sys_ptps_log &
chrt -f 95 phc2sys -m -s /dev/ptp0 -c CLOCK_REALTIME --step_threshold=1 -w &> ~/phc2sys_rt_log &
else
chrt -f 95 phc2sys -m -c /dev/ptp0 -s CLOCK_REALTIME --step_threshold=1 -w &> ~/phc2sys_ptp0_log &
chrt -f 95 phc2sys -m -c /dev/ptp1 -s CLOCK_REALTIME --step_threshold=1 -w &> ~/phc2sys_ptp1_log &
fi
#!/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
-p Use a linuxptp profile (see in linuxptp/configs)
BOARD_HOSTNAME Uses /etc/hosts to find the IP address associated to the hostname
ENDUSAGE
1>&2;
exit 1;
}
ptp_opts=""
while getopts "hsp:" opt; do
case "${opt}" in
h )
usage
;;
s )
software_ts=1
;;
p )
ptp_opts+=" -p ${OPTARG}"
;;
* )
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 $ptp_opts -i enp1s0;
$script_dir/run-ptp4l $ptp_opts -i enp2s0;
else
$script_dir/run-ptp4l $ptp_opts -i enp1s0 -H;
$script_dir/run-ptp4l $ptp_opts -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 $ptp_opts -s";
$script_dir/sudossh $board2 "run-ptp4l $ptp_opts -s";
#!/bin/bash
script_dir=$(dirname $(realpath $0))
usage() {
cat << ENDUSAGE
Usage: $0 [-h] [-i USEC -c USEC -t MSEC] [-TX] 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
-t MSEC Set the start timestamp offset
-X Use XDP
-T Enable tracing on the boards
BOARD_HOSTNAME Uses /etc/hosts to find the IP address associated to the hostname
ENDUSAGE
1>&2;
exit 1;
}
interval=1000
server_opts=""
ts_offset=2000
while getopts "hc:i:o:rt:TX" opt; do
case "${opt}" in
h )
usage
;;
i )
interval=${OPTARG}
;;
c )
delay=${OPTARG}
;;
t )
ts_offset=${OPTARG}
;;
T )
enable_tracing=1
;;
X )
server_opts+=" -X "
;;
* )
usage
;;
esac
done
shift $((OPTIND-1))
if [ $# -ne 2 ]; then
usage
fi
board1=$1
board2=$2
if [ -n "$enable_tracing" ]; then
server_opts+=" -T $((interval*2)) -E \"-e irq -e sched -e net -e napi -e gpio\" -B 100000"
fi
$script_dir/sudossh $board1 "killall server";
$script_dir/sudossh $board2 "killall server";
killall client;
killall run-client;
$script_dir/exec-ssh-nohup $board1 "run-server -c $interval $server_opts" server_log;
$script_dir/exec-ssh-nohup $board2 "run-server -c $interval $server_opts" server_log;
ts=$($script_dir/get-ptp-time -m $ts_offset)
echo "Timestamp: $ts";
echo "Start clients on master";
cd $script_dir;
if [ -z "$delay" ]; then
delay=$((interval / 2))
fi
echo "$script_dir/run-client -a 1 -i $interval -I enp1s0 -c $delay -s $ts $board1 &> client_enp1s0_log&";
echo "$script_dir/run-client -a 2 -i $interval -I enp2s0 -c $delay -s $ts $board2 &> client_enp2s0_log&";
$script_dir/run-client -a 1 -i $interval -I enp1s0 -c $delay -s $ts $board1 &> client_enp1s0_log&
$script_dir/run-client -a 2 -i $interval -I enp2s0 -c $delay -s $ts $board2 &> client_enp2s0_log&
#!/usr/bin/env python3
#
# Copyright (c) 2018, Intel Corporation
#
# SPDX-License-Identifier: BSD-3-Clause
#
# Expected input file format is a CSV file with:
#
# <FRAME_NUMBER, FRAME_ARRIVAL_TIME, FRAME_PAYLOAD_BYTES>
# E.g.:
# 1,1521534608.000000456,00:38:89:bd:a1:93:1d:15:(...)
# 2,1521534608.001000480,00:38:89:bd:a1:93:1d:15:(...)
#
# Frame number: sequence number for each frame
# Frame arrival time: Rx HW timestamp for each frame
# Frame Payload: payload starting with 64bit timestamp (txtime)
#
# This can be easily generated with tshark with the following command line:
# $ tshark -r CAPTURE.pcap -t e -E separator=, -T fields -e frame.number \
# -e frame.time_epoch \
# -e data.data > DATA.out
#
import argparse
import csv
import struct
import math
import sys
import json
def compute_offsets_stats(file_path, interval):
interval = int(interval)
measure_set = {}
measure_set["measure_type"] = "packet_jitter_tcpdump"
measure_set["props_names"] = ["jitter"]
measure_set["units"] = ["us"]
measure_set["props_type"] = "histogram"
measure_set["metadata"] = {"i": interval}
measure_set["middle"] = 1000
histogram = [0 for i in range(0, 2000)]
with open(file_path) as f:
min_t = sys.maxsize
max_t = -sys.maxsize
i = 0
prev_tstamp = 0
for line in csv.reader(f):
arrival_tstamp = int(line[1].replace('.', ''))
if i > 0:
val = arrival_tstamp - prev_tstamp
jitter = (val - interval * 1000) / 1000
histogram_index = int(1000 + jitter)
if histogram_index < 0 or histogram_index > 2000:
print("jitter too high: {}\n".format(jitter))
else:
histogram[histogram_index] += 1
# Update statistics.
min_t = jitter if jitter < min_t else min_t
max_t = jitter if jitter > max_t else max_t
i += 1
prev_tstamp = arrival_tstamp
if i > 0:
print("Jitter: {}us".format(max_t - min_t))
measure_set["props"] = [histogram]
data = {}
data["measure_sets"] = [measure_set]
path = "tcpdump_histogram"
with open(path, 'w') as outfile:
json.dump(data, outfile)
def main():
parser = argparse.ArgumentParser()
parser.add_argument('-f', dest='file_path', default=None, type=str,
help='Path to input file (e.g. DATA.out) generated by tshark with:\
tshark -r CAPTURE.pcap -t e -E separator=, -T\
fields -e frame.number -e frame.time_epoch\
-e data.data > DATA.out')
parser.add_argument('-i', nargs=1, required=False, help='Indicate which interval was used')
# Default interval
interval = 1000000
args = parser.parse_args()
if args.i is not None:
interval = args.i[0]
if args.file_path is not None:
compute_offsets_stats(args.file_path, interval)
else:
parser.print_help()
if __name__ == "__main__":
main()
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