Skip to content

Instantly share code, notes, and snippets.

@rfdonnelly
Last active September 14, 2025 20:41
Show Gist options
  • Save rfdonnelly/b7c91864ba70970765f9263eb191b97c to your computer and use it in GitHub Desktop.
Save rfdonnelly/b7c91864ba70970765f9263eb191b97c to your computer and use it in GitHub Desktop.
1588 one-step timestamping

1588 one-step hardware timestamping

onestep-scenario <timeTransmitter> <timeReceiver>
$ ./onestep-scenario tt tr
+ curl -LO https://github.com/richardcochran/linuxptp/raw/refs/tags/v4.2/configs/gPTP.cfg --silent
+ scp -q -O gPTP.cfg tt:
+ scp -q -O gPTP.cfg tr:
+ ssh tt tcpdump -i eth1 -w tt.pcap
+ ssh tr tcpdump -i eth1 -w tr.pcap
+ sleep 10
+ ssh tt ptp4l -f gPTP.cfg -i eth1 --twoStepFlag 0 --BMCA noop --serverOnly 1 --priority1 0 --priority2 0
+ ssh tr ptp4l -f gPTP.cfg -i eth1 --twoStepFlag 0 --BMCA noop --clientOnly 1 --step_threshold 1
tcpdump: listening on eth1, link-type EN10MB (Ethernet), snapshot length 262144 bytes
tcpdump: listening on eth1, link-type EN10MB (Ethernet), snapshot length 262144 bytes
+ ssh tt killall ptp4l
+ ssh tt killall tcpdump
111 packets captured
116 packets received by filter
0 packets dropped by kernel
+ ssh tr killall ptp4l
+ ssh tr killall tcpdump
117 packets captured
117 packets received by filter
0 packets dropped by kernel
+ scp -q -O tt:tt.pcap .
+ scp -q -O tr:tr.pcap .

The packet captures show that the timeTransmitter sent a zeroed timestamp to it's NIC while the timeReceiver received a non-zero timestamp from its NIC.

packet diff

#!/bin/sh
tt=$1
tr=$2
hosts="$tt $tr"
intf=eth1
set -x
curl -LO https://github.com/richardcochran/linuxptp/raw/refs/tags/v4.2/configs/gPTP.cfg --silent
for host in $hosts; do
scp -q -O gPTP.cfg $host:
done
for host in $hosts; do
ssh $host tcpdump -i $intf -w $host.pcap &
done
ssh $tt ptp4l -f gPTP.cfg -i $intf --twoStepFlag 0 --BMCA noop --serverOnly 1 --priority1 0 --priority2 0 &
ssh $tr ptp4l -f gPTP.cfg -i $intf --twoStepFlag 0 --BMCA noop --clientOnly 1 --step_threshold 1 &
sleep 10
for host in $hosts; do
ssh $host killall ptp4l
ssh $host killall tcpdump
done
for host in $hosts; do
scp -q -O $host:$host.pcap .
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment