openPTrack| Time Synchronization 时间同步

本节介绍如何安装标准网络时间协议(NTP),并描述了在我们的测试工作的两种不同的NTP配置

节点之间的时间同步是OpenPtrack工作的关键,需要利用NTP实现时间同步

目前,探测窗口必须不大于1个视频帧(30帧每秒,约33毫秒),理想情况下,要产生有效的跟踪,窗口必须小得多。在实际系统中,我们的目标是在开始校准或跟踪之前,NTP报告的偏移和抖动小于10毫秒。

较差的主机时间同步的一个常见症状是分裂(即一个人被显示为两个检测)。

OpenPTrack多摄像头集成需要在每个主机CPU上同步时间。对于目标平台(Ubuntu),建议在以下配置中使用NTP。一旦选择一台机器作为服务器,其他cpu将侦听时间同步。

首先 安装NTP

sudo apt-get install ntp

然后,编辑客户机和服务器配置文件。

注意::我们成功地使用了两种NTP配置。第一种配置用于较小的网络,即5个或更少的cpu。这种配置还可以更快地使每个CPU上的时间正常化;偏移量很快收敛。第二种配置已经用于更大的网络,超过5个cpu。我们发现这种配置在更大的网络上更稳定;偏移量不太可能漂移,但是跨越网络的时间需要更长的时间来收敛。

配置 1

server: /etc/ntp.conf:

filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

# Specify one or more NTP servers.

# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
#server 0.ubuntu.pool.ntp.org
#server 1.ubuntu.pool.ntp.org
#server 2.ubuntu.pool.ntp.org
#server 3.ubuntu.pool.ntp.org
#server 0.north-america.pool.ntp.org iburst
server ntp.ucla.edu
server 127.127.1.0
fudge 127.127.1.0 stratum 10


# Use Ubuntu's ntp server as a fallback.
#server ntp.ubuntu.com

# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.

# By default, exchange time with everybody, but don't allow configuration.
#restrict -4 default kod notrap nomodify nopeer noquery
#restrict -6 default kod notrap nomodify nopeer noquery

# Local users may interrogate the ntp server more closely.
#restrict 127.0.0.1
#restrict ::1
restrict 192.168.100.0 mask 255.255.255.0 nomodify notrap

# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 192.168.123.0 mask 255.255.255.0 notrust


# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255

# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines.  Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient
broadcast 192.168.100.255

要使其他节点同步到此主服务器,并且如果主服务器未联机,请注释掉第一个外部服务器。请注意,这里假设是192.168.100。X网络(如有必要,更改广播以匹配网络)。

client: /etc/ntp.conf:

客户机上还有许多其他“东西”需要删除。有些设置会干扰将从客户机/客户机同步到LAN上的主服务器的最终简单目标。为此,将/etc/ntp.conf文件完全替换为以下文件:

# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
driftfile /var/lib/ntp/ntp.drift
# Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
# Specify one or more NTP servers.
server 192.168.100.101 iburst
disable auth
broadcastclient

必须将192.168.100.101更改为所选主/ LAN时间服务器的IP。

需要将客户机ntp.conf添加到所有其他非主节点。

配置 2

server: /etc/ntp.conf:

driftfile /var/lib/ntp/ntp.drift

# Enable this if you want statistics to be logged.
statsdir /var/log/ntpstats/

statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

# Specify one or more NTP servers.

# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.

#server 64.67.62.194 iburst

# Do not use a low minpoll/maxpoll, to keep things typical to outside world
server time1.ucla.edu iburst
server time2.ucla.edu iburst

peer 192.168.100.102 minpoll 4 maxpoll 6 iburst
peer 192.168.100.103 minpoll 4 maxpoll 6 iburst
peer 192.168.100.104 minpoll 4 maxpoll 6 iburst
peer 192.168.100.105 minpoll 4 maxpoll 6 iburst
peer 192.168.100.106 minpoll 4 maxpoll 6 iburst

# We are the master, so listen on the subnet but no modification
restrict 192.168.100.0 mask 255.255.255.0 

# Local users may interrogate the ntp server more closely.
# Needed for ntpq if we use restrict default ignore
restrict 127.0.0.1
restrict ::1

上面的配置中,有三部分代码需要修改

# Do not use a low minpoll/maxpoll, to keep things typical to outside world
server time1.ucla.edu iburst
server time2.ucla.edu iburst

