A Blind Signal Samples Detection Algorithm for Accurate Primary User Traffic Estimation

The energy detection process for enabling opportunistic spectrum access in dynamic primary user (PU) scenarios, where PU changes state from active to inactive at random time instances, requires the estimation of several parameters ranging from noise variance and signal-to-noise ratio (SNR) to instantaneous and average PU activity. A prerequisite to parameter estimation is an accurate extraction of the signal and noise samples in a received signal time frame. In this paper, we propose a low-complexity and accurate signal samples detection algorithm as compared to well-known methods, which is also blind to the PU activity distribution. The proposed algorithm is analyzed in a semi-experimental simulation setup for its accuracy and time complexity in recognizing signal and noise samples, and its use in channel occupancy estimation, under varying occupancy and SNR of the PU signal. The results confirm its suitability for acquiring the necessary information on the dynamic behavior of PU, which is otherwise assumed to be known in the literature.


Introduction
In cognitive radios, detecting white spaces, and determining channel occupancy in a dynamic radio environment is essential for opportunistic access to radio resources. The simplest and widely used method of assessing the availability of the radio resources is energy detection, for which efficiency in terms of probability of detection and probability of false alarm is analyzed extensively in the literature [1][2][3]. However, these studies consider the context of a static primary user (PU) signal, which is either active or inactive within the entire detection period. In realistic scenarios, however, the PU signal can dynamically switch between active and inactive states, while detection is in progress. The detection of discontinuous PU is considered in [4][5][6][7] by redesigning the detection algorithms, in which, however, signal, noise, and PU traffic parameters are assumed to be known a priori while the methods to obtain/estimate these necessary parameters are not described.
Many studies show that any uncertainty in estimating parameters of the received signal seriously limits the ability of the detector to assign energy to a particular activity state correctly [8]. Consequently, the correct operation of the energy detector in a dynamic radio channel requires accurately estimating, (a) PU traffic parameters such as the average and current duration of the PU, and its channel occupancy ratio and, (b) signal and noise parameters as noise variance and signal-to-noise ratio (SNR). Importantly, the estimation of all these parameters and the ensuing detection performance starts with the accurate splitting of the signal and noise samples in received energy samples.
In this paper, we present a practical algorithm for energy samples recognition-marking of signal and noise samples in a received time frame-of a dynamic PU signal. The algorithm uses rank order filtering, earlier studied for signal spectrum analysis only [9][10][11], for temporal signal analysis by redesigning the signal processing and samples marking processes. We evaluate the algorithm in terms of signal samples detection and complete samples recognition with respect to SNR and different PU activity factors, and also examine the execution time of the detection process. Besides, its performance is compared with the well-known reference methods in the literature [12][13][14], which is then followed by its utility appraisal for channel occupancy estimation. To assess the accuracy of these operations, a semi-experimental simulation setup of packet-based PU transmission is designed, where the background distortion comes from the radio frequency (RF) noise traces captured with National Instrument software defined radio (SDR), USRP-2900. The proposed solution, with its appealing performance, provides a convenient basis, although not the subject of this article, for parameter estimation in the subsequent detection of intermittent PU signals.
The rest of the article is organized as follows. Section 2 gives the motivation for samples recognition, and Section 3 describes the proposed detection algorithm. Section 4 explains the simulation methodology and shows numerical results. Finally, Section 5 gives the concluding remarks.

