(轉)windows環境下rac節點時間同步方法

xz43發表於2010-12-07

在rac環境中,會要求各個節點之間的時間差不能超時。一般如果超過30秒,節點很可能會重啟。
所以要同步各節點的時間。例如,我們需要配置一個ntp時鐘伺服器,來給rac的各個節點進行時
間同步。或者讓節點之間進行時間同步,保證各節點的時間同步,但無法保證rac資料庫的時間的準確性。

目錄:
一. 節點間的時間同步方法:
        方法一:建立ntp時鐘伺服器,各節點與ntp server同步時間
        方法二:利用定時任務,讓節點間時間同步(用rdate或ntpdate)
二. ntp相關錯誤及解決方法
三. ntp原理

--------------------------------------------------------------------------


一. 節點間的時間同步方法

環境:ntp server是wxp
      client是centos5


在這裡,我以windows機器(192.168.2.29)做ntp server,以1臺linux為clent客戶端(192.168.2.245)來說明時間同步方法。

方法一:

1.ntp服務端配置


首先下載安裝windows版的ntp server —— ntp-424p311502-foehr-v2-o-win32-setup

安裝很簡單,直接執行exe檔案即可,安裝後修改ntp.conf配置檔案,新增如下兩行內容:

server 127.127.1.0 prefer      
fudge 127.127.1.0 stratum 10


說明:
127.127.1.0 : 該IP為NTP定義的server自己的IP
prefer :這個參數列示該server是master server
fudge:這個參數列示該IP為NTPserver,
stratum:表示該系統所在的NTP層級.

我的windows ntpserver的"C:\Program Files\NTP\etc\ntp.conf"檔案如下:

# NTP Network Time Protocol
# Configuration File created by Windows Binary Distribution Installer Rev.: 1.22  mbg
# please check
for additional documentation and background information

# Use drift file
driftfile "C:\Program Files\NTP\etc\ntp.drift"

# your local system clock, could be used as a backup
# (this is only useful if you need to distribute time no matter how good or bad it is)
#server 127.127.1.0
# but it should operate at a high stratum level to let the clients know and force them to
# use any other timesource they may have.
#fudge 127.127.1.0 stratum 12

#skate add
server 127.127.1.0 prefer
fudge 127.127.1.0 stratum 10
#skate add

# End of generated ntp.conf --- Please edit this to suite your needs

配置完成後,重新啟動ntp

重啟方法:開始-》執行-》services.msc-》Network Time Protocol Daemon。

2.配置client的linux

A.修改客戶端linux的配置檔案 /etc/ntp.conf,新增如下一行

server 192.168.2.29 prefer

如果是多個time server伺服器的話,可以按如下的方式:

server 192.168.2.29 prefer        ---prefer表示該server是master server
server 192.168.3.29
server 192.168.4.29
server 192.168.5.29

註釋掉如下一行
server 127.127.1.0 # local clock


在這裡要另外說一下,網上的有朋友說要把

“fudge   127.127.1.0 stratum 10” 改成 “fudge   192.168.2.29 stratum 10”

但經過我的測試發現,如果這樣修改的的話,就不能自動同步時間了。

我的客戶端的linux的 /etc/ntp.conf 內容如下:


[root@localhost ~]# more /etc/ntp.conf
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.

restrict default nomodify notrap noquery

# Permit all access over the loopback interface.  This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1


# -- CLIENT NETWORK -------
# Permit systems on this network to synchronize with this
# time service.  Do not permit those systems to modify the
# configuration of this service.  Also, do not use those
# systems as peers for synchronization.
# restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap


# --- OUR TIMESERVERS -----
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (
).
server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org


# --- NTP MULTICASTCLIENT ---
#multicastclient                        # listen on default 224.0.1.1
# restrict 224.0.1.1 mask 255.255.255.255 nomodify notrap
# restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

# --- GENERAL CONFIGURATION ---
#
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available. The
# default stratum is usually 3, but in this case we elect to use stratum
# 0. Since the server line does not have the prefer keyword, this driver
# is never used for synchronization, unless no other other
# synchronization source is available. In case the local host is
# controlled by some external source, such as an external oscillator or
# another protocol, the prefer keyword would cause the local host to
# disregard all other synchronization sources, unless the kernel
# modifications are in use and declare an unsynchronized condition.
#

#server 127.127.1.0     # local clock
fudge   127.127.1.0 stratum 10

#skate add
server 192.168.2.29 prefer
#skate add


#
# Drift file.  Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
#
driftfile /var/lib/ntp/drift
broadcastdelay  0.008

#
# Keys file.  If you want to diddle your server at run time, make a
# keys file (mode 600 for sure) and define the key number to be
# used for making requests.
#
# PLEASE DO NOT USE THE DEFAULT VALUES HERE. Pick your own, or remote
# systems might be able to reset your clock at will. Note also that
# ntpd is started with a -A flag, disabling authentication, that
# will have to be removed as well.
#
keys            /etc/ntp/keys
[root@localhost ~]#


B.修改/etc/ntp/ntpservers檔案,把裡面的server IP改為自己的ntp server的IP,

   也就是windows機器,下面是我的/etc/ntp/ntpservers:

[root@localhost ~]# more /etc/ntp/ntpservers

#This file contains a list of ntp servers to show in the system-config-date user interface.
#It is not recommended that you modify this file by hand.

0.centos.pool.ntp.org
1.centos.pool.ntp.org
2.centos.pool.ntp.org
3.centos.pool.ntp.org

#skate add
192.168.2.29
#skate add

[root@localhost ~]#

C.修改/etc/hosts檔案,加入windows主機的IP和主機名。---測試中發現不用修改這個

D。手工做一次時間同步,因為如果客戶端和時間伺服器的時間偏移量超過1000秒,在啟動ntp服務後
   客戶端不能自動與NTP master伺服器進行同步。

[root@localhost ~]# service ntpd status
ntpd is stopped


[root@localhost ~]# service ntpd start
Starting ntpd: [  OK  ]


[root@localhost ~]# ntpdate 192.168.2.29
 5 May 18:57:55 ntpdate[27167]: the NTP socket is in use, exiting

[root@localhost ~]# ps -ef |grep ntp
ntp      27164     1  0 19:08 ?        00:00:00 ntpd -u ntp:ntp -p /var/run/ntpd.pid -g
root     27185 26987  0 19:15 pts/4    00:00:00 grep ntp
[root@localhost ~]# kill 27164


[root@localhost ~]# ps -ef |grep ntp
root     27187 26987  0 19:15 pts/4    00:00:00 grep ntp


[root@localhost ~]# ntpdate 192.168.2.28
 5 May 19:15:29 ntpdate[27188]: no server suitable for synchronization found

[root@localhost ~]# ntpdate -u 192.168.2.28
 5 May 19:15:40 ntpdate[27190]: no server suitable for synchronization found

 間隔一段時間後,就可以同步了,因在ntp server上重新啟動ntp服務後,ntp server自身或者與其server的同步的需要一個時間段,
 這個過程可能是5分鐘,在這個時間之內在客戶端執行ntpdate命令時會產生no server suitable for synchronization found的錯誤。


[root@localhost ~]# ntpdate 192.168.2.28
 5 May 19:55:49 ntpdate[27226]: step time server 192.168.2.28 offset 939.130626 sec
[root@localhost ~]# ntpdate 192.168.2.28
 5 May 19:56:25 ntpdate[27227]: adjust time server 192.168.2.28 offset 0.000300 sec

E. 啟動客戶端的ntp服務

[root@localhost ~]# service ntpd status
ntpd dead but pid file exists


[root@localhost ~]# service ntpd start
Starting ntpd: [  OK  ]


[root@localhost ~]# service ntpd status
ntpd (pid 27248) is running...


[root@localhost ~]#

配置其自啟動的級別


[root@localhost ~]# chkconfig --list |grep ntp
ntpd            0:關閉  1:關閉  2:關閉  3:關閉  4:關閉  5:關閉  6:關閉
[root@localhost ~]# chkconfig --level 5 ntpd on
[root@localhost ~]# chkconfig --list |grep ntp
ntpd            0:關閉  1:關閉  2:關閉  3:關閉  4:關閉  5:啟用  6:關閉
[root@localhost ~]#

##########################################################################


方法二:

環境:ntp server是redhat4
      client是centos5

除了用上面的ntp協議來實現時間的同步外,還可以用date和ntpdate命令做定時任務來實現和遠端伺服器同步時間。例如

(一).ntp server端的配置:

1.檢視ntp協議是否安裝
2.修改ntp.conf
3.啟動ntp服務

實際步驟:

1.檢視ntp協議是否安裝


[root@svr-db-test ~]# rpm -qa | grep ntp
ntp-4.2.2p1-5.el5
chkfontpath-1.10.1-1.1
You have new mail in /var/spool/mail/root

如果沒有安裝,可以用rpm -Uvh ntp*.rpm或者yum命令安裝

2.修改ntp.conf

修改這個配置檔案是為了讓遠端客戶端有權來同步時間

[root@svr-db-test ~]# vi /etc/ntp.conf
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.

#skate modify
#restrict default kod nomodify notrap nopeer noquery
#restrict -6 default kod nomodify notrap nopeer noquery
#skate modify

#skate add
restrict default kod nomodify  nopeer noquery
restrict -6 default kod nomodify  nopeer noquery
#skate add


# Permit all access over the loopback interface.  This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1

# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (
).
server 0.rhel.pool.ntp.org
server 1.rhel.pool.ntp.org
server 2.rhel.pool.ntp.org

#broadcast 192.168.1.255 key 42         # broadcast server
#broadcastclient                        # broadcast client
#broadcast 224.0.1.1 key 42             # multicast server
#multicastclient 224.0.1.1              # multicast client
#manycastserver 239.255.254.254         # manycast server
#manycastclient 239.255.254.254 key 42  # manycast client

# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server  127.127.1.0     # local clock
server  192.168.2.245
fudge   127.127.1.0 stratum 10

# Drift file.  Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
driftfile /var/lib/ntp/drift

# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys

# Specify the key identifiers which are trusted.
#trustedkey 4 8 42

# Specify the key identifier to use with the ntpdc utility.
#requestkey 8

# Specify the key identifier to use with the ntpq utility.
#controlkey 8
[root@svr-db-test ~]#

注意:這個檔案這裡有兩種修改方法:


A、第一種配置:允許任何IP的客戶機都可以進行時間同步
將“restrict default kod nomodify notrap nopeer noquery”這行修改成:
restrict default kod nomodify notrap nopeer

B、第二種配置:只允許192.168.211.***網段的客戶機進行時間同步
在restrict default kod nomodify notrap nopeer noquery(表示預設拒絕所有IP的時間同步)之後增加一行:
restrict 192.168.211.0 mask 255.255.255.0 nomodify notrap

但是在我的修改中我只是把”restrict default kod nomodify notrap nopeer noquery“改為
”restrict default kod nomodify  nopeer noquery“

為什麼這麼做呢?如果不去掉notrap的話,在客戶端同步時間會報錯,例如:

[root@localhost ~]# ntpdate 192.168.2.203
 5 May 21:35:14 ntpdate[27467]: no server suitable for synchronization found

[root@localhost ~]# ntpdate -u 192.168.2.203
 5 May 21:35:07 ntpdate[27466]: no server suitable for synchronization found

[root@localhost ~]# ntpdate -d 192.168.2.203
 5 May 21:35:20 ntpdate[27470]: ntpdate Mon Jul 28 11:06:17 EDT 2008 (1)
Looking for host 192.168.2.203 and service ntp
host found : 192.168.2.203
transmit(192.168.2.203)
transmit(192.168.2.203)
transmit(192.168.2.203)
transmit(192.168.2.203)
transmit(192.168.2.203)
192.168.2.203: Server dropped: no data
server 192.168.2.203, port 123
stratum 0, precision 0, leap 00, trust 000
refid [192.168.2.203], delay 0.00000, dispersion 64.00000
transmitted 4, in filter 4
reference time:    00000000.00000000  Thu, Feb  7 2036 14:28:16.000
originate timestamp: 00000000.00000000  Thu, Feb  7 2036 14:28:16.000
transmit timestamp:  cf8bf29b.578ef34d  Wed, May  5 2010 21:35:23.342
filter delay:  0.00000  0.00000  0.00000  0.00000
         0.00000  0.00000  0.00000  0.00000
filter offset: 0.000000 0.000000 0.000000 0.000000
         0.000000 0.000000 0.000000 0.000000
delay 0.00000, dispersion 64.00000
offset 0.000000

 5 May 21:35:24 ntpdate[27470]: no server suitable for synchronization found

出現這個問題的原因可能有二:

1。檢查ntp的版本,如果你使用的是ntp4.2(包括4.2)之後的版本,
   在restrict的定義中使用了notrust的話,會導致以上錯誤。

解決方法:把restrict定義中的notrust去掉

2。檢查ntp server的防火牆。可能是server的防火牆遮蔽了upd 123埠。
   如果關閉防火牆,再嘗試從ntp客戶端的同步,如果成功,證明是防火牆
   的問題,需要更改iptables的設定。
  
解決方法: service iptables stop


開始診斷:

在ntp server端執行

首先看是不是ntp server的防火牆的問題:

[root@svr-db-test ~]# service iptables status
防火牆已停

在檢視ntp的版本:
[root@svr-db-test ~]# ntpq -c version
ntpq Wed Nov 29 15:16:31 UTC 2006 (1)中

在我的ntp server的ntp.conf中restrict的定義中使用了notrust,然後修改配置檔案
把notrust去掉,再重起ntp server 的ntp服務,從客戶端就可以同步時間了,不過要等幾分鐘
因為ntp server要先自己同步一段時間,前面有介紹。在這期間你要嘗試同步的話,會得到
錯誤”no server suitable for synchronization found“

下面是來自ntp官方網站的說明:
A. The behavior. of notrust changed between versions 4.1 and 4.2.
B. In 4.1 (and earlier) notrust meant "Don't trust this host/subnet for time".
C. In 4.2 (and later) notrust means "Ignore all NTP packets that are not
   cryptographically authenticated." This forces remote time servers to authenticate themselves to your (client) ntpd

3.啟動ntp服務

[root@svr-db-test ~]# service ntpd restart
ntpd (pid 13608 13597) 正在執行...
或者
[root@svr-db-test ~]# /etc/init.d/ntpd restart
ntpd (pid 13608 13597) 正在執行...
[root@svr-db-test ~]#

開機啟動ntp服務的方法:

[root@svr-db-test ~]# chkconfig --list |grep ntp
ntpd            0:關閉  1:關閉  2:關閉  3:關閉  4:關閉  5:關閉  6:關閉
[root@svr-db-test ~]# chkconfig --level 5 ntpd on
[root@svr-db-test ~]# chkconfig --list |grep ntp
ntpd            0:關閉  1:關閉  2:關閉  3:關閉  4:關閉  5:啟用  6:關閉
[root@svr-db-test ~]#


(二)。客戶端的配置

利用crontab來執行
crontab -e
0 21 * * * ntpdate 192.168.2.29 >> /root/ntpdate.log 2>&1
每天晚上9點進行同步

說明:rdate命令時間同步的方法要簡單些,也沒有ntpdate時間精確。就不介紹了啊


參考:

http://www.oracleblog.cn/working-case/install-ntp/
**.com/blog/576421

-------------------------------------------------------------------------------


二。ntp相關錯誤及解決方法

ntpdate相關命令:

ntpdate  192.168.2.29
ntpdate -d 192.168.2.29 除錯模式
ntpdate -u 192.168.2.29  用非授權埠
ntpdate -s 5 192.168.2.29 延時5秒看行否

1. ntpdate同步時間時經常出錯如下:“no server suitable for synchronization found”

A。

  在重啟ntp服務的時候,ntp server自身或者與其server的同步的需要一個時間段,
   這個過程可能是5分鐘,在這個時間之內在客戶端執行ntpdate命令時會產生
   no server suitable for synchronization found的錯誤。

那麼如何知道何時ntp server完成了和自身同步的過程呢?可以用如下的命令

在ntp server上執行:
[root@svr-db-test ~]# watch ntpq -p

Every 2.0s: ntpq -p                                                               Wed May  5 22:07:19 2010

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*LOCAL(0)        .LOCL.          10 l   54   64  377    0.000    0.000   0.001
 192.168.2.245   .INIT.          16 u    -  256    0    0.000    0.000   0.000

注意LOCAL的這個就是與自身同步的ntp server

