explaingit

nt2ds/win32_ptp

23CAudience · ops devopsComplexity · 4/5Setup · hard

TLDR

A Windows C library and daemon that synchronizes clocks to microsecond precision using IEEE 1588 PTPv2, embed it in your own app or run the standalone executable for testing.

Mindmap

mindmap
  root((repo))
    What it does
      Clock synchronization
      IEEE 1588 PTPv2
      Windows only
    Modes
      Grandmaster device
      Slave-only device
    Integration
      Library files
      Handler object init
      Standalone executable
    Use cases
      Audio video production
      Industrial control
      Telecom networks
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Sync a Windows machine's clock to microsecond precision for audio/video production or industrial control networks.

USE CASE 2

Embed PTPv2 grandmaster or slave mode into your own Windows C application by copying a handful of files.

USE CASE 3

Test precision time synchronization on Windows without writing code using the standalone executable.

Tech stack

CWindows API

Getting it running

Difficulty · hard Time to first run · 1h+

Requires administrator privileges on Windows to adjust the system clock, hardware timestamping is planned but not yet implemented.

In plain English

This is a Windows implementation of the Precision Time Protocol version 2 (PTPv2, also known as IEEE 1588), written from scratch in C using only the Windows API. PTPv2 is a standard used in networks where multiple devices need their clocks synchronized to within microseconds of each other, such as in audio/video production, industrial control, or telecommunications equipment. The daemon runs in its own thread so it does not block the rest of your program while it keeps the clock in sync. You can integrate it as a library in your own project by copying a handful of files and initializing a handler object with the IP address of the network adapter you want it to use. A standalone executable is also available on the releases page for testing without writing any code. The program supports running as a grandmaster (the device that other clocks follow) or as a slave-only device (a device that follows another clock). You can specify a network domain and a priority value that affects which device wins the automatic election for grandmaster when multiple time sources are present. Software timestamping is supported, hardware timestamping and a peer-delay measurement mechanism are listed as planned for future additions. The author notes the code avoids branching in favor of lookup tables for performance, and that comments in the source explain not just what each section does but why those design choices were made. The project is currently in a testing phase and is part of a larger effort to build an AES67 audio-over-IP transmitter and receiver for Windows, which the author plans to release as open source when finished. Running the executable requires administrator privileges because adjusting the system clock on Windows is a protected operation.

Copy-paste prompts

Prompt 1
Show me how to initialize the win32_ptp handler object in C with a specific network adapter IP address and run it as a PTP slave device.
Prompt 2
I want to run win32_ptp as a grandmaster on Windows. What settings do I configure for domain number and priority value?
Prompt 3
My win32_ptp slave is not syncing to the grandmaster. What are common causes and how do I debug the clock offset?
Open on GitHub → Explain another repo

← nt2ds on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.