今天就ntp的tinker來做專項學習。此處的tinker指的是ntp.conf配置文件中的一個配置指令名。它還有相關的配置選項
經過查看官方文檔其中對ntp.conf中的tinker是如下描述的:
官方文檔:http://doc.ntp.org/4.2.6/miscopt.html
意思是這個tinker指令是改變由時鍾紀律算法使用的某些系統變量,這些變量的默認值已經針對廣泛的網絡速度和可靠性期望進行了精心優化,很少有必要去改變它的默認值,除非有的人忍不住非要去轉動旋鈕(即修改tinker指令對應的選項參數)。
同時tinker指令對應的選項參數也有相應的解釋:
[ allan allan ]
Specifies the Allan intercept,which is a parameter of the PLL/FLL clock discipline algorithm,in seconds with default 1500 s.
上面的意思翻譯過來是:指定allan截距,這是PLL / FLL時鍾紀律算法的參數,以秒為單位,默認為1500秒。
經過查找相關背景資料對時鍾紀律算法的解釋是如下:
網絡時間控制協議的規范和參考是由時鍾紀律算法實現的。該算法采用了一個循環機制,該算法有2種模式:第一種phase-lock loop(簡稱PLL),即階段鎖定循環,第二種frequency-lock loop(簡稱FLL),即頻率鎖定循環。二者相互結合,能自適應參數,能對階段鎖定/頻率鎖定做出回饋。這是一個復雜的算法,可以自動調整最佳性能,同時能最大限度地減少網絡開銷。
[ dispersion dispersion ]
Specifies the dispersion increase rate in parts-per-million(PPM) with default 15 PPM.
翻譯過來是:指定每百萬分之1的分散增長率,默認是15 PPM(即分散增長率的默認值是每百萬分之15) 。
我在apache的kudu官方網站看到apache hadoop團隊開發的kudu對ntp.conf的設置的是dispersion 500 和 allan 0 引用他們官方的描述的理由是縮小最大誤差:
We’ve performed experiments using the default NTP time source available in a Google Compute Engine data center and were able to obtain a reasonable tight max error bound, usually varying between 12-17 milliseconds.
The following parameters should be adjusted in /etc/ntp.conf to tighten the maximum error
-
server my_server.org iburst minpoll 1 maxpoll 8
-
tinker dispersion 500
-
tinker allan 0
[ freq freq ]
Specifies the frequency offset in parts-per-million (PPM) with default the value in the frequency file.
翻譯過來是:指定在frequency file(即driftfile)中設置的以每百萬分之幾的默認頻率偏差值。
[ huffpuff huffpuff ]
Specifies the huff-n'-puff filter span,which determines the most recent interval the algorithm will search for a minimum delay.The lower limit is 900 s (15 m),but a more reasonable value is 7200 (2 hours).
翻譯過來的大意是:指定了Huff&Puff過濾跨度,這決定了最近的區間算法將搜索最小延遲。下限是900秒(15分鍾),但一個更合理的值是7200秒(2小時)。
針對Huff&Puff的解釋,我查閱了《NTP Clock Discipline Principles》一書,其中對Huff&Puff的描述是:"Huff&puff algorithm corrects for large outliers and asymmetric delays".意思是Huff&Puff是一種算法,用於糾正離群值和非對稱延遲。
[ panic panic ]
Specifies the panic threshold in seconds with default 1000s.If set to zero,the panic sanity check is disabled and a clock offset of any value will be accepted.
翻譯過來的意思是:指定一個panic閾值,單位是秒,默認情況下是1000秒。如果設置為0的話,panic就被禁用了完整性檢查並且任意一個時鍾偏差值都會被接受。
[ step step ]
Specifies the step threshold in seconds.The default without this command is 0.128 s. If set to zero, step adjustments will never occur. Note: The kernel time discipline is disabled if the step threshold is set to zero or greater than 0.5 s.
翻譯過來是:指定step閾值。默認值0.128s。如果設置為0,step調整將永遠不會發生。注意:如果step的閾值被設置為0或者大於0.5s的話內核時間紀律將被禁用。
關於step的解釋在《NTP Clock Discipline Principles》一書中只有一句:" ignore if offset exceeds until stepout."
大意是:如果step的閾值到達stepout的閾值時偏差還沒有抵消的話就自動忽略。
[ stepout stepout ]
Specifies the stepout threshold in seconds. The default without this command is 900s. If set to zero, popcorn spikes will not be suppressed.
翻譯過來是:指定stepout的閾值以秒為單位。默認值是900秒。如果設置為0的話, 爆米花峰值將不能被抑制。
關於stepout的解釋在《NTP Clock Discipline Principles》一書中也只有一句:"interval within which step spikes are ignored."
大意是:在stepout 設置的這個閾值范圍內step的峰值會被忽略。
關於popcorn spikes的解釋我只在"The NTP Pool System"中看到相關的片段:"a huff-and-puff algorithm corrects for large outliers and asymmetric delays, and a popcorn spike suppressor clips noise spikes. "
大意是:Huff&Puff算法是為了解決較大的離群值和延遲,以及爆米花峰值,抑制clips噪音峰值。這里的clips我不知道如何翻譯比較合適,如果按照字面翻譯為剪輯的話比較奇怪,如果有人知道的話還望糾正一下。
以上是ntp.conf中的tinker的參數解釋,但是實際驗證和原理驗證我並沒有做,我也看了ntp的算法,相當復雜,況且我的數學水平針對那樣的算法簡直是讓我難堪,到目前我沒有看到網上有相關的中文翻譯和算法解釋。期待有人能這么做。