ntp

NTP协议实现

匆匆过客 提交于 2019-12-07 21:30:16
10.4 实验内容 ——NTP协议实现 1.实验目的 通过实现NTP协议的练习,进一步掌握Linux网络编程,并且提高协议的分析与实现能力,为参与完成综合性项目打下良好的基础。 2.实验内容 Network Time Protocol(NTP)协议是用来使计算机时间同步化 的一种协议,它可以使计算机对其服务器或时钟源(如石英钟,GPS等)做同步化,它可以提供高精确度的时间校正(LAN上与标准时间差小于1毫秒,WAN上几十毫秒),且可用加密确认的 方式来防止协议攻击。 NTP提供准确时间,首先要有准确的时间来源,这一时间应该是国际标准时间UTC。 NTP获得UTC的时间来源可以是原子钟、天文台、卫星,也可以从Internet上获取。这样就有了准确而可靠的时间源。时间是按NTP服务器的等级传 播。按照距离外部UTC 源的远近将所有服务器归入不同的Stratun(层)中。Stratum-1在顶层,有外部UTC接入,而Stratum-2则从Stratum-1获取 时间,Stratum-3从Stratum-2获取时间,以此类推,但Stratum层的总数限制在15以内。所有这些服务器在逻辑上形成阶梯式的架构并 相互连接,而Stratum-1的时间服务器是整个系统的基础。 进行网络协议实现时最重要的是了解协议数据格式。NTP数据包有48个字节,其中NTP包头16字节,时间戳32个字节

嵌入式移植NTP(Network Time Protocol)

左心房为你撑大大i 提交于 2019-12-07 12:32:48
ST板子OTT盒子没法通过实时码流获取时间,只能通过网络实时获取时间,这篇文档记录下自己解决的整个过程,网上已经有很多NTP 服务器配置、ARM板子移植博文,大家可以参考,详细原理我也是查阅网上的资料; 1、NTP官网下载源码: http://www.ntp.org/downloads.html 2、编译 [root@bogon ntp-4.2.6p5]#./configure --prefix=/opt/ntp --exec-prefix=/opt/ntp --host=sh4-linux CC=/opt/STM/STLinux-2.4/devkit/sh4/bin/sh4-linux-gcc 其中: If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. 通常对于嵌入式系统来说,--target、--build不需要更改; 交叉编译参数只需要指定 --host=sh4-linux 即可; 接着编译: [root@bogon ntp-4.2.6p5]# make ntp_loopfilter.c:520:27: error: ?.OD_NANO?.undeclared

How good is NTP for distributed time synchronization?

痴心易碎 提交于 2019-12-07 10:10:10
问题 How accurate is NTP for keeping a set of servers time synchronized? I'm writing a service which requires a set of servers (some acting as clients, some as servers) synchronized to second level granularity. I'm wondering if NTP is the best thing to use, or if there's something better? Should I run a ntp server on one of them, and have the others use that as their source? Any other recommendations/horror stories with NTP? All the servers are linux. Update: Service levels: I'd like the one

Get time/date from server with sntp(windows c++)

筅森魡賤 提交于 2019-12-07 04:15:46
问题 I'm searching for a working code in c/c++ that gets the time and date from the server(ntp.belnet.be). It works with UDP and uses port 123. Can someone help? //sending pakket memset(&sntp_msg_header, 0, sizeof sntp_msg_header); sntp_msg_header.flags = 27; sntp_msg_header.originate_timestamp_secs = time(NULL); // Get data in rxmsg ... ... // print time timeval = ntohl(rxmsg.transmit_timestamp_secs) - ((70ul * 365ul + 17ul) * 86400ul); printf("%s", ctime(&timeval)); This is what i have so far.

C++使用Boost实现Network Time Protocol(NTP)客户端

吃可爱长大的小学妹 提交于 2019-12-06 22:53:52
引 言 笔者机器上安装了两个系统,一个Linux Ubuntu,一个Windows8.1。让人感到郁闷的是,每次从Ubuntu重启进入Windows时,系统时间总是少了8个小时,每次都要用Windows的时间程序进行同步,也就是下面这个东西: 这个东西其实就是一个NTP Client,从Internet上选择一台NTP Server,获取UTC时间,然后设置本地时间。 于是我想自己实现一个这样的程序,先百度一下吧,网上有很多关于NTP的资料和实现代码,大多是单一平台的,不能跨平台 ,下面给几个参考: http://blog.csdn.net/loongee/article/details/24271129 http://blog.csdn.net/chexlong/article/details/6963541 http://www.cnblogs.com/TianFang/archive/2011/12/20/2294603.html 本文使用boost的Asio来跨平台实现NTP Client. 准备 1. 最新的 boost 库,本文使用的是1.56.0版本 要用到里面的ASIO网络库 2. IDE是Visual Studio 2013 with Update3 笔者是版本帝 3. WireShark也是最新的1.12.1版本 用来分析Windows自带的NTP Client

linux ntp时间服务器配置 (资料)

≯℡__Kan透↙ 提交于 2019-12-06 21:06:46
Network Time Protocol (NTP) 是新增的考试要求. 学习的时候也顺便复习了一下如何设置Linux的时间,现在拿出来和大家分享: 设置NTP服务器不难但是NTP本身是一个很复杂的协议. 这里只是简要地介绍一下实践方法 和上次一样,下面的实验都在RHEL5上运行 使用ITM监控ntp服务的检查、ntp自启动未开启的检查、ntp未配置的检查、时钟前调大量测试工作等等。 NTP的配置也比较容易,在不更改默认参数的情况下,主要配置文件为/etc/ntp.conf,在文件中指定主服务器名或ip即可. server 主时间服务器 prefer server 从时间服务器 为保证NTP自动启动,需在服务配置中,将NTP服务设置为开机启动。 注:ITM是监控软件,利用ITM客户端上的Agent可以在客户端统一发命令。 常见用法 : 1) 查看NTP状态:ntpq -p 可以使用ntpq –p查看ntp状态。正常情况下:remote列的各个服务器前, 应该有一个*,其它为+ 2) 查看实时时间偏差:ntpdate -q 对方ip 正常输出如下: server 192.168.11.33, stratum 2, offset 0.000843, delay 0.02579 24 Jan 20:09:19 ntpdate[10420968]: adjust time server

NTP时间同步

旧街凉风 提交于 2019-12-05 19:59:52
NTP 时间同步 4.1 问题 本案例要求搭建一个 NTP 服务器,为整个网络环境中的所有主机提供时间校准服务,具体要求如下: 部署一台 NTP 时间服务器 设置时间服务器上层与 0.centos.pool.ntp.org 同步 设置本地服务器层级数量为 10 允许 192.168.4.0/24 网络的主机同步时间 客户端验证时间是否同步 4.2 方案 准备实验所需的虚拟机环境,实验环境所需要的主机及对应的 IP 设置列表如表 -4 所示,正确配置 IP 地址、主机名称,并且为每台主机配置 YUM 源。 表- 4 主机列表 实验拓扑如图 -8 所示。 图 -8 Network Time Protocol (网络时间协议)采用的是分层设计,如图 -9 所示, Stratum 层的总数限制在 15 以内。 图 -9 4.3 步骤 实现此案例需要按照如下步骤进行。 步骤一:部署 NTP 服务 1 )安装软件包 [root@proxy~]#yum -y install chrony [root@proxy~]#rpm -qc chrony// 查看配置文件列表 /etc/chrony.conf /etc/chrony.keys .... 2) 修改配置文件 [root@proxy~]#cat /etc/chrony.conf .... server 0.centos.pool.ntp

ntp服务设置开机自启动失败

无人久伴 提交于 2019-12-05 19:20:20
设置了ntpd开机自启动,重启服务器ntpd没有自启动 1.需要禁掉chronyd.service: systemctl disable chronyd.service 2.手动启动ntpd: systemctl start ntpd 3.再次设置开机自启动: systemctl enable ntpd 4.重启服务器测试ntpd即可正常自启动了 来源: https://www.cnblogs.com/wannengachao/p/11941376.html

How to Programmatically Set GPO to Not Configured or Disabled

强颜欢笑 提交于 2019-12-05 12:24:39
I'm looking for a programmatic solution that has the same effect as setting the "Configure Windows NTP Client" state in GPOE Administrative Templates > System > Windows Time Service > Time Providers > Configure Windows NTP Client to Not Configured or Disabled , but I'll take any help I can get at this point. Is there a registry key I can modify using the .NET Registry class or a property I can modify using the RSoP WMI classes? I've been looking in both places for days, but haven't found anything that will effectively disable the GPO or have the same effect as disabling or setting it to Not

How good is NTP for distributed time synchronization?

我与影子孤独终老i 提交于 2019-12-05 11:52:22
How accurate is NTP for keeping a set of servers time synchronized? I'm writing a service which requires a set of servers (some acting as clients, some as servers) synchronized to second level granularity. I'm wondering if NTP is the best thing to use, or if there's something better? Should I run a ntp server on one of them, and have the others use that as their source? Any other recommendations/horror stories with NTP? All the servers are linux. Update: Service levels: I'd like the one server to be accurate UTC(second level, not microsecond or such), and I'd like all the other servers to be