Download presentation
Presentation is loading. Please wait.
Published byLogan Simpson Modified over 9 years ago
1
Remote Servers Server 1 Server 2 Peer/Poll 1 Server 3 Peer/Poll 2 Peer/Poll 3 Selection and Clustering Algorithms Combining Algorithm Loop Filter VFO Clock Discipline Process System Process Peer/Poll Processes Clock Adjust Process Figure 1. Implementation Model
2
TimestampFraction NTP Timestamp Format 0313263 TimestampFraction NTP Date Format 06364127 Era 3132 Figure 2. NTP Time Formats SecondsFraction NTP Short Format 0151631
3
0 0. 0 0 t 2 = clock t3t3 t4t4 t5.t5.t1t1 t5t5 t6t6 t7t7 org rec t3t3 t4t4 T 3 ≠ t 3 ? t8t8 t5t5 t6t6 T3 ≠ t1?T3 ≠ t1? t6t6 org rec t1t1 t2t2 t1t1 t2t2 t4t4 t3.t3. t2t2 t6t6 t5.t5. t1t1 0 0t1t1 t2t2 t3.t3. T 3 ≠ 0? t4t4 t4t4 t3t3 t2t2 t1t1 t5t5 t6t6 t8t8 t7t7 t4t4 t2t2 t3t3 t6t6 t7t7 t8t8 t 6 = clock t 1 = clockt 5 = clock t 4 = clockt 8 = clock t 3 = clockt 7 = clock t1t1 t5t5 Packet Variables Peer B State Variables Packet Variables Peer A State Variables T1T1 T3T3 T2T2 T4T4 T1T1 T3T3 T2T2 T4T4 t7t7 T 1 = t 3 ? xmt t3t3 0 t1t1 t5t5 T 1 = t 5 ?T 1 = t 1 ? Figure 3. On-Wire Protocol
4
mode = 3? yes client_packet Figure 4. Receive Processing yes auth OK? format OK? access OK? receive() no access deny no format error match_assoc no auth error yes no
5
Packet VariableVariable x.leap ← s.leap x.version ← r.version x.mode ← 4 x.stratum ← s.stratum x.poll ← r.poll x.precision ← s.precision x.rootdelay ← s.rootdelay x.rootdisp ← s.rootdisp x.refid ← s.refid x.reftime ← s.reftime x.org ← r.xmt x.rec ← r.dst x.xmt ← clock x.keyid ← r.keyid x.digest ← md5 digest Figure 5. Client Packet Processing client_packet copy header MD5 digest fast_xmit() xmt = T 3 copy T 1,T 2 T 3 = clock auth OK? NAK digest yesno return
6
yes T 3 = xmt? no duplicate T 1 = 0? or T 2 = 0? T 1 = xmt? yes no mode = 5? packet T 3 = 0? yes format error no auth error yes no yes no auth = NAK? org = T 3 rec = T 4 match_assoc no return org = T 3 rec = T 4 Figure 6. Timestamp Processing
7
PeerPacket VariablesVariables p.leap ← r.leap p.mode ← r.mode p.stratum ← r.stratum p.ppoll ← r.ppoll p.rootdelay ← r.rootdelay p.rootdisp ← r.rootdisp p.refid ← r.refid p.reftime ← r.reftime Figure 7. Packet Processing ok header? packet bad header error clock_filter poll_update() copy header reach |= 1
8
no Copy filter to a temporary list. Sort the list by increasing Let i, i, i, t i be the ith entry on the sorted list. Shift sample t into filter shift register clock_filter yes t 0 > t clock_select() Figure 8. Clock Filter Algorithm return
9
no clock_select() find majority clique clustering algorithm accept()? scan candidates yes add peer return( SYNC ) n < CMIN ? survivors? no yes no s.p = v 0.p return( UNSYNC ) yes s.p = NULL Figure 9. clock_select() Routine selection algorthm
10
no Set the number of midpoints d = 0. Set c = 0. Scan from lowest endpoint to highest. Add one to c for every lowpoint, subtract one for every highpoint, add one to d for every midpoint. If c ≥ m f, stop; set l = current lowpoint Set c = 0. Scan from highest endpoint to lowest. Add one to c for every highpoint, subtract one for every lowpoint, add one to d for every midpoint. If c ≥ m f, stop; set u = current highpoint. Add one to f. Is f < m / 2? Select the lowpoint, midpoint and highpoint of these intervals. Sort these values in a list from lowest to highest. Set the number of falsetickers f = 0. Failure; a majority clique could not be found.. Success; the intersection interval is [l, u]. yes For each of m acceptable associations construct a correctness interval [ –, + ] If d ≤ f and l < u? no yes Figure 10. Selection Algorithm
11
no all no no return( NO) accept() reach = 0? yes refid = addr? leap = 11? stratum >= MAXSTRAT ? yes any yes server not synchronized root distance exceeded server/client sync loop root_dist() >= MAXDIST ? Figure 11. accept() Routine no return( YES) yes server not reachable
12
For each candidate s, compute the selection jitter s (RMS peer offset differences between s and all other candidates). Select max as the candidate with maximum s. Delete the outlyer candidate with max ; reduce n by one. Done. The remaining cluster survivors are the pick of the litter. The survivors are in the v structure sorted by . no yes Let ( , , ) represent a candidate peer with offset jitter and a weight factor = stratum MAXDIST +. Select min as the candidate with minimum . Save the candidates in the v structure sorted by increasing . Let n be the number of candidates. max < min or n ≤ NMIN ? Figure 12. Clustering Algorithm
13
return done scan cluster survivors y = z = w = 0 x = rootdist() clock_combine() VariableProcessDescription systemcombined clock offset p systemcombined jitter 0 survivor listfirst survivor offset survivor listith survivor offset x, y, z, wtemporaries Figure 13. clock_combine() Routine Variables and Parameters
14
ADJ local_clock() clock_update() yes no PANIC clear all associations STEP *update system variables panic exit IGNOR return SystemSystem Peer VariablesVariables leap← leap stratum← stratum + 1 refid← refid reftime← reftime ← R + ← E R + + + + | | leap = 3 stratum = MAXSTRAT *Update System Variables Figure 14. clock_update() Routine
15
Peer Variables Client System Variables Server Figure 15. System Variables Processing
16
Figure 16. Clock Discipline Algorithm VdVd VcVc Phase/freq Prediction Clock Filter Clock Adjust Phase Detector VFO VsVs r + c c NTP Loop Filter x y
17
y PLL PLL Predict VsVs x Phase Correct y y FLL FLL Predict Figure 17. PLL/FLL Prediction Functions
18
no yesno yes | > PANICT ? SYNC return( PANIC ) local_ clock() | | > STEPT ? FREQ SPIK yes state = SPIK < WATCH FREQSPIK SYNC return(rval) yes rval = ADJ FSET NSET FSET state = NSET? R = no step_time ( rval = STEP rst(new, off) Figure 18. local_clock() Routine (1 of 2) freq = 0 rval = IGNOR Calculate new freq adjustment from and using hybrid PLL and FLL. no < WATCH FREQ ? yes state = new B = off R R = off tc return yes return(rval) rst( SYNC, 0) rst( FREQ, 0) no R =
19
yes R > PGATE count += count LIMIT? count = 0 no yes count = 2 ++ < MAXPOLL count LIMIT? count = yes > MINPOLL no yes return(rval) tc += freq state = SYNC Figure 19. local_clock() Routine (2 of 2)
20
clock_adjust() R = tmp next < timer? += adjust_time ( + tmp) Figure 20. clock_adjust() Routine poll() return noyes
21
Figure 21. poll() Routine yes no unreach++ hpoll++ burst = 0? unreach < UNREACH ? reach = 0? reach & 0x7 = 0? clock_filter (0, 0, ∞, t) burst peer_xmit() reach <<= 1 last = timer BURST & accept()? burst = BCOUNT IBURST & unreach = 0? unreach = 0 hpoll = poll() no yes no poll_update() mode = 6? mode= 5? yes no yes return no yes
22
Packet VariableVariable x.leap ← s.leap x.version ← VERSION x.mode ← p.mode x.stratum ← s.stratum x.poll ← p.hpoll x.precision ← s.prec x.rootdelay ← s.rootdelay x.rootdisp ← s.rootdisp x.refid ← s.refid x.reftime ← s.reftime x.org ← p.org x.rec ← p.rec x.xmt ← clock x.keyid ← p.keyid x.digest ← md5() Figure 22. transmit() Routine peer_xmit() copy header MD5() xmit_packet() return copy T 1,T 2 T 3 = get_clock() xmt = T 3
23
next = last + (1 << poll) poll_update() Figure 23. poll_update Routine return burst > 0 next += 2 yesno hpoll = min[ MAXPOLL, max( MINPOLL, hpoll)] poll = min[hpoll, max( MINPOLL, ppoll)] next = last yesno
24
StratumPollLIModeVN Root Delay Root Dispersion Reference Identifier Reference Timestamp (64) Originate Timestamp (64) Receive Timestamp (64) Transmit Timestamp (64) Message Digest (128) Key Identifier Cryptosum MAC (Optional) Extension Field 1 (optional) Extension Field 2… (optional) Precision Figure 24. NTP Header Format 0258162431
25
CodeLength Association ID Signature Length Timestamp Filestamp Value Length Value Fields (optional) Figure 25. NTP Extension Field Format 0281631 REVN Value (optional) Padding (zeros) Signature (optional) Padding (zeros)
26
Table 1. Association and Packet Modes Association ModeAssoc. ModePacket Mode Symmetric Active11 or 2 Symmetric Passive21 Client34 Server 43 Broadcast Server555 Broadcast Client6na
27
YearMJDNTP DateNTP EraNTP TimestampEpoch 1 Jan -4712 2,400,001 208,657,814,400 491,795,583,104First day Julian Era 1 Jan -1 679,306 59,989,766,400 14139,775,7442 BCE 1 Jan 0 678,941 59,958,230,400 14171,311,7441 BCE 1 Jan 1 678,575 59,926,608,000 14202,934,1441 CE 4 Oct 1582 100,851 10,011,254,400 32,873,647,488Last day of Julian Calendar 15 Oct 1582 100,840 10,010,304,000 32,874,597,888First day Gregorian Calendar 31 Dec 189915,019 86,400 14,294,880,896Last day NTP Era 1 1 Jan 190015,020000First day NTP Era 0 1 Jan 197040,5872,208,988,80002,208,988,800First day Unix 1 Jan 197241,3172,272,060,80002,272,060,800First day UTC 31 Dec 199951,5433,155,587,20003,155,587,200Last day 20th century 1 Jan 200051,5443,155,673,60003,155,673,600First day 21st century 7 Feb 203664,7304,294,944,00004,294,944,000Last day NTP Era 0 8 Feb 203664,7314,295,030,400163,104First day NTP Era 1 16 Mar 2172114,4418,589,974,400239,808First day NTP Era 2 1 Jan 2500234,16618,934,214,40041,754,345,2162500 CE 1 Jan 3000416,78734,712,668,8008352,930,4323000 CE Table 2. Interesting Historic NTP Dates
28
Table 3. Name Prefix Conventions NameDescription r. receive packet header variable x. transmit packet header variable p. peer/poll variable s. system variable c. clock discipline variable
29
Table 4. Global Parameters NameValueDescription PORT 123NTP port number VERSION 4version number TOLERANCE 15e-6frequency tolerance ( ) (s/s) MINPOLL 4 minimum poll exponent (16 s) MAXPOLL 17maximum poll exponent (36 h) MAXDISP 16maximum dispersion (s) MINDISP.005minimum dispersion increment (s) MAXDIST 1distance threshold (s) MAXSTRAT 16maximum stratum number
30
NameFormulaDescription leap leapleap indicator (LI) version versionversion number (VN) mode modemode stratum stratumstratum poll pollpoll exponent precision R precision exponent rootdelay R root delay rootdisp R root dispersion refid refidreference ID reftime reftimereference timestamp org T 1 origin timestamp rec T 2 receive timestamp xmt T 3 transmit timestamp dst T 4 destination timestamp keyid keyidkey ID digest digestmessage digest Table 5. Packet Header Variables
31
NameFormulaDescription Configuration Variables srcaddr srcaddrsource address srcport srcportsource port dstaddr dstaddrdestination address dstport destportdestination port keyid keyidkey identifierkey ID Packet Variables leap leapleap indicator version versionversion number mode modemode stratum stratumstratum ppoll ppollpeer poll exponent rootdelay R root delay rootdisp R root dispersion refid refidreference ID reftime reftimereference timestamp Timestamp Variables t tepoch org T 1 origin timestamp rec T 2 receive timestamp xmt T 3 transmit timestamp Statistics Variables offset clock offset delay roundtrip delay disp dispersion jitter jitter Table 6. Peer Variables
32
Table 7. Packet Error Checks
33
NameFormulaDescription t tepoch leap leapleap indicator stratum stratumstratum precision precision p psystem peer pointer offset combined offset jitter combined jitter rootdelay root delay rootdisp root dispersion refid refidreference ID reftime reftimereference time NMIN 3minimum survivors CMIN 1minimum candidates Table 8. System Process Variables and Parameters
34
Table 9. Clock Discipline Variables and Parameters NameFormulaDescription t timerseconds counter offset combined offset resid R residual offset freq clock frequency jitter clock jitter wander frequency wander tc time constant (log2) state statestate adj adjfrequency adjustment count counthysteresis counter STEPT 125step thresh (.125 s) WATCH 900stepout thresh (s) PANICT 1000panic thresh. (1000 s) LIMIT 30hysteresis limit PGATE 4hysteresis gate TC 16time constant scale AVG 8averaging constant
35
State < STEP STEP Comments NSET FREQ, adj. time FREQ, step timeFrequency never set. FSET SYNC, adj. time SYNC, step timeFrequency set from file. SPIK SYNC, adj. freq, adj. timeif < WATCH, SPIKOutlyer found. else step time FREQ if < WATCH, FREQ if WATCH, FREQFrequency measurement. else step freq, adj. timeelse SYNC step freq, step time SYNC SYNC, adj freq, adj. time SPIKNormal operation. Table 10. Clock Discipline State Transition Table
36
NameFormulaDescription hpoll hpollhost poll exponent last lastlast poll time next nextnext poll time reach reachreach register unreach unreachunreach counter UNREACH 24unreach limit BCOUNT 8burst count BURST flagburst enable IBURST flagiburst enable Table 11. Poll Process Variables and Parameters
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.