Enhanced Timestamping Method for Sub-Nanosecond Time Synchronization in IEEE 802.11 over WLAN Standard Conditions

Abstract—The Time-Sensitive networks paradigm envisions applications, such as wireless SHARP [3] or WirelessHP [4], the integration of Operation Technology and Information require accurate time synchronization, as it is essential to Technology in the same network. One of the requirements for reduce inter-frames spacing and improve the wireless system building Time-Sensitive networks is sharing a global time along performance. Furthermore, hybrid Time-Sensitive networks the network. This requirement is especially critical in wireless also demand accurate time synchronization along the systems, where there are few robust methods to perform accurate time transfer. In this paper, the problem of time transfer over wired/wireless segments to deterministically schedule frames realistic wireless channels is studied and a time distribution with minimum latency. However, the vast existence of scheme is proposed. The time distribution scheme has three heterogeneous technologies and implementations in hybrid components: Precision , a novel timestamping networks could be a major issue to obtain high-performance method (enhanced timestamps) and an algorithm to implement time synchronization. On the other hand, most RT applications the enhanced timestamps. The performance of the proposed have strict time synchronization requirements. For example, scheme has been evaluated in MATLAB using the IEEE 802.11n time synchronization is especially critical in Cyber Physical standard under several standard Wireless Systems and Distributed Control Systems, where every element channel models. The results show that the system can reach sub- of the system must synchronously perform specific tasks, such nanosecond time transfer accuracy under Non-Line-of-Sight and time-variant conditions, but its performance greatly depends on as reading a sensor or changing the state of an actuator. One the Signal-to-Noise-Ratio and on the channel variation rate. single failure in the time synchronization can lead to the failure of the entire system, which can cause from loss of profits to loss Keywords— Indoor Localization, IEEE 1588, IEEE 802.11, of human lives. NLoS, PTP, Timestamping, Time-Sensitive, Time synchronization, The synchronization problem is usually addressed from two Wireless Communications, wireless TSN main perspectives: Global Navigation Satellite System (GNSS)-based synchronization, and time distribution through I. INTRODUCTION the network. The first one requires Line-of-Sight (LoS) with Operation Technology (OT) and newer Real-Time (RT) GNSS constellation and its performance is severely Information Technology (IT) applications are pushing the deteriorated under bad environmental conditions. Furthermore, legacy networks to the Time-Sensitive network paradigm [1]. it is not cost-effective for many applications. The second This novel paradigm envisions the support for heterogeneous perspective is not greatly affected by changes in the applications in the same network. The next applications, among environment conditions and its performance can be similar to others, are expected to coexist in the same network [2]. From GNSS-based solutions. Finally, it is common to use a hybrid the OT paradigm: autonomous driving, factory automation, approach, where the master clock synchronizes its clock to a smart transportation, and Wireless Sensor and Actuator GNSS system. The master is usually situated outside of the Networks (WSAN); whereas from the IT paradigm: RT facility with LoS conditions to obtain an adequate performance gaming, High Frequency Trading, video calls, multimedia and it distributes its time to the rest of the nodes (Fig. 1). This streaming services and web browsing. A lot of efforts are being approach results in a more accurate and cost-effective solution, made by researchers in different fields to obtain a solid solution as only one GNSS receiver is needed, and because every node that could support the vast variety of applications and their will be synchronized to a common reference. requirements in a single integrated hybrid and heterogeneous Among the existing protocols for , network. two protocols stand as the most widely used nowadays: One of the main requirements and challenges of (NTP) [5] and Time-Sensitive networks is sharing a common base time along (PTP) [6]. NTP protocol was designed to perform time transfer every element of the network. For example, novel in IT services and its accuracy is in the millisecond range. high-performance wireless systems for Time-Sensitive Therefore, it cannot provide enough accuracy for OT applications. PTP accuracy is superior to the NTP protocol and hence the natural option to obtain very high clock accuracy in Time-Sensitive networks. Nonetheless, PTP timestamping precision is proportional to the timestamping clock period, and GMC Monitoring then it cannot provide sub-nanosecond time synchronization in most systems. A third protocol, White Rabbit [7], stands out as a solution to eliminate the PTP limitations. White Rabbit is Switch Switch Switch based on three technologies: Synchronous (SyncE) [8], PTP, and the Dual Mixer Time Difference [7]. White Rabbit protocol implemented on Ethernet links can effectively AP AP AP provide sub-nanosecond time synchronization [7]. Wireless systems exhibit several limitations that challenge successful high-performance time synchronization. We may Fig. 1. Clock distribution along a hybrid network using GNSS as its highlight, among others, low bandwidth, multipath reference time. propagation, channel variation over time, and the lack of (Line- of-Sight) LoS. The bandwidth imposes a timestamp granularity in the order of the inverse of the bandwidth, which clearly limits the synchronization accuracy. This is the main reason why Ultra-Wide Band (UWB) radios are usually found in Radio- Frequency (RF) indoor localization systems [9]. The multipath propagation produces signal time-dispersion that also affects Industry 4.0. Smart Transportation time synchronization performance. In addition, the changes of the environment over time yield to a time-variant Channel Impulse Response (CIR) and, thus, a variant signal time dispersion. Time-variant channels are present in networks with mobility which might be produced by moving communication Indoor Localization Scientific Experiments nodes and/or moving environment (people, machinery, etc.). Finally, the lack of LoS produces strong variations of the Fig. 2. Applications benefitting from accurate time synchronization. wireless channel delay, which in turn introduces a strong error synchronization has significant impact in the application in the time synchronization. The combined effect of these performance, such as indoor localization [11] (Fig. 2). phenomena greatly increases the error on the timestamps and, In this work we have used the accuracy, trueness and thus, are challenging hurdles for high-performance time precision terms as defined by the ISO 5725-1:1994 [12]. synchronization over real-world wireless channels. Trueness is defined as the difference between the mean value In this work, PTP synchronization mechanism is described of a series of results and the true value, precision is defined as in detail, and it is shown that timestamps based on conventional the std deviation of a series of results, and accuracy is defined frame start detectors (or conventional timestamps) have two as the combination of both the trueness and accuracy. Then, an main issues in wireless systems. In the first place, they cannot accurate system is a system that has both good trueness, and guarantee a time transfer accuracy better than the sampling good precision. period. In the second place, the multipath propagation and the The rest of the paper is organized as follows. First, the state- wireless channel time-variant character reduces the precision of of-the-art of time transfer is presented in section II. PTP the frames Time-of-Arrival (ToA), which introduces an error protocol over wireless networks is described in section III. In component in the time synchronization. This is especially section IV, the limitations of conventional timestamps are critical under Non-Line of Sight (NLoS) conditions, where a analyzed, and the enhanced timestamping method is proposed. prevalent propagation path does not exist, thus the ToA may The algorithm to implement the enhanced timestamps is have strong variations. described in Section V. Section VI details some guidelines to Based on the above-mentioned analysis, we proposed an successfully integrate the synchronization scheme into a improved wireless timestamping method (enhanced wireless system. Section VII presents the numerical results timestamping) which precisely estimates the frames ToA in achieved with the proposed solution. Finally, section VIII severe multipath conditions and overcomes the inherent summarizes some conclusions of the work. limitations of conventional timestamps. The enhanced timestamping uses the whole CIR to precisely estimate the ToA II. BACKGROUND AND RELATED WORK and can be seamlessly used in both LoS and NLoS conditions, As previously stated, a common approach to time because it does not rely on the detection of the main channel distribution is the use of a GNSS satellite constellation. GNSS- component and because it is very robust to multipath based solutions can obtain time synchronization accuracy in the propagation. The two main limitations of the enhanced ten nanosecond range [13]. In [14], some considerations to timestamps precision are the channel variation rate and the reduce the synchronization error to less than 1 ns are presented. Signal to Noise Ratio (SNR). The performance of the presented These considerations assume that the nodes are situated in an technique has been obtained numerically through Matlab open space with LOS to the GNSS system. In addition, bad simulations using the IEEE 802.11n physical layer and four environmental and climate conditions can significantly wireless time-dispersive and time-variant channel models. deteriorate the link quality and, hence, the synchronization These simulations show that the use of the enhanced performance. To the best of our knowledge, the performance of timestamping compared to conventional timestamping yields a the considerations stated in [12] has not been tested yet in a real meaningful increase of synchronization accuracy that reaches testbed. sub-nanosecond performance. Finally, we include some One application that could use this approach is autonomous guidelines to effectively implement the enhanced timestamping driving, as future vehicles will include a GNSS receiver. into already existing wireless systems or in proprietary However, the existence of tunnels, underground roads and solutions. The proposed time synchronization scheme has been parking, and the fact that GNSS signals can be interfered or designed to improve time synchronization in wireless spoofed require the use of at least a non-GNSS dependent Time-Sensitive networks and its possible applications (Fig. 2: approach as a backup system or as the main synchronization industry 4.0, autonomous driving, smart transportation, etc.). In system. addition, there are some applications that need to deploy a The second approach is time distribution within a communication system just for performing time distribution. communication system using PTP or a similar protocol. The These networks are usually found in scientific experiments performance of this approach heavily relies on the [10], where a system must gather data with very high time communication system capacities, its implementation and the accuracy over large areas. In this case, the use of wireless links deployment environment. Low accuracy, yet simpler, PTP for time transfer, instead of wired links, could lead to more cost- software implementations can achieve a clock synchronization effective solutions, faster deployments, and lower failure in the range of several hundreds of nanoseconds [15]. This possibility, due to the inexistence of cables. Finally, this solution is very far from the desired performance. PTP with solution may be useful in other fields where time Software-based timestamps is significantly overcome by PTP with hardware-based timestamps, where the timestamps of PTP the timestamping precision and the overall system frames are taken at the physical layer [16]. However, to the best performance. A real testbed is developed, and its performance of our knowledge, there is not yet any wireless standard that is evaluated in [22]. It is shown that the system can obtain sub- natively supports PTP with hardware-based timestamps. This nanosecond synchronization accuracy over LoS conditions, but clearly contrasts with the Ethernet standard, which already its performance for NLoS conditions is not reported. Finally, covers the use of hardware timestamping and it is implemented the timestamping validation strategy presented in [24] does in a high variety of chips. neither include NLoS conditions. In conclusion, this solution is There are several wireless custom systems in the literature very suitable for LoS and static conditions, but it is not suitable for different wireless technologies that are based on PTP or for NLoS and time-variant conditions. similar protocols using hardware timestamps. In [16], several There are also some attempts to port white rabbit to the solutions for time synchronization over 802.11 are compared. wireless domain. The wireless white rabbit approaches are In [17], an 802.11g modem implementation over Field- mainly based on transmitting the clock phase and frequency programmable Gate Array (FPGA) with conventional hardware from the master to the slave, and synchronize the slave clock timestamps is described. The timestamps are taken using the by using an Analog Phase Locked Loop (PLL). For example, frame start detection block (a preamble cross-correlator), and the design presented in [25] estimates the clock phase and its timestamp granularity is 50 ns. The time synchronization frequency to synchronize the slave of a 5G wireless backhaul performance was measured over the IEEE 802.11 Wireless link, obtaining (by simulations) an accuracy of about 40 ps in Local Area Network (WLAN) standard channel models [18] LoS conditions. However, the system performance is highly using a channel emulator. The measurements show that the degraded when a simple multipath propagation channel is clock synchronization accuracy can be as low as 30 ns in low considered, and the synchronization accuracy drops and medium-dispersive channels with time-variant conditions. immediately to more than 1 ns. On the other hand, the carrier However, this solution is far from the sub-nanosecond time phase can also be used to synchronize the slave clock phase and synchronization performance, as its timestamps precision is frequency. This approach is effectively implemented in [26], fixed to the inverse of the bandwidth of the system. where it is detailed a partial implementation of a custom IEEE Advanced timestamping techniques have been proposed in 802.11g modem with carrier phase estimation which obtains an the literature in order to obtain sub-nanosecond time exceptional accuracy of 50 ps. Again, this design requires LoS synchronization over IEEE 802.11 [19], [20] and [21]. In [19], and no multipath. it is described an 802.11b implementation in FPGA with Finally, a robust timing synchronization technique over a hardware timestamps and subsample timestamping precision. custom Orthogonal Frequency Division Multiplexing (OFDM) This design is based on conventional hardware timestamps physical layer along with an enhancement to PTP are proposed combined with a synchronizer used to calculate the phase in [27]. The robust timing synchronization technique is difference between the transmitter and receiver clocks. This designed to reduce the jitter in the frame start detection, design resulted in a synchronization accuracy better than 600 whereas the enhanced PTP is designed to reduce the error in the picoseconds for static conditions. However, according to the clock offset estimation. The performance of the timing experiments documented in [19], the performance of the system synchronization technique was evaluated over several channel is highly deteriorated for time-variant channels, showing a models with different time-dispersion characteristics. synchronization error bigger than 20 ns. The receiver presented However, the presented results do not include the time transfer in [19] is improved in [20] and in [21] to combat the multipath performance, but only the frame start detection precision. propagation. The improvements proposed in [20] are mainly Although both parameters are related, the time transfer based on the use of frequency hopping in order to obtain accuracy cannot be directly derived from the frame start timestamps considering several independent channels. This is detection precision, as the channel variation during the PTP used to average the timestamping error introduced by the frame exchange must be considered. multipath propagation. However, such a system needs a very specific implementation and the authors state in the paper that III. PRECISION TIME PROTOCOL the ranging error is significantly larger when the target is PTP is a well-known and broadly used protocol described moving. The solution proposed in [21] uses the interpolation of in IEEE 1588 standard [6]. The protocol follows a master-slave the cross-correlation peak to take timestamps with subsample structure, where the master shares its local time with the slaves precision and an equalizer to combat the multipath components connected to it. To perform the time distribution, PTP uses the and reduce the ranging error. However, the system is still timestamps taken in a four frame exchange (Fig. 3). Firstly, a designed for LoS conditions, and it is vulnerable to strong Sync frame is transmitted by the master, which takes the 푡1 multipath components. In summary, these solutions [19], [20] timestamp. The frame arrives to the slave that estimates the ′ [21] require a strong LoS because they rely on the detection on ToA and takes the timestamp 푡2. Then, a Follow_up frame is the first channel replica, which is not available under NLoS sent from the master to the slave to transmit the timestamp 푡1 conditions. to the slave. The follow up frame is optional, as the 푡1 Another wireless synchronization scheme based on the timestamp can be also delivered through the Sync frame if the interpolation of the cross-correlation peak but over IEEE PTP implementation supports that option. In this paper, it is 802.15.4 Chirp Spread Spectrum (CSS) is shown in [22], [23] considered that the follow up is not necessary. Afterwards, the and [24]. In [21] it is developed a theoretical analysis of the Delay Request frame (Delay_Req) is transmitted to obtain two ′ feasibility of the CSS modulation to perform precise more timestamps (푡3, 푡4). Finally, the Delay Response frame timestamping and an early experimental validation is presented. (Delay_Resp) delivers the 푡4 timestamp to the receiver. Once The system performance is reported through simulations under the four timestamps are in the slave side, it performs the direct LoS and limited multipath propagation conditions. calculations stated in (1) and (2) to synchronize its time with Furthermore, the authors note that the system is not designed the master time for NLoS conditions and the lack of LoS would strongly affect Master time Slave time being 휏ℎ the channel delay, 푡푒 the timestamping error and 푡퐴̃ the estimated ToA. A wireless channel is usually composed of t 1 several signal replicas received at different time instants (i.e. tms time-dispersive channel), thus a unique 휏ℎ definition does not t2‘ exist. Due to this, 휏ℎ definition will depend on which algorithm is used to perform the ToA estimation. The most commonly definition is considering that 휏ℎ is equal to the delay of first (t1, t2‘) channel component. This definition is reasonable for LoS

t3‘ (t1, t2‘, t3) channels, but it will present strong variations in NLoS channels. t In addition, the timestamping error 푡푒 will greatly depend on sm the frame start detection algorithm and on the communication t4 system properties. In the following subsections, a comprehensive analysis of the limitations of conventional timestamps is shown, and the enhanced timestamps are developed. (t , t ‘, t ‘, t ) 1 2 3 4 A. Timestamp model t t‘ Let be 푠[푙] a pseudorandom white sequence with length and Fig. 3. PTP frame exchange, being 푡 the time of the master clock and 푡’ the energy L and known by the receiver and transmitter. The time of the slave clock. sequence has the next property ′ ′ 푡2 − 푡1 + 푡4 − 푡3 푡̃ = , (1) 푅 [푛] ≈ 퐿 훿[푛], (4) 푚푠 2 푠푠

where 푅푠푠 is the autocorrelation of 푠[푙] and 훿[푛] is the ̃ ′ ̃ 푡표 = 푡2 − 푡1 − 푡푚푠, (2) Kronecker delta. The sequence 푠[푙] is sent using a where 푡푚푠̃ represents the estimated path delay and 푡표̃ is the pulse-shaping filter with impulse response 푔(푡), thus, the estimated clock offset between the master and slave clocks. The transmitted signal may be written as follows time correction is performed by subtracting 푡표̃ from the slave 퐿−1 time. s1(t) = ∑ 푠[푙] 푔(푡 − 푙푇 + 휙푇푥푇), (5) Whereas the IEEE 1588 standard clearly describes the 푙=0 mechanisms to obtain accurate time synchronization, where 푇 is the symbol rate and 휙푇푥푇 is the uncertainity in the differences among implementations can cause vast sampling instant (i.e. the jitter of the transmitter) that is performance differences. The main error contributions in modeled as a zero-mean Gaussian distribution 휙 ∼ wireless PTP are: the time-dispersive and time-variant 푇푥 풩(0, 휎2 ). Without loss of generality, we will assume that character of the wireless channels, the timestamping error, and 휙푇푥 1 the calibration of the nodes. 푔(푡) is a real, band-limited signal, with bandwidth 퐵 = and At a given instant, we can consider that the wireless CIR 2푇 unit energy. s (t) is the complex baseband representation of the from master to slave equals the CIR from slave to master 1 passband signal with carrier frequency 푓 . Although 푔(푡) is not (symmetric channel) and, thus, 푡 = 푡 . However, a wireless 푐 푚푠 푠푚 time-limited, it can be assumed that most of the energy 푔(푡) is CIR is varying along the time due to environment changes. confined in the interval [0, 푇 ], thus it is approximated by a Thus, to satisfy the assumption of symmetry it is necessary that 𝑔 the elapsed time between the PTP sync and PTP Delay Request truncated version of 푔(푡). Therefore, 푔(푡) is considered a finite is much smaller than the coherence time of the channel. impulse response. The signal s1(t) is transmitted through a Regarding timestamping errors, they may be induced by a communication channel whose impulse response is noted as plethora of sources: software jitter, precision in the estimation ℎ(푡). The CIR is defined in the interval [푇푑, 푇ℎ + 푇푑], where 푇푑 of the Time-of-Departure (ToD) and ToA, jitter caused by is the CIR start and 푇ℎ is the CIR duration. ℎ(푡) is the complex analog components, the communication system characteristics baseband representation of the passband CIR with a carrier (narrowband, wideband, preamble length, etc.), and the quality frequency of 푓푐. Hence, the signal at the input of the matched of the communication, i.e., the SNR. filter is Finally, the timestamping calibration of the nodes is not 퐿−1 related to the protocol, thus it is not analyzed in this paper. 푠2(푡) = ∑ 푠[푙] 푔ℎ(푡 − 푙푇 + 휙푇푥푇) + 푛2(푡), (6) 푙=0 IV. HIGH-PERFORMANCE TIME SYNCHRONIZATION THROUGH where 푔ℎ(푡) is the convolution of 푔(푡) and ℎ(푡), i.e., 푔ℎ(푡) = ENHANCED TIMESTAMPS (푔 ∗ ℎ)(푡). The noise component 푛2(푡) is modeled as Additive The key to obtain High-Performance time synchronization White Gaussian Noise (AWGN). The matched filter with a is tightly related to the timestamps quality. Timestamps quality response equal to 푔(−푡 + 푇𝑔) is applied to 푠2(푡) and it results is commonly defined as the difference between the exact 퐿−1 ToA/ToD and the estimated ToA/ToD. The ToD (푡퐷) may be 푟(푡) = ∑ 푠[푙] 푝(푡 − 푙푇 + 휙푇푥푇) + 푛(푡), (7) accurately estimated (푡퐷̃ ) whenever the communication chain 푙=0 jitter and the calibration error are negligible. In this work, it is being 푝(푡) the convolution of 푔 (푡) and 푔(−푡 + 푇 ), and 푛(푡) considered that these conditions are satisfied. In addition, the ℎ 𝑔 estimated ToA can be defined as the filtered noise resulted from the convolution of 푛2(푡) and 푔(−푡 + 푇𝑔). Finally, 푟(푡) is sampled at the receiver with a ̃ 푡퐴 = 휏ℎ + 푡퐷 + 푡푒, (3) sampling period 푇 the other hand, the timestamps resolution cannot be higher than the sampling period. A detailed analysis of the quantization drawback of conventional timestamps is shown in the next subsection. C. PTP with conventional timestamps In order to illustrate the quantization drawback of conventional timestamps, an example of the PTP performance using conventional timestamps is shown in a simplified setup. Fig. 4. Issue of threshold-based timestamps: small CIR variation can cause It has been assumed that: a big frame start detection error. - ℎ(푡) = 훿(푡 − 휏 ), being 훿(푡) a Dirac delta. [ ] ( ) ℎ 푟 푘 = 푟 푡 |푡=푘푇+휙푅푥푇 퐿−1 - The clock offset is 푡표 = −(𝑖0 + 휙)푇. - The master and slave clocks have the same clock drift, = ∑ 푠[푙]푝((푘 − 푙)푇 + 휙푇) + 푛(푘푇 + 휙푅푥푇), (8) 푙=0 and the jitter is almost constant. Hence, 휙 = 휇푅푥. - The noise is negligible. being 휙푅푥 the timing jitter resulted from the sampling of 푟(푡) Being 𝑖표 ∈ ℤ and 휙 ∈ [0,1). 𝑖표 represents the number of clock and 휙 = 휙푅푥+휙푇푥, the whole jitter. 휙푅푥 is modeled as 2 cycles between the start of both clocks, and 휙 the clocks 풩(휇휙 , 휎휙 ), being 휇휙 the unkown phase difference 푅푥 푅푥 푅푥 relative phase. The master clock signal 퐶푀(푡) and the slave between the master and slave clocks. 휇 is considered time- 휙푅푥 clock signal 퐶푆(푡) are represented in Fig. 5. invariant because the clock drift variation is negligible taking The local time of the master and the slave can be expressed into account the time length of 푟(푡). The quantization noise due as to the signal sampling may be another source of error that could 푡푀(푡) = 푡, limit the synchronization accuracy. The quantization noise (11) ( ) would basically create a noise floor, which limits the SNR and 푡푆 푡 = 푡 + 푡표 = 푡 − (𝑖0 + 휙)푇. hence the synchronization accuracy. We have not included The master and slave represent their local time as a discrete quantization noise in this work, but it should be considered in distribution by sampling their local time at each clock rising receivers with low resolution Analog to Digital Converters edge. (ADC). 푡푀(푡)|𝑖푇 = 𝑖푇 → 푡푀[𝑖] = 𝑖푇. B. Conventional timestamps (12) 푡푆(푡)|푡=𝑖푇+휙푇 = (𝑖 − 𝑖0)푇 → 푡푆[𝑖] = (𝑖 − 𝑖0)푇, As stated before, PTP performance is mainly limited by the precision in the ToA estimation. A common approach to with 𝑖 an integer value, i.e., 𝑖 ∈ ℤ. The PTP frame exchange precisely estimate the ToA is to use the frame start detector starts at 푡푀[𝑖1], where the master sends a PTP sync frame and included in the physical layer of the communication system. A takes the 푡1 timestamp. widely used frame detector is based on detecting a known 푡1 = 푡푀[𝑖1]. (13) sequence in the received samples. For example, this detector is The frame is received by the slave, which detects the frame at used in [17] to take PTP timestamps and perform time 푡 [𝑖 ] and takes the timestamp 푡′ The relation between both synchronization. In order to find the training sequence, 푟[푘] is 푆 2 2. timestamps can be expressed as cross-correlated with 푠[푘]. −휙푇 + 휏ℎ 푅 [푛] = (푟 ⋆ 푠)[푛]. (9) 푡′ = 푡 [𝑖 ] = 푡 [𝑖 ] − 𝑖 푇 + ⌈ ⌉ 푇 = 푡 [𝑖 ] − 𝑖 푇 + 푡̂ , (14) 푟,푠 2 푆 2 푀 1 표 푇 푀 1 표 푚푠 푅 [푛] will have a peak when the training sequence is cross- 푟,푠 being 푡푚푠̂ the apparent channel delay from master to slave and correlated with the received training sequence. If the peak ⌈⋅⌉ the ceil operator. Afterwards, the slave transmits a Delay exceeds a threshold, it will be considered that a frame has been Request frame at 푡푆[𝑖3]: detected. Hence, the estimated frame start (푛𝑖푛𝑖) is ′ 푡3 = 푡푆[𝑖3]. (15) 2 [ ] (10) 푛𝑖푛𝑖 = min {푛 ∈ ℕ/|푅푟,푠 푛 | > 휃}. The Delay Request arrives to the master, which detects the The timestamping algorithms based on threshold detection frame at 푡푀[𝑖4] rely on detecting the first component of 푅푟,푠[푛], or the first (휙 − 1)푇 + 휏 푡 = 푡 [𝑖 ] = 푡 [𝑖 ] + 𝑖 푇 + ⌈ ℎ⌉ 푇 = 푡 [𝑖 ] + 𝑖 푇 + 푡̂ , (16) signal replica. Therefore, the channel delay for this approach 4 푀 4 푆 3 표 푇 푀 1 표 푠푚 could be defined as 휏ℎ = 푇푑. The value of 휃 is usually set based on minimizing the number of undetected frames without exceeding a false alarm probability. This simple solution has CM(t) two main drawbacks: tM[0]=0 tM[1]=T tM[2]=2T tM[3]=3T  The algorithm is not robust, as small differences in

푅푟,푠[푛] can produce big differences in the frame start t = 0 t C (t) detection. S tS[i0]=0 tS[i0+1]=T tS[i0+2]=2T  The timestamps are quantized to the sampling period.

An example of the first drawback is depicted in Fig. 4, t i0T ϕT where a similar 푅푟,푠[푛] results in a totally different ToA -t estimation. This situation can be very common in wireless o Fig. 5. Representation of master and slave clocks with a time offset between channels without a strong path, such as in NLoS conditions. On them of 푡표 = −(𝑖0 + 휙)푇. being 푡푠푚̂ the apparent channel delay from master to slave. Nonetheless, this solution can only be effectively used over Finally, the PTP Delay Response frame delivers the 푡4 channels with a strong direct component and over static timestamp to the slave. channels, because STR algorithms performance is deteriorated Once the slave has the four timestamps, it calculates the under time-dispersive and time-variant channels. Furthermore, channel delay and clock offset between its local clock and the STR algorithms rely on the detection of only one component, master clock. which would lead to a very unstable ToA estimation in NLoS, as shown in Fig. 4. Hence, the aim is to design an algorithm to 푡′ − 푡 + 푡 − 푡′ 푡̂ + 푡̂ 푡̃ = 2 1 4 3 = 푚푠 푠푚. (17) precisely estimate the ToA in time-dispersive channels (i.e. 푚푠 2 2 퐵푐 ≤ 퐵). 푡̂ − 푡̂ 푡̂ − 푡̂ The ToA in a wireless system operating under a time- 푡̃ = 푡′ − 푡 − 푡̃ = −𝑖 푇 + 푚푠 푠푚 = 푡 + 휙푇 + 푚푠 푠푚. (18) 표 2 1 푚푠 0 2 0 2 dispersive channel should not be defined as a unique instant, as the signal is replicated and received in multiple instants. where it has been considered that 푡 = −(𝑖 + 휙)푇. From 표 0 Therefore, the channel delay 휏 has been defined as the mean equation (18), we might identify the synchronization error, 휖 , ℎ 푡 delay spread of 푝(푡) [30] as the difference between the real clock offset and the estimated +∞ |푝(푡)|2 푡 푑푡 clock offset, i.e., ∫−∞ 휏ℎ = 휏 = +∞ . (23) |푝(푡)|2 푑푡 푡푚푠̂ − 푡푠̂ 푚 휏ℎ − 휙푇 휏ℎ + (휙 − 1)푇 푇 ∫−∞ 휖푡 = 휙푇 + = 휙푇 + (⌈ ⌉ − ⌈ ⌉) . (19) 2 푇 푇 2 It must be noted that, under time-variant channel propagation, 푇 Using equation (19), it is clear that 휖 = , if 휙 = 0 or 1; and the CIR can change over time, so the channel delay will also 푡 2 1 change. Nonetheless, from definition (23), it is clear that two that 휙푇 ≤ 휖 ≤ (휙 + ) 푇, if 0 < 휙 < 1, for these 푡 2 similar 푝(푡) will produce similar 휏ℎ. Furthermore, the mean intermediate values of 휙, the actual value of 휖푡 depends also on delay spread property ∞ ∞ 휏ℎ. From this analysis it is clear that PTP with conventional |푝(푡 − 푡 )|2 푡 푑푡 |푝(푡)|2 푡 푑푡 ∫−∞ 0 ∫−∞ timestamps cannot provide a perfect synchronization, 휖 = 0, 휏 = ∞ = ∞ + 푡0, (24) 푡 ∫ |푝(푡 − 푡 )|2 푑푡 ∫ |푝(푡)|2 푑푡 and that, for most of cases, the jitter will be distributed in the −∞ 0 −∞ 1 interval [휙푇, (휙 + ) 푇]. shows that it is linearly affected by the reference instant. This 2 property offers a great advantage in the implementation of the enhanced timestamps, as they can be implemented as an D. Enhanced timestamps improvement to the conventional timestamps. These details are In this subsection the enhanced timestamping method is developed in Section V, where it is proposed an algorithm to stated. The enhanced timestamps have been designed with two implement a receiver with enhanced timestamps. main purposes. The first goal is to overcome the sampling clock Furthermore, it can be proven by using Lemma 1 that 휏 can period bound, 푇, that limits the precision of the conventional be calculated from the discrete mean delay operator applied to timestamping method. The second goal is the robustness the discrete version of 푝(푡) sampled at the Nyquist Rate against small CIR variations that produce strong ToA +∞ |푝(푡)|2푡 푑푡 +∞ 2 ∫−∞ ∑n=−∞|푝[푛]| 푛 fluctuations in conventional timestamps. For the sake of clarity, 휏 = +∞ = 푇 +∞ 2 . (25) ∫ |푝(푡)|2 푑푡 ∑n=−∞|푝[푛]| (8) is repeated here −∞

퐿−1 Lemma 1. Let 푝(푡) be a causal signal of duration Tg, with unit 푟[푘] = 푟(푡)| = ∑ 푠[푙] 푝(푘푇 − 푙푇 + 휙푇) 푡=푘푇+휙푅푥 (20) energy, and approximately band-limited to bandwidth 퐵; and 푙=0 + 푛(푘푇 + 휙 푇). let 푇 = 1/2퐵 be the sampling period. Then, it follows the next 푅푥 identity: As can be seen, (20) leads to a similar expression of the +∞ ∞ classical Symbol Timing Recovery (STR) problem [28]. From ∫ |푝(푡)|2 ⋅ 푡 푑푡 = 푇2 ⋅ ∑ |푝[푛]|2푛, (26) −∞ here two cases can be distinguished n=−∞ 퐵 > 퐵, 푐 (21) being 퐵푐 ≤ 퐵, 푝[푛] = 푝(푡) |푡=푛푇 = 푝(푛푇). (27) where 퐵푐 is the coherence bandwidth of the channel and 퐵 is the system bandwidth. When the channel coherence bandwidth Hence, the discrete mean delay spread also has the shift is higher than the system bandwidth, the CIR can be property (24), which means that it is unaffected by delay shifts approximated by a Dirac delta with weight ℎ [29]. The in 푝[푛], such as the unknown sampling phase. Therefore, the 0 operator does not have any quantization and can be used to magnitude of ℎ0 is equal to the square root of the channel power gain and its phase is equal to the phase of the CIR. Thus, the obtain the ToA without error. received signal can be expressed as Nevertheless, in most communications systems the CIR is not known, thus it has to be estimated at the receiver. A suitable 퐿−1 option is estimating the CIR based on the received 푟[푘] = ℎ ∑ 푠[푙] 푔 (푘푇 − 푙푇 + 휙푇) + 푛(푘푇 + 휙 푇), (22) 0 1 푅푥 sequence 푟[푘]. The most widely used CIR estimators are the 푙=0 minimum mean-square error (MMSE) estimator and the Least being 푔1 the convolution of 푔(푡) and 푔(−푡 + 푇𝑔). Therefore, Square (LS) estimator [31]. However, a more appropriate the ToA can be precisely estimated by using any STR estimator in this case could be the cross-correlation of 푟[푘] algorithm, which are already included in most communication and 푠[푘], because the estimation is directly obtained in the time systems. Very similar solutions are described in other works domain. [18] [21], where the receiver estimates the phase of the master clock and takes timestamps with sub-sample precision. 푝̃[푛] ∝ 푅푟,푠[푛] = (푟 ⋆ 푠)[푛]. (28) Algorithm 1. Enhanced timestamps implementation 푅푟,푠[푛] is proportional to 푝̃[푛] in the absence of noise considering that the autocorrelation of 푠[푘] is approximately Input: 푟[푘], s[푘], 퐾𝑖푡 equal to a Kronecker delta with amplitude 퐿. Furthermore, 푝̃[푛] Output: 휏 1. Compute 푅푟,푠[푛] = (푟 ⋆ 푠)[푛]; and 푅푟,푠[푛] will be equivalent, because the mean delay spread 2 2. Find 푛𝑖푛𝑖 = min {푛 ∈ ℕ/|푅푟,푠[푛]| > 휃}; normalizes the signal energy. On the other hand, 푅푟,푠[푛] is not 3. repeat limited in energy, thus the sum of the discrete mean delay 3.1. 푛푠 = 푛𝑖푛𝑖 − 푁/2; spread operator must be limited. To establish the sum limits, it ∑푛푠+푁−1 |푅 [푛]|2⋅푛 is assumed that the autocorrelation of 푠[푘] is approximately 푛=푛푠 푟,푠 3.2. 휏 = 푇 푛푠+푁−1 2 ; ∑푛=푛푠 |푅푟,푠[푛]| equal to a Kronecker delta. Then, the sum start is 휏̃ Td 3.3. 푛 = 푟표푢푛푑 ( ); 푛 = ⌈ − 휙⌉, (29) 𝑖푛𝑖 푇 푠 T and its length is 3.4. 푘𝑖푡 = 푘𝑖푡 + 1; 3.5. until 푘𝑖푡 == 퐾𝑖푡; Th + 2Tg 푁 = ⌈ ⌉. (30) higher than the complexity of the rounding operation and its 푇 implementation should only be considered for specific cases, Thus, the enhanced timestamps operator reduces to when the error caused by the rounding operation limits the 2 ∑푛푠+푁−1 synchronization performance. 푛=푛푠 |푅푟,푠[푛]| 푛 휏 = 푇푠 2 . (31) Regarding the algorithm implementation in real devices, ∑푛푠+푁−1|푅 [푛]| 푛=푛푠 푟,푠 some specific parts of the algorithm must be implemented in Eq. (31) results in a very simple and robust expression to hardware and other parts can be either implemented in estimate the ToA of the received frames, because: it is not hardware or in software. The steps 1 and 2 of Algorithm 1 must vulnerable to start errors, as it integrates the whole CIR and it be implemented in hardware because of the high computation does not have a resolution bound. Therefore, the problem complexity of the cross-correlation, and because 푛𝑖푛𝑖 must be inherent of conventional timestamps is overcome by the obtained with high precision using a hardware clock. Once a definition of the enhanced timestamps. Nonetheless, 푛푠 and 푁 frame has been detected and 푛𝑖푛𝑖 has been obtained, the result are not known in advance, and they must be estimated to ensure of the cross-correlation (i.e. the CIR) along with 푛𝑖푛𝑖 can be that 휏̃ is obtained with minimum jitter. To do so, a simple and transmitted to a software layer to compute 휏. Therefore, the robust algorithm based on a dual 휏 calculator is proposed. The effort to add the enhanced timestamps to a wireless system is algorithm is described in the next section. low, as the operations of step 1 and 2 are usually included in wireless receivers, such as in the receiver implemented in [17], V. ENHANCED TIMESTAMPS IMPLEMENTATION and the operations of step 3 can be done at software. The enhanced timestamping method relies on the VI. INTEGRATION OF THE SYNCHRONIZATION SCHEME INTO A knowledge of 푛푠 and 푁 to establish the correlation window limits, but this information is not known in advance. To obtain WIRELESS SYSTEM an adequate performance, the estimation of 푛푠 and 푁 must be The presented synchronization scheme combines PTP with very robust, because errors in the integration window position our novel timestamping method and it is able to provide high will deteriorate the timestamps precision. synchronization accuracy over a large variety of wireless First, the correlation window length, 푁, is pre-configured conditions. To achieve this purpose, it has been assumed that according to the communication systems properties. For the uplink CIR equals the downlink CIR during the PTP sync example, in an OFDM-based system 푇ℎ can be set to the and PTP delay request frame exchanges and that the CIR stays duration of the cyclic prefix, due to it is the maximum CIR constant during that period of time 푇 . The uplink- ( 푆−퐷푟 ) duration to avoid inter symbol interferences. On the other hand, downlink channel symmetry requires the use of Time Division 푇 should be chosen according to the implemented pulse- 𝑔 Duplex (TDD). The invariance of the CIR during 푇 time shaping filter. Therefore, the problem is reduced to find 푛 . 푆−퐷푟 푠 entails a fast frame exchange whose requirements we have To estimate 푛 , an iterative algorithm based on two 푠 found through simulations (see results section). For instance, timestamping methods is proposed. The algorithm is stated in Algorithm 1. The received signal is first introduced to the for low mobile conditions (up to 3 km/h), 푇푆−퐷푟 = 1 ms is cross-correlator (9) and the frame start index is detected using enough to keep the time synchronization performance, meanwhile for higher speeds (more than 80 km/h) an elapsed a threshold (10). 푛𝑖푛𝑖 is set as the mid position of the CIR, so 푛푠 = 푛𝑖푛𝑖 − 푁/2. The captured samples are sent to the time 푇푆−퐷푟 = 0.1 ms might be necessary. discrete delay spread operator. The result of the operation will Low 푇푆−퐷푟 is usually difficult to fulfill in wireless be the enhanced timestamp (휏̃). However, the threshold technologies depending on their throughput and their medium detector is prone to errors, thus 푛𝑖푛𝑖 estimation may not be access procedure. For example, 푇푆−퐷푟 = 1 ms is unfeasible in exact. Therefore, 푛𝑖푛𝑖 is recalculated using 휏̃ to improve its legacy IEEE 802.11 because IEEE 802.11 medium access is precision. This process is iteratively done until a fixed number based on Carrier Sense Multiple Access with Collision of iterations 퐾𝑖푡. Avoidance (CSMA/CA) [33], which is not deterministic. This algorithm performs a rounding in step 3.3, which adds Hence, the PTP delay request may be delayed several an error to the correlation window position. To eliminate this milliseconds after the PTP sync frame. Furthermore, broadcast error, a fractional delay filter based on sinc interpolation [32] PTP sync frames could be received at the same time by several can be used instead of the rounding operation. This operation slaves. Then, the slaves would try to answer with a PTP delay allows a perfect alignment of the correlation window and request almost at the same time, which would probably cause eliminates the error bound of Algorithm 1. However, the frame collisions, and would greatly reduce wireless system computational complexity of this operation is considerably overall throughput. Thus, the implementation of the synchronization scheme over legacy 802.11 arises two inter-symbol interference). The 802.11 frames have been challenges: avoiding frame collisions and achieving low generated using the MATLAB® WLAN Toolbox™. latency. The system performance has been evaluated over the A, B, To avoid frame collisions, a wireless system can use a C and E 802.11 standard channel models [18]. These channel unicast PTP implementation. Although common PTP models are widely used to evaluate wireless systems and they implementations are /broadcast, the use of unicast represent four different environments, from small office to PTP over wireless is very convenient, as it solves some issues open space. The channel models have an RMS delay spread of found in wireless, such as the collisions problem and, in fact, 50 ns, 100 ns, 150 ns and 250 ns respectively. PTP standard supports unicast implementations [6]. Then, the The system performance has been also evaluated over master clock will keep each slave synchronized by pooling mobile conditions, because the CIR variation is the main them with Sync frames, which will be answered with PTP delay limitation of the synchronization scheme performance along request frames. with the SNR. Therefore, and to test the synchronization To achieve a low 푇푆−퐷푟, some already existing mechanisms scheme over a high variety of scenarios, the simulations have of IEEE 802.11 may be used. For example, the master clock been carried out over mobile conditions using mobile nodes may reserve some airtime by using a predefined NAV counter from nearly static nodes to nodes running at 300 km/h. It should value at the transmission of the sync frame. The NAV counter be noted that IEEE 802.11 physical layer is not designed for [33] is used to defer the access of other wireless nodes, and running at high speeds because 802.11 nodes are meant to be would allow the slave to freely answer the PTP delay request nearly static. Nonetheless, the proposed synchronization as fast as possible. The delay may be in the range of 0.5 ms to scheme could be used in other wireless systems meant to 1 ms using this procedure. Although these changes are not support high mobile conditions, such as 5G and LTE. standard compliant and need specific SW implementation, the The wireless channel variation due to the movement of the modifications can be easily carried out and the nodes would be nodes has been modeled with a Doppler spectrum following a still compatible with the 802.11 standard. Another option to Jakes model [34]. The maximum Doppler shifts have been obtain low 푇푆−퐷푟 in IEEE 802.11 would be using the IEEE calculated from the speed of the nodes, 푣, and the carrier 802.11 ACK frame as the PTP delay request frame to take the frequency, 푓푐. timestamps t3 and t4. This would not strictly be PTP compliant, Regarding the PTP configuration, the PTP frame exchange but it is a simple modification, and 푇푆−퐷푟 < 150 μs can be period has been set to 1 s, which means that the whole frame obtained. In this case, the airtime duration of the PTP sync exchange is performed every 1 s, and it is considered that frame limits the value of 푇푆−퐷푟. 푇푆−퐷푟 = 1 ms. Furthermore, a Proportional-Integral Loop filter Other medium access schemes, such as Time Division has been used to reduce the noise of the 푡0̃ calculation. The filter −3 Multiple Access (TDMA), which is used in 5G and LTE, would was configured with 퐾𝑖 and 퐾푝 constants equal to 2.6 ⋅ 10 allow an easier implementation of the synchronization scheme. and 5.5 ⋅ 10−2 respectively. In TDMA, the AP can pre-allocate radio resources to allow the The clock sampling period has been set to 50 ns, equal to deterministic transmission of the PTP sync, the PTP delay the bandwidth of the system. The maximum clock drift of both request and (if needed) the PTP delay response. In this case, master and slave clocks has been set to 10 ppm and the standard 푇푆−퐷푟 = 1 ms can be fulfilled if a proper scheduler is designed. deviation of the clock jitter has been set to 8 ps following a Finally, a dedicated procedure may be followed in normal distribution, which is a common value in oscillators proprietary wireless systems specifically designed for used in wireless systems. The clock drift and the time start of industrial applications, such as SHARP [3], or wireless systems the master and the slave clocks have been set to a random value for indoor localization [9], where time synchronization is a vital for each simulation. The clock jitter moves the temporal part of the system performance. In this case, the delay request position of the clock rising edges and hence its error is directly could be sent as an ACK frame to the sync frames. With this summed to the timestamping error. Furthermore, the jitter also procedure, 푇푆−퐷푟 < 0.2 ms could be obtained, depending on modifies the transmitted and received signal shape, as the signal the bandwidth of the wireless system and its physical layer is not sampled at the perfect moment. Nonetheless, the SNR complexity. For example, in SHARP using a bandwidth of 20 and channel impairments are the dominant error source. In the MHz, 푇푆−퐷푟 may be lower than 80 μs if a high order most favorable conditions (푆푁푅 = 30 dB, 푣 < 0.1 km/h and modulation is used. on channel A), they induce more than 100 ps and, hence, the clock jitter effects are negligible for common clock jitter VII. SIMULATION SETUP AND NUMERICAL RESULTS values. The wireless physical layer used to test the synchronization It has been found in preliminary simulations that the performance is the physical layer of the IEEE 802.11n WLAN algorithm to estimate the start window shows little standard. The carrier frequency has been set to 2.412 GHz. The improvements for more than 2 iterations. Therefore, the number bandwidth of the system has been set to 20 MHz. A Single of iterations of the algorithm for the simulation has been set Input, Single Output (SISO) antenna configuration has been to 퐾𝑖푡 = 2. Besides, the length of the channel has been set used. to 푇ℎ = 16푇 (800 ns), (equal to the cyclic prefix length in a The 802.11 frames comprise two main training sequences, 802.11 frame), and 푇𝑔 = 7푇 (350 ns), thus 푁 = 30. the Short Training Field (STF), and the Long Training Field The simulation tool used to evaluate the performance of the (LTF). The STF and LTF sequences have a total length of 160 enhanced timestamps is MATLAB®. The simulation has been samples each. The LTF is situated after the STF, and it is used carried out as follows. Firstly, the channel models are generated to detect the frame start after the frequency offset correction. using the Power Delay Profile (PDP) obtained from [18] and Therefore, the training sequence 푠[푙] is the LTF. Specifically, the nodes speed configuration. Afterwards, a fixed number of 푠[푙] is the last 128 samples of the LTF sequence (the cyclic PTP frame exchanges are performed and the slave clock is prefix has been eliminated to gain robustness against corrected in each frame exchange. Finally, the time synchronization error is calculated in each frame exchange as

Fig. 6. Time synchronization accuracy over WLAN channel A (RMS delay Fig. 8. Time synchronization accuracy over WLAN channel C (RMS delay spread = 50 ns) as function of the speed of the nodes for different SNR. spread = 150 ns) as function of the speed of the nodes for different SNR.

Fig. 7. Time synchronization accuracy over WLAN channel B (RMS delay Fig. 9. Time synchronization accuracy over WLAN channel E (RMS delay spread = 100 ns) as function of the speed of the nodes for different SNR. spread = 250 ns) as function of the speed of the nodes for different SNR. the difference between the master time and the slave corrected does the probability of misalignment in the integration window time. A total of 104 PTP frame exchanges have been carried and the probability of missing some CIR components in the out for each speed and SNR. integration. This causes a small error in the ToA estimation, The results of the time synchronization accuracy are which is added to the time synchronization error. Furthermore, depicted in Fig. 6, Fig. 7, Fig. 8 and Fig. 9. The enhanced the performance bound over channel A and B, which is found timestamps using Algorithm 1 are labeled as (E. TS.) and the at an SNR about 30 dB, is caused by the error of the rounding conventional timestamps are labeled as (C. TS.). The operation in step 3.3 of algorithm 1. Nonetheless, the bound is conventional timestamps are based on the detector stated in found for SNR that are unrealistic in wireless systems, and thus (10). The time synchronization accuracy is the combination of the use of more complex algorithms to implement the enhanced the precision and trueness of the measurement. Nonetheless, the timestamps is not necessary. trueness of the measurement is approximately equal to 0 ns in In the second region (from 3 km/h to 80 km/h), the every simulation, and thus accuracy and precision match for the synchronization performance is linearly deteriorated as a simulations shown in this section. function of the speed of the nodes. This is the expected The results show that the enhanced timestamps have three behavior, as the channel coherence time is still very high, but it different performance regions regarding the channel variation is not enough to consider a perfectly symmetric channel. rate during the PTP sync and PTP delay request exchange: Regarding the synchronization accuracy with conventional slowly time-variant (푣 < 3 km/h), mid time-variant timestamps, it is not very affected by the changes in the (3 km/h < 푣 < 80 km/h), and fast time-variant (푣 > environment, but their performance is still very far from the 80 km/h). The three regions are noticeable in the results over performance of the enhanced timestamps. the four channel models and are indicated by the vertical black Finally, in the fast time-variant region (> 80 km/h) the dashed lines. synchronization performance of the conventional timestamps In the first region, the slowly time-variant region and the enhanced timestamps converges. This situation is (< 3 km/h), the channel coherence time is 30 times higher reached at 80 km/h because the channel coherence time at such speed is approximately equal to 푇 = 1 ms. than 푇푆−퐷푟, thus the wireless channel can be considered 푆−퐷푟 symmetric during the PTP frame exchange. This is clearly To gain more insight about the relation between the channel represented in the results as the proposed synchronization variation rate and the value of 푇푆−퐷푟, we have carried out one scheme obtains a time synchronization of less than 220 ps at an more simulation over the channel model B, but using 푇푆−퐷푟 = SNR of 30 dB over channel A and B, which is 25 times smaller 0.1 ms. 푇푆−퐷푟 = 0.1 ms is a very challenging requirement in than the achieved by the conventional timestamps under the wireless communications, but it can be obtained following the same conditions. On the other hand, and compared to the results guidelines stated in Section VI. The results of this simulation over channel A and B, the performance of the enhanced are depicted in Fig. 10. The results show that there is a strong timestamps is slightly deteriorated in the simulation over relation between the time synchronization performance channel C and severely deteriorated in the simulation over and 푇푆−퐷푟. In fact, the threshold between the first and the channel E. This is caused by the error of the correlation second region is shifted to the right from 3 km/h to 30 km/h. window. The number of CIR components increases and so it Therefore, the requirement of channel symmetry during the APPENDIX Lemma 1. Proof.

Let be 푓(푡)

푓(푡) = √푡 푝(푡). (32) The energy of 푓(푡) is

+∞ +∞ ‖푓(푡)‖2 = ∫ |푓(푡)|2 푑푡 = ∫ |푝(푡)|2푡 푑푡, (33) −∞ −∞ taking into account that 푝(푡) is causal.

Fig. 10. Time synchronization over WLAN channel B (RMS delay spread of Now let consider 100 ns) as function of the speed of the nodes for different SNR. 푇 = 푆−퐷푟 푓[푛] = 푓(푡)| = 푛푇 푝(푛푇), (34) 0.1 푚푠. 푡=푛푇 √

PTP frame exchange has been verified numerically, and it has 푝[푛] = 푝(푡)|푡=푛푇 = 푝(푛푇). (35) been shown that 푇푆−퐷푟 has a great impact in the synchronization 푓(푡) can be expressed as function of 푓[푛] performance. Thus, to ensure almost perfect channel symmetry ∞ and obtain high time synchronization performance 푇 푆−퐷푟 푓(푡) = √푇 ∑ 푓[푛] ℎ(푡 − 푛푇), (36) should be at least 20-30 times lower than the channel coherence 푛=−∞ time. being ℎ(푡) an ideal interpolator filter of unit energy VIII. CONCLUSIONS 1 푡 ℎ(푡) = sinc ( ), (37) In this paper, we deal with the inherent issues of delivering √푇 푇 high-performance time synchronization through wireless and being systems. Time distribution protocols (i.e. PTP) rely on sin(휋푡) precisely estimating the frames ToA to synchronize the master sinc(푡) = . (38) clock to the slave clock. However, conventional ToA 휋푡 estimators have two main limitations over wireless: the The energy of 푓(푡) can be expressed in terms of the energy of timestamps quantization caused by the usually low bandwidth the sampled version of wireless systems and the wireless channel behavior. The ∞ wireless channel behavior is the most challenging limitation, as ‖푓(푡)‖2 = ∫ |푓(푡)|2푑푡 −∞ ∞ ∞ wireless channels usually present multipath propagation, which ∞ ∗ ∗ causes time dispersion and deteriorates the ToA estimation. = 푇 ∫ ∑ 푓[푛] ℎ(푡 − 푛푇) ⋅ ∑ 푓 [푚]ℎ (푡 − 푚푇) (39) −∞ 푛=−∞ 푚=−∞ ∞ ∞ Furthermore, the multipath propagation is subject to variations ∞ caused by the movements of the nodes or environment changes, = 푇 ∑ ∑ 푓[푛] 푓∗[푚] ∫ ℎ(푡 − 푛푇) ⋅ ℎ∗(푡 − 푚푇). −∞ which dynamically varies the channel delay. Therefore, in this 푚=−∞ 푛=−∞ paper we have analyzed in detail these impairments and we Due to have proposed a time synchronization scheme based on a novel ∞ ∗ timestamping method. We have analytically proven that the ∫ ℎ(푡 − 푛푇) ⋅ ℎ (푡 − 푚푇) = sinc(푚 − 푛) = 훿푚,푛, (40) enhanced timestamping method precision is independent of the −∞ sampling period and that it offers a very robust ToA estimation being over time-dispersive and time-variant channels. 1, 𝑖푓 푚 = 푛 훿 = { (41) The numeric simulations show that PTP combined with the 푚,푛 0, 𝑖푓 푚 ≠ 푛. enhanced timestamps can provide sub-nanosecond time transfer accuracy at slowly time-variant conditions, i.e. when Then the CIR can be considered constant during 푇 . The results ∞ ∞ ∞ 푆−퐷푟 2 ∗ 2 also show that the synchronization performance is deteriorated ‖푓(푡)‖ = 푇 ∑ ∑ 푓[푛] 푓 [푚] 훿푚,푛 = 푇 ∑ |푓[푛]| 푚=−∞ 푛=−∞ 푛=−∞ (42) when the ratio between the channel coherence and 푇푆−퐷푟 is +∞ lowered, because the channel cannot be considered symmetric = 푇2 ⋅ ∑ |푝[푛]|2푛. as it is not invariant. The performance of the enhanced and n=−∞ conventional timestamps converge when the channel coherence Finally, is equal to 푇 . Hence, it can be concluded that the enhanced +∞ 푆−퐷푟 ∞ timestamps greatly outperforms the conventional timestamps ∫ |푝(푡)|2 ⋅ 푡 푑푡 = 푇2 ⋅ ∑ |푝[푛]|2푛. (43) −∞ under the design assumption of channel symmetry between the n=−∞ master and slave. The proposed synchronization scheme may be very useful REFERENCES in the implementation of wireless systems that needs accurate [1] Piotr Lipnicki , Daniel Lewandowski, Diego Pareschi, Enrico time synchronization, such as wireless industrial networks. Ragaini, and Pakos Waldemar, “Future of IoTSP – IT and OT Furthermore, its use may be very interesting in other integration,” in 2018 IEEE 6th International Conference on Future applications that needs a network just to perform time of Things and Cloud (FiCloud), 2018. [2] P. Popovski, “Ultra-Reliable Communication in 5G Wireless synchronization, such as scientific experiments or wireless Systems,” Int. Conf. 5G Ubiquitous Connect., 2014. localization. [3] Ó. Seijo, Z. Fernández, I. Val, and J. A. López-Fernández, “SHARP : A Novel Hybrid Architecture for Industrial Wireless Sensor and Actuator Networks,” in IEEE International Workshop on Factory [27] D. Shrestha, Z. Pang, and D. Dzung, “Precise clock synchronization Communication Systems (WFCS), 2018. in high performance wireless communication for time sensitive [4] M. Luvisotto, Z. Pang, D. Dzung, M. Zhan, and X. Jiang, “Physical networking,” IEEE Access, vol. 6, pp. 8944–8953, 2018. Layer Design of High Performance Wireless Transmission for [28] U. Mengali, Synchronization Techniques for Digital Receivers. Critical Control Applications,” IEEE Trans. Ind. Informatics, vol. Springer, 1997. 3203, no. c, pp. 1551–3203, 2017. [29] A. V. Oppenheim and R. W. Schafer, Discrete-Time Signal [5] D. Mills, U. Delaware, J. M. Ed., ISC, J. Burbank, and W. Kasch, Processing, 2nd ed. Prentice Hall. “Network Time Protocol Version 4: Protocol and Algorithms [30] F. Pérez Fontán and P. Mariño Espiñeira, Modeling the Wireless Specification,” IETF, RFC5905, 2010. [Online]. Available: Propagation Channel: A Simulation Approach with MATLAB®. ://tools.ietf.org/html/rfc5905. Wiley, 2008. [6] IEEE Standard for a precision clock synchronization protocol for [31] J.-J. van de Beek, O. Edfors, M. Sandell, S. K. Wilson, and P. O. networked measurement and control systems. IEEE Standard 1588, Borjesson, “On channel estimation in OFDM systems,” IEEE 45th 2009. Veh. Technol. Conf. Countdown to Wirel. Twenty-First Century, [7] F. Ramos, J. L. Gutiérrez-Rivas, J. López-Jiménez, B. Caracuel, and 1995. D. Javier, “Accurate Timing Networks for Dependable Smart Grid [32] H. Zhao and J. Yu, “A Simple and Efficient Design of Variable Applications,” IEEE Trans. Ind. Informatics, vol. 14, no. 5, pp. Fractional Delay FIR Filters,” IEEE Trans. Circuits Syst. II Express 2076–2084, 2018. Briefs, vol. 53, no. 2, pp. 157–160, 2006. [8] K. Hann, S. Jobert, and S. Rodrigues, “ to [33] IEEE Standard for Information technology-- transport frequency and phase/time,” IEEE Commun. Mag., vol. 50, and information exchange between systems Local and metropolitan no. 8, pp. 152–160, 2012. area networks--Specific requirements Part 11: Wireless LAN [9] A. Jiménez Ruiz and F. S. Granja, “Comparing Ubisense, BeSpoon, (MAC) and Physical Layer (PHY) and DecaWave UWB Location Systems: Indoor Performance Specifications. IEEE, 2012. Analysis,” IEEE Trans. Instrum. Meas., 2017. [34] M. Mfeze and E. Tonye, “Comparative Approach of Doppler Spectra [10] M. Rizzi, M. Lipiński, P. Ferrari, S. Rinaldi, and A. Flammini, for Fading Channel Modelling by the Filtered White Gaussian Noise “White Rabbit clock synchronization : ultimate limits on close-in Method,” Int. J. Comput. Sci. Telecommun., vol. 6, no. 11, 2015. phase noise and short-term stability due to FPGA implementation,” IEEE Trans. Ultrason. Ferroelectr. Freq. Control, 2018. [11] A. Makki, A. Siddig, M. Saad, J. R. Cavallaro, C. J. Bleakley, and S. Member, “Indoor Localization Using 802 . 11 Time Differences of Arrival,” IEEE Trans. Instrum. Meas., 2015. [12] “ISO Accuracy (trueness and precision) of measurement methods and results -- Part 1: General principles and definitions,” ISO Stand. 5725-11994, 1994. [13] H. Guo, S. Member, and P. Crossley, “Design of a Time Synchronization System based on GPS and IEEE 1588 for Transmission Substations,” IEEE Trans. Power Deliv., 2016. [14] M. Weiss, “Getting accurate time from GNSS receivers: Considerations to approach nanosecond time,” IEEE Int. Symp. Precis. Clock Synchronization Meas. Control. Commun. ISPCS, 2017. [15] A. Mahmood, R. Exel, and T. Sauter, “Delay and jitter characterization for software-based clock synchronization over WLAN using PTP,” IEEE Trans. Ind. Informatics, vol. 10, no. 2, pp. 1198–1206, 2014. [16] A. Mahmood, R. Exel, H. Trsek, and T. Sauter, “Clock synchronization over IEEE 802.11 - A survey of methodologies and protocols,” IEEE Trans. Ind. Informatics, vol. 13, no. 2, pp. 907–922, 2017. [17] Ó. Seijo, I. Val, J. A. López-fernández, and M. Vélez, “IEEE 1588 Clock Synchronization Performance over Time-Varying Wireless Channels,” IEEE Int. Symp. Precis. Clock Synchronization Meas. Control. Commun. ISPCS, 2018. [18] V. Erceg et al., “TGn Channel Models,” 2004. [19] R. Exel, “Clock Synchronization in IEEE 802.11 Wireless LANs using Physical Layer Timestamps,” in IEEE International Symposium on Precision Clock Synchronization for Measurement, Control, and Communication, ISPCS, 2012. [20] R. Exel, “Receiver Design for Time-Based Ranging with IEEE 802.11b Signals,” Int. J. Navig. Obs., vol. 2012, 2012. [21] R. Exel and T. Bigler, “ToA Ranging using Subsample Peak Estimation and Equalizer-based Multipath Reduction,” IEEE Wirel. Commun. Netw. Conf., 2014. [22] P. Ferrari et al., “Timestamping and Ranging Performance for IEEE 802.15.4 CSS Systems,” IEEE Trans. Instrum. Meas., vol. 63, no. 5, pp. 1244–1252, 2014. [23] P. Ferrari, G. Giorgi, C. Narduzzi, S. Rinaldi, and M. Rizzi, “Timestamp Validation Strategy for Wireless Sensor Networks Based on IEEE 802.15.4 CSS,” IEEE Trans. Instrum. Meas., vol. 63, no. 11, pp. 2512–2521, 2014. [24] C. M. De Dominicis et al., “Timestamping of IEEE 802.15.4a CSS Signals for Wireless Ranging and Time Synchronization,” IEEE Trans. Instrum. Meas., vol. 62, no. 8, pp. 2286–2296, 2013. [25] Ó. Seijo, I. Val, and J. A. López, “On the use of White Rabbit for Precise Time Transfer in 5G URLLC Networks for Factory Automation Applications,” IEEE Int. Conf. Ind. Cyber-Physical Syst., pp. 1–6, 2019. [26] M. Appel, F. Winkler, and B. Meffert, “Phase-based High-Precision Synchronization for Wireless Networks using FPGAs,” 2018 IEEE Int. Symp. Precis. Clock Synchronization Meas. Control. Commun., pp. 1–6, 2018.