A NOVEL PRECISE AND ACCURATE CLOCK SYNCHRONIZATION ALGORITHM

Execution of a task in a synchronized manner in a distributed setting, one needs the common idea of time. To accomplish this task, clock synchronization is conceptualized. Clock drifting is an intrinsic property of a clock, which necessitates the synchronization and resynchronization. A network consists of nodes, which may behave appropriately or behave badly. The mischievous node may pose difficulty in clock synchronization. We require a method to overcome the effect of mischievous nodes. Synchronization can be achieved in two ways namely accuracy and precision. In this paper, we present an accurate weighted average clock synchronization algorithm to execute a coordinated activity in a fault-tolerant manner. We use trusted clock value from GPS/GLONASS/IRNSS as a reference clock to achieve better accuracy. We also use behavior of the node to compute normalized weight in a localized manner, which lies between unit intervals. This weight assignment enables us to contain the effect of misbehavior up to some extent. This algorithm offers better accuracy and precision while tolerating mischievous nodes. The upper bound of tolerance boundary is one-third of the network size.


INTRODUCTION
A distributed network consists of spatially scattered diverse nodes. These nodes are essential to carry out cooperative functions in close synchronization to one another. This is achievable only when they share some familiar idea of time. This ensures chronological precedence order across the network. In the contemporary world, with proliferation of internet and development of information technology, many facets of our life are integrated over the web. Internet of Things (IoT) is the trend which integrate all our smart devices over the web so as some major aspects of our life [1]. Our smart devices collect various data and share information over the network for better management. All of these systems are able to function only they are synchronized over the network. The clock synchronization process will help in faithful collection of data and its transmission [2]. IoT seldom works in isolation. Many synchronization algorithms use GPS/GLONASS/similar trusted clock signal. However, there are certain applications in which such trusted clock signal cannot be used for certain reasons. Some of these applications may use these clock signal for some time and as per design may not use at other times. We have designed an algorithm in which there is an option to use the trusted clock signal whenever necessary. This will help a network to work in isolation without any contact with outside world, if there should exist such a requirement.

RELATED WORK
Time and message format for synchronization are defined in IEEE 1588 standards [3] [4]. In the IEEE standards a grand Master node propagates periodically synchronization information to the slave nodes over the boundary clock and the transparent clocks. The synchronization information may also be carried over either by boundary clock or transparent clock only. There are multiple Precision Time Protocol (PTP) ports in a boundary clock. The boundary clock can also act as master clock which can synchronize other clocks, as slave clocks. In such a scheme the grand master will first synchronized its neighbouring slave clocks and then these slaves in turn will 111 A NOVEL PRECISE AND ACCURATE CLOCK SYNCHRONIZATION ALGORITHM synchronize their neighbouring slave clock. Here the slave clocks performed the role of a master clocks.
Over a period of time, many researchers had suggested various precise clock synchronization algorithm which are IEEE 1588 compliant. Some of them had also demonstrated their algorithm [5] - [9]. These suggested algorithms mainly cater for single hop network. Ability of these algorithms working in multi hop distributed network is suspect since for such multi hop environment, the requirement for high accuracy is mandatory. The clock synchronization error increases as number of hops increases in a distributed network. This is a major limitation in boundary clock synchronization scheme. Peaktopeak clock synchronization error increases to 0.8, 08, 40 & 300 microsec for 01, 03, 05 & 10 hops respectively for such scheme. Simulation for the same is reported in [10].
Many researchers had proposed various clock synchronization algorithm catering for various requirement including that of IoT [11] - [16]. Maintaining time records of information sent and received is a basic function of synchronization algorithm. Timestamp for each for such bits of information is always enclosed with the information sent/received. The slave clock is able to synchronize by calculating various clock parameters like clock offset, compensate time etc. A basic protocol is under numerated: a) Master clock forwards a Sync message to the neighbouring slave clocks and it records the transmit time t1. b) On receiving the message, this slave clock records the reception time as t2.
c) The master clock may also immediately forwards another sync message carrying t1.
d) The slave clock, then, forwards a message requesting to forward the delay in transmission to the master clock.
e) The slave clock, then, will initiate the calculation of the reverse transmit delay and records the transmit time t3. f) On receiving this message, master clock records the received time as t4. g) Now on receiving the message requesting delay, the master clock forwards back a message carrying t4 as response to the request. Now the slave clock has 04 time stamps t1, t2, t3 & t4. Utilizing the time records we can calculate the total round trip delay between the master and slave clocks as [(t2 − t1) + (t4 − t3)]. As the network is symmetric, the one-way delay between the master and slave clocks is [(t2 −t1) + (t4 −t3)]/2. Therefore, the clock deviation of the slave clock from the master clock is: Malicious nodes in the network may however use these timestamp to exploit the system. The problem become more acute if the slave nodes require to go through multiple hops for synchronization with the master node. W. Dong [16] has suggested a novel graph theoretical algorithm to counter the effect of malicious behaviour. In the algorithm malicious behaviour is detected at the message level only. This approach is however computing resource exhaustive.
Hence, there is a requirement of an approach to counter malicious behaviour while ensuring resource efficient clock synchronization.

