Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Lularible/ptp-book

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PTP技术书 — 从思想实验到协议实现

一本从思想实验到源码、从理论到动手实现的开源PTP技术书。

在线阅读

📖 在线浏览本书

实际运行效果

ptp_demo

这本书讲了什么

全书 41 节,分四章:

  • 第一章(4 节):从“你周围的一切都静止了”这个思想实验开始,讲时间的本质与同步的意义
  • 第二章(18 节):逐机制拆解 PTP 协议——BMCA 选举、四个时间戳的数学、透明时钟、硬件时间戳、安全机制
  • 第三章(13 节):走进 LinuxPTP 源码,看工业级实现如何驾驭 9 种端口状态、PI 伺服控制器怎么让时钟“追上”主时钟
  • 第四章(6 节):亲手实现一个轻量级 PTP 程序(ptp-lite,约 1000 行 C),主时钟和从时钟可以实际运行起来做同步

不需要网络协议的先修知识。第一章的四节思想实验足够让你进入状态。

快速开始

在线阅读:直接浏览 chapters/ 目录下的 Markdown 文件,按文件名顺序阅读。

推荐 VS Code + Markdown Preview Enhanced 插件,或者 Typora、Obsidian。

运行示例代码:

git clone https://github.com/Lularible/ptp-book.git
cd ptp-book/ptp_lite
make

# 终端 A
sudo ./ptp_master eth0[替换为实际网卡名]

# 终端 B
sudo ./ptp_slave eth0[替换为实际网卡名]

许可证

书籍内容:CC BY-NC-ND 4.0 · ptp-lite 源码:MIT

姊妹篇

本书是"汽车电子七部曲"系列中的一部。另外五部已发布:

致谢


"汽车电子七部曲"是一个持续更新的系列——还有软件工程在打磨中。 如果觉得这系列对你有用,不妨给个 ⭐ 关注进度。

About

A comprehensive open-source book on the Precision Time Protocol (IEEE 1588/gPTP). From thought experiments to protocol internals, LinuxPTP source code analysis, and a hands-on ptp-lite implementation (~1000 lines C). A complete guide from theory to running code.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.