This repository contains two Python scripts used for PTP synchronization monitoring and resynchronization time testing with a commercial RU (Benetel) device connected at IP address 10.10.0.100.
Both scripts connect via SSH to the RU, monitor /var/log/pcm4l, and either visualize synchronization metrics in real-time or record recovery time under different configuration settings.
Continuously monitor and visualize synchronization performance metrics (offset, delay, mean, std) in real time from the Benetel RU via SSH.
- RU IP:
10.10.0.100 - Log Source:
/var/log/pcm4l
- Saves all parsed data to a CSV file named
sync_log.csv. - Displays four live-updating plots:
- Offset (ns)
- Delay (ns)
- Mean (ns)
- Standard Deviation (ns)
- Opens an SSH connection and runs:
ssh root@10.10.0.100 tail -F /var/log/pcm4l
- Parses log lines containing either:
or
offset: X ns delay: Y nsmean: M ns, std: S ns - Writes parsed values with timestamps into
sync_log.csv. - Plots real-time trends using
matplotlib.
python3 du_monitor.py- Python 3.7+
- Installed libraries:
pip install matplotlib
[RECV] offset=-12.3 ns, delay=184.0 ns
[RECV] mean=0.2 ns, std=0.8 ns
Automatically test re-synchronization time after simulated sync loss, across different logSyncInterval values.
- RU IP:
10.10.0.100 - Log Source:
/var/log/pcm4l
PTP_CONF = /home/inss/srs_scripts/ptp4l.confSCRIPT = /home/inss/srs_scripts/s0_ptp_run.sh- Output results saved to:
/home/inss/peihao/resync_times.csv
- Iterates through a list of
logSyncIntervalvalues:[-5, -4, -3, -2, -1, 0, 1, 2]. - For each interval:
- Updates the
logSyncIntervalinptp4l.conf. - Restarts the PTP service via
s0_ptp_run.sh. - Monitors
/var/log/pcm4lremotely through SSH.
- Updates the
- Detects sync loss (
Lost master alarm raised) and recovery (offset:/delay:). - Calculates and logs the resynchronization duration for each interval.
- Saves all results into
resync_times.csv.
python3 sync_test.py- Python 3.7+
- SSH access to the RU at
10.10.0.100 - Local read/write permission for the paths defined above
[INFO] logSyncInterval set to -3
[INFO] Restarting PTP service...
[LOG] Lost master detected
[LOG] Recovered sync in 5.62 seconds
[DONE] Results saved to /home/inss/peihao/resync_times.csv
- Both scripts assume passwordless SSH access to
root@10.10.0.100. You can enable this using an SSH key:ssh-copy-id root@10.10.0.100
- Ensure
/var/log/pcm4lis being continuously written by the RU’s synchronization process. - The scripts are designed for Benetel commercial RU, but can be adapted for other devices by changing the SSH target and log parsing regex.