注意reach這個值,在啟動ntp server服務後,這個值就從0開始不斷增加,當增加到17的時候,
從0到17是5次的變更,每一次是poll的值的秒數,是64秒*5=320秒的時間。
如果之後從ntp客戶端同步ntp server還失敗的話,用ntpdate –d來查詢詳細錯誤資訊,再做判斷。

2.用ntpdate –d ip可能診斷出兩個錯誤

A。錯誤1.Server dropped: Strata too high

在ntp客戶端執行ntpdate serverIP,出現no server suitable for synchronization found的錯誤。
在ntp客戶端用ntpdate –d serverIP檢視,發現有“Server dropped: strata too high”的錯誤,
並且顯示“stratum 16”。而正常情況下stratum這個值得範圍是“0~15”。

這是因為NTP server還沒有和其自身或者它的server同步上。

以下的定義是讓NTP Server和其自身保持同步,如果在/ntp.conf中定義的server都不可用時,將使用local時間作為ntp服務提供給ntp客戶端。


server 127.127.1.0              
fudge 127.127.1.0 stratum 8

B。錯誤2.Server dropped: no data

這個問題上面已經說過了啊,這裡就不說了啊。

參考:
http://www.blogjava.net/spray/archive/2008/07/10/213964.html


---------------------------------------------------------------------

三。ntp原理

     NTP(Network Time Protocol)是由美國德拉瓦大學的David L. Mills教授於1985年提出,除了可以估算封包在網路上的往返延遲外,
還可獨立地估算計算機時鐘偏差,從而實現在網路上的高精準度計算機校時,它是設計用來在Internet上使不同的機器能維持相同時間
的一種通訊協議。時間伺服器(time server)是利用NTP的一種伺服器,透過它可以使網路中的機器維持時間同步。在大多數的地方,
NTP可以提供1-50ms的可信賴性的同步時間源和網路工作路徑。

      網路時間協議(NTP)的詳細說明在RFC-1305[Mills 1992]中。RFC-1305對 NTP協議自動機在事件、狀態、轉變功能和行為方面給出了明確的說明。它以合適的演算法以增強時鐘的準確性,並且減輕多個由於同步源而產生的差錯,實現了準確性低於毫秒的時間服務,以滿足目前因特網中路徑量測的需要。

NTP是一個跨越廣域網或區域網的複雜的同步時間協議,它通常可獲得毫秒級的精度。RFC2030[Mills 1996]描述了SNTP(Simple Network Time Protocol),目的是為了那些不需要完整NTP實現複雜性的主機,它是NTP的一個子集。通常讓區域網上的若干臺主機透過因特網與其他的NTP主機同步時鐘,接著再向區域網內其他客戶端提供時間同步服務。

NTP的特點

1,從UTC獲取標準時間
網路時間協議,提供在互連的網路上提供校時服務和傳送標準時間給計算機。目前已成為Internet上時間同步的標準協議。NTP提供準確時間,首先要有準確的時間來源,這一時間應是國際標準時間UTC。NTP獲得UTC的時間來源可以是原子鐘,天文臺,衛星,也可以從Internet上獲取。這樣就有了準確而可靠的時間源。

2,NTP伺服器分層提供服務
時間按NTP伺服器的等級傳播。按照離外部UTC源的遠近將所有伺服器歸入不同的Stratum(層)中。Stratum-1在頂層,由外部UTC接入,而Stratum-2則從Stratum-1獲取時間,Stratum-3從Stratum-2獲取時間,以此類推,但Stratum層的總數限制在15以內。所有這些伺服器在邏輯上形階梯式的架構相互連線,而Stratum-1的時間伺服器是整個系統的基礎。

3,過濾演算法選擇時間的最佳路徑和來源
計算機主機一般同多個時間伺服器連線,利用統計學的演算法過濾來自不同伺服器的時間包,以選擇最佳的路徑和來源來校正主機時間。即使主
機在長時間無法與某一時間伺服器相聯絡的情況下,NTP服務依然有效運轉。

4,識別機制抗干擾和惡意破壞
為防止對時間伺服器的惡意破壞,NTP使用了識別(Authentication)機制,檢查來對時的資訊是否是真正來自所宣稱的伺服器並檢查資料的返回路徑,以提供對抗干擾的保護機制。