应该将两个UCLA NTP服务器更改为离安装物理位置最近的NTP服务器。

peer 192.168.100.102 minpoll 4 maxpoll 6 iburst
peer 192.168.100.103 minpoll 4 maxpoll 6 iburst
peer 192.168.100.104 minpoll 4 maxpoll 6 iburst
peer 192.168.100.105 minpoll 4 maxpoll 6 iburst
peer 192.168.100.106 minpoll 4 maxpoll 6 iburst

对等点应该反映网络中不充当服务器机器的cpu。这反映的网络有六个cpu;主机IP地址为192.168.100.101;对等IP地址为192.168.100.102 - .106。

 # We are the master, so listen on the subnet but no modification
 restrict 192.168.100.0 mask 255.255.255.0 

192.168.100.0应该反映您的网络设置为的子网,如果你的子网是。0,你的代码将是:

 # We are the master, so listen on the subnet but no modification
 restrict 192.168.0.0 mask 255.255.255.0 

client: /etc/ntp.conf:

#/etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help

driftfile /var/lib/ntp/ntp.drift

# Enable this if you want statistics to be logged.
statsdir /var/log/ntpstats/
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

# Restrict what we listen to
restrict default ignore

# We are a peer so allow devices on the subnet to modify
restrict 192.168.100.0 mask 255.255.255.0

# Local users may interrogate the ntp server more closely.
# Needed for ntpq if we use restrict default ignore
restrict 127.0.0.1
restrict ::1

# Sync with our peers
## NOTE THIS MUST BE EDITED PER MACHINE
## TO LIST OTHER PEERS, THIS IS AN EXAMPLE
## FOR 102
peer 192.168.100.101 minpoll 4 maxpoll 6 iburst
peer 192.168.100.103 minpoll 4 maxpoll 6 iburst
peer 192.168.100.104 minpoll 4 maxpoll 6 iburst
peer 192.168.100.105 minpoll 4 maxpoll 6 iburst
peer 192.168.100.106 minpoll 4 maxpoll 6 iburst

注意::同样,有两个需要做的改变:

 # We are the master, so listen on the subnet but no modification
 restrict 192.168.100.0 mask 255.255.255.0 

192.168.100.0应该反映您的网络设置为的子网i。e,如果你的子网是。0,你的代码将是:

 # We are the master, so listen on the subnet but no modification
 restrict 192.168.0.0 mask 255.255.255.0
peer 192.168.100.102 minpoll 4 maxpoll 6 iburst
peer 192.168.100.103 minpoll 4 maxpoll 6 iburst
peer 192.168.100.104 minpoll 4 maxpoll 6 iburst
peer 192.168.100.105 minpoll 4 maxpoll 6 iburst
peer 192.168.100.106 minpoll 4 maxpoll 6 iburst

对等点应该反映网络中不充当服务器机器的cpu。这反映的网络有六个cpu;主机IP地址为192.168.100.101;对等IP地址为192.168.100.102 - .106。

配置完成!但要确认同步(配置后,这将只在配置1上工作):

NTP调节是渐进的,但是上面的iburst设置将收敛速度加快到5-10秒。虽然没有必要:

sudo service ntp stop
sudo ntpd -gq
sudo service ntp start

虽然也没有必要每次在系统启动时启动(这将增加几秒钟的启动时间),在/etc/rc.中地方,把:

/etc/init.d/ntp stop
until ping -nq -c3 8.8.8.8; do
echo "Waiting for network..."
done
ntpd -gq
/etc/init.d/ntp start )&

验证时间同步:

无论如何,要确认时间同步,按主机类型:

ntpq --peers

主机应显示以下内容或类似内容:

	remote       	refid  	st t when poll reach   delay   offset  jitter
==============================================================================
*0.north-america.p  .GPS.        	1 u	8   64  377   25.118   -2.756   2.843
 LOCAL(0)    	.LOCL.      	10 l 1164   64	0	0.000	0.000   0.000
 192.168.100.255 .BCST.      	16 u	-   64	0	0.000	0.000   0.000

客户端应显示以下内容或类似内容:

remote       	refid  	st t when poll reach   delay   offset  jitter
==============================================================================
*opt-node-4.loca 164.67.62.199	2 u	2   64   37	0.078   -1.867   1.670

一台服务器机器,运行:

ntpq -p

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值