OUR PROPOSED CLOCK SYNCHRONIZATION SCHEME
Clock synchronization in a distributed system has been exhaustively deliberate in the previous few decades. Many synchronization algorithms used averaging method as convergence function with varying degrees of competence and complexities. Some of the important algorithm are already discussed in the section above.
Here we are giving some essential definitions, which help to build up our system model and synchronization algorithm. clocks, which give different time to different nodes at the same real time.

System model and problem statement
In this section we give a thorough explanation of the system model. We also describe the problem statement of the paper subsequently.

System Model
The system model is explained in two parts; at first we describe the network architecture and then the Malfunction model of the network.

Network Architecture
We consider a connected distributed static network which has three levels of hierarchies. As shown in the Fig. 1, the layers are Reference layer (RL), Pseudo reference layer (PRL) and Non reference layer (NRL). In the reference layer there are one or more than one Master Node (MN) which receives reference clock value for outside trusted sources such as GPS/GLONASS/ IRNSS/Galileo etc. The MN can utilize this clock value for clock synchronization process for rest of the network. However, these MN can also switch off receiving this clock value. The MN in the reference layer are connected to Pseudo Master Nodes (PMN) in the Pseudo reference layer. The number of MN is much fewer than PMN. There are at least two PMN in the Pseudo layer and any MN is connected to the at least two or more PMN. All PMN are fully connected and they are much fewer than the number of nodes. PMN in the pseudo reference are connected to Nodes in the non-reference. Here any node is connected to at least one PMN and the nodes are generally connected to their neighboring nodes but not necessarily Each of the MN, PMN and Nodes has a local physical clock from where the logical clock of the node is derived. We assumed that the physical clocks run continuously with respect to the real time. This physical clock can drift at rate ρ apart from the real time due to factors like temperature, pressure or aging. We make the following assumptions in our paper: Drift-Bound: The Physical Clock for any node , ( ) ρ-bounded for all real time t as following: The logical clock is related to the physical clock as L( t ) = P( t ) + A(t) where A(t) is the called the adjustment. This adjustment can be done discretely or linearly.
Initial synchronization: The logical clock of any two nodes and at 0 where 0 is the real time at the start of the synchronization algorithm differ by real time α.
This is basically the initial synchronization assumption. Here we are assuming that all the nodes are initially synchronized at real time t0.

Malfunction Model
In our system malfunctions can occur to malfunction of nodes, their clock or due to link malfunction between the nodes or a combination of some or all of these malfunction. A clock is considered failed if the Drift-Bound assumption is violated. We are basically considering two types of clock malfunctions namely timing malfunction and mischievous clock. If a clock gives inaccurate, untimely and conflicting information or behaves like a 'dual-faced' clock then we assumed the clock is a mischievous clock. A clock is a good clock if it is running without any malfunction. We also assumed that the maximum number of bad clock is f.

Maximum Clock Malfunction:
There are at maximum f number of faulty clock in the network for 3f+1 nodes.

Problem Statement
Our algorithm uses trusted reference clock value and a weighted averaging and sliding window method for attaining synchronization of the nodes in a distributed network. The synchronization obtained is both accurate and precise. The synchronization algorithm satisfies the following properties: Agreement Property: For good clocks of nodes and at real time t immediately after resynchronization, ( ) and ( ) satisfy: where Π ≤ (δ + ε) is the precision of our synchronization algorithm.

Incremental
Step property: The correct clocks change every time by some amount ξ at each synchronization.
Accuracy property: The correct clock of node , for some constants a, b, c and d holds for real time 1 < 2 the following: We would like to make Π as small as possible so that clocks are close to one another. The validity of the Agreement property and Incremental Step property implies that our good clocks are running linearly with respect to real time. We would also like to make ( 2 − 1 ) as close as possible to ( 2 ) -( 1 ) for any node . This ensures the time elapsed by the clock of any node is same to the real time elapsed in the interval. For optimal accuracy a and c should be equal to one and b and d should be zero in expression of Accuracy property.

Accurate Weighted Average Synchronization Algorithm (AWASA)
A synchronization algorithm which achieves clock synchronization by using a weighted averaging as a convergence function is described in [17]. This algorithm is called WASA and it utilizes the concept of sliding window to find the minimum variance data set upon which the convergence function is used. WASA achieves a precise clock synchronization. Here we are designing an algorithm which is both precise and accurate. Since this algorithm is an improvement on WASA, we call this algorithm as AWASA.  In this paper our focus is to counter the individual misbehavior which includes consistent and inconsistent behavior both with the aim to achieve an accurate and precise clock synchronization.
We have initially taken the trusted clock value from reputed authentic source like GPS/ GLONASS/IRNSS/ Galileo etc to the MN. This clock value is used as a reference to synchronized the rest of the network but after undergoing a check. This is done since the behavior of the clocks at PMN may have, by any probability, gone corrupted. We have devised a sliding window technique to find the set of values, which show minimum deviation among the values. We know that Gaussian distribution is widely present in nature. We capitalized this knowledge to design the weight function. This weighted approach is used to mitigate the misbehavior.