NTP的實現方式

1,無線時鐘:伺服器系統可以透過串列埠連線一個無線時鐘。無線時鐘接收GPS(全球衛星定位系統)的衛星發射的訊號來決定當前時間。
   無線時鐘是一個非常精確的時間源,但是需要花一定的費用。

2,時間伺服器:還可以使用網路中NTP時間伺服器,透過這個伺服器來同步網路中的系統的時鐘。 列出了Internet上有效的一級時間伺服器。

3,區域網內的同步:如果只是需要在本區域網內進行系統間的時鐘同步,那麼就可以使用區域網中任何一個系統的時鐘。你需要選擇局
   域網中的一個節點的時鐘作“權威的”的時間源,然後其它的節點就只需要與這個時間源進行時間同步即可。使用這種方式,所有的節
   點都會使用一個公共的系統時鐘,但是不需要和區域網外的系統進行時鐘同步。如果一個系統在一個區域網的內部,同時又不能使用
   無線時鐘,這種方式是最好的選擇。


NTP的工作模式

1,Sever/Client mode:使用者向一個多幾個伺服器提出服務請求,根據所交換的資訊,從中選擇認為最準確的時間,並調整本地的時鐘。

2,Multicast/Broadcast mode:此種模式是適用於用在高速的LAN上。利用一個或多個伺服器在固定的週期向某個多播地址做廣播。

3,Symmetric mode:二個以上的Server互相進行時間訊息的通訊,可以互相校正對方的時間,以維持整個subnet的時間一致性。

NTP協議結構

NTP packet = NTP header + Four TimeStamps = 48bytes
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[header, 16bytes]
2   3      3         8              8      8      共32bits
LI  VN  Mode  Stratum  Poll  Precision
Root Delay (32bits)
Root Dispersion (32bits)
Reference Identifier (32bits)

[Timestamp 1, 8bytes]
Reference Timestamp (64bits)

[Timestamp 2, 8bytes]
Originate Timestamp (64bits)

[Timestamp 3, 8bytes]
Receive Timestamp (64bits)

[Timestamp 4, 8bytes]
Transmit Timestamp (64bits)

Key Identifier (optional) (32bits)
Message digest (optional) (128bits)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

欄位說明:

* LI:LeapYearIndicator, 跳躍指示器,警告在當月最後一天的最終時刻插入的迫近閨秒(閨秒)。
* VN:VersionNumber, 版本號。
* Mode:模式, 0-預留;1-對稱行為;3-客戶機;4-伺服器;5-廣播;6-NTP 控制資訊
* Stratum:層級。
* Poll:PollInterval, 有符號整數表示連續資訊間的最大間隔。
* Precision:有符號整數表示本地時鐘精確度。
* Root Delay:有符號固定點序號表示主要參考源的總延遲,很短時間內的位15到16間的分段點。
* Root Dispersion:無符號固定點序號表示相對於主要參考源的正常差錯。
* Reference Identifier:識別特殊參考源。

* Reference Timestamp
* Originate Timestamp:這是向伺服器請求分離客戶機的時間,採用64位時標格式。
* Receive   Timestamp:這是向伺服器請求到達客戶機的時間,採用64位時標(Timestamp)格式。
* Transmit  Timestamp:這是向客戶機答覆分離伺服器的時間,採用64位時標(Timestamp)格式。

* Authenticator(可選):主要識別符號和資訊數字域就包括已定義的資訊認證程式碼(MAC)資訊。

網路延時與時鐘偏差的測量

Timestamp Name             ID        When Generated
Originate Timestamp       T1        time request sent by client
Receive Timestamp         T2        time request received at server
Transmit Timestamp        T3        time reply sent by server
Destination Timestamp   T4        time reply received at client

t 為伺服器和客戶端之間的時間偏差;

d 為兩者之間的往返時間

∵ T2 = T1 + t + d/2; ∴ T2 - T1 = t + d/2;
∵ T4 = T3 - t + d/2;  ∴ T3 - T4 = t - d/2;
∴ d = (T2 - T1) + (T4 - T3); t = [(T2 - T1) + (T3 - T4)] / 2;


-------end-----

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9399028/viewspace-681057/,如需轉載,請註明出處,否則將追究法律責任。

相關文章