外文文獻翻譯-計算機網(wǎng)絡(luò)冗余GPS時間同步電路板的設(shè)計與實現(xiàn)【中文5000字】【中英文WORD】
外文文獻翻譯-計算機網(wǎng)絡(luò)冗余GPS時間同步電路板的設(shè)計與實現(xiàn)【中文5000字】【中英文WORD】,中文5000字,中英文WORD,外文,文獻,翻譯,計算機網(wǎng)絡(luò),冗余,GPS,時間,同步,電路板,設(shè)計,實現(xiàn),中文,5000,中英文,WORD
計算機網(wǎng)絡(luò)冗余GPS時間同步電路板的設(shè)計與實現(xiàn)
摘要:如今,在計算機網(wǎng)絡(luò)系統(tǒng)中準確和可靠的時間是一個基本要求。為實現(xiàn)這一必要性,時間同步想法產(chǎn)生了。同時在某些情況下,可靠的時間是如此的重要,以致于一個冗余的結(jié)構(gòu)得以應(yīng)用。在本文中,時間同步系統(tǒng)的主要研究是設(shè)計和實施一個時間同步電路,該電路能夠通過NTP協(xié)議與計算機網(wǎng)絡(luò)同步時間。在本設(shè)計中還嵌入了冗余方案以便提供更高的可靠性。
關(guān)鍵字:計算機網(wǎng)絡(luò) GPS時間 NTP 冗余 時間同步 時間同步協(xié)議 時間服務(wù)器
1. 引言
我們通常會把電腦的時間和手表的誤差設(shè)置在一兩分鐘內(nèi),但另一方面,準確和可靠的時間對于財務(wù)和法律事務(wù)、運輸、分銷系統(tǒng),和許多其他涉及資源分布廣泛的應(yīng)用程序是必要的。舉一個例子說明,在一個分布式的機票預(yù)訂系統(tǒng),如果分布式計算機時間不同,座椅可以賣出兩倍價格甚至更多,或者在網(wǎng)上股票交易完成之前會產(chǎn)生法律后果。在這方面,世界協(xié)調(diào)時和時鐘同步已開發(fā)出來。基礎(chǔ)的時間尺度已隨著歷史得到改進,以地球自轉(zhuǎn)為基礎(chǔ)的地球時和原子時也產(chǎn)生了。一些重要的時間尺度還包括國際原子時(TAI)、通用協(xié)調(diào)時間尺度(UTC)、和標準時間或民用時間。
時鐘同步協(xié)議的想法是,即使最初設(shè)置準確,但電腦的內(nèi)部時鐘也可能與世界時鐘不同。之后,由于時鐘漂移,會有相當(dāng)大的誤差,所以總是有必要將這些漂移的時鐘同步到參考時鐘源。
時間同步源包括地球上的無線電同步技術(shù)(WWV, WWVH, WWVB, DCF77 and LORAN-C)、衛(wèi)星時間同步技術(shù)(GOES, GPS, GLONASS, and Galileo)、互聯(lián)網(wǎng)時間同步技術(shù)以及電話撥號時間同步技術(shù)。在這些時鐘源中,全球定位系統(tǒng)(GPS)提供了一些特殊的優(yōu)點,如時間精度、抗噪聲干擾、在世界各地都可用、并不斷引用國際標準。如今,相比其他時鐘資源,全球定位系統(tǒng)時鐘的使用更為廣泛。
圖1顯示了一個典型的時間同步結(jié)構(gòu),其中時間服務(wù)器從GPS接收的數(shù)據(jù)作為時間同步源。接下來,時間服務(wù)器為需要時間的設(shè)備發(fā)送滿足同步協(xié)議的準確時間消息。這些設(shè)備通過收到的消息同步它們的內(nèi)部時鐘。
當(dāng)今各種各樣的同步協(xié)議為時間同步提供了不同的手段,但他們都遵循兩種常用的一般模式。無論是客戶端向服務(wù)器發(fā)出請求,并且服務(wù)器以當(dāng)前時間響應(yīng)客戶端,或者是服務(wù)器向組內(nèi)或所有的客戶發(fā)送消息。一些重要的標準計算機網(wǎng)絡(luò)時間同步協(xié)議如下:
時間協(xié)議:時間協(xié)議規(guī)定在RFC868,返回一個32位并行的二進制數(shù)表示時間,參考自1900年1月1日協(xié)調(diào)世界時秒。服務(wù)器監(jiān)聽端口37上的時間請求,并響應(yīng)TCP/IP 和UDP/IP 格式的請求。
白天協(xié)議:白天協(xié)議規(guī)定在RFC867,發(fā)送時間使用ASCII字符。服務(wù)器監(jiān)聽端口13,并且響應(yīng)TCP/IP和UDP/IP格式的請求。
網(wǎng)絡(luò)時間協(xié)議(NTP):協(xié)議規(guī)定在RFC-5905,對于通過網(wǎng)絡(luò)同步電腦始終來說,是最古老的(并且仍在使用)和最先進的時間同步協(xié)議。這個NTP服務(wù)器監(jiān)聽123端口,并通過發(fā)送一個滿足NTP協(xié)議格式的UDP數(shù)據(jù)包來響應(yīng)請求。
簡單網(wǎng)絡(luò)時間協(xié)議(SNTP):SNTP是NTP協(xié)議的一個不太復(fù)雜的實現(xiàn)版本。當(dāng)完整的NTP最終表現(xiàn)不需要的時候可以使用SNTP。
精密時間協(xié)議(PTP):PTP正式出現(xiàn)在IEEE 1588-2008,是一個旨在提高相對于傳統(tǒng)的基于以太網(wǎng)協(xié)議比如NTP的時間精確度,但是在實際應(yīng)用當(dāng)中更昂貴。
對于開源,對于典型的應(yīng)用來說NTP具有足夠的精度,并且有能力工作在大型網(wǎng)絡(luò)中,NTP是公共互聯(lián)網(wǎng)中使用最廣泛的,并且已經(jīng)為許多私人網(wǎng)絡(luò)服務(wù)了超過三十年。
可靠性要求對于時間同步來說可能太嚴格了,以致于一個單一的時間服務(wù)器都可能不可信。因此,在一個冗余結(jié)構(gòu)中需要使用多個時間服務(wù)器。
在本文中,我們將探討時間同步系統(tǒng)的設(shè)計與實現(xiàn),通過從一個低成本的GPS接收器獲取時間的數(shù)據(jù),然后使用NTP協(xié)議同步計算機網(wǎng)絡(luò)。在本設(shè)計中,以使用兩個時間同步板以提供更高的可靠性的方式嵌入了冗余管理。
這份文件的組織如下:第二部分給出了關(guān)于NTP協(xié)議的一個簡短解釋,并且使用它同步時間。第三部分給出關(guān)于冗余的更多解釋。第四部分給出了建立一個網(wǎng)絡(luò)時間同步器的結(jié)構(gòu),包括硬件設(shè)計和軟件算法。第五部分給出最后的測試和結(jié)果。
2. 什么是NTP?
NTP主要包含三個部分:NTP軟件程序,在UNIX系統(tǒng)中稱為守護進程,在WINDOWS系統(tǒng)中成為服務(wù);用于在服務(wù)器和客戶機之間交換時間值的協(xié)議;和一套處理時間值提前或延緩系統(tǒng)時鐘的算法。因為NTP軟件往往是和操作系統(tǒng)捆綁在一起的(如大多數(shù)的WINDOWS和UNIX系統(tǒng)),是計算機網(wǎng)絡(luò)時間同步中最常用的協(xié)議。例如,我們不打算涵蓋所有三部分,但我們打算描述設(shè)計一個網(wǎng)絡(luò)時間服務(wù)器中所涉及的協(xié)議。更詳細的細節(jié)可在正式規(guī)范中瀏覽。
NTP協(xié)議是基于互聯(lián)網(wǎng)協(xié)議(IP)和用戶數(shù)據(jù)報協(xié)議(UDP)建立的,在IEEE 802.3以太網(wǎng)幀中。該NTP協(xié)議報頭,在可選的擴展域和一個可選的消息認證碼(MAC)后有12個字。
NTP工作模式,包括C/S模式和廣播模式。在客戶機/服務(wù)器模式中,客戶端向服務(wù)器發(fā)出請求,服務(wù)器以當(dāng)前時間響應(yīng)請求。然而在廣播模式,時間服務(wù)器周期性地向客戶端發(fā)送NTP數(shù)據(jù)包,客戶端使用接收到的數(shù)據(jù)包調(diào)整自己的時間。
在NTP數(shù)據(jù)包中最重要的領(lǐng)域是時間戳字段。一個NTP的時間戳是一個64位無符號定點數(shù)的整數(shù)部分,在前32位顯示以1900年1月為參考的時間和小數(shù)部分在最后32位。這種表示的精度是約2 - 32秒(233皮秒)。
時間同步的精度取決于網(wǎng)絡(luò)環(huán)境。今天,在互聯(lián)網(wǎng)的大多數(shù)地方,提供準確的時間為10 - 100毫秒,而如果在一個良好的條件,沒有太多的路由器的局域網(wǎng)上,正常同步在幾毫秒。
3. 什么是冗余?
冗余是一種通常用于提高系統(tǒng)可靠性的技術(shù)。它有多種形式和類型。冗余最一般的形式冗余是Mout-of-N(MooN)冗余,其中MooN至少必須是有效的系統(tǒng)函數(shù)。這方面的例子如圖2所示。M-out-of-N冗余廣泛應(yīng)用于不同的領(lǐng)域,例如,在安全系統(tǒng)、編程等。
同時,尊重切換時間,冗余可分為并行和備用冗余。在并行模式下,冗余的部分是連續(xù)運行,在待機模式下,當(dāng)一個正常運行的操作組件失敗時,他們才切換至一個操作模式。兩者之間的本質(zhì)區(qū)別如圖3所示。
只要時間同步系統(tǒng)需要更多的可靠性,冗余技術(shù)就可以用。圖4顯示了一個在時間同步系統(tǒng)中的1oo3冗余結(jié)構(gòu)。根據(jù)這個數(shù)據(jù),三個時間服務(wù)器正在從是時間同步源(GPS)那里獲取時間,然后作為時間服務(wù)器,反饋給和一個共同網(wǎng)絡(luò)連接的群體的客戶端以準確和可靠的時間。
值得一提的是,不同的冗余度也可以增加時間同步的可靠性。這是通過讓時間從一種以上的時間參考實現(xiàn)的。例如一個時間服務(wù)器從GPS獲取時間,而另一個時間服務(wù)器從DC F77廣播時間源獲取時間。
4. 時間同步電路設(shè)計
A. 硬件設(shè)計
在這里,我們提出一個方案,一個時間服務(wù)器從GPS獲取時間數(shù)據(jù),并且通過NTP協(xié)議為客戶端提供準確的時間。圖5給出了時間服務(wù)器主板的內(nèi)部結(jié)構(gòu)。它主要由五個部分組成:低成本的GPS接收器、單片機、以太網(wǎng)接口、用戶接口和電源。
在提出了時間服務(wù)器中,單片機中起著重要的作用。它應(yīng)該被適當(dāng)?shù)鼐幊虂砗推渌糠纸涣?,讓他們作為一個時間服務(wù)器一起工作。GPS接收器通過串行接口連接到單片機。它為單片機提供NMEA協(xié)議格式的時間數(shù)據(jù)和與UTC同步的1PPS信號(秒脈沖)。以太網(wǎng)控制器接口計算機網(wǎng)絡(luò)建立一個連接并通過它傳輸以及接收數(shù)據(jù)。用戶接口包括一個液晶顯示器和觸摸屏。它從用戶得到所需的配置數(shù)據(jù)從而顯示時間同步的結(jié)果。
B. 軟件設(shè)計
關(guān)于時間服務(wù)器中單片機的算法設(shè)計包括三個子算法,如圖7所示:主回路、GPS 1PPS中斷服務(wù)程序(ISR),和GPS串行接口(ISR)。
主回路首先初始化以太網(wǎng)控制器、GPS接收器、和用戶接口,然后進入一個死循環(huán),等待GPS時間脈沖和串行接口的中斷。
這1PPS ISR被設(shè)置為上升沿觸發(fā)。本ISR具有最高優(yōu)先級,并且能夠讓單片機在數(shù)萬納秒精度的情況下獲得世界協(xié)調(diào)時。在這個程序中計數(shù)器設(shè)置為每10秒發(fā)送一次NTP數(shù)據(jù)包。NTP的工作模式是廣播模式,讓所有連接到網(wǎng)絡(luò)的客戶端可以接收數(shù)據(jù)包。
GPS的串行接口ISR每次運行都會接收來自GPS接收機的一個串行數(shù)據(jù)。如果收到的數(shù)據(jù)是一個時間數(shù)據(jù),就會進行解碼并且存儲在“Time”變量中。同時NTP數(shù)據(jù)包會在下一個1PPS被發(fā)送出去,其時間戳提前1秒。
冗余也嵌入算法當(dāng)中。如圖6所示,為此板“優(yōu)先級”和“優(yōu)先權(quán)”的參數(shù)。主機發(fā)送時間信息到以太網(wǎng)。此外,主機發(fā)送一個“活消息”給另一個板的地址。監(jiān)測器接收 “活消息”,如果超過3秒還沒有收到,從站承擔(dān)主機的責(zé)任向以太網(wǎng)發(fā)送時間消息和“活消息”。
5. 結(jié)果
A. 硬件實現(xiàn)
在測試中實現(xiàn)網(wǎng)絡(luò)時間顯示,選擇NEO-5Q GPS接收器,atmeaga128單片機,ENC28j60以太網(wǎng)控制器,45以太網(wǎng)插座,128 *64液晶顯示器和觸摸屏,和一個電源(周圍建立的電壓調(diào)節(jié)器)。圖8顯示了根據(jù)結(jié)構(gòu)圖5建立的一個原型板。
B. 軟件實現(xiàn)
為實現(xiàn)時間服務(wù)器的軟件使用了“CodeVisionAVR”。根據(jù)上述算法編寫了C++程序,本程序編譯并下載到單片機中。圖9顯示了設(shè)計的由菜單顯示的同步結(jié)果和由用戶配置的數(shù)據(jù)。
C. 同步結(jié)果
為了測試系統(tǒng)板,通過一個HUB與安裝了“Sun Virtual Box”虛擬機軟件的計算機相連接。其中一個是作為主機,另一個作為從機。下一步,建立兩個虛擬機,并且都裝有Windows XP,所有三個互聯(lián)。通過操縱注冊表鍵的綜合時間同步服務(wù)(W32服務(wù))讓他們NTP時間同步。所有計算機都成功同步到了時間服務(wù)器。
圖10顯示W(wǎng)ireshark軟件的截屏(免費的網(wǎng)絡(luò)協(xié)議分析儀),捕捉NTP數(shù)據(jù)包在這些電腦之間的傳送,服務(wù)器的客戶端請求和服務(wù)器答復(fù)溯源。
測試冗余功能,主機與網(wǎng)絡(luò)斷開,從機在3秒內(nèi)成功地承擔(dān)了主機的責(zé)任。因為客戶端每10秒接收NTP數(shù)據(jù)包,他們不覺得時間服務(wù)器更改了。
6. 結(jié)論
如今,準確的時間對于以計算機為基礎(chǔ)的系統(tǒng)來說必不可少,在這方面,通常用一個時間同步系統(tǒng)從一個時間參考來獲取的時間,同時通過時間同步協(xié)議為需要時間的系統(tǒng)提供精確的時間。
考慮到GPS作為一個參考時間源的巨大優(yōu)勢,也因為其具有高度的準確性和對NTP協(xié)議廣泛的適用性,它常用在時間同步系統(tǒng)中。
在本文中探討了一個典型的時間同步系統(tǒng)的設(shè)計和實現(xiàn)方法,時間服務(wù)器從一個低成本的GPS接收器上獲取時間數(shù)據(jù)然后使用NTP協(xié)議給計算機網(wǎng)絡(luò)同步時間。同時提供更可靠的時間同步服務(wù),建造了兩個時間服務(wù)器主板,設(shè)計了一個冗余方案,并且在一個1oo2冗余結(jié)構(gòu)中實現(xiàn)了方案。
參考文獻
[1] Liskov, B.,”時鐘同步在分布式系統(tǒng)中的實際應(yīng)用”。分布式計算,6卷,pp.211- 219,1991年4月。
[2] K. Behrendt 和 K. Fodero?!蓖昝赖臅r間:時間同步技術(shù)測試”。第三十三屆年度西部保護會議,斯波坎,華盛頓,2006年10月。
[3] Postel,J .時間協(xié)議。美國網(wǎng)絡(luò)工作組的報告RFC-868,南加州大學(xué)信息科學(xué)研究所,1983。
[4] Postel,J .白天協(xié)議。美國網(wǎng)絡(luò)工作組的報告RFC-867,南加州大學(xué)信息科學(xué)研究所, 1983年5月。
[5] Mills, D.L網(wǎng)絡(luò)時間協(xié)議(4版)-協(xié)議和算法規(guī)范。美國網(wǎng)絡(luò)工作組的報告RFC-5905,德拉瓦大學(xué), 2010年6月。
[6] Mills, D.L簡單網(wǎng)絡(luò)時間協(xié)議(種)4版本為IP v6和IP v4,開放系統(tǒng)互連,RFC 4430。德拉瓦大學(xué),2006 年1月。
[7] 關(guān)于網(wǎng)絡(luò)測量和控制系統(tǒng)的標準時鐘同步協(xié)議的國際標準,標準1588-2008, 2008年7月。
[8] D . L .Mills,計算機網(wǎng)絡(luò)時間協(xié)議:在地球和空間運用的NTP。第二版,出版社,2011。
[9] R . billinton和R. N. Allan,工程系統(tǒng)可靠性評估。紐約:全會,1992。
[10] 美國0183標準接口海洋電子設(shè)備,是美國國家海洋電子協(xié)會,1983。
[11] virtualbox.org,操作,可用:http://www.virtualbox.org/,9月16日訪問。
[12] 微軟支持的注冊表項,W32服務(wù),提供:http://support.microsoft.com/kb/223184,2011年10月6日訪問。
[13] 世界上最重要的網(wǎng)絡(luò)協(xié)議分析器,wireshark-go deep,可用:http://www.wireshark.org/,2011年10月6日訪問。
1. GPS得到廣泛應(yīng)用,但仍存在不足。GPS已成為全球性的高新技術(shù)產(chǎn)業(yè),成為一種信息基礎(chǔ)設(shè)施,正逐步進入人們的日常生活。存在的不足是十分明顯的,它是個軍方控制的系統(tǒng),不可能在任何時候任何地點保證民用;在鬧市、密林,或有遮擋和環(huán)境惡劣的情況下,其可用性受到限制;單系統(tǒng)本身就存在著局限性,不可能確保任何應(yīng)用。
2. GLONASS備受關(guān)注,卻令人失望。GLONASS一度給人們以很樂觀的情景,現(xiàn)實又如此無情,經(jīng)濟和技術(shù)的雙重原因,使它只能殘缺不全地工作,今僅有不足十顆星工作,且很不穩(wěn)定。
3. Galileo先聲奪人,與GPS組合應(yīng)用為總體思路。Galileo計劃高舉的純民用旗幟,給人一個放心和安全感。而且它公開宣布與GPS兼容互動,更增強了其吸引力和競爭力,以及服務(wù)保證承諾。豐富多彩的服務(wù)可滿足不同檔次和應(yīng)用領(lǐng)域的需求。
4. 多系統(tǒng)組合并非多多益善,應(yīng)用設(shè)備做到適可而止。多年后,可能有多個衛(wèi)星導(dǎo)航系統(tǒng)在天空運行,是不是多多益善,一是沒有必要,二是應(yīng)用接收機不能做得太復(fù)雜,不然會大幅增加成本,無法大批量推廣,三是接收到的衛(wèi)星數(shù)達到一定數(shù)目后,衛(wèi)星信號再多也不會帶來明顯好處。一般有雙系統(tǒng)足矣。
5. 增強系統(tǒng)層出不窮,最終出路是多系統(tǒng)的組合?,F(xiàn)在各種各樣的衛(wèi)星導(dǎo)航增強系統(tǒng)層出不窮,僅以廣域增強系統(tǒng)而言,就有美國的WAAS,歐洲的EGNOS,中國的CWAAS,日本的QZSS(還有一種為MSAS)。一旦有兩個完整的全球?qū)Ш较到y(tǒng)(GNSS)工作,在軌衛(wèi)星達50-60個,就沒有必要去建設(shè)那些廣域增強系統(tǒng)了。更多地是要走既省錢,又辦事的國際合作之路。
Redundant GPS Time Synchronization Boards
for Computer Networks
Abstract --Nowadays, accurate and reliable time is an essential requirement in computer network based systems. To fulfill this necessity, time synchronization idea has been developed. Meanwhile in some cases, reliable time is so vital, therefore a redundant structure can be used. In this paper, a time synchronization system is investigated by designing and implementing a time synchronization board capable of synchronizing time of computer networks using NTP(Network Time Protocol). A redundant scheme is also embedded in this work to provide more reliability.
Keywords--Computer Network, GPS Time, NTP, Redundancy, Time Synchronization, Time Synchronization Protocols, Time Server.
I. INTRODUCTION
We may usually set our computer’s time by our wristwatch to within a minute or two, but on the other side, accurate and reliable time is necessary for financial and legal transactions, transportation, distribution systems, and many other applications involving widely distributed resources. To make sense, as an example, in a distributed airline reservation system, a seat can be sold twice or not at all if the distributed computers vary in time or there may be legal consequences when an online stock trade is completed, before it is bid [1]. In this regard, coordination to an international time scale and clock synchronization have been developed. The basis for the time scales has been refined throughout the history and sidereal time, earth rotation based time, and atomic time have been developed. Some important time scales include International Atomic Time scale (TAI), Coordinated Universal Time scale (UTC), and Standard Time or civil time.
Clock synchronization deals with the idea that internal clocks of computers may differ even if initially set accurately. After a while due to clock drift, there will be considerable clock errors, so there is always need for keeping these drifty clock synchrone to a time synchronization source as a reference clock.
Time synchronization sources include earth-based radio transmission (WWV, WWVH, WWVB, DCF77 and LORAN-C), satellite-based signal transmission (GOES, GPS, GLONASS, and Galileo), and time-setting messages via communications networks and telephone modem services [2]. Among these sources, Global Positioning System (GPS) offers some special advantages such as great time accuracy, noise immunity, worldwide availability for free, and continuously referenced to an international standard. Nowadays GPS based clocks are used very often as the time synchronization sources over the other clock recourses.
Fig. 1 shows a typical time synchronization structure, where a time server receives time data form GPS as a time synchronization sources. The time server then provides the time needing devices with accurate time by sending them a massage in form of a synchronization protocol. The devices synchronize their internal clocks using the received massage.
The various synchronization protocols in use today provide different means to time synchronization, but they all follow two general models. Whether the client sends a request to the server and the server responds with its current time, or the server sends messages to a group or all of the clients. Some important standard computer network time synchronization protocols are as follows:
Time Protocol: Time protocol specified in RFC868 [3], returns a 32-bit unformatted binary number that represents the time in UTC seconds since January 1st, 1900. The server listens to time requests on port 37, and responds in either TCP/IP or UDP/IP formats.
Daytime Protocol: Daytime Protocol specified in RFC867 [4], sends time using ASCII characters. The server listens on port 13, and responds to requests in either TCP/IP or UDP/IP formats.
Network Time Protocol (NTP): NTP specified in RFC-5905 [5], is the oldest (and still in use) and most sophisticated time protocols for synchronizing computer clocks across a network. The NTP servers listen for a NTP request on port 123, and respond by sending a UDP/IP data packet in the NTP format.
Simple Network Time Protocol (SNTP): SNTP is a less complex implementation version of NTP protocol [6]. SNTP can be used when the ultimate performance of the full NTP implementation is not needed.
Precision Time Protocol (PTP): PTP formalized by IEEE 1588-2008 [7], is a protocol designed to increase timing accuracy over traditional Ethernet based protocols like NTP but it is more expensive in implementation.
For being open source, having sufficient accuracy for typical applications and the ability to work on large networks, NTP is the one widely in use on the public Internet and numerous private networks for over almost three decades.
The reliability requirements for time synchronization may be so strict that a single time server cannot always be trusted. Therefore, more time servers can be used in a redundant structure.
In this paper, we will investigate time synchronization system by design and implementation of a time synchronization board which gets time data from a low-cost GPS receiver and then synchronize time of computer networks using NTP protocol. In this design, redundancy is also embedded in a way that two time synchronization boards can be used together to provide more reliability.
The remainder of this document is organized as follows. Section II presents a brief explanation of NTP protocol and time synchronization using it. Redundancy gets more interpreted in section III. A structural scheme for building a network time synchronizer board, hardware design and software algorithms are proposed in section IV. Finally the implemented board and the results are presented in sections V.
II. WHAT IS NTP?
NTP has three major parts: the NTP software program, called a Daemon in UNIX and a Service in Windows; a protocol that exchanges time values between servers and clients; and a suite of algorithms that processes the time values to advance or retard the system clock [8]. Because NTP software is often bundled with the operating systems (such as most flavors of Windows and UNIX) it is the most common used protocol for computer network time synchronizations. For instant, we are not going to cover all the three parts but we are intending to describe the Protocol which is in need for designing a NTP time server. Further details can be found in the formal specification in [5].
The NTP is built on the Internet Protocol (IP) and User Datagram Protocol (UDP) in an IEEE 802.3 Ethernet frame demonstrated in Table 1. The NTP packet header, shown in Table 2, has 12 words followed by optional extension fields and an optional Message Authentication Code (MAC).
NTP working modes include client/server and broadcast mode. In client/server mode, the client sends a request to the server and the server responds with its current time. In broadcast mode however, time server periodically sends NTP packets to the clients and they use the packet to adjust their time.
The most important field in the NTP packet is the timestamp field. An NTP timestamp is a 64-bit unsigned fixed-point number, with the integer part in the first 32 bits showing the past seconds from 0h 1 January 1900 and the fraction part in the last 32 bits. The precision of this representation is about 2-32 second (233 picoseconds).
Accuracy of NTP synchronization depends on the network environment. Today in most places of the Internet, NTP provides time accurate to the order of 10-100 mSec while under good conditions on a LAN without too many routers synchronization to within a few milliseconds is normal [8].
III. WHAT IS REDUNDANCY?
Redundancy is a technique usually used in order to increase the reliability of a system. It comes in many forms and types. The most general form of redundancy is the Mout-of-N (MooN) redundancy, where at least M of N components must be functional in order the system functions. Some examples of this mode are shown in Fig. 2. Applications of M-out-of-N redundancy can be found in various applied areas, for example, in safety systems, N-version programming, etc [9].
Meanwhile, respecting the switch over time, redundancy can be classified as Parallel and Standby redundancy [10]. In parallel mode, redundant components are continuously operating and in standby mode they are only switched into an operating mode when a normally operating operation component fails. The essential difference between these two modes is illustrated in Fig. 3.
Whenever time synchronization in a system needs to be done with more reliability, redundancy technique can be used. Fig. 4 shows a 1oo3 redundancy structure in a time synchronization system. According to this figure, three time servers are getting time from time synchronization source (GPS) themselves and then act as time servers to feed a much larger group of clients connected with a common network with an accurate and reliable time.
It worth mentioning that diverse redundancy can also increase time synchronization reliability. This is done by getting time from more than one type of time references. For example a time server gets time from GPS satellites and the other one gets it from DCF77 radio time source.
IV. TIME SYNCHRONIZATION BOARD DESIGN
A. Hardware design
Here we present a scheme of a time server board which gets timing data from GPS and provides accurate time for the clients via NTP protocol. Fig. 5 presents the internal structure of the proposed time server board. It consists of five main parts; low-cost GPS receiver, Ethernet interface, Microcontroller, user interface and power supply.
In this structure the Microcontroller plays an important role in the proposed time server. It should be programmed properly to communicate with the other parts and make them work together as a time server. GPS receiver connects to the microcontroller via a serial interface. It provides microcontroller with timing data in form of NMEA protocol [11] and a 1PPS (one Pulse Per Second) signal which is synchronized to UTC. The Ethernet controller interface establishes a connection to the computer network and transmit/receive packets to/from it. The user interface consists of a LCD display and a touchscreen. It gets the needed configuration data from user and displays time synchronization results.
B. Software design
The designed algorithm for microcontroller in the time server consists of three sub algorithms, shown in Fig. 7; main loop, GPS 1PPS Interrupt Service Routine (ISR), and GPS serial interface ISR.
The main loop first initializes Ethernet controller, GPS receiver, and the user interface, then it enters an endless loop, waiting for interrupts from GPS time pulse and serial interface.
The 1PPS ISR is set to be called at the rising edge of time pulse. This ISR has the highest priority and lets the microcontroller knows the happening of UTC seconds with tens of nanosecond accuracy. In this routine a counter is set to send NTP packets every 10 seconds. The NTP working mode is Broadcast mode, so all of the clients connected to the network can receive the packets.
The GPS serial interface ISR runs every time a serial data is received from GPS reviver. If received data be a time data, it is decoded and stored in “Time” variable. As the NTP packet will be sent at the next 1PPS, its timestamps should point to 1 second in advance.
Redundancy is also embedded in the algorithm. As Fig. 6 illustrates, for this purpose one board is parameterized as “Priority Master” and the other as “Priority Slave”. The Master transmits the time message to the Ethernet. In addition, the Master transmits an “Alive message” to the address of the other board. The Slave monitors the reception of the “Alive message” and if it is not received for more than 3 seconds, the Slave assumes the duty of the Master and transmits both the time message and the “Alive message” to the Ethernet.
V. RESULTS
A. Hardware Implementation
For implementing the Network Time Display in practice, NEO-5Q GPS receiver, ATmeaga128 Microcontroller, ENC28j60 Ethernet Controller, RJ-45 Ethernet Socket, 128*64 graphical LCD with touch-screen, and a power supply (build around Voltage Regulators) were selected. Fig. 8 shows a prototype board built according to the structure in Fig. 5.
B. Software Implementation
In order to implement the software for time server, “CodeVisionAVR” was used. Some C++ codes were written according to the mentioned algorithm in Fig. 7 to build the whole program. This program is then compiled and transferred to the Microcontroller. Fig . 9 shows some of the designed menus for showing the synchronization results and configuring the board by user.
C. Synchronization Results
In order to test the boards, they were connected via a HUB to a computer with “Sun Virtual Box” [12] virtual machine software installed in it. Then one of them was set as priority master and the other as priority slave. Next, two virtual machines were made in Sun Virtual Box, Windows XP was installed in each and all three were networked together. By manipulating registry keys [13] of the integrated windows time synchronization service (w32time service) they we made to be synchronized from the NTP time. All computers successfully synchronized to the time server.
Fig. 10 shows screenshot of Wireshark software (a free network protocol analyzer [14]) capturing the NTP packets transmitted between three computers and the time server in which client requests and time server replies are traceable.
To test the redundancy feature, Priority Master Board was disconnected from the network, Priority Slave board successfully assumed the duty of the Master board within 3 seconds. Because the clients receive NTP packets every 10 seconds, they did not felt the time server change.
VI. CONCLUSION
Now
收藏