Motivation for Samples Recognition
To reason the need for samples recognition, we restate the energy detection (ED) process for dynamic PU signals. Consider the ED-based sampling of dynamic PU modeled as an alternating renewal process, similar to [4][5][6], and shown in Figure 1. Energy detection as an auxiliary process in basic secondary user (SU) operations is considered as discontinuous and periodic, and therefore may not register constant PU activity in the detection window, but rather may contain transitions between the activity states. At any time instant, PU is either in ON (active) or OFF (idle) state, while the state transition occurs at random time instances, and the state holding times are exponentially distributed with mean τ and µ, respectively. The energy detector collects signal samples x n , n = 1 . . . N in a detection interval of duration (T), which is independent of the PU ON/OFF process. As the signal is sampled at a specific frequency f s , total number of collected samples are N = f s T, and N 0 and N 1 represent the number of samples corresponding to hypothesis (subject to detection) H 0 and H 1 . As N → ∞, normalized occupancy/absence rate N i /N approaches its average value p i , i ∈ {0, 1}. A predominant model to characterize energy detection performance for such dynamic PU scenario, in terms of test statistic (β), probability of detection (P d ), and probability of false alarm (P f ), is as follows [4] where γ is the decision threshold, σ 2 w is noise variance and ρ is the SNR, which in instantaneous form, for mixed signal-with-noise and noise-only samples, can be calculated as a ratio of averaged powers [15] To implement this detection model or any other involving PU transition probabilities (e.g., [6]), several necessary parameters, as noise variance, SNR, instantaneous and mean occupancy/absence rates, are assumed to be known. Some of these parameters remain dependent on the primary user activity (i.e., N 0/1 , p 0/1 ) and can be derived directly from the received signal. Others depend on the operating conditions of the receiver (i.e., σ 2 w , ρ) and must be estimated based on the appropriate groups of the received samples. In practice, the very first step to extract these parameters is samples recognition. Figure 2 summarizes the different stages of the energy detection process while featuring the source and demand of the necessary parameters at each stage. In this context, our objective is to develop a samples separation algorithm that is effective in extracting the necessary (detection-related) parameters of bursty PU signal. We assume a specific (exponential) distribution of PU idle/active state; however, the design of the algorithm is generic and blind to the PU activity pattern.

Algorithm Design and Description
In this section, we describe the design of the proposed algorithm, which finds its motivation from rank order filtering (ROF). ROF, a commonly used image processing technique, sorts the input values in ascending order, and selects for the output value encountered at a certain rank order number. The selected input value becomes the output, without any calculation performed on the input values. The two special operations of ROF are erosion-equivalent to lowest rank as it returns the minimum of the input set, and dilation-equivalent to highest rank as it returns the maximum. Erosion and dilation, besides being useful in image processing, can also be effectively used in impulse noise reduction and noise power estimation, as demonstrated in [9][10][11]. These studies iteratively increase the size of the filters used on the power spectrum samples. By filtration, the peak values of the spectrum are reduced until the difference in the noise floor achieved in i-th and (i + 1)-th iteration falls below a predetermined threshold value. Although effective, the algorithms in [9][10][11] are only dedicated to estimating spectrum parameters and are burdened with the following disadvantages that limit their usefulness for time-domain analysis of dynamic PU behavior: • The selection of an appropriate threshold for the noise floor difference is problematic due to its unambiguous interpretation.

•
The process carried out on spectrum samples strongly benefits from the processing gain provided by the fast Fourier transform (FFT) [16]. Although the transition between frequency and time domains can be performed quite efficiently, for simple energy detectors, it is not imperative to transform the signal into the frequency domain.
With these considerations, we design a new signal samples detecting technique, by reconstructing the ROF-based solutions, for accurate extraction of parameters from intermittent PU transmission, while keeping the samples recognition process as simple as possible to enable low-complexity detection. The main steps of the proposed algorithm are as follows: Initialization-energy vector: The detection algorithm starts with the conversion of an N complex samples, i.e., x = [x 1 , . . . , x N ], into a vector of energy samples, y n = |x n | 2 . Afterward, a moving average (MAV) of a small size m init N is used to reduce noise variance initially. The right choice for m init in accordance with N, i.e., small enough not to reduce the signal but large enough to reduce noise variance, increases the algorithm's accuracy for signals of longer duration or high SNR. However, too large m init may limit the algorithm's sensitivity for weak signals. Because the recursive formulation of the m-sized MAV asȳ n =ȳ n−1 + 1 m (y n − y n−m ) requires only one addition, one subtraction, and one division per sample, the formula is independent of the number of samples N, and the runtime complexity for each sample is constant, i.e., O(1). Thus, the complexity of the pre-processing preceding filtering is kept to a minimum. However, it should also be noted that the recursive implementation of the moving average can cause a risk of error propagation in the event of a calculation error, which depends on the device's computational capabilities, i.e., limited precision. Therefore, it is a trade-off for simple devices between hardware load and the risk of introducing a faulty observation window for further processing. Nevertheless, considering the case of short observation windows, the error accumulation and propagation has a limited impact.
LOOP process-ROF: In this step, the initially averaged energy vectorȳ is iteratively filtered by consecutive erosion and dilation operations. After each filtration, the total energy e of the vector is determined. A consistent increase in the size k of movmin and movmax filters allows finding the size m sec for which the energy decrease in relation to the energy after previous filtration e k = e k−1 −e k e k−1 remains the highest. The search for maximum value removes the requirement to set a threshold, as typical in earlier works. The resulting size of the filter m sec is interpreted as the probable longest continuous signal duration in the analyzed frame, and is used in the second moving average,ȳ. Samples marking process-derivative evaluation: The identification of signal and noise samples is based on the evaluation of the derivative of the double-averaged energy vector y n = y n −ȳ n−1 . The intervals in which the derivative has positive values with a width wider than the assumed threshold of minimal signal width λ msw indicate signal samples. The threshold λ msw can be interpreted as a resolution of the algorithm, i.e., the minimum detectable signal duration. Due to the influence of the noise variance, the problem of maintaining the required interval continuity occurs. Positive intervals potentially indicating the signal can be divided by single samples with non-positive values. Therefore, before assessing if the width of the positive interval meets the condition of λ msw , adjacent intervals separated by the single non-positive sample are combined. This simple step significantly improves the marking accuracy of the algorithm for weak signals.
The above-presented solution results in a simple yet effective samples recognition technique for the detection of packet-based PU signals. The pseudo-code of the proposed scheme is given in Algorithm 1 with notations: m init -initial size of the moving average, λ msw -minimal signal width, x-received signal, y-processed signal, e-energy, e -energy decrease, and y -differential.

