JCHub

  • Home
  • Category
    • A/V
    • WebRTC
    • Beauty of Programming
    • Linux
    • Windows
    • Moments of Life
    • Campus Life
  • Reference
    • API Reference
    • Utilities
    • AV Test
    • Doc
  • Message Board
  • About
JCHub
Code as My Sword, Lost in Obsession
  1. Main page
  2. Windows
  3. Main content

为什么Windows下无法实现ptp协议

2017年3月27日 5650hotness 11likes 1comments

前段时间,要写一个windows下的分布式软件,刚开始的方案是需要一个精确的时钟同步,误差必须控制在1毫秒内。也许很多人都知道有NTP以及PTP 时间同步协议。windows本身自带NTP协议的服务,通过注册表配置即可实现,但是误差无法满足要求,而且每次配置都要重启W32Time服务。也只有PTP这个精确时钟同步协议满足要求,后面想自己实现PTP协议,不过查了些资料,发现想的太简单了。

PTP协议的原理虽然简单,不过实现起来不简单,需要确定最佳主时钟,而且需要获取高精度的本地时钟(后面查到win8以上系统可以通过GetSystemTimePreciseAsFileTime获取<1us的高精度时钟)。后来发现有个著名的开源ptp协议实现:ptpd(Precision Time Protocol daemon)。不过该代码只针对linux系统,至于为什么没有在windows下的实现,大概有如下的原因:

1)windows不提供带时间戳的网络包,不像linux下socket有SO_TIMESTAMP选项,而且也不提供高精度时钟的内核api(win8以下系统);
2)部分windwos系统存在时钟调整Bug,比如你调整的系统时间低于16个tick(系统的时基)单位,将会被忽略。

由于以上原因,后面也没去做windows上的ptp协议实现。

This article is licensed with Creative Commons Attribution-NonCommercial-No Derivatives 4.0 International License
Tag: windows
Last updated:2017年6月11日

Jeff

管理员——代码为剑,如痴如醉

Tip the author Like
< Last article
Next article >

Comments

  • 匿名

    学习了

    2017年4月2日
    Reply
  • razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
    Cancel

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    Related Posts
    • FireBreath插件IE浏览器中文字符乱码问题
    • Win10任务管理器GPU信息
    • DXGI中的flip显示模型
    • CreateSwapChainForHwnd返回0x887A0001错误
    • DirectX 9 到DirectX 11 API的对应
    Categories

    COPYRIGHT © 2026 jianchihu.net. ALL RIGHTS RESERVED.

    Theme Kratos Made By Seaton Jiang