Detailed View of AWASA
We In tref phase the MN receive trusted clock value from authentic source such as GPS/GLONASS/IRNSS etc. The ultimate aim to synchronize all types of nodes in the network to this clock value. In such a scenario, the clock synchronization will be very accurate as all the nodes will have clock value of the trusted/ reference clock. However, synchronization of all nodes in the network with GPS/similar trusted clock value will not be possible. Some of the possible reasons for the same is given below. AWASA can overcome this type of scenario easily without effecting the synchronization process. The same will be explained subsequently. a) Every node may not have a GPS/ similar receiver b) Some nodes may be in such a location where they are not able to access the GPS signal c) There arises such a situation in which the system administrator considers it not to utilize such external source of clock input, may be, in order to maintain secrecy d) The GPS/similar sys is no longer trustworthy, etc.
When the MN is at time ts, it sends a resync request to all PMN. If the clock state of the PMN is between trs and tre, an ACK is replied after due verification of the request. Timeline for one such tref is depicted in Fig.3. This indicates the start of the resynchronization process. However, if no ACK is received, the MN will understand that the resynchronization time has not yet started and waits for next resynchronization time and again send out its resync request. On receiving the ACK, the MN sends the trusted clock value received from GPS/similar source to all connected PMN.
The PMN then assigns this clock value as their new clock value and hence resynchronize with the MN. For each resynchronization process, we follow the IEEE 1588 standard: as already described in the related work section.
In tpref phase as all the PMN are now in sync with the MN, the PMN now need to further resync with the connected node. However before sending out the clock value to all connected Nodes with IEEE 1588 standard, all the PMN under a WASA [17] check. WASA consists of three phases namely Information Collection Phase (ICP), Sliding Window Phase (SWP) and Weighted Average Phase (WAP). The same is described briefly below.

Sliding Window Phase (SWP)
We introduced the notion of window. The size of window is n-f where n network size and f is allowed bad PMN, if any. Initially we placed the left boundary of the window at the beginning of the array. So first window consists of first − values of the array. Thereafter we slide the window one step in the right direction and this consists of next − values. We continue this process until the right boundary of the window reaches the end of the array. In this process we find the f data set of size − . Now out of f data sets we find out the data set with minimum variance.

Weighted Average Phase (WAP)
We use the minimum variance data set calculated in the SWP for finding the weighted average with some modifications. Since the size of the minimum variance window is − , it contains at 121 A NOVEL PRECISE AND ACCURATE CLOCK SYNCHRONIZATION ALGORITHM least − 2 good clocks and at most f bad clocks. For the worst case the minimum variance window contains − 2 good clocks and f bad clocks. There can be also at maximum f good clocks outside the minimum variance window.
We now push these good clocks outside the minimum variance window inside the window by assigning the value of the good clock nearest to them inside the window. Now data set values inside the minimum variance window are assigned weights as per weight function and the weighted average is calculated. These weighted average value, θ, is the new clock.
For assignment of the weights, clock value within one ± σ distance from μ are assigned weight 1 , where μ is the mean and σ is the standard deviation of the window. Clocks within ± σ to ± 2 σ are assigned weight 2 and clocks within ± 2 σ to ± 3 σ are assigned weight 3 . Finally clocks beyond ± 3 σ are assigned zero weight.

Best and Worst Case Scenario of WASA
The precision of WASA in an ideal condition where there is no PMN clock is = , which is optimal. The worst possible precision of WASA for large value of bad PMN is within: The worst possible precision guaranteed by WASA is given by Since ≪ , Hence WASA guaranteed Agreement Property. and NRL is precisely in sync with PRL. On availability of the trusted clock value, the resynchronization will revert back to its usual protocol.

CONCLUSION
In this paper, we devise and present AWASA algorithm for clock synchronization, which is suitable for fully connected network. AWASA achieve at least 33% tighter accuracy and precision in the worst-case scenario. Even the worst-case scenario occurrence is very less but our study provides meaningful analytically insight. AWASA guarantees clock synchronization in presence of mischievous clocks if the upper bound of mischievous nodes is just under one-third of the network size. Using this algorithm, we are able to achieve highly accurate and precise synchronization when there is presence of GPS/GLONASS/IRNSS etc clock value. The algorithm also works in absence of such trusted clock values as well. However, since a reference clock value is not present, the algorithm will give highly precise synchronization value only. In our current work, we provide the analysis for static network. In future work we will try to achieve synchronization for a dynamic connected network.