Simulation Setup and Results
To assess the performance of the proposed algorithm, we have developed a simulation setup that supports random ON/OFF traffic behavior of PU. For background noise, the simulator uses radio-frequency (RF) noise I/Q traces sampled in a bandwidth of 5 MHz centered around 868 MHz, i.e., the first channel of the IEEE 802.15.4 standard. The RF noise traces are collected in an open university area using National Instrument USRP-2900. The receiver digitizes RF samples using direct downconversion to baseband. We recorded the average noise power of −110.7 dBm, which is normalized to 1 mW in the simulations.
It should be noted that although the pseudorandom noise approach is the most commonly used in simulated transmission models, the use of pseudorandom noise, fitted to the theoretical assumptions of the white Gaussian noise, may significantly differ from the background noise recorded by the real radio receiver. The use of real noise traces includes an uneven distribution of power between frequencies, instantaneous noise power variations, and distortions due to receiver limitations.
In the simulations, the subject of analysis is non-overlapping time frames, each containing 1024 samples. A new noise realization is recorded for each frame, to which a PU signal is added as a rectangular pulse as shown in Figure 3(top). The radio pulse is adopted as a deterministic signal hidden in noise due to its universality in reproducing an unknown signal while maintaining a simple regulation of amplitude and time duration. Both the signal-with-noise pulses and the following noise-only durations are exponentially distributed with mean values being swept respectively from 10% to 30% and 90% to 70% of the time frame. The sample splitting is based on a positive or non-positive differential processed according to Algorithm 1, and depicted in Figure 3(bottom). In simulations, as input parameters of the algorithm, m init and λ msw are set as 1% and 5% of the observation window, respectively. As the basic reference method, we study the estimation of primary user activity based on the idle/busy periods determined by using short spectrum sensing decisions [12,13,17]. As the above method, however, requires noise floor information, which we obtain using the extended Forward Consecutive Mean Excision (FCME) algorithm with Welch FFT [13,17]. For the simulation of the FCME-based algorithm, a 64-sample periodogram is adopted along with an energy detection window with a length of 5% of the analyzed time frame and a false alarm probability of 1%.
As the second reference method (operating in the time-domain), we adopt linear discriminant analysis (LDA). LDA is used in statistics and pattern recognition as a basic mathematical tool to separate two classes of objects, applied as Fisher discriminant function [14].
The performance of the algorithms is measured by the average percentage of correctness in assigning samples to groups of signal-with-noise or noise-only samples, compared to a known pattern generated independently for each time frame. Each comparison point in Figures 4 and 5 is obtained after averaging 1000 observations, generated according to point parameters. In the simulated SNR dependencies, the variability of the N 0 and N 1 ratio in Equation (4) should be considered. Therefore, the SNR value is determined as the average value obtained for all observations at the assumed constant pulse amplitude set relative to the average noise amplitude, and taking into account the average duration of the pulse generated with a given τ.   Figure 4 shows the detection accuracy for the signal group, indicating a decrease in the assignment accuracy with a decrease in SNR. The adopted metric approximates the probability of detection as N → ∞. The comparison indicates that the proposed ROF-based signal detection (RSD) shows a performance near to FCME-based solution and significantly higher than LDA (i.e., the reference time-domain method). Moreover, the accuracy of RSD remains almost independent of the mean occupancy of the time frame.
The total marking accuracy, measured as an average ratio of correctly recognized signal-with-noise samples and noise-only samples, is shown in Figure 5. With a decrease in SNR, the curve indicates an increase in type I and type II errors. The efficiency of RSD decreases by the percentage close to the signal presence in the frame, which in extreme cases is entirely recognized as noise. Thus, the inaccuracy in RSD is mainly limited to error type false negative, i.e., less recognizable signal samples are assigned to the noise group, while the noise is rarely classified as a signal, leading to reduced false positive errors. At high SNR, the accuracy does not drop more than the assumed 5% resolution threshold.
To complement the comparison, it is also necessary to analyze the complexity of the methods. However, for short observation windows, thus small number of samples, such as those used in this study, the asymptotic behavior of the methods may not dominate. The differences in performance can be caused by time-consuming operations other than calculations, i.e., bringing the data into and out of the processor cache. Therefore, the use of asymptotic analysis for practical N values has limited utility. Accordingly, Figure 6 compares the average execution time of the proposed RSD algorithm with the reference methods. The results were obtained by averaging the time over a thousand single-threaded function calls performed on a quad-core 3.07 GHz Intel Xeon W3550. Time analysis shows that the proposed RSD method exhibits significantly lower complexity, especially for a small number of samples, with respect to the reference solutions. These time differences are of significant importance as the samples recognition remains only a supportive process for effective estimation of channel parameters and primary user detection. The marking efficiency of signal-with-noise samples in the exemplary application can be directly used for estimating the average occupancy of the PU signal under test. For each observation window, based on the algorithm's indications, the number N 1 of signal-with-noise samples is determined. Samples are collected over 1000 observation windows and based on them, the average occupancy of the transmission channel is determined. Then the relative error of the estimated channel occupancy is determined relative to the expected value τ for which the frames were generated. As shown in Figure 7, it is visible that for a low PU occupancy of 10-20% with SNR above 0 dB, the proposed algorithm preserves high 1-2% accuracy. In the case of increasing occupancy and weak signals, the algorithm noticeably loses efficiency. Therefore, for a secondary user subject to strong PU signals with a moderate activity factor, the proposed algorithm demonstrates to be a perfectly matched, easy to implement, and accurate signal samples detection technique.

Conclusions and Future Work
Stimulated by the need for estimating several vital parameters to perform the energy detection of dynamic PU, we developed a new algorithm for accurate recognition of signal and noise samples in the received signal time frame. The algorithm has its roots in rank order filtering-based spectral analysis that we reconstructed for low-complexity time-domain analysis of bursty signals. We evaluated the algorithm in terms of its accuracy to detect signal samples, complete sample recognition, time complexity and utility in channel occupancy estimation. The algorithm exhibits an accuracy of 87% in marking samples even for weak signals with SNR close to 0 dB. For strong and narrow pulses, it provides up to 97% of correct sample recognition and remains competitive for twice as complex solutions. The achieved accuracy, together with a simple design, makes the proposed solution a convenient basis for obtaining information required for effective energy detection.
Future fully real-data experiments can provide detailed information related to the impact of the remaining operational parameters, i.e., m init and λ msw and their optimization to enhance the overall accuracy of the proposed solution. As a future work, we also aim to consider variable sensing periods and transmission power levels, and multiple PUs.

Conflicts of Interest:
The authors declare no conflict of interest.

Abbreviations
The following abbreviations are used in this manuscript: