当前位置:网站首页>Several time synchronization methods of Beidou timing system (GPS timing equipment)
Several time synchronization methods of Beidou timing system (GPS timing equipment)
2022-06-11 03:52:00 【Anhui Jingzhun】
Beidou timing system (GPS Timing equipment ) Several time synchronization methods
Beidou timing system (GPS Timing equipment ) Several time synchronization methods
The distributed system consists of Tanenbaum Definition ,“ A distributed system is a set of independent computers , stay ” Distributed systems — Principles and examples “ As a single user , Coherent systems emerge ”.
Blockchain through the construction of global distributed system , Try to implement a decentralized new data storage and organization structure .
First , The main reason for positioning to distributed systems is scalability , Location and availability . Blockchain is no exception . Geographic scalability , Form a global value storage network / Information protection area , This includes tamper proofing under decentralized architecture / Zero downtime availability . These are the future of distributed systems in block Implemented in .
0. Catalog
X. Blockchain and distributed systems
1. brief introduction ( Overview of synchronization and overall process )
2. Clock synchronization
2–1. Physical clock ( Clock and clock offset )
2–2. Clock synchronization algorithm ( Network time protocol (NTP)/ Berkeley algorithm )
3. Logical clock
3–1. Lamport The logical clock of ( Fully ordered multicast )
3–2. Vector clock ( Causal order multicast )
4. Exclusive control
4–1. Centralized algorithm
4–2. Decentralized algorithm
4–3. Distributed algorithms
5. Election algorithm
5–1. Bullying algorithms
5–2. Ring algorithm
6. Block chain and synchronization as distributed systems
6–1. Block chain and clock synchronization ( Block chains and Physics / Logical clock )
6–2. Block chain and exclusive control algorithm (PoW·PoS·BFT Exclusive control algorithm in )
6–3. Block chain and leader election algorithm (PoW·PoS·BFT Leader Selection Algorithm in )
1. brief introduction ( Overview of synchronization and overall process )
Unlike a centralized system , It's not easy to agree on time in a distributed system .
In the former case , The absolute order relationship can be determined based on the global shared clock , But in the latter case , Due to clock value error and corresponding time , So it's hard to share absolute time .
however , The order of absolute time is not absolutely necessary , If the relative order is fixed , Usually enough .
In this paper , Synchronization between nodes will be interpreted in the following order .
How clock synchronization happens ?
Using the relative sorting method of logical clock and vector clock
On the consistency exclusion control algorithm of distributed system
About the leader election algorithm in distributed system
2. Clock synchronization
2–1. Physical clock
Clock and clock skew
Most computers have circuits that hold time , This device is called “ The clock ”. It's vibration based on frequency , The vibration can be passed through the crystal type , The method of cutting and the amount of pressure at which tension is applied to precisely machined quartz are clearly defined .
Although this frequency is quite stable , But there's no guarantee that all the crystals in different computers will run at exactly the same frequency . The resulting difference in synchronization time is called clock skew .
under these circumstances , Especially in real-time systems , How to synchronize multiple clocks with real clocks and how to synchronize clocks is a problem .
The initial average time in the second is based on the real world time of the sun , But now cesium 133 transition 9,192,631,770 Times are defined as 1 second , And it defines the international atomic time and the universal coordinated time (UTC). In order to provide... To people who need the exact time UTC, Use WWV And time to ±10 Millisecond accuracy provides .
2–2. Clock synchronization algorithm
however , Most machines don't have WWV Receiver . therefore , Every machine needs time tracking and management algorithms , So that all machines can synchronize time .
By the way , Error used to determine if resynchronization is required , Real time clock offset , The measurement is as follows .
take H It is defined as the number of interrupts per second caused by crystal vibrations counted by each machine ( The number of degrees ), And will C Expressed as the value of the clock . set up Cp(t) Represents the clock value of the machine , When UTC Time is t when .
If you will p Defined as the maximum drift rate that defines the amount of clock offset allowed , It is assumed that it operates in the following range .
1-p 《= dC/dt 《= 1+p
in other words , After starting from the previous synchronization At Seconds later , Two clocks are separated at most 2pΔt.
When it is guaranteed that the operation is not greater than & When the deviation is , At least every &/2p Resynchronize the software .
Network time protocol (NTP)
It's common in many protocols ,[Cristian,1989] The first proposed method is a method of communicating with client server . Because the time server has WWV The receiver may have an accurate clock , So it can provide the current time . When communicating with the server , It's important to delay reporting the delay in message propagation , But by estimating the delay , Here you can minimize errors . at present , It is known that NTP In the 1 to 50 Precision in milliseconds .
Berkeley algorithm
In such as NTP In many algorithms of , The time server is passive and only answers queries . On the other hand , stay Berkeley In the algorithm, , The time server receives the time held by each participating node , And it also changes its own time based on the average . When the value of time doesn't have to be related to the real world , It's easy to reach an agreement at the same current time , And it works for this algorithm .
3. Logical clock
up to now , Although we describe a method of synchronizing the clock with absolute time according to the actual clock as a reference , But usually only relative synchronization is performed . here , The concept of logical clock is used to determine the relative order .
3–1. Lamport The logical clock of
To synchronize the logical clock ,Lamport Defines a name happen-before The relationship between . expression a→b Express “a It happened in b Before ”, This means that the event happened first , Then all processes agree to the event b Will happen . Before it happened — Relationships can be observed directly in two situations .
If a and b It's an event in the same process and a Appear in the b Before , be a→b It's true .
- If a Is the event of a message sent by a process , also b Is an event of the message received by another process , that a→b So it is with . Unable to receive message before sending it , Even if the message also needs a limited non-zero time .
Because the relationship was in transition before it happened , If a→b and b→c, Then it can be proved that a→c. If the event x,y In different processes that don't exchange messages , be x→y and y→x It's not true , And these events are considered concurrent . ( What happened before is unknown .)
Using a logical clock , By assigning all processes to each event a Consistent time C(a) To measure the relative time . If these time values are a→b, Correct them by adding positive values to the time , bring C(a)《C(b). By assigning time values as shown in the figure below , Can grasp the relationship that happened before .
stay Lamport In the logical clock of , If a→b, Then it can be proved that C(a)《C(b), But if C(a)《C(b) be a→b Not necessarily . let me put it another way ,a→b yes C(a)《C(b) Necessary conditions , And it's not a sufficient condition . Lamport The logical clock has been improved , It's a vector clock , This necessary and sufficient condition can be satisfied .
Fully ordered multicast
For more information , see also “ Distributed system consistency ” The content of the article
in many instances , It is necessary to perform fully ordered multicast between duplicate copies . let me put it another way , All messages need to be delivered to each recipient in the same order . Lamport The logical clock can be used to implement fully ordered multicast in a fully distributed system .
When a process receives a message , It will be placed in the local queue in order according to the timestamp . The recipient multicast confirms to another process . If you follow Lamport To adjust the local clock , Then all processes actually have the same copy of the local queue . Only if the message is at the head of the queue and acknowledged by all other processes , There is only one process that can deliver messages from the queue to the running application , therefore , All messages are delivered in the same order . let me put it another way , A fully ordered multicast has been established .
3–2. Vector clock
Use vector clock , Can master Lamport Causal relationships that logical clocks cannot grasp . Suppose the event a The vector clock is VC(a), Then perform the following steps , bring a→b Become VC(a)《VC(b) The necessary and sufficient conditions of .
Before sending a message over the network , node Pi To vector clock VCi [i] add to 1, Or operate some internal events .
If processing Pi The message is m Send to Pj, be Pi After performing the previous step, you will m Vector timestamps for ts(m) Set equal to VCi.
When a message is received m when , process Pj Execution steps 1, Distribute messages to applications , Then update each of its own vector clocks k, As shown below :VCj [k]←max {VCj [k],ts(m)[k]}.
Causality multicast
By using vector clocks , The causal ordered multicast which is slightly weaker than the complete ordered multicast mentioned above can be realized .
By comparing the values of the vector clock and mastering the relationship that happened before , For specific events x, Other events can be classified as past events , Concurrent events and future events . for example , In the diagram above , When events d When used as a reference point , The past events were a,b,c,i, Concurrent events are j,l,m, The future event is f,g,h.
here , Suppose that causal ordered multicast is a sequence of past events and causal events , And there's all the causality , In order to be consistent in all processes , But the order of concurrent events is irrelevant . In this way , And Lamport The logical clock is different , You can use vector clocks to master causality .
4. Exclusive control
Concurrent operation and cooperative operation among multiple processes are the basic of distributed system , But to ensure exclusive access to resources , In order to access the same resource through multiple processes at the same time is not in an inconsistent state , Distributed algorithms need to be exclusive .
Distributed exclusive control algorithms can be divided into the following two types .
be based on Token Solutions for
Permission based approach
Based on Token The scheme , It's easy to avoid StarvaTIon( Access to resources is not allowed for a long time ) And deadlocks ( Multiple processes wait for each other to progress ). A typical example is Token Ring algorithm . however , When held Token The process stops abnormally and Token The loss of , It is necessary to generate only a new Token, This complexity is a serious drawback .
Many other decentralized exclusive control algorithms use a privilege based approach , And there are many different ways to get permission , We will explain in detail .
4–1. Centralized algorithm
By simulating the functions of a single processor system , It is easy to realize single access of exclusive control in distributed system . In a centralized algorithm , A process is designated as the coordinator , And when processes access shared resources , The request message is sent to the coordinator to obtain permission . If the shared resource is not accessed by other processes , The coordinator returns the permission response , And after receiving a reply , The requested process executes the process .
It's easy to see , The algorithm guarantees exclusive access to resources , But it has the serious drawback of a single point of failure . Although this may be a performance bottleneck in large systems , But the advantages of simplicity can still make up for these shortcomings .
4–2. Decentralized algorithm
Suppose everything will repeat n Time . In a decentralized algorithm , When a process accesses a resource , Need to approve most of m》 n / 2. If you get a majority approval , The process is licensed and can be processed .
Although the scheme solves the single point fault problem of centralized algorithm , But if there are too many nodes trying to access , There is another problem , In other words, no node can get enough votes and not get enough performance .
4–3. Distributed algorithms
In this algorithm , Suppose that the order of all events on a system can be defined as a completely ordered relationship . As a basis , Use the... Described in the previous chapter Lamport The logical clock of , And suppose no message is lost .
When a process attempts to access a shared resource , It creates a message , It contains the resource name , Its own process number and current logical clock , And send it to all other processes . When the request message is received , Perform the following operations according to its own state .
If the recipient does not access the resource and does not attempt to access the resource , The recipient will return to the sender “ determine ” news .
If the recipient is already accessing the resource , Please do not reply and execute the queuing request .
If the recipient is trying to access the resource but has not yet completed , Compare the timestamp in the input message with that in the message sent to other processes , And take the lower one as the winner . If the received message has a small timestamp , Then the recipient returns OK news . If your message has a smaller timestamp , The receiver will not queue the input message .
obviously , If it doesn't look like process1 or 2 That conflict , This algorithm will work . Even in the case of conflict , It only establishes the only condition that a process can access .
Like the centralized algorithm , This algorithm can guarantee exclusive control , No deadlock or starvation . Besides , No single point of failure . For all that , A single point of failure is broken down n Location features replace . It can be resolved by replying or denying permissions and introducing timeouts , But there are other problems , For example, multicast communication primitives are needed . Unfortunately , At present, there is no distributed algorithm beyond centralized algorithm , And it's still under study .
When comparing algorithms , Changed to the following .
5. Leader election algorithm
Many distributed algorithms require a special process , It has the role of a leader as a coordinator or initiator . Which process is the leader , Whether the only process can be a leader is an important question , Researchers have been working hard for decades .
5–1. Bullying algorithms
When the coordinator fails and any process P When you notice the situation ,P Activate the election according to the following process .
· P Send... To all processes that have higher values than themselves ELECTION news .
· If no one answers ,P Will win the election and become the coordinator .
· If it comes from having higher than P The answer to the numerical process of , Will replace it . P The work of is over .
Use this algorithm , The coordinator can be uniquely identified . however , This algorithm needs a lot of message and data traffic , It's redundant . As an alternative , Existence loop algorithm .
5–2. Ring algorithm
Different from the general ring algorithm , The algorithm does not use Token. Find any process that the coordinator does not work. Construct a process with its own process number ELECTION news , And send the message to its successor ( The next node in the ring ). If the successor fails , Please skip. . If there is no higher value than your node , Your message will still be returned to your own process number , So it will be designated as the coordinator .
In this algorithm , Conduct a leader election with a reduced number of messages , But we can also set the destination of the message to two adjacent nodes to realize the algorithm with a small amount of data traffic .
6. Block chain and synchronization as distributed systems
therefore , In the block chain as one of the distributed systems , How synchronization between processes occurs ?
6–1. Blockchain and clock synchronization
Block chain and logic clock
First , Consider whether the physical clock in the blockchain can be used to master the absolute time relationship . As the first 2 Chapter , Each node participating in the network does not always maintain the correct physical clock , And there should be clock skew . Because the average generation time of bitcoin blockchain is 10 minute , Therefore, it is considered that even a certain degree of large clock deviation is acceptable . However , When nodes are scattered around the world, it is difficult to synchronize the physical clocks , And there may be nodes that camouflage clocks . By introducing network time protocol (NTP) To resynchronize the correct time between nodes is a difficult technique .
Blockchain and logical clock
therefore , It's practical to prepare a logical clock instead of a physical clock . actually , By adding a time stamp to the block , Can be prepared with Lamport Logical clocks are very similar mechanisms .
Such as [ The currency : Point to point e-cash system Satoshi Nakamoto] Described in , Each node that writes to the block as a miner has its own role as a timestamp server . Each timestamp is chained by including the previous timestamp in its hash . however , There is no guarantee that these nodes will keep the correct physical clock . The value of the timestamp , That is, the order and time of each transaction are relatively fuzzy .
Because of the ambiguity of the clock , It is possible to make double payments . however , In the bitcoin blockchain , Only the longest chain is legal , Discard the incorrect transaction after secondary validation . therefore , The sequence of blocks is uniquely determined over time . As each timestamp increases , The previous timestamp has been enhanced .
All in all , Under the fuzzy timestamp in the blockchain , The order consistency of transactions is not accurate . However , Using the simple mechanism of chaining , The pre transaction relationship of each transaction is established over time . Besides , There is also an incentive structure , So that the miners can move to good , Inconsistent order of transactions does not happen .
so to speak , The implementation is similar to Lamport The method of clock synchronization of logical clock , Because of the relative order between transactions , That is, the relationship that happened before becomes clearer .
For most transactions , There is no causal relationship , So if you introduce vector clocks and adopt the concept of causal ordering , It can greatly relax the constraints of order relations . However , In blockchain , Because the structure itself shares the order of all blocks by default , So keep the total order ( Relative to blocks after a period of time ).
6–2. Blockchain and exclusive control algorithm
Even in the blockchain as a distributed system , Also need to get rid of control . In the blockchain network , Each node operates asynchronously in parallel . here , The information of the blockchain itself to be shared should not be inconsistent .
PoW·PoS Exclusive control algorithm in
As the first 4 Chapter , Distributed exclusive control algorithm can be divided into the following two types .
· be based on Token Solutions for
· Rights based solutions
PoW and PoS It's permission based , among , It can be said that it is similar to the distributed algorithm mechanism . that , When do you get access to resources ? Yes , Just when you find a random number .
stay PoW in , Only if it is found after the hash value 0 Heel n by 0 When the random number of , To perform a valid new block write operation . The miners performing the operation broadcast it to all miners and share .
Usually , When the node finds a nonce And create a block earlier than his own ,minor This information will be synchronized and moved to search for the next nonce value . This is because if you use the rule that the longest chain is considered legal to search for the next nonce value , They can make more profits . Even though PoS Give priority to resource access for people with large coin Holdings , But the structure of basic exclusion control algorithm is similar to distributed algorithm .
however , Strictly speaking , Do not perform exclusion control . It's about synchronization and consensus in public time 10 minute , Until the next block . When two or more nodes find random values at the same time , Write operations are performed in an exclusive state . here , Since only the longest chain is considered legal , So the information in the blockchain network is consistent with the passage of time . One of the problems with forks is that strict exclusive control is not enforced and the final result is not confirmed .
BFT Type exclusive control algorithm
On the other hand , adopt BFT type , Permission based decentralized algorithms perform exclusive control . The algorithm solves the bifurcation and termination problems , This is a PoW Similar to distributed algorithms .
stay BFT Type in the , There is only one name Proposer,Orderer The nodes of the, etc. have the right to generate new blocks . When creating blocks , You can collect votes from all participating nodes , Get over 2/3 Consent of , You have the right to create new blocks . here , It is necessary to agree more than 2/3 Not most of the reasons are dealing with Byzantine failures , More information about this problem is in “ Fault tolerance in distributed systems ” It is described in the article .
stay BFT In the type algorithm , And PoW And so on , Only one node can gain exclusive access to the blockchain , So it's not immediately certain fork and finality. however , Anyone who can participate in the network as a miner is often lost .
6–3. Blockchain and leader selection algorithms
PoW,PoS And leader selection algorithms
The leader selection algorithm on blockchain is similar to the mechanism of exclusive control algorithm . In bitcoin , Algorithm for electing leaders , namely , The node of the newly created block is PoW.
PoW Allow to add a block as a good leader , Provides computing complexity and discovery for bitcoin networks nonce The node of . Every miner who becomes a leader will try to contribute to the bitcoin network , Because it is easier to synchronize early to discover the current node first and start searching the current value of the next block, it is more likely to get rewards . Despite the problem that the chain is completely branched by hard forks , But by preparing a very simple incentive structure based on Game Theory , Synchronization as a distributed system in block chain network .
In the case of Ethereum , Because the block generation time is very short , So there's a tendency for more bifurcations . On this point , By adopting unkle The concept of block , We implemented a structure , Even if the illegal chain will be given a certain reward .
To introduce into the future PoS It allows priority to generate blocks of nodes with large coin holding amount as a guide . It's a solution / improve PoW The necessary power becomes huge and vulnerable 51% The algorithm of the problem of attack . This is an election algorithm based on Game Theory , If a node holds a large number of coins , We won't take malicious actions .
BFT And leader selection algorithms
BFT The problem with the type algorithm is how to choose the leader who votes for block generation as the Proposer or Orderer.
stay PBFT Adopted HyperLedger among , A reliable organization will be registered as Orderer. But it's a centralized approach to leader selection , There are obvious differences with distributed systems .
stay Tendermint In the agreement , Leaders are chosen in a circular fashion , To make recommendations by alternating with different verifiers . here , Leadership candidates are based on PoS, And it can be said that it is one of the algorithms that can realize Leader Selection in distributed system .
边栏推荐
- A.前缀极差(C语言)
- js最常用的排序---手撕js系列
- [pan micro E9 development] single sign on Kingdee eas
- [elt.zip] openharmony paper Club - multi tier storage hierarchical data compression
- [CNN]|CNN与Transformer区别
- 从功能测试进阶自动化测试,熬夜7天整理出这一份3000字超全学习指南【附网盘资源】
- 【CNN】|How much position information do convolutional neural networks encode?
- Docker uses PXC to build a MySQL Cluster (mysql:5.7.24)
- [dataset] | UAV Perspective
- ARM开发板方案与厂商分析
猜你喜欢

/The world of 10 recommended websites for learning programming has entered the era of the Internet. According to a recently released Internet trends 2016 report, China has become a leader in the Inter
![[elt.zip] openharmony paper Club - fast random access string compression](/img/e6/e47046d6e56ca0c2608fc50060eb23.png)
[elt.zip] openharmony paper Club - fast random access string compression

After the installation of Damon database is completed, query whether it is case sensitive

Samsung Galaxy S21 ultra and Apple iPhone 13 Pro Max: which one should you choose

开源项目 英雄联盟 之WPF

Composition and configuration of GPS Beidou clock synchronization (satellite time synchronization system) in power plant
![[pan micro E9 development] single sign on Kingdee eas](/img/c7/50af4513be38b5e963ffc62de4e16d.jpg)
[pan micro E9 development] single sign on Kingdee eas

Guide de migration Maui
![[CNN]|CNN与Transformer区别](/img/ed/2b47387ba390a02c24bf9ff85b36e4.png)
[CNN]|CNN与Transformer区别

Shopping and retail backstage management system of chain supermarket based on SSM framework
随机推荐
Student teacher examination management system based on SSM framework
regular expression
2_ Introduction to SPU related services
Docker swarm installs redis cluster (bitnami/redis cluster:latest)
OpenGL Chapter 7 basic lighting
Samsung Galaxy S21 ultra and Apple iPhone 13 Pro Max: which one should you choose
OpenGL第七章 基础光照
/The world of 10 recommended websites for learning programming has entered the era of the Internet. According to a recently released Internet trends 2016 report, China has become a leader in the Inter
Brew source change
Thoughts on the number of threads and CPU caused by the CPU load high alarm
联易融一面(已过)
Synchronized locked objects
The tide play power is really firepower! The first big screen cinema for young people? Cool open TV Max 86 "sudden attack
OpenGl第十章 投光物
pmm监控oracle
1_ Attribute management function
Kirin V10 installation of tongweb7.0
UML系列文章(28)体系结构建模---协作
Google 有哪些牛逼的开源项目?
GPS Beidou time service, NTP makes network clock synchronization more accurate