Patent Publication Number: US-2022239532-A1

Title: Secure ultra wide band ranging

Description:
FIELD OF THE INVENTION 
     The present invention relates generally to wireless communication systems, and, in particular, to a wireless communication system adapted to perform secure ultra-wideband (“UWB”) channel sounding and ranging. 
     BACKGROUND OF THE INVENTION 
     By way of example, in an ultra-wideband (“UWB”) communication system, a series of special processing steps are performed by a UWB transmitter to prepare payload data for transmission via a packet-based UWB channel. Upon reception, a corresponding series of reversing steps are performed by a UWB receiver to recover the data payload and compute the range. Details of both series of processing steps are fully described in IEEE Standards 802.15.4 (“802.15.4”) and 802.15.4a (“802.15.4a”), copies of which are submitted herewith and which are expressly incorporated herein in their entirety by reference. As is known, these Standards describe required functions of both the transmit and receive portions of the system, but specify implementation details only of the transmit portion of the system, leaving to implementers the choice of how to implement the receive portion. 
     One or more of us have developed certain improvements for use in UWB communication systems, which improvements are fully described in the following pending applications or issued patents, all of which are expressly incorporated herein in their entirety: 
     “A Method and Apparatus for Transmitting and Receiving Convolutionally Coded Data”, U.S. Pat. No. 7,636,397, issued 22 Dec. 2009; 
     “A Method and Apparatus for Generating Codewords”, U.S. Pat. No. 7,787,544, issued 31 Jul. 2010; “A Method and Apparatus for Transmitting and Receiving Convolutionally Coded Data”, U.S. Pat. No. 8,358,709, issued 22 Jan. 2013; and 
     “Receiver for Use in an Ultra-Wideband Communication System”, U.S. Pat. No. 8,437,432, issued 7 May 2013; 
     “Convolution Code for Use in a Communication System”, U.S. Pat. No. 8,677,224, issued 18 Mar. 2014; 
     “Adaptive Ternary A/D Converter for Use in an Ultra-Wideband Communication System”, U.S. Pat. No. 8,436,758, issued 7 May 2013; 
     “Receiver for Use in an Ultra-Wideband Communication System”, U.S. Pat. No. 8,760,334, issued 24 Jun. 2014; 
     “Receiver for Use in an Ultra-Wideband Communication System”, U.S. Pat. No. 9,054,790, issued 9 Jun. 2015; 
     “Adaptive Ternary A/D Converter for Use in an Ultra-Wideband Communication System”, U.S. Pat. No. 9,325,338, issued 26 Apr. 2016. 
     “Secure Channel Sounding”, PCT Application EP2017/052564, filed 6 Feb. 2017 and published as WO/2017/134310 on 10 Aug. 2017. 
     SUMMARY OF THE INVENTION 
     Aspects of the invention are set out in the independent claims and preferable features are set out in the dependent claims. 
     There is described herein a method for use in a wireless communication system comprising a transmitter and a receiver, the method comprising: receiving, in the receiver, data comprising a plurality of channel-distorted cipher codes; generating a receiver cipher sequence at the receiver, the receiver cipher sequence comprising a plurality of receiver cipher codes; analysing the received data to identify correlations between the plurality of channel-distorted cipher codes in the received data and the plurality of receiver cipher codes; accumulating the identified correlations as accumulator data in an accumulator; identifying one or more peaks in the accumulator data; identifying a first correlation peak in the accumulator data that meets one or more criteria; and using the first correlation peak to identify the first path of a data packet from the transmitter. 
     The ultimate goal is to calculate time-of-arrival (TOA), which may later be used to compute time-of-flight and later, the distance, between receiver and transmitter. In order to do this, it is necessary to identify the correlation peak which relates to the first, or most direct, path of a packet between the transmitter and receiver (e.g. later peaks may be indicative of receiving the same packet, but reflected off one or more surfaces and so take longer to reach the receiver). There may, however, be several peaks, which may be identified as the first peak, for example if a malicious attack creates peaks in the accumulator date or there is a lot of noise in the accumulator data. Therefore one of the one or more identified peaks in the accumulator data is identified, or selected, as being indicative of the first path, but only if it meets one or more criteria. In other words, the identified one or more peaks in the accumulator data are candidate first path peaks. There may be more than one criteria for accepting the peak to calculate the time of flight, and in these cases more than one (in most cases all) of the criteria must be met. Sometimes these are referred to as the final criteria for accepting a peak as the first correlation peak for the time of flight calculation. 
     Of course, the transmitter and the receiver may be devices that are each capable of both transmitting and receiving. In some scenarios, the transmitter is capable of transmitting and also receiving, whilst the receiver can only receive (but not transmit) the messages or packets. 
     Preferably the method is a ranging method and/or the wireless communication system is an ultra-wideband UWB network. 
     Preferably the accumulator is part of the receiver. 
     The received data may comprise a data packet transmitted from the transmitter that has been distorted over the receiving channel. 
     The first correlation peak is generally the temporally earliest correlation peak that meets the one or more criteria. 
     The first path is generally the first path of a data signal or data packet from the transmitter to reach the receiver. In wireless communications there may be several paths a wireless signal can take between the transmitter and the receiver, due to scattering, reflection or refraction of the signal. For example, the direct path (or “line of sight” path) will be the shortest path (e.g. a straight line) and so the data signal that reaches the transmitter first (referred to as the “first path”) will generally have taken the direct path to reach the receiver. Identifying the data signal that has taken the direct path and when it arrives at the receiver is useful since this can provide accurate information about the distance and/or direction from the receiver to the transmitter. Indirect paths, which can occur when the data signal is reflected or refracted between the transmitter and the receiver, will reach the receiver later than the data signal that has taken the first path (or direct path) since it will have travelled a longer distance. 
     The received data is preferably in the form of a plurality of pulses. 
     The method may further comprise receiving, in the receiver, data comprising a plurality of channel-distorted synchronization codes. The channel-distorted synchronization codes may be used for channel sounding, which may improve receipt of data packets. 
     The method may comprise executing one or more diagnostic tests to verify that during the reception, or receipt, of the data the receiver performance and parameters are within expected limits. Identified peaks in the accumulator data may be rejected if certain diagnostic checks fail. For example, the criteria could include passing the diagnostic tests during receipt of the data. 
     Receiving the data, or receiving the data packet, at the receiver is generally over a wireless communication protocol, such as ultra-wideband communication. 
     The expected cipher sequence should be known to both the transmitter and receiver. The cipher sequence may be pseudo-randomly generated at both the transmitter and receiver, for example using CSPRNG (cryptographically secure pseudorandom number generator). Thus the transmitter may generate a transmitter cipher sequence to include in a packet transmitted to the receiver, whilst the receiver may generate an identical receiver cipher sequence to compare against the received cipher sequence in the received packet. The respective cipher sequences may be generated by, in both the transmitter and the receiver, setting a common seed and nonce for initialization of the CSPRNG. 
     Thus the method may further include, in the transmitter, generating a transmitter cipher sequence and transmitting to the receiver a packet including the transmitter cipher sequence. 
     Preferably, the method further comprises applying one or more countermeasure checks to the identified first correlation peak in the accumulator data that meets one or more criteria; and rejecting the identified first path and/or rejecting the data packet if the one or more countermeasure checks are not passed. By applying one or more countermeasure checks to the identified first correlation peak it is possible to improve security. 
     Preferably, the step of identifying a first correlation peak in the accumulator data that meets one or more criteria comprises: comparing the one or more identified peaks in the accumulator data to a threshold value to identify a first correlation peak that exceeds the threshold value. 
     In other words, one of the one or more criteria is exceeding a threshold value. 
     Preferably the method further comprises computing the threshold value based on one or more of: length of the cipher sequence; pulse repetition frequency (PRF) of the cipher sequence; transmission power used; configuration of one or more sidelobe minimization receiver algorithms; a required security level; and static configuration of the receiver gain. These parameters are static parameters and therefore the threshold value may be predetermined or pre-configured. 
     Optionally, the method further comprises: measuring one or more parameters; and computing the threshold value based on the one or more measured parameters. Thus it is possible to use dynamic parameters to set the threshold value. The threshold value may be selected as a function of both a pre-configured static parameter and also one or more measured dynamic parameters (and so vary as the measured value(s) of the dynamic parameter(s) change). 
     For example, computing the threshold value may be done by analysing the result of one or more executed diagnostic routines relating to the parameters. 
     In some embodiments the one or more measured, dynamic parameters are selected from: average noise level in the accumulator (or accumulators, where more than one is used); amplitude of the highest peak or peaks in the accumulator data before an expected first path; strength of multipath reflections and the multipath profile; carrier frequency offset, CFO; dynamic behaviour of automatic gain control, AGC, applied at the receiver; configuration of the analog-to-digital converter (ADC), preferably including converged ADC threshold values. The position of the expected first path peak may be estimated from the position of the first path peak found from the previously received Ipatov or sync sequence, or from a previous packet. By looking at the amplitude of the highest peak or peaks in the accumulator data ahead of the expected position of first path in the accumulator data (sometimes referred to as the precursor area of the accumulator), it is possible to take into account noise levels. 
     Preferably computing the threshold value comprises setting the threshold value to at least a predetermined minimum threshold value. 
     Optionally, the received data further comprises channel-distorted synchronisation codes, a start of frame delimiter and/or payload data; and wherein identifying a first correlation peak in the accumulator data that meets one or more criteria comprises: recording one or more analog-to-digital output statistics at the receiver during reception of the channel-distorted cipher codes; recording one or more analog-to-digital output statistics at the receiver during reception of at least one of the synchronisation codes, start of frame delimiter and payload data; and wherein identifying a first correlation peak in the accumulator data that meets one or more criteria comprises: determining that the value(s) of the one or more statistics during reception of the channel-distorted cipher codes does not differ from the value(s) of the statistics during reception of at least one of the synchronisation codes, start of frame delimiter and payload data by more than a predetermined difference value. 
     In some cases there is a pulse repetition frequency (PRF) change between the synchronisation part and the cipher sequence, for example an increase in PRF between the synchronisation part and the cipher sequence. In that case, cipher ADC statistics during receipt of the cipher codes would be higher, so it is necessary to scale the statistics relating to the synchronization code (or relating to the cipher codes) before comparing the synchronisation ADC statistics with the cipher ADC statistics. For example, in  4   z  enhanced mode SYNC has PRF=100 MHz and cipher has PRF=128 MHz, so under normal conditions the cipher would be expected to include 28% more pulses above ADC threshold than the synchronisation sequence. Thus the method may further comprise scaling the value(s) of the ADC statistics for one of the channel-distorted cipher codes, synchronisation codes, start of frame delimiter or payload data based on the relative pulse repetition frequency (PRF) and wherein the step of determining whether the value(s) of the one or more statistics during reception of the channel-distorted cipher codes does not differ from the value(s) of the statistics during reception of at least one of the synchronisation codes, start of frame delimiter and payload data by more than a predetermined difference value is based on the scaled value of the ADC statistic. 
     Preferably the one or more analog-to-digital output statistics are indicative of the energy level of the analog-to-digital converter, preferably the rate of energy per unit time. 
     Optionally, the receiver cipher sequence comprises a plurality of cipher symbols, and wherein analysing the received data comprises: identifying the correlation strength (and preferably phases) of each of the plurality of cipher symbols in the receiver cipher sequence with the plurality of channel-distorted cipher codes-in the received data; and counting the number of symbols having a correlation strength above a specified minimum correlation strength threshold, and preferably also being within a phase limit; and wherein the one or more criteria comprises: the number of symbols having a correlation strength above the specified minimum-correlation strength threshold (and preferably also being within a phase limit) being above a predetermined symbol correlation number threshold, or the proportion of the symbols in the receiver cipher sequence having a correlation strength above a correlation strength threshold (and preferably also being within a phase limit) being above a predetermined symbol correlation proportion threshold. 
     For example, the cipher sequence may comprise a predetermined number of cipher symbols, e.g. between 50 and 500 cipher symbols. In certain embodiments, the cipher sequence comprises 128 cipher symbols or 256 cipher symbols. Each symbol generally comprises a number of pulses, for example at least 50 and/or less than 500 pulses. For example, each symbol may be around 64 or 128 pulses. The cipher sequence may comprise a plurality of segments (e.g. between 2 and 10 segments, for example 2 or 4 segments), each segment being made up of a plurality of symbols (e.g. between 20 and 500 symbols, preferably between 50 and 200 symbols, for example 64 symbols). Each segment of the cipher sequence may be accumulated in a different accumulator at the receiver. 
     A method according to any preceding claim, wherein the one or more criteria is based on monitoring the accumulator growth rate over time. The growth rate of the first path peak or at an expected location of the first path peak in the accumulator data may be measured. The expected location of the first path peak in the accumulator data may be found from determining the location of the first path peak from the Ipatov or sync sequence, or the first path peak from one or more previously received packets from the same transmitter. In some embodiments, the growth rate of the first path peak in the cipher may be found after having identified a possible first path peak in the cipher accumulator data; the growth rate may thus be analysed retrospectively to verify the first path peak is a true, authentic first path peak. 
     The criteria may be based on monitoring the accumulator growth rate at each of a plurality of delay times. Each of the plurality of delay times may be during receipt of one of: the synchronisation part, the SFD and/or a cipher symbol. Preferably the monitoring of the accumulator growth rates is performed on both real and imaginary axes. 
     Preferably, monitoring the accumulator growth rate over time comprises: computing a linear growth function based on the accumulator data, such as based on the first path peak in the accumulator data; and comparing the accumulator growth rate (preferably at the first path peak) over time with the linear growth function; and wherein one of the one or more criteria comprises: the accumulator growth rate diverging from the linear growth function by less than a predetermined growth rate divergence threshold. Whether the accumulator growth rate diverges at more or less than the predetermined divergence threshold may be found using a function that calculates a metric of how far the accumulator growth rate deviates. 
     The growth rate may be diverging by more than the growth rate divergence threshold if the growth rate at any particular time differs from the gradient of the linear growth function by more than a predetermined gradient difference threshold. 
     In some embodiments, using the first path to calculate the time of flight and/or distance between the transmitter and receiver. Calculating the time of flight and/or distance between transmitter and receiver may involve first calculating the time of arrival at the receiver. The time of arrival at the receiver can be found by identifying the peak in the cipher accumulator that corresponds to the first path (or the shortest, most direct path, e.g. a straight line), which is referred to herein as the “first path peak”. 
     The method may further comprise: calculating a first time of flight between the transmitter and receiver based on the first correlation peak in the ciphered accumulator data that meets the one or more criteria; accumulating correlations in the received channel-distorted synchronization data in a synchronization accumulator; calculating a second time of flight between the transmitter and receiver based on a first correlation peak in the synchronization accumulator; and wherein identifying the first path comprises: identifying the first correlation peak in the accumulator data that meets the one or more criteria as indicative of the first path if the first time of flight differs from the second time of flight by less than a predetermined time of flight difference threshold. In other words there is an additional criterion that must be met for accepting the time of flight of the first correlation peak as indicative of the first path between transmitter and receiver (and therefore can be used as an accurate representation of the time of flight between the two and to calculate the distance between the transmitter and receiver). This additional criterion is that the calculated first time of flight and the calculated second time of flight differ by less than a time of flight difference threshold. The time of flight difference threshold may be predetermined. 
     The time of flight difference threshold may be less than 10 ns, preferably less than 5 ns, more preferably less than 3 ns. Generally the time of flight threshold will be at least around 0.2 ns, or at least 0.5 ns. In some embodiments the time of flight difference threshold is at least 1 ns and not more than 5 ns, in some embodiments at least 2 ns and not more than 4 ns. The accuracy of first path detection is usually around +/−0.2 ns, but sometimes can be worse, such as in low-SNR (signal to noise ratio) conditions where the error may be up to +/−0.5 ns. Thus if the first time of flight estimate has +0.5 ns error and the second has −0.5 ns error, this would result in 1 ns difference in total. 
     The method may further comprise: accumulating correlations in the received channel-distorted synchronization data in a synchronization accumulator; calculating a first time of flight between the transmitter and receiver based on a first correlation peak in the synchronization accumulator; accumulating correlations in the received channel-distorted ciphered data in a cipher accumulator; calculating a second time of flight between the transmitter and receiver based on a first correlation peak in the ciphered accumulator; and wherein calculation of the second time of flight comprises: accepting the second time of flight only if the calculated first time of flight differs from the calculated second time of flight by less than a predetermined time of flight difference threshold. 
     In some embodiments the channel-distorted cipher codes in the received data correspond to at least a first data packet and a second data packet, and wherein the method further comprises: calculating a first time of flight between the transmitter and receiver based on the first correlation peak in the cipher accumulator data that meets the one or more criteria in the first data packet; calculating a second time of flight between the transmitter and receiver based on the first correlation peak in the cipher accumulator data that meets the one or more criteria in the second data packet; determining the difference between the calculated first time of flight and the calculated second time of flight; and accepting one of the first time of flight and the second time of flight as identifying the first path of a data packet from the transmitter to the receiver only if the calculated first time of flight and the calculated second time of flight differ by less than a predetermined time of flight difference threshold. Thus the final criteria for accepting the time of flight calculation comprises an additional criterion, being that the calculated first time of flight and the calculated second time of flight differ by less than a time of flight difference threshold. 
     Following this, in some embodiments, the correlation peak associated with the first data packet and the correlation peak associated the second data packet may only be identified as meeting the one or more criteria only if the first time of flight differs from the second time of flight by less than a predetermined time of flight difference threshold. 
     Peaks may be associated with different data packets based on identifying an SFD in the received data; peaks separated in time by receipt of an SFD may correspond to different packets. 
     In some embodiments there is a PRF (pulse repetition frequency) change between synchronization/SFD/data and the cipher, and then ADC statistics can be scaled before being compared to provide a better comparison. For example, wherein the received data further comprises channel-distorted synchronisation codes, a start of frame delimiter and/or payload data; then identifying a first correlation peak in the accumulator data that meets one or more criteria comprises: recording a first set of one or more analog-to-digital output statistics at the receiver during reception of the channel-distorted cipher codes; recording a second set of one or more analog-to-digital output statistics at the receiver during reception of at least one of the synchronisation codes, start of frame delimiter and payload data; and wherein identifying a first correlation peak in the accumulator data that meets one or more criteria comprises: determining a change in pulse repetition frequency (PRF) between the cipher codes and the at least one of the synchronisation codes, start of frame delimiter and payload data; and scaling the first set of analog-to-digital output statistics based on the determined change; and determining that the scaled value(s) of the first set do not differ from the value(s) of the second set by more than a predetermined difference value; or scaling the second set of analog-to-digital output statistics based on the determined change; and determining that the scaled value(s) of the second set do not differ from the value(s) of the first set by more than a predetermined difference value. 
     Sometimes, prior to the step of receiving data at the receiver, the method comprises: generating a transmitter cipher sequence at the transmitter, the transmitter cipher sequence comprising a plurality of transmitter cipher codes; and transmitting a packet from the transmitter, the packet comprising the plurality of transmitter codes. 
     In some embodiments, accumulating the identified correlations between the channel-distorted cipher codes and the receiver cipher codes comprises accumulating the correlations in a plurality of cipher accumulators; and identifying one or more peaks is based on multiple of the cipher accumulators. 
     The cipher sequence may comprise a plurality of segments, each made up of a plurality of symbols, e.g. N segments. Typically, cipher segments are 4096 pulses, made up of 64 symbols each of 64 pulses. Therefore multiple segments (e.g. N segments) are N*4096 pulses separated by a gap. Each segment would generally be accumulated into a separate accumulator. Thus there may be N cipher accumulators. N is generally between around 2 and 10. 
     A method according to any preceding claim, wherein the plurality of channel-distorted cipher codes and/or the plurality of transmitter cipher codes and/or the plurality of receiver cipher codes comprises a plurality of sets of codes. 
     For example, plurality of channel-distorted cipher codes and/or the receiver cipher sequence, and preferably the transmitter cipher sequence, comprises N sets of m cipher codes. 
     In some embodiments, each of the sets of channel-distorted cipher codes is received at the receiver in a different segment, and preferably wherein the correlations in each segment are accumulated in a separate accumulator. 
     Generally the transmitter will transmit each set of transmitter cipher codes in a different segment. For example, each of the N sets of a transmitter cipher is transmitted in a different segment of a data packet. 
     In some embodiments, analysing the received data to identify correlations between the plurality of channel-distorted cipher codes in the data packet and the plurality of receiver cipher codes comprises: developing a set of m channel correlations by correlating each of the channel-distorted cipher codes with a corresponding receiver cipher code of the receiver cipher set with the corresponding code of the channel-distorted cipher codes. 
     Preferably, the method further comprises: calculating a first time of flight between the transmitter and receiver based on a correlation peak associated with a first segment; and calculating a second time of flight between the transmitter and receiver based on the correlation peak associated with a second segment, preferably wherein the first and second segment are associated with the same data packet; and wherein the one or more criteria comprise the calculated first time of flight and the calculated second time of flight differing by less than a predetermined time of flight difference threshold. 
     For example, the correlation peak associated with the first segment and the correlation peak associated the segment may be identified as meeting the one or more criteria only if the first time of flight differs from the second time of flight by less than a predetermined time of flight difference threshold. The correlation peaks for the first and second segment may be identified in accumulator data for first and second accumulators, respectively. For example, the method comprises: calculating a first time of flight between the transmitter and receiver based on a first correlation peak of a first segment in the ciphered accumulator data that meets the one or more criteria; and calculating a second time of flight between the transmitter and receiver based on a first correlation peak of a second segment in the ciphered accumulator data that meets the one or more criteria, preferably wherein the first and second segment are associated with the same data packet; and accepting one of the first time of flight and the second time of flight as identifying the first path of a data packet from the transmitter to the receiver only if the calculated first time of flight and the calculated second time of flight differ by less than a predetermined time of flight difference threshold. 
     In some embodiments, identified correlations are accumulated in a plurality of accumulators and the method further comprises: identifying a plurality of first correlation peaks that meet the one or more criteria, each identified first correlation peak corresponding to one of the plurality of accumulators; and comparing the distribution of the accumulator data around each of the identified first correlation peaks; and using the identified plurality of first correlation peaks to identify the first path of a data packet from the transmitter only if the distribution of the accumulator data around each of the identified first correlation peaks is sufficiently similar. 
     The plurality of accumulators may each relate to different cipher accumulators (e.g. for different segments of the cipher) and/or different parts of the data packet (e.g. synchronisation, cipher and/or SFD). The data around each of the peaks is preferably data in a region directly surrounding the peak, for example a predetermined number of accumulator values surrounding the peak (e.g. temporally surrounding), for example at least 10 accumulator values surrounding the peak, or at least 20 accumulator values surrounding the peak. Normally fewer than 100 accumulator values surrounding the peak. Generally the data considered symmetrically surrounds the peak value. 
     Determining whether the distribution is sufficiently similar may be performed by calculating a function indicative of the probability that the accumulator data around each of the identified first correlation peaks is the same. 
     The distribution of accumulator data may be the channel estimate amplitudes. 
     Preferably, the method further comprises: determining if the distribution of the accumulator data around each of the identified first correlation peaks is sufficiently similar by calculating a measure of the distribution similarity and determining the distribution similarity is within a similarity threshold. 
     The distribution similarity measure in one example is a rank sum test. 
     Optionally, the method further comprises, prior to determining if the distribution of the accumulator data around each of the identified first correlation peaks is sufficiently similar: normalising the data around each of the identified first correlation peaks based on one or more of: the amplitude of the corresponding correlation peak; the length of the corresponding sequence (e.g. cipher segment or synchronisation sequence); and the number of energy pulses detected during accumulation of the corresponding sequence. 
     Optionally, the received data further comprises a plurality of channel-distorted synchronisation codes, and the method further comprises: developing, preferably at the receiver, a synchronization-based channel estimate from the received data packet based on the plurality of channel-distorted synchronisation codes. 
     In such a case the packet transmitted by the transmitter would comprise a plurality of synchronisation codes. The synchronisation codes could, for example, be Ipatov codes. Developing a channel estimate from the channel-distorted synchronisation codes may comprise correlating the channel-distorted synchronisation codes with expected synchronisation codes and accumulating repeating correlations in a synchronisation accumulator. Identifying one or more peaks in the accumulator data may also be based on the synchronisation accumulator (e.g. in addition to one or more cipher accumulators). 
     In some embodiments the method further comprises: developing, at the receiver, a channel estimate from the received data packet based on the plurality of channel-distorted cipher codes. 
     Optionally, identifying a first correlation peak in the accumulator data that meets one or more criteria comprises: selecting a channel-matched filter based on a or the channel estimate; demodulating the received data using the channel-matched filter; and identifying one of the one or more criteria is met if the demodulated data is correct. Thus the final criteria for accepting the first peak as being indicative of the first path includes the demodulated data being correct based on a channel estimate. The data may be identified as being correct if it matches expected data. 
     The method may comprise determining whether the demodulated data is correct by using a cyclic redundancy check (CRC). 
     Optionally, identified correlations are accumulated in a plurality of accumulators and the method further comprises: identifying a plurality of first correlation peaks that meet the one or more criteria, each identified first correlation peak corresponding to one of the plurality of accumulators; comparing the phase of the channel estimate data at each of the identified first correlation peaks; and using the identified plurality of first correlation peaks to identify the first path of a data packet from the transmitter only if the phase of the accumulator data at each of the identified first correlation peaks is within a phase difference threshold. Thus the final criteria for accepting the peaks are indicative of the first path includes the phase at each of the peaks being within the phase difference threshold. 
     The phase difference threshold is preferably small, e.g. 10 degrees or less, or 5 degrees or less. The phase difference threshold may be around 4 degrees, for example. Preferably the phase difference threshold is at least 1 degree or at least 2 degrees. In some embodiments there are transition-related phase changes (e.g. between sequences), such as predetermined phase offsets. In such cases the phase difference threshold would be a threshold surrounding the predetermined phase offset. 
     Comparing the phase at each of the correlation peaks may comprise calculating the phase difference between consecutive samples at each of the peaks. 
     The method may further comprise determining a channel estimate corresponding to each of the first correlation peaks of each accumulator; and wherein comparing the phase of the accumulator data comprises comparing the phase of each determined channel estimate. 
     Preferably, the identified correlations are accumulated in a plurality of accumulators and the method further comprises: identifying a plurality of first correlation peaks that meet the one or more criteria, each identified first correlation peak corresponding to one of the plurality of accumulators; comparing the phase of the channel estimate data at each of the identified first correlation peaks; and using the identified plurality of first correlation peaks to identify the first path of a data packet from the transmitter only if the phase of the accumulator data at each of the identified first correlation peaks is the same or differs by a predetermined phase offset, within a phase difference threshold. The phase offset is preferably at least 80 degrees and not more than 180 degrees. For example, the phase offset may be at least 100 degrees and/or not more than 150 degrees. In some embodiments the phase offset is between 130 degrees and 140 degrees. The phase difference threshold (discussed above) means values within the difference threshold of the phase offset will be accepted. For example the phase difference offset may be around 138 degrees, within a tolerance or threshold of around 4 degrees. 
     This may comprise selecting a plurality of samples (e.g. four samples, preferably two or more, preferably fewer than 10) surrounding or immediately following the peak. 
     Optionally, the one or more criteria are based on a classification that was learned from a training data set. Thus the classification can be derived from machine learning. 
     For example, the one or more criteria may be learned using a logistic regression-based assessment. 
     Preferably, the method further comprises: converting the received data from analog to digital using an analog-to-digital converter having limited resolution restricted to five or fewer levels, preferably three or fewer levels (e.g. only a two or three levels at the ADC output). It is conventional to use more levels of ADC output, such as 8 or 10. However the inventors have found that reducing the resolution provides improved results. 
     Optionally, the received data comprises channel-distorted synchronisation codes received prior to receipt of the plurality of channel-distorted cipher codes; the method further comprising: selecting gain and/or analog-to-digital converter parameter(s) based on the channel-distorted synchronisation codes; maintaining the selected gain and/or analog-to-digital converter parameter(s) during receipt of the plurality of channel-distorted cipher codes. 
     In some embodiments, the received data comprises channel-distorted synchronisation codes, a start of frame delimiter and/or payload data; the method further comprising: reading a first set of gain and/or analog-to-digital converter parameter(s) based on the channel-distorted synchronisation codes, start of frame delimiter and/or payload data; reading a second set of gain and/or analog-to-digital converter parameter(s) based on the received plurality of channel-distorted cipher codes; and determining differences between the first set of gain and/or analog-to-digital converter parameter(s) and the second set of gain and/or analog-to-digital converter parameter(s); using the first correlation peak to identify the first path only if the determined differences do not exceed a predetermined parameter threshold for each of the parameter(s). Thus the final criteria for accepting the time of flight may comprise the requirement that the determined differences do not exceed a predetermined parameter threshold for each of the parameter(s). For example, one of the one or more criteria may only be met if the determined differences do not exceed a predetermined parameter threshold for each of the parameter(s). 
     Sometimes, the method further comprises: estimating the carrier frequency offset (CFO) based on the received data; calculating the timing offset of the received data to compensate for offset between a clock of the receiver and a clock of the transmitter, wherein the adjustment of the receiving time is based on the estimated CFO; wherein the timing adjustment is limited to a predetermined maximum adjustment, preferably based on a predetermined packet duration and/or maximum allowed clock frequency offset (CFO); and adjusting the timing offset of the received data by no more than the calculated adjustment. 
     Preferably, generating the cipher sequence is performed by pseudo-random generation as a function of a seed; and wherein the same seed is used by the transmitter and receiver. The same nonce may also be used by the transmitter and receiver in order to generate the cipher sequence. 
     Preferably, in a single-sided two-way ranging with first message transmitted by the initiator and the second message transmitted by the responder the method further comprises: estimating the first carrier frequency offset (CFO1) based on the first data packet received by the responder; estimating the second carrier frequency offset (CFO2) based on the second data packet received by the initiator; identifying that a correlation peak in the accumulator data meets one or more criteria only if the CFO1 is sufficiently close to −CFO2. 
     Optionally, the method further comprises: the receiver performing analysis of the noise distribution before the candidate 1 st  path peak and identifying that a correlation peak in the accumulator data meets one or more criteria only if the noise distributions is sufficiently similar to typical Gaussian noise distribution. A method according to any preceding claim, wherein analysing the received data to identify correlations between the plurality of channel-distorted cipher codes in the data packet and the plurality of receiver cipher codes comprises: developing a set of channel correlations by correlating each of the channel-distorted cipher codes with a corresponding receiver cipher code. 
     In some embodiments the method further comprises: designating identified peaks in the accumulator data that occur prior to the first correlation peak that meets the one or more criteria as corresponding to false early first paths. 
     Optionally, the method further comprises: estimating, at the receiver, a first carrier frequency offset estimate associated with the received data; receiving, at the receiver, a second carrier frequency offset estimate calculated by the transmitter; and comparing the first carrier frequency offset estimate and the second carrier frequency offset estimate; wherein one of the one or more criteria is met if the first frequency offset estimate differs from the negative of the second frequency offset estimate by less than a frequency offset difference threshold. 
     The frequency carrier offset relates to the difference in clock frequencies of the transmitter and receiver, e.g. the relative clock frequencies. 
     The second carrier frequency offset may be received in the data at the receiver over the wireless communication protocol (e.g. by ultra-wideband communication), for example the received data may include payload data that comprises the second frequency offset estimate. In alternative embodiments, the second carrier frequency offset is received over a different communication protocol from the one over which the received data is received. 
     The second carrier frequency offset estimate may have been estimated at the transmitter, for example based on a previous data packet transmitted from the receiver to the transmitter. 
     The frequency offset difference threshold is generally less than 5 ppm, preferably not more than 2 ppm, or may even be 1 ppm. 
     It is necessary to consider the negative because these are relative offsets, so will be the inverse of one another. In other words, the one or more criteria may be met if the first frequency offset estimate differs from the opposite sign second frequency offset estimate by less than a frequency offset difference threshold 
     There is also described a method for use in a wireless communication system comprising a transmitter and a receiver, the method comprising: receiving, in the receiver, data comprising a plurality of channel-distorted synchronization codes; estimating, at the receiver, a first carrier frequency offset estimate associated with the received data; receiving, at the receiver, a second carrier frequency offset estimate calculated by the transmitter (e.g. calculated by the transmitter based on a packet previously sent from the receiver and received by the transmitter); comparing the first carrier frequency offset estimate and the second carrier frequency offset estimate; and determining the likelihood of an attack is increased if the first frequency offset estimate differs from the negative of the second frequency offset estimate by more than a frequency offset difference threshold. If the first frequency offset estimate differs from the negative of the second frequency offset estimate by more than a frequency offset difference threshold the final criteria for accepting the peaks as being indicative of the first path between transmitter and receiver will not be met, and so the correlation peak will not be used to perform the time of flight measurement for the first path. 
     In some embodiments, the method further comprises: discarding the received data if the first frequency offset estimate differs from the negative of the second frequency offset estimate by more than a frequency offset difference threshold 
     Preferably, identifying that a correlation peak in the accumulator data that meets one or more criteria comprises: determining the distribution of the accumulator data in the accumulator prior the peak; and identifying the peak meets one of the one or more criteria if the distribution of the accumulator data in the accumulator has a substantially normal distribution. Thus the final criteria for accepting a peak as being indicative of the first path may comprise the distribution of accumulator data being substantially normal. 
     Sometimes determining the distribution of the accumulator data comprises: calculating the mean noise value (MNV) of the accumulator data prior to the peak; and determining the proportion of accumulator samples in the accumulator data prior to the peak that exceed a threshold multiple of the MNV, for example two MNV, three MNV, five MNV or seven MNV; and wherein the criteria is based on the proportion of accumulator samples that exceed the threshold multiple of the MNV. 
     By prior to the peak, we mean the accumulator data that is temporally before the peak in the accumulator data. 
     There is also described a device or system having means for performing a method as set out above. 
     There is also described a wireless receiver configured to: receive data comprising a plurality of channel-distorted cipher codes; generate a receiver cipher sequence comprising a plurality of receiver cipher codes; analyse the received data to identify correlations between the plurality of channel-distorted cipher codes in the received data and the plurality of receiver cipher codes; accumulate the identified correlations as accumulator data in an accumulator; identify one or more peaks in the accumulator data; identify a first correlation peak in the accumulator data that meets one or more criteria; and use the first correlation peak to identify the first path of a data packet from a transmitter. 
     The receiver may be further configured to perform or participate in the methods described above. 
     There is also described a wireless communication system comprising: a receiver as described above; and a transmitter. 
     There is also described computer-readable medium comprising software code adapted, when executed by a data processing device, to perform a method as set out above. 
     Any system feature as described herein may also be provided as a method feature, and vice versa. As used herein, means plus function features may be expressed alternatively in terms of their corresponding structure. 
     Any feature in one aspect of the invention may be applied to other aspects of the invention, in any appropriate combination. In particular, method aspects may be applied to system aspects, and vice versa. Furthermore, any, some and/or all features in one aspect can be applied to any, some and/or all features in any other aspect, in any appropriate combination. 
     It should also be appreciated that particular combinations of the various features described and defined in any aspects of the invention can be implemented and/or supplied and/or used independently. 
    
    
     
       BRIEF DESCRIPTION OF THE FIGURES 
       Methods and systems for ultra-wideband communications are described by way of example only, in relation to the Figures, wherein: 
         FIG. 1  shows an ultra-wideband physical layer (UWB PHY) frame structure; 
         FIG. 2  shows an UWB frame with a cipher sequence inserted before the payload data; 
         FIG. 3  shows an UWB frame with a cipher sequence appended after the payload data portion; 
         FIG. 4  shows an example channel count plot from a cipher accumulator; 
         FIG. 5  shows another example channel count plot from a cipher accumulator and various possible detection threshold levels; 
         FIG. 6  illustrates probabilities of random attacker sequences satisfying an acceptance threshold for various acceptance thresholds; 
         FIG. 7  shows false-positive detection rates in the case of a 4096-bit long HRP system; 
         FIG. 8  shows an example growth rate of the genuine versus false paths in an accumulator; 
         FIG. 9  shoes another example growth rate of the genuine versus false paths in an accumulator; 
         FIG. 10  shows original and retransmitted sequences in an exemplary attack; and 
         FIG. 11  shows a block diagram of an attack on a keyfob and anchor system. 
     
    
    
     DETAILED DESCRIPTION 
     UWB systems can provide distance determination between a transmitter and receiver by analyzing the time of arrival of packets at a receiver. UWB systems can be characterized by having either low-rate pulses (LRP) or high-rate pulses (HRP). In LRP systems, pulses are transmitted at a lower rate (e.g. around 1 MHz) but at higher power per pulse than in HRP systems (typical rate can be &gt;64 MHz). 
     The IEEE standard 802.15.4-2011 describes an ultra-wideband physical layer (UWB PHY) with the frame structure and two way ranging ability shown in  FIG. 1 . The following abbreviations are used in  FIG. 1  and subsequent diagrams to denote certain portions of the frames:
         SYNC—Sync pattern   SFD—Start Frame Delimiter   PHR—PHY (Physical layer) Header       

     The Sync pattern is a sequence of symbols forming a frame preamble, which may be based on a predefined code sequence having certain properties that make it useful for channel sounding purposes (including perfect periodic autocorrelation). 
     From the ranging security perspective, this structure has the following vulnerabilities: 
     1) If the start of the SYNC is known in advance or detected by listening to the packet, the rest of the SYNC is entirely predictable. 
     2) The SYNC is periodic, i.e., it repeats the same symbol again and again, so a version which is delayed by just one symbol looks like almost identical to the original with no delay. 
     3) The attacker could transmit identical SYNC or retransmit the genuine one with such a delay to inject false correlation peaks into the accumulator, thus affecting the ranging procedure. 
     While multiple countermeasures are possible to prevent such attack, an attacker, in theory, could come up with even more sophisticated attacking equipment and mechanisms in order to defeat the countermeasures. In general, the methods described herein deal with a problem of designing an improved first path detection method, to allow the receiver to select the true first path originated from a genuine transmitter, in a secure way, that is, without false-positive earlier detections (for example triggered by the noise peaks, channel types, hardware imperfections or the attacks). 
     In order to address these vulnerabilities and to provide means for more secure channel sounding and ranging, an additional cryptographically-generated sequence (“CIPHER”) may be appended (or inserted) to the packet. The cipher sequence can consist, for example, of pulses of pseudo-random polarity, which would not be repeatable or predictable (for example generated by CSPRNG—cryptographically secure pseudorandom number generator). 
       FIG. 2  shows an UWB frame with a cipher sequence inserted before the data.  FIG. 3  shows an UWB frame with a cipher sequence appended at the end. 
     The cipher contains expected, cryptographically generated pulses (or bits). A typical length of cryptographically generated key, or cipher, can be 32, 64 or 128 in case of LRP systems and 4096, 8192 . . . , N*4096 in case of HRP. 
     Due to the much lower number of pulses in LRP systems, a high level of security can only be achieved if all the bits (or nearly all) are received correctly, whereas in HRP systems the ranging exchange can still be extremely secure if a significant number of bits are received incorrectly (even&gt;40%). 
     In both LRP and HRP, the receivers work on the basis of comparing the received bits to a locally generated reference. This can be implemented in the form of a correlator (with accumulator) which cross-compares the incoming signal at various delays. Each delay in the accumulator will correspond to a certain distance travelled by the signal; closer distances will result in correlations at earlier delays in the accumulator. Alternatively, instead of using longer accumulators it is possible to verify correlation at only one delay; in this case the system needs to know the most probable distance/delay (possibly from earlier sequences/preambles or exchanges) and use the ciphered sequence for its verification. Certain threshold levels can be implemented to verify if the obtained correlation is strong enough to signify a securely received first path. 
     A Channel Impulse Analysis (CIA) algorithm is responsible for analysis of any of the channel impulse response estimates that are stored in the accumulators. It can determine the location of the first path and from that, calculate the time-of-flight (TOF), the time-of-arrival (TOA) and finally, the distance between the transmitter and receiver. It also computes the phase of the first path and depending on the implemented phase-difference-of-arrival (PDOA) mode, also the phase difference between the appropriate accumulators. It can compensate for known changes in the analog front end, such as delay changes due to the gain control decisions or temperature variations. 
     The ranging will be secure if the receiver is able to determine the position of the first path very reliably, despite presence of noise, various hardware imperfections and even malicious actions performed by the attackers. While an attacker cannot predict the cipher sequence to introduce an earlier correlation peak, it can attempt to confuse the receiver by transmitting various interfering patterns, even completely disregarding the regulatory transmit power limits. Such malicious transmissions could tamper with the reception of the ciphered sequence. Therefore, one of the goals of the methods described herein is to verify the integrity of the received cipher sequence despite distortion that may be introduced due to the transmission channel. 
       FIG. 4  shows an example channel count plot  401  from a cipher accumulator, showing a weak early path (marked by vertical line  410 ) and strong reflections  430 ,  440 ,  450 . 
     While ranging security can be improved simply by configuring a higher detection threshold, it would also reduce the sensitivity. In  FIG. 5  another example channel plot  501  from a cipher accumulator and various possible detection threshold levels, a first threshold  510  at around level of 290 (correlation strength), a second threshold at around level of 595 and a third threshold  530  at around level of 880 are shown. The third threshold  530 , while theoretically offering the highest protection against false first path detection in this example would result in the peak of the genuine first path  540 , which is only at a level of 620, being missed. 
     The first path detection algorithm does not necessarily need to be based on simply locating the first sample higher than the threshold. Multiple approaches could be used, for example testing various “conditional” lower thresholds. Using a lower threshold could help identify earlier and weaker first paths, and may be used in conjunction with additional verification steps to maintain a higher security level. The additional verification steps could, for example, include comparing the first path positions obtained through sending and receiving two cipher segments; or ciphers from two separate packets. 
     In order to maintain very high security, without significant sensitivity degradation, improved methods could take into many more factors when deciding which early correlation peaks are potential candidates and whether to accept them or not. Some methods could eliminate potential attacks by detecting harmful interference and if present, ignoring the ranging result. 
     There are described herein a number of steps and checks that may be performed and taken into account during the process of secure first path detection to improve security. 
     One of the possible attack mechanisms could involve the malicious attacker triggering ranging exchanges constantly and transmitting random bit patterns which overlap the genuine transmission in time but at higher power, thus overwriting the original message, in the hope of triggering sufficiently high correlation in the earlier part of the accumulator, so that the receiver would interpret the artificially inserted correlation peaks as a genuine one. 
     Depending on the required security level, stronger or weaker requirements can be placed on the correlation threshold. 
     In case of the LRP system which requires 100% bits (or nearly 100%, depending on security level) to be correct, it is easy to establish that the probabilities of successful attack for 32, 64 and 128-bit long keys are: 2 −32  (2.33e-10), 2 −64  (5.42e-20) and 2 −128  (2.94e-39) respectively (assuming 100% bits need to be received correctly). 
     In case of an HRP system, the same probabilities as in LRP can be achieved. In order to match the security level of 32, 64 and 128-bit long LRP keys, an example HRP receiver using a 4096-bit cipher sequence, would need to set the detection threshold at the levels corresponding to approx. 55%, 57%, 60.5% rate of the correctly received bits. 
       FIG. 6  illustrates the minimum required percentage of correctly received bits for first path acceptance thresholds for a 32-bit, 64-bit, 128-bit and 4096-bit key.  FIG. 7  shows false-positive detection rates in the case of a 4096-bit long HRP. 
       FIG. 6  shows the probability of an attacker guessing (e.g. by transmitting random bits) more or equal than certain percentage of bits in the HRP system (configured for 4096 ciphered pulses), which would result in certain correlation peaks. For the purpose of this example, we assume that the correlation peak amplitude is always a positive (absolute) value, i.e. negative correlation would cause certain (positive) amplitude peak. For example, guessing all bits incorrectly results in a correlation peak of −4096, but in this example, as we ignore the peak sign, it would be equivalent to +4096. 
     The sign is ignored because on multipath channel, when using a coherent receiver, each path will have a different phase. Even if the receiver attempts to lock the main (the strongest) path to a certain phase (such as 0 degrees), the first weaker path could have a completely different phase. Therefore in post-processing, when searching for the first path, phases are ignored and absolute values are analyzed. Therefore setting the correlation threshold at 0 would result in 100% false positive rate because the absolute correlation result will always be greater or equal to 0. 
       FIG. 6  demonstrates that it is equally hard to guess all 128 out of 128 bits (in an LRP system), as it is to guess at least 2478 bits out of 4096 bits (more than 60% guessed bits in an HRP system). 
     In the vast majority of cases, the attacker on the HRP system, transmitting random bit patterns, will guess fewer than 2148 bits correctly (2048 on average). The probability of guessing more than 2148 is 0.0019, more than 2200 is 2.175e-06, more than 2248 is 4.3983e-10. It is therefore possible to set a threshold depending on particular security requirements. 
     It is also possible to have longer HRP cipher lengths (N*4096) which will result in even lower probabilities of successful attack for a given threshold (relative to the peak correlation). 
     Both in LRP and HRP, a designer can select a set of parameters which will result in any desired security level. If the probability requirement of a successful attack is, for example, lower than 1e-19, in LRP a 64-bit long key should be used and in case of HRP with 4096-bit cipher, a detection threshold higher than 2340 correct pulses should be used. Choosing appropriate parameters, almost any security level can be configured and achieved in both LRP and HRP. 
     Both LRP and HRP have sensitivity limits, where it would be harder to detect a very weak first path. Due to limited transmission power, increasing the security level inversely correlates with sensitivity. In LRP, more secure longer sequences will result in power reduction per pulse/bit, thus reducing sensitivity. In HRP, increasing the correlation threshold will have similar effect. 
     In the case of LRP, where there is a (nearly) 100% correctness requirement, any short-lasting glitch or interference (not necessarily malicious as it could come from an impulse noise source nearby, e.g. another unrelated UWB transmitter) affecting even a single bit, will result in a failed ranging exchange. HRP on the other hand is more robust and can tolerate interference and destruction of a significant part of the cipher. For example, with a very secure threshold set to 2340 correct bits, even up to 1756 bits out of 4096 could be destroyed and correlation from the remaining bits could still be strong enough to pass (assuming the remaining bits can be received with sufficient quality). 
     In order to provide a more secure way of ranging and distance estimation, we provide a method for use in a wireless communication system comprising a transmitter and a receiver. Both the transmitter and the receiver pseudo-randomly generate, as a function of the same seed, identical code sets of m codes. Note that a code could be a simple BPSK (Binary Phase Shift Keying) positive or negative pulse or it could be a longer code, e.g. a length k golay code or even a pseudo randomly selected random binary code. The receiver then may additionally modify the receiver code set in order to, for example, reduce the number of correlation sidelobes. The transmitter then transmits the transmitter code set and the receiver receives a channel-distorted form of the transmitted code set. The receiver then develops a set of m channel correlations by correlating each code of the generated receiver code set with the corresponding code of the channel-distorted form of the transmitter code set; and, finally, develops a channel estimate by accumulating the set of m channel correlations. 
     In one embodiment, the receiver processes the channel estimate identifying the earliest correlation peak fulfilling certain required criteria. The earliest correlation peak location will affect the time-of-flight measurement, hence the distance between the transmitter and the receiver. There may be multiple criteria that must be met for acceptance of the peak as a valid correlation peak (i.e. a packet received from a genuine transmitter). In the simplest case it could be that its amplitude exceeds a pre-configured fixed threshold. The value of such a threshold may depend on one or more parameters. Such parameters may be predetermined, or static. In some embodiments, the threshold selection may be based additionally or alternatively on dynamic parameters. Example parameters are transmission power, the required security level, noise level in the accumulator, length of the cipher sequence, detected channel characteristics such as the strength of reflections, carrier frequency offset (CFO), gain parameters e.g. automatic gain control (AGC). Using multiple and/or dynamic parameters can improve the receiver&#39;s first path sensitivity, by allowing the detection threshold to be lowered while still providing the required security level. 
     In some embodiments, the final threshold selecting algorithm may combine both static and dynamic parameters. Where the threshold value is a function of dynamic parameters, a static minimum threshold value can also used. If the threshold value calculated initially based on one or more dynamic (and optionally static) parameters is lower than a predetermined minimum threshold value (which may itself be based on other static parameters), then the minimum level would be used for the comparison. The minimum threshold level could be either a fixed value or depend on certain static parameters such as cipher length, transmit power, the required security level or others. Therefore, even in a case where detection threshold calculation depended on the accumulator noise levels and accumulator was almost noiseless (for example as a consequence of a malicious attack), accidental noise samples would not trigger false detection. 
     In some embodiments, the receiver can be configured to use a low resolution analog to digital converter (ADC), for example 1-bit consisting of a single threshold (i.e. 2 levels) or 1.5-bit consisting of two thresholds (i.e. three levels), compared to typical ADCs, which generally have higher resolutions (e.g. 3-bits or more). One possible attack mechanism is for the attacker to use increased power for a small portion of the channel sounding sequence, e.g. to send a signal with random polarity at a much higher power than the rest of the sequence. Because this signal has higher power it will give a higher correlation peak in the victim receiver than the true signal, and much fewer correct guesses would be necessary to trigger a bogus first path detection. One way to defeat such an attack is to have a receiver with a lower resolution, e.g. with a small number of ADC levels e.g. 2, 3, 4, 5, 6 or 7 levels compared to the usual receiver ADC with 8 or more levels (3 bit or more ADCs are common in wireless receivers) and to fix the thresholds for these levels and the receiver gain (or to only allow them to change by a small factor) during reception of the channel sounding sequence. 
     In one other embodiment, the function controlling acceptance of the cipher correlation peak as a valid peak may also use additional information and statistics collected earlier, during the entire packet reception (and/or also collected during reception of previous packets and/or during the silence period). This information may for example indicate if there is something unusual present in the received signal which could interfere with proper functioning of the receiver and of the earliest path detection algorithm in particular. In that case, the algorithm would not only adapt the 1st path acceptance threshold (as discussed before), but could also conditionally reject certain packets, for example if certain diagnostic information about channel quality was not satisfactory. 
     Examples of such diagnostics and possible interference could be the attacker using equipment and methods to distort the signal in order to try to influence the measured distance. The attacker could use, for example, UWB transmitters and/or amplifiers, transmitting various bursts of interference or other patterns or retransmitting the original signal at much higher power, possibly with some distortion. The purpose of the attack could be to inject an artificial glitch or correlation peak into the accumulator which could be interpreted as a genuine correlation peak, resulting in reduced measured distance. In order to prevent such an attack from having any effect, the receiver can employ multiple additional methods and tests and collect additional diagnostic information for its analysis. These could include:
         A. Verification that ADC output statistics are at least substantially unchanged during the reception of the whole data frame. The statistics of the ADC output during the cipher may be compared to the expected or measured ADC output statistics during earlier sequences (e.g. Ipatov synchronization, data symbols). ADC statistics can, for example, include the number of pulses with high, medium or low energy, per some unit of time, such as, for example, symbol duration. Such analysis would confirm whether the received signal properties were constant during the packet or changed (for example as a result of the attacker transmitting shorter bursts of signal or interference or transmitting interference only during the ciphered part of the packet).   B. Freezing the gain settings and/or ADC parameters after the initial synchronization state in order to prevent potential attacks which could affect the receiver&#39;s gain settings. Freezing the receiver gain settings should result in constant and predictable signal receive power. It also makes it easier to collect reliable ADC statistics about the signal and to detect malicious interference. This could prevent attacks, for example, that include the transmission of bursts of pulses or retransmission of the whole or part of the original sequence but at the different transmission power (higher or variable). Such attacks could lead to unusual contents in the accumulator, which could be (potentially) incorrectly interpreted.   C. As an alternative to freezing gain settings and/or ADC threshold parameters during reception of channel sounding sequence, it is possible instead to verify that the gains and thresholds behaved as expected for a sequence that was not attacked, e.g. they didn&#39;t change much or they changed by the expected amount.   D. Monitoring the correlation strengths (and optionally phase) of each cipher symbol during the accumulation process and setting a requirement on the minimum number of symbols with sufficiently good correlation (e.g. having a strong enough correlation and being within certain phase limits). This is to ensure that (nearly) all cipher symbols correlate consistently and similarly and that the attacker is not damaging only some of the symbols, or producing short lasting burst-type interference.   E. Verifying the correctness of data demodulation using channel-matched filters, which may be calculated based on the selected channel estimate. If the system is attacked with random noise and its channel estimate is damaged, there is also a high probability that data payload demodulation will fail as consequence. The selected channel matched filter may be that based on Ipatov (SYNC) or one of the cipher segments.   F. Comparing times-of-arrival as computed based on the Ipatov (SYNC) and the cipher accumulators. They are both estimates of the same channel (but measured using different codes), therefore they should return very similar results. If the system is attacked it is extremely unlikely that both the Ipatov sequence and the cipher would produce false correlation peaks at exactly the same delay.   G. Comparing times-of-arrival computed based on cipher accumulators from different packets, for example packets transmitted (or received) one after another (e.g. consecutively, or within a certain time difference).   H. Comparing times-of-arrival computed based on cipher accumulators from two (or more) cipher segments sent during the same packet, for example consecutive cipher segments.   I. Comparing the channel estimate amplitude distribution around the first path region, between sync/Ipatov sequence and cipher accumulators (or between cipher accumulators obtained from different segments, e.g. where a cipher comprises several segments). While the distributions should be similar (because the channel is assumed to be unchanged during reception of the whole packet), amplitudes may be scaled, for example proportionately to sequence lengths and number of energy pulses collected during accumulation of both Ipatov and cipher sequences. A function can be designed to calculate the probability that the compared first path regions have the same distribution.       

     In some embodiments, the function used is a rank sum test (also known as the Wilcoxon rank sum test or Mann-Whitney U test) may be used. It is a non-parametric hypothesis test that can be used to determine whether two independent sets of samples were selected from populations having the same distribution. An example of a rank sum test will now be described. Note that the statistics are not exactly the same between Wilcoxon rank sum test and Mann-Whitney U test, but the two have the same efficiency. 
     Rank sum tests have 95% efficiency of student-test but without requirement of prior information. 
     The rank sum test contains the following 5 steps:
         1. Samples are obtained from each of the two populations A and B containing n A  and n B  samples, respectively. All samples are assumed to be independent from each other.   2. Rank all the samples obtained in ascending order from 1 to (n A +n B ). Tiers (samples which have the same value) have the same rank.   3. Sum all the ranks for samples from populations A and B, respectively and note as W A  and W B .   4. When both n A  and n B  are 10 or greater, and n A ≤n B , we can treat the distribution of W A  as if it were Normal (μ A , σ A ), where       

     
       
         
           
             
               µ 
               A 
             
             = 
             
               
                 
                   n 
                   A 
                 
                 ⁡ 
                 
                   ( 
                   
                     
                       n 
                       A 
                     
                     + 
                     
                       n 
                       B 
                     
                     + 
                     1 
                   
                   ) 
                 
               
               2 
             
           
         
       
       
         
           
             
               σ 
               A 
             
             = 
             
               
                 
                   
                     n 
                     A 
                   
                   ⁢ 
                   
                     
                       n 
                       B 
                     
                     ⁡ 
                     
                       ( 
                       
                         
                           n 
                           A 
                         
                         + 
                         
                           n 
                           B 
                         
                         + 
                         1 
                       
                       ) 
                     
                   
                 
                 12 
               
             
           
         
       
         
         
           
              If having tiers, the correction below is used, k is the number of distinct tiers, t i  is the number of samples sharing ranks. 
           
         
       
    
     
       
         
           
             
               σ 
               A 
             
             = 
             
               
                 
                   
                     
                       n 
                       A 
                     
                     ⁢ 
                     
                       n 
                       B 
                     
                   
                   12 
                 
                 ⁢ 
                 
                   ( 
                   
                     
                       
                         
                           
                             ( 
                             
                               
                                 n 
                                 A 
                               
                               + 
                               
                                 n 
                                 B 
                               
                               + 
                               1 
                             
                             ) 
                           
                           - 
                         
                       
                     
                     
                       
                         
                           
                             ∑ 
                             
                               i 
                               = 
                               1 
                             
                             k 
                           
                           ⁢ 
                           
                             
                               
                                 t 
                                 1 
                                 3 
                               
                               - 
                               
                                 t 
                                 i 
                               
                             
                             
                               
                                 ( 
                                 
                                   
                                     n 
                                     A 
                                   
                                   + 
                                   
                                     n 
                                     B 
                                   
                                 
                                 ) 
                               
                               ⁢ 
                               
                                 ( 
                                 
                                   
                                     n 
                                     A 
                                   
                                   + 
                                   
                                     n 
                                     B 
                                   
                                   - 
                                   1 
                                 
                                 ) 
                               
                             
                           
                         
                       
                     
                   
                   ) 
                 
               
             
           
         
       
         
         
           
              Then, 
           
         
       
    
     
       
         
           
             z 
             = 
             
               
                 
                   
                     w 
                     A 
                   
                   - 
                   
                     µ 
                     A 
                   
                 
                 
                   σ 
                   A 
                 
               
               ∼ 
               
                 N 
                 ⁡ 
                 
                   ( 
                   
                     0 
                     , 
                     1 
                   
                   ) 
                 
               
             
           
         
       
         
         
           
             5. Compare z to the threshold determined by significant level. If |z|≤threshold, we accept a null hypothesis that the two populations are from the same distribution unless the alternative hypothesis is taken. 
           
         
       
    
     The proposed double rank sum tests to verify first path has the following steps:
         1. Calculate equivalent Ipatov_first_path=Cipher_first_path−implementation_specific_offset   2. Samples are taken from the floor (first path estimation) in Ipatov and cipher with n Ip =n cy =30, respectively.   3. Remove the DC offset from the samples then calculate the amplitude of each sample and normalize them by peak amplitude. DC offset in cipher is provided by CIA algorithm. In Ipatov, DC offset=median (accumulator (1:((first path −1))).   4. Run the first rank sum test with threshold  3  which is equivalent to significant level 0.135%. For any statistics|z 1 |&gt;3, mark it as a false early first path.
           With the assumption that the Ipatov and cipher are passing through the same channel but have the different noise, |z 1 | should be small enough unless the cipher first path falls in the noise region rather than channel window.   However, if the false early first path is small and close to the channel window, the statistics |z 1 | would be small as well. In order to detect the false early first path in this case, a 2 nd  rank sum test is introduced.   
           5. For packets passing the first rank sum test, run a second rank sum test with the same 30 cipher samples and 25 Ipatov samples that remove the first 5 samples, n Ip =25 and n cy =30. Then we have the 2 nd  statistics z 2 .   6. If the absolute difference |z 1 −z 2 |&lt;0.58, calculate the first path and peak path amplitude ratio in the cipher, if the ratio r&lt;0.25, mark it as an false early first path.
           The principle behind point 5 and 6 is that if there is a fake strong first path only in cipher, it would not pass the first rank sum test. However if there is a strong real first path in the cipher accumulator, it should be in Ipatov accumulator as well. Hence, if we remove the first five samples in the Ipatov which definitely contain the first path, the difference |z 1 −z 2 | would be large enough unless the first path was weak or non-existent in the Ipatov accumulator, eg. added by attack.   In summary, the proposed double rank sum tests detect a false early first path by two main means:
               1. The first rank sum test catches all the false very early first paths that fall into the noise region and the near but strong false early first paths as well.   2. The weak and close false early first path is caught by the second rank sum test and following first path to peak path ratio.   
               
           J. Comparing sample phases in the first path region between Ipatov/sync pattern and cipher (or between cipher segments). Depending on how transitions between sequences are handled (Ipatov sync, SFD, cipher and data), the phase may be either fixed throughout the whole packet or certain phase offsets may be added. After subtracting any effects due to transition-related phase changes, the respective phases should be similar. A phase consistency test can verify that cipher and Ipatov (or consecutive cipher segments) first path regions have similar phase differences between subsequent samples.
           A second variant is also possible; rather than verifying that the phases of samples in the first path regions match, it is also possible to verify phase changes (progression) between consecutive samples match. An example will now be described:   The core idea behind this test is that if the cipher first path is a real first path, the sync pattern, or Ipatov preamble, will also contain signal energy in those positions and the phase in the first path region should be similar. If there is an early false cipher first path, whether due to a side lobe or an attack, the corresponding section in the Ipatov accumulator will contain different noise samples and hence the phase should differ.   This approach could have a number of advantages:
               By comparing the phase in the first path region, the actual shape of the first paths are compared, rather than just the distribution of the samples;   By comparing phase rather than amplitudes, the need for normalization due to different accumulation lengths is avoided   Unlike in PDOA (Phase Difference Of Arrival) applications, the absolute phase is not important. Errors due to phase advance and ambiguity functions could be avoided by working with the relative phase progressions rather than the absolute phases.   
               
           A number of variations can be considered.
           i. Selection of first path samples:
               In the cipher accumulator, a window of four samples is considered starting from the sample before the first path position;   In the sync pattern or Ipatov accumulator, the corresponding window of four samples is taken, based on the fact that there is a fixed offset between the Ipatov and cipher accumulator first paths.   
               ii. Convert to phase progressions:
               Calculate the four phases in each set of samples (in the following, it is assumed the phase is expressed in degrees).   Convert to three phase progressions (diff(angles) in Matlab)   
               iii. Consider the difference between the two phase progressions:
               Take the difference between the two phase progressions   Convert to an angle between −180 and 180 degrees   Two of the three phase differences have to be within 5 degrees.   
               
           K. Applying machine learning based classification algorithms to assess integrity of the first path estimation, e.g. using a machine learning logistic regression-based assessment of the cipher-based time-of-arrival. Machine learning based classification algorithms learn the probabilities of integrity and shapes of correct and erroneous first path estimates from training datasets that can contain data from simulation or real measurements from different use cases. When the learning phase is completed, the experiences and patterns that algorithms learned are applied to the measured accumulators to predict integrity of the first path estimations. Machine learning logistic regression-based classification can be configured to learn how to classify an early first path from a training data set by modeling the output, e.g. following a binary Bernoulli distribution. An example will now be described.
           If we categorize early first path as ‘1’ and correct first path as ‘0’, early first path detection becomes a binary classification problem. In machine learning, many classification algorithms have been proposed in the past years. Given the requirements of low computational complexity, fast processing time and labelled training data (we know which estimations are early first path and which are not), logistics regression is good candidate to start from.   Logistic regression is a statistics-based classification algorithm. A logistic model is one where the log-odds of the probability of an event is a linear combination of independent or predictor variables. In logistic regression, we assume that output follows a binary Bernoulli distribution with the probability   
               

     
       
         
           
               
             
               
                 TABLE 1 
               
             
            
               
                   
               
               
                 Probability in logistic regression 
               
            
           
           
               
               
               
            
               
                 y 
                 0 
                 1 
               
               
                   
               
               
                 Probability 
                 
                   
                     
                       
                         
                           1 
                           - 
                           p 
                         
                         = 
                         
                           
                             e 
                             
                               
                                 - 
                                 
                                   θ 
                                   T 
                                 
                               
                               ⁢ 
                               x 
                             
                           
                           
                             1 
                             + 
                             
                               e 
                               
                                 
                                   - 
                                   
                                     θ 
                                     T 
                                   
                                 
                                 ⁢ 
                                 x 
                               
                             
                           
                         
                       
                     
                   
                 
                 
                   
                     
                       
                         p 
                         = 
                         
                           1 
                           
                             1 
                             + 
                             
                               e 
                               
                                 
                                   - 
                                   
                                     θ 
                                     T 
                                   
                                 
                                 ⁢ 
                                 x 
                               
                             
                           
                         
                       
                     
                   
                 
               
               
                   
               
            
           
         
       
         
         
           
             
               
                 where x=(x 1 , x 2 , . . . , x n ) is an input feature vector and θ=(θ 1 , θ 2 , . . . , θ n ) is the parameter or coefficient vector, y are known labels in training data. Then the likelihood function is 
               
             
           
         
       
    
     
       
         
           
             
               
                 
                   
                     L 
                     ⁡ 
                     
                       ( 
                       
                         θ 
                         | 
                         x 
                       
                       ) 
                     
                   
                   = 
                     
                   ⁢ 
                   
                     Pr 
                     ⁡ 
                     
                       ( 
                       
                         Y 
                         | 
                         
                           ( 
                           
                             X 
                             ; 
                             θ 
                           
                           ) 
                         
                       
                       ) 
                     
                   
                 
               
             
             
               
                 
                   = 
                     
                   ⁢ 
                   
                     
                       Π 
                       i 
                     
                     ⁢ 
                     
                       
                         
                           h 
                           θ 
                         
                         ⁡ 
                         
                           ( 
                           
                             x 
                             i 
                           
                           ) 
                         
                       
                       
                         y 
                         i 
                       
                     
                     ⁢ 
                     
                       
                         ( 
                         
                           1 
                           - 
                           
                             
                               h 
                               θ 
                             
                             ⁡ 
                             
                               ( 
                               
                                 x 
                                 i 
                               
                               ) 
                             
                           
                         
                         ) 
                       
                       
                         ( 
                         
                           1 
                           - 
                           
                             y 
                             i 
                           
                         
                         ) 
                       
                     
                   
                 
               
             
           
         
       
     
     where 
     
       
         
           
             
               
                 h 
                 θ 
               
               ⁡ 
               
                 ( 
                 
                   x 
                   i 
                 
                 ) 
               
             
             = 
             
               
                 1 
                 
                   1 
                   + 
                   
                     e 
                     
                       
                         - 
                         
                           θ 
                           T 
                         
                       
                       ⁢ 
                       x 
                     
                   
                 
               
               . 
             
           
         
       
     
     The cost function in logistic regression is −log (L(θ|x)) is 
     
       
         
           
             
               - 
               
                 log 
                 ⁡ 
                 
                   ( 
                   
                     L 
                     ⁡ 
                     
                       ( 
                       
                         θ 
                         | 
                         x 
                       
                       ) 
                     
                   
                   ) 
                 
               
             
             = 
             
               
                 - 
                 
                   
                     ∑ 
                     i 
                   
                   ⁢ 
                   
                     
                       y 
                       i 
                     
                     ⁢ 
                     
                       log 
                       ⁡ 
                       
                         ( 
                         
                           
                             h 
                             θ 
                           
                           ⁡ 
                           
                             ( 
                             
                               x 
                               i 
                             
                             ) 
                           
                         
                         ) 
                       
                     
                   
                 
               
               + 
               
                 
                   ( 
                   
                     1 
                     - 
                     
                       y 
                       i 
                     
                   
                   ) 
                 
                 ⁢ 
                 
                   log 
                   ⁡ 
                   
                     ( 
                     
                       ( 
                       
                         1 
                         - 
                         
                           
                             h 
                             θ 
                           
                           ⁡ 
                           
                             ( 
                             
                               x 
                               i 
                             
                             ) 
                           
                         
                       
                       ) 
                     
                     ) 
                   
                 
               
             
           
         
       
         
         
           
             
               
                 Logistic regression uses optimization techniques to obtain a parameter vector {circumflex over (θ)} that minimizes a cost function based on paired training data sets (x, y). 
                 With the coefficient vector {circumflex over (θ)}=({circumflex over (θ)} 1 , {circumflex over (θ)} 2 , . . . {circumflex over (θ)} n ), we could predict probabilities of y being ‘0’ and ‘1’ for new data by using Tabl. After comparing with a pre-defined threshold, y could be classified as ‘1’ if probability is larger than a threshold, or ‘0’ for other cases. 
                 When using logistic regression in early path detection, input feature vector X can be samples around first path estimation in cipher accumulator and threshold can be set according to the missing and false early first path detection requirements. 
                 Meanwhile, as probability of an early first path would be much smaller than a correct first path. The training process will tend to bias towards a dominant class even if we adjust the threshold. The dominant class is the class that most of the samples are belong to. For instance, real first path is the dominant class as the number of its samples are much larger than false early first path. To mitigate the effect of imbalanced data, we give different weights for different classes in the cost function to make cost of instance in class ‘1’ higher than class ‘0’. Then cost function becomes 
               
             
           
         
       
    
     
       
         
           
             
               - 
               
                 log 
                 ⁡ 
                 
                   ( 
                   
                     L 
                     ⁡ 
                     
                       ( 
                       
                         θ 
                         | 
                         x 
                       
                       ) 
                     
                   
                   ) 
                 
               
             
             = 
             
               - 
               
                 
                   ∑ 
                   i 
                 
                 ⁢ 
                 
                   
                     w 
                     i 
                   
                   ⁡ 
                   
                     ( 
                     
                       
                         
                           y 
                           i 
                         
                         ⁢ 
                         
                           log 
                           ⁡ 
                           
                             ( 
                             
                               
                                 h 
                                 θ 
                               
                               ⁡ 
                               
                                 ( 
                                 
                                   x 
                                   i 
                                 
                                 ) 
                               
                             
                             ) 
                           
                         
                       
                       + 
                       
                         
                           ( 
                           
                             1 
                             - 
                             
                               y 
                               i 
                             
                           
                           ) 
                         
                         ⁢ 
                         
                           log 
                           ⁡ 
                           
                             ( 
                             
                               ( 
                               
                                 1 
                                 - 
                                 
                                   
                                     h 
                                     θ 
                                   
                                   ⁡ 
                                   
                                     ( 
                                     
                                       x 
                                       i 
                                     
                                     ) 
                                   
                                 
                               
                               ) 
                             
                             ) 
                           
                         
                       
                     
                     ) 
                   
                 
               
             
           
         
       
         
         
           
             
               
                 where w i  is the cost for each instance and its value is 
               
             
           
         
       
    
     
       
         
           
             
               w 
               i 
             
             = 
             
               { 
               
                 
                   
                     
                       1 
                       
                         frequency 
                         ⁢ 
                         
                             
                         
                         ⁢ 
                         of 
                         ⁢ 
                         
                             
                         
                         ⁢ 
                         class 
                         ⁢ 
                         
                             
                         
                         ⁢ 
                         
                           1 
                           
                               
                           
                           ′ 
                             
                             
                           ′ 
                         
                       
                     
                   
                   
                     
                       
                         if 
                         ⁢ 
                         
                             
                         
                         ⁢ 
                         instance 
                         ⁢ 
                         
                             
                         
                         ⁢ 
                         i 
                       
                       ∈ 
                       
                         class 
                         ⁢ 
                         
                             
                         
                         ⁢ 
                         
                           1 
                           
                               
                           
                           ′ 
                             
                           
                               
                           
                           ′ 
                         
                       
                     
                   
                 
                 
                   
                     
                       1 
                       
                         frequency 
                         ⁢ 
                         
                             
                         
                         ⁢ 
                         of 
                         ⁢ 
                         
                             
                         
                         ⁢ 
                         class 
                         ⁢ 
                         
                             
                         
                         ⁢ 
                         
                           0 
                           
                               
                           
                           ′ 
                             
                             
                           ′ 
                         
                       
                     
                   
                   
                     
                       
                         if 
                         ⁢ 
                         
                             
                         
                         ⁢ 
                         instance 
                         ⁢ 
                         
                             
                         
                         ⁢ 
                         i 
                       
                       ∈ 
                       
                         class 
                         ⁢ 
                         
                             
                         
                         ⁢ 
                         
                           0 
                           
                               
                           
                           ′ 
                             
                           
                               
                           
                           ′ 
                         
                       
                     
                   
                 
               
             
           
         
       
         
         
           
             
               
                 For coefficient vector {circumflex over (θ)} estimation, we need to train a logistic regression classifier using training data. The classification error in training set is called training error. In order to test performance of logistic regression classifier, a disjoint data set should be used as testing data set. Similarly, classification error in testing set is named as testing error. Testing error is also known generalization error as a measurement of ability to predict unseen data. 
                 We use training error to tune feature length and thresholds. The performance of the logistic regression classifier is evaluated on a test data set. 
               
             
             L. Analyzing the correlator output (sum of correlated bits) at each delay as it gets accumulated over time. Analysis may be done on both real and imaginary axes. The property of the genuine weak first path is that it will produce weak correlation output in each correlated symbol, resulting in slow but steady accumulator growth at the particular delay. A sidelobe, mimicking weak path (for example introduced by the attacker&#39;s malicious transmissions), would result in very noisy and random correlator output, sometimes positive, sometimes negative. Accumulator growth at this delay will therefore be chaotic: sometimes growing in the right direction, sometime strongly backtracking in the other.
           Therefore monitoring of the growth pattern of the accumulated sample will provide a criteria for distinguishing between genuine slowly growing first path and chaotic growth of the false path (e.g. of a sidelobe).   Example patterns have been presented in  FIGS. 8 and 9 . The algorithm may, for example, compute how far the growth function diverges from the ideal linear growth and implement a threshold for acceptance the path based on this criteria.   
         
           
         
       
    
       FIGS. 8 and 9  show example growth rates of the genuine versus false paths.
         M. The attacker could record and retransmit the genuine signal pulses at high power with a variable retransmission delay. This would introduce an additional strong path which would appear like a strong reflection. The timing recover algorithm may lock onto the strongest energy in certain selected window and then try to maintain the lock to the strongest signal. If the retransmitted path had a variable delay it could manipulate the timing recovery algorithm to compensate for the changing delay and shift the whole correlation window, thus shortening the apparent distance of the genuine paths. There are several ways possible to counteract this:
           In the case where carrier and baseband (modulation) clocks are synchronized (in the transmitter), in the receiver it is possible to calculate timing recovery adjustments as a function of the carrier frequency offset (CFO), since these two are closely synchronized. Usually a scaling factor is needed to calculate timing offset adjustment based on the CFO.   Alternatively (also in cases where the transmitter carrier and baseband clocks were not synchronized), it would be possible to limit the maximum timing shift that the timing recovery algorithm is allowed to apply, during the packet reception. Considering the packet&#39;s short duration and maximum allowed clock difference tolerance, the maximum timing offset during the packet is limited and can be calculated. If the attacker artificially shifts path timing offset by more than that value, the receiver will only be able to follow that shift within specified limits, thus preventing significant change to the first path position.   
           N. The attacker could attack the ranging protocol. In single-sided two-way ranging, it is necessary to compensate for the clock differences between the two sides. This is due to the fact that the response delay will be clocked at different rates if transmitter and receiver clocks differ. A compensation typically involves subtracting the compensation factor which depends on both the response delay duration and the clock difference (CFO, carrier frequency offset). If the attacker retransmits the original response message but at slightly changed rate, the receiver will estimate the wrong CFO and perform incorrect compensation, which could result in shortening of the distance. To prevent this, the two CFO estimates (CFO1 and CFO2) calculated on both sides during the reception of the two ranging packets, should be compared. If CFO1 is not close to −CFO2, it could indicate some kind of carrier clock manipulation, in which case the distance measurement could be rejected by the host processor. The measured CFO1 and CFO2 can be transmitted in data payload or through other protocols. For example, it may be necessary to check CFO1 and −CFO2 are within 1 ppm of each other, e.g. abs(CFO1+CFO2)=&lt;1 ppm.       

     CFOs are generally in the range of −40 ppm to +40 ppm.
         An example of such an attack is illustrated in  FIGS. 10 and 11 . The attacker retransmits the original message consisting of a series of pulses, but at slightly lower rate, resulting in the message being stretched as shown in  FIG. 10 .   In  FIG. 11  below, the initiator (in this case the keyfob) receives a modified response message from the responder (anchor) and computes an incorrect CFO2. It appears to the keyfob that the anchor&#39;s clock is slower. The keyfob predicts that the anticipated response should arrive later, because the anchor clocked the response delay at a slower rate than the keyfob. The keyfob therefore calculates the distance (using the incorrect CFO2) and subtracts the wrong time offset (translating into the distance offset), which would result in the keyfob estimating a lower distance.   To prevent this kind of attack it is possible to compare CFO1 estimated by the anchor and CFO2 estimated by the keyfob. In normal circumstances CFO1 should be close to −CFO2. For example, the criteria may be that abs(CFO1-CFO2) less than 1 ppm, but in other embodiments the criteria may be that abs(CFO1-CFO2) is less 2 ppm or less than 3 ppm. The attack on CFO would only provide meaningful distance reduction if corrupt CFO was &gt;20-40 ppm.   O. The precursor area in the accumulator, that is, the area before the first path, in normal circumstances is noisy and noise should typically have a normal, or Gaussian-like distribution. A receiver could perform an analysis of the actual distribution of the precursor samples. This analysis could for example use the mean noise value (MNV) and check how many precursor samples are above 2*MNV, 3*MNV, 5*MNV, 7*MNV etc. In many types of malicious attacks, the noise in the precursor area will have unusual distributions, for example, there can be more samples having quite high amplitude compared to the mean noise (‘spikes’). The verification would involve checking if proportions of low noise samples and high noise sample are as expected for the typical Gaussian-like noise distribution. An example attack, could be where malicious transmitter transmits high-power random pulses during or just after the preamble. This would result in receiver gain to adapt to it and ADC thresholds to increase; as a consequence, there would be no noise getting through the ADC. As a result, the accumulator would be very clean, without the usual background noise, but could contain some ‘spikes’. This verification method would help identify cases where unusually high number of high ‘spikes’ are present and possibly result in rejected ranging measurement.       

     While a specific architecture is shown, any appropriate hardware/software architecture may be employed. For example, external communication may be via a wired network connection. 
     The above embodiments and examples are to be understood as illustrative examples. Further embodiments, aspects or examples are envisaged. It is to be understood that any feature described in relation to any one embodiment, aspect or example may be used alone, or in combination with other features described, and may also be used in combination with one or more features of any other of the embodiments, aspects or examples, or any combination of any other of the embodiments, aspects or examples. Furthermore, equivalents and modifications not described above may also be employed without departing from the scope of the invention, which is defined in the accompanying claims.