Designing a Real-time Swept Spectrum Analyser with USRP B210

Cognitive radio has received considerable amount of attention as a promising technique to provide dynamic spectrum allocation. Spectrum sensing is one of the basic functions in the cognitive radio and is crucial to all other functions. Software-defined radios (SDRs) are considered due to its very high flexibility and have become a common platform for CR implementation replacing expensive spectrum analysers. The most popular among various SDR platforms is the universal software-defined radio peripheral (USRP). This paper presents a real-time swept spectrum sensing solution based on USRP B210. It also presents a detailed explanation of the concept of energy detection and the methodology for wide-band sensing. Finally, the performance of the proposed sensing solution is analysed through FFT graphs and spectrogram plot taken for 8 hours. The results showed that the proposed sensing solution was capable of achieving high resolution in the frequency domain of the wide band measured which implies that wide bands with heterogenous signals like the ISM band can be accurately resolved and analysed.


Introduction
According to Huawei, a communication company, there has been tremendous growth in wireless communication as the predictions of mobile users in 2020 made in 2010 have been exceeded in 2012 (Pretz, 2012). As wireless communication technology evolves rapidly, radio spectrum resources became ever more crowded. A trending solution uses an autonomous radio design because the problem of scarcity is due to allocations of these frequencies but many radio systems do not transmit all the time or in every location. These radios are cognitive radios (CRs), introduced as a promising technology to improve the efficiency of spectrum utilization by enabling them to adapt their transmission parameters to the local spectrum environment (Haykin, 2005). One of the basic functions of the cognitive radio is spectrum sensing which have in the past been carried out with spectrum analysers by researchers. However, these spectrum analysers are expensive compared to the softwaredefined radios (SDRs) and the results of these designs (both the spectrum analysers and softwaredefined radios (SDRS)) only show little difference in measured spectrum occupancy (Fanan, et al., 2015). Section 1.1 reviews existing sensing algorithms and techniques used by researchers in cognitive radio design. The materials used and the methodology used in implementing sensing solution is introduced in detail in Section 2. Section 3 first analyses the performance of the proposed solution through the FFT graphs and spectrogram plots of the measured wide-band, afterwards the requirements for measurement are discussed to avoid too much dropped samples. Finally, some conclusions are drawn in Section 4.

Existing sensing algorithms
A thorough list of sensing algorithms is presented in Yucek & Arslan (2009). Sensing algorithm is a trade-off between performance and complexity; some algorithms have high complexity and good performance while others are less complex or simple and fast. The designer therefore chooses to pick what is best suited for a specific goal.
Matched filtering is an optimum detector for detection of primary users (PUs) when the transmitted signal is known. It is done by comparison of the received signal with the input signal (Proakis, et al., 1994). This implies that the radio has to demodulate the signal, hence needs perfect knowledge of the primary signal. Due to this, the complexity of the receiver increases with the number of signal types that need to be detected. Therefore, it is not suitable for wide-band general purpose sensing.
Waveform based sensing is a method that uses certain known patterns in wireless communications such as preambles, regularly transmitted pilot patterns, spreading sequences, etc. In wireless communication systems, these patterns are usually utilized to achieve synchronization. This sensing algorithm is performed by correlating the received signal with a certain known pattern (Tian & Giannakis, 2006). This method is only applicable to systems with known patterns and requires the receiver to be aware of those patterns. This implies that a certain level of priori knowledge is necessary.
Cyclo-stationary feature detection exploits the cyclo-stationary features of the primary signals. These features are the periodic patterns within signals (Cabric, et al., 2004). There is no need to demodulate the signal hence it requires less a-priori knowledge compared with the previous methods. The main advantage of this method is the ability to distinguish noise from that of the primary user.
Energy detection-based sensing is suitable due to its low computational and implementation complexity (Hossain, et al., 2009). These advantages make it the most common way of spectrum sensing. The major advantage however, is that no a-priori knowledge is required. A case in point where this method will shine is in the ISM band where all users share the same right to use the spectrum resource. Hence the users typically are interested only in finding a channel with good quality to communicate. Energy detection, for its low computational cost and speed, is best suitable for fast channel quality evaluation and is therefore easy to implement. This paper implements this sensing method for an SDR-based spectrum analyser.
Many narrow-band sensing algorithms exist, but when it comes to wide-band sensing, much less work has been done. The major limitation can be attributed to the ADC and filtering as there is a restriction on the highest attainable sample rate in available ADCs and a high computation cost in carrying out filtering at those rates (Liu, et al., 2011). There are methodologies for multiple spectrum band sensing that is done simultaneously. It makes use of advanced signal processing techniques (Hoseini & Beaulieu, 2010;Tian & Giannakis, 2006).
One other style of solution to wide-band sensing is distributed sensing; a group of co-operating devices cover sensing of the large bandwidth. One such solution is the multi-band joint detection (MJD) proposed in (Quan, et al., 2008). A wide-band sensing method was also proposed by Liu et al. (2011) using USRP2 and Iris software. The method forms the foundation of the development of this paper as there is not a GNU Radio version of the proposed solution which uses USRP B210. According to the paper, the proposed solution has tolerable sweep time in the 2.4 GHz band which it was measured. Therefore, this paper provides the proposed solution using GNU Radio 3.8 and USRP B210.

Methodology
The Universal Software Radio Peripheral (USRP) developed by Ettus Research (Research, 2021) is a low-cost SDR platform that utilizes a general-purpose processor and has gained widespread usage. USRP consists of two parts, a fixed mother board and a plug-in daughter board (see Figure 1). The mother board mainly contains ADC/DAC, an FPGA mainly for digital down sampling with programmable decimation rate and an interface connected to host PC. The daughter board provides basic RF front-end functionality. The integrated RF frontend on the USRP B210 is designed with the new Analog Devices AD9361, a single-chip direct-conversion transceiver, capable of streaming up to 56 MHz of real-time RF bandwidth. The B210 uses both signal pipelines of the AD9361 thereby providing coherent 2 × 2 MIMO capability. Onboard signal processing and control of the AD9361 is performed by the Spartan6 XC6SLX150 FPGA connected to a host PC using USB 3.0. The USRP B210 real time throughput is benchmarked at 61.44MS/s quadrature, providing the full 56 MHz of instantaneous RF bandwidth to the host PC for additional processing using GNU Radio or applications that use the UHD API (driver). The board of the USRP B210 is shown in Figure 1. UHD is available for all major platforms including Linux, Windows, and can be built with many popular compilers such as GCC (Research, 2021;Liu, et al., 2011).
Several researches in cognitive radio reflect the use of GNU Radio (GR) with USRP. GNU Radio (GR) is an open-source software providing various signal processing blocks accompanied with a graphical user interface. Other software platforms such as Simulink and LabView are also readily available (Liu, et al., 2011;Instrument, 2021). USRP B210 has powerful ADC, capable of IQ sampling, 61.4 MHz sample rate and 14-bit resolution for each I or Q sample (Research, 2021). With some signal processing after the DDC, the available samples are generated at a maximum instantaneous sample rate of 56 Msps. With the USB 3.0 cable the bus throughput depends on the host computer and therefore varies. Choice of sample rate no more than 56 Msps in a 1 × 1 transceiver operation or 30.71 Msps in a 2 × 2 transceiver operation will depend on the rate of dropped samples (Research, 2021). Suppose the host PC allows 25 Msps to be received conveniently, therefore, the most practical way to construct a wide-band spectrum based on energy detection is by tuning the centre frequency of the mixer at the RF front-end, e.g., sensing one band at a time and then combining the measurements.
A complete visit of the measured frequency band or range is called one sweep as depicted in Figure 2. The duration of the sweep determines the probability of intercept (POI) of the design towards short transmitting signals. The sweep or revisit time should be as short as possible so that the combined results from each centre frequency captured in a sweep can be read as that captured at an instance in time. According to Nyquist theory, the covered bandwidth of Fourier Transform depends on the sample rate such that the correctly captured frequencies are within half of the sample rate or measured bandwidth. This is true for real signals. However, the USRP B210 produces I and Q samples or complex signals. When using complex samples, the covered bandwidth is the same as the sample rate. Hence the maximum sample rate achievable in design is limited by the rate allowable for the host PC through the USB cable which is 25 Msps.

Figure 2: Sweep
The tuning of the RF front-end of USRP B210 brings along with it some practical concerns during implementation. During operation whenever the USRP switches its operating frequency, it takes time for the host PC to issue a configuration command and for the hardware on the front-end to settle down. The former is referred to as the tune time and the latter is referred to as the lock time. Lock time is not consistent; it varies depending upon the device and requested settings. After tuning and before streaming, the lo_locked sensor should be checked for confirmation that the USRP device has settled and locked the tuned frequency (Research, 2021). According to Richard (2016), the estimated lock time measured using Ubuntu 14.04 LTS, GNU Radio 3.7.10 with UHD 3.9.3 was 124 . Such a wait caused by channel switching, will lead to asynchronization between the host PC and the USRP. This unsynchronized interface will pose a difficulty for the host PC to control the timing of channel switching accurately enough. With the old version of GR, like the GR 3.7 such a problem would only have been solved by implementing a non-continuous mode of measurement. Such that the USRP will only stream samples when the already sent samples have been processed by the host PC and a frequency change request have been issued (Liu, et al., 2011). This is because if the USPR is set to operate in a continuous mode, when the maximum number of samples is collected and the host PC issues a command to switch, samples will still be streamed before the channel switching command reaches the USRP. These new samples are not tagged and therefore cannot be used. In GR 3.8 there are tags produced by the UHD specifying the centre frequency of the samples. Another concern is the presence of strong DC level in the first batch of samples arriving from USRP right after tuning the frequency or starting up. The obtained spectrum from those samples does not reflect the actual environment and hence cannot be used. Therefore, the first batch of samples that are streamed to the host PC are then dropped by a software component in the implementation. Figure 3 shows the flow graph designed for energy detection sensing method. First, a certain number of complex samples under a certain centre frequency are collected with the UHD Source block. The streaming samples are tagged with the centre frequency tag, rx_freq by the UHD Source block. The generated samples are vectorized into a N-dimensional column vector whose length matches the FFT length used in the measurement. The FFT is taken on these vectors to produce the FFT complex samples. The magnitude of the resulting IQ samples is computed after some FFT frames have been dropped using the Keep 1 in N block, to match processing speed of host PC with the rate of the USRP B210. The resulting FFT vector of block size N, form the sub-blocks for the entire measured bandwidth, X. Each block has 50% overlap with its two adjacent blocks. This overlapping is required due to the frequency response of the DDC. To avoid spectral leakage, each block is multiplied by an equal-size Blackman Harris window. The measurement is saved in a file as a file metadata-a file containing the samples and extra information such as all tags produced in GR program. For visualization of the saved samples as a magnitude versus frequency plot, there is the GUI Vector Sink.

Figure 3: GNU Radio Companion (GRC) implementing the energy detection method with FFT
Further processing is required for data reduction and visualization of the measured band X. The measured band is presented as either a one sweep spectrum plot or a spectrogram which takes into account the time of measurement. For each windowed block, the FFT samples are averaged across a number of FFT frames collected for a centre frequency to produce a clean FFT frame. Then, the final FFT results from all blocks form the spectrogram data with the timeframe of measurement also noted. Certain parameters are prerequisite to operating the spectrum analyser such as the centre frequency and span, video bandwidth (VBW) and resolution bandwidth (RBW). The centre frequency and span represent the bandwidth to be measured. It can be expressed also as the start and stop frequencies. The VBW adjusts the smoothness of the trace of the measured samples just like each measured block is averaged to produce a clean trace. Lastly, the RBW is dependent on the signal type. Narrow-band signals require higher FFT length or block size of N to achieve better frequency resolution. ITU-R recommends a maximum of half the bandwidth of the measured signal (Bureau, 2011). In a FM band for instance the RBW should be no more than 100 kHz. However, higher resolution comes at a cost, the resulting spectrum is noisier, which makes it harder to recognize the real signal of interest. Also, better resolution means longer sample collection time as processing time increases, which compromises the time resolution.
This process, of collecting X samples should ensure the right choice of the measurement parameters due to the type of signal being measured. Suppose the band, 791 MHz to 960 MHz, is to be measured then the question is what size frequency hopping step should be taken? As previously mentioned, the spectrum obtained for each centre frequency covers 25 MHz and the measurement is overlapped at 50% to correct the attenuated edges in the DDC. The entire band to be measured is 169 MHz which is clearly higher than the 25 MHz limit. Therefore, the entire band is captured in successive steps. At 25 MHz sample rate, the number of steps is given as: (1) Therefore, for the 791 MHz to 960 MHz band the number of steps calculated by Equation 1 turns out as 7 steps. This number of steps leads to a small value of revisit time and POI. Next is the question of what value of RBW should be used? It should be noted that the choice of RBW affects the processing time and the lower the value of RBW, the higher the sweep time for the fixed number of steps (7 steps in the case considered band). If we choose N to be 128 then X and N are related by: Then each FFT segment will contain 128 frequency bins and due to the overlap in frequency, only 50% of these bins will be used. Hence in total there should be 128 × 0.5 × 7 = 448 FFT bins in the measured band. The resulting frequency resolution can be calculated as: The RBW for the 791 MHz to 960 MHz band example is therefore equal to 377.2 kHz. It is also possible to change the sample rate to less than 25 MHz, with corresponding overlap to any other value than 50% but no more than 75% (Seeber, 2014).
The architecture of the design is illustrated in Figure 4, while the test setup is shown in Figure 5. It shows the entire process of the spectrum analysis. The measurement to produce the file metadata and the post-processing to produce the spectrum plots. The separate operations are both python programs and are used with the required parameters. The spectrum analyser takes parameters like the sample rate, start and stop frequencies, the gain, the FFT length, the dwell time, the tune delay, the time of measurement and lastly the location of the saved file metadata. The post-processing program takes the file metadata location and the sample rate. It produces the plot of a sweep of the measured band and the spectrogram plots.  Another test of the design was taken in the FM band, 87.5 MHz to 108 MHz and the FFT plot is shown in Figure 8(a). The measurement is taken at 4 Msps which gave 1408 FFT bins resulting in a RBW of 14.56 kHz. The test setup made observations of the design using a comparison of the spectrum plot of the swept spectrum analyser that was designed and a narrowband measurement whereby the USRP B210 was tuned to the centre frequency of 97.75 MHz and capturing the 20.5 MHz bandwidth at a RBW of 20.02 kHz. The narrowband measurement was designed in GNU Radio 3.8 using the GUI Frequency Sink for visualization of the signals captured by the USRP B210. It was observed as shown in Figure 8 that the low SNR signals were difficult to spot in the swept spectrum analyser compared to the real time narrowband measurement. The observation is significant with lower RBW as the noise floor rises and buries the signal when measurements are made at lower RBW. It was also observed that the design had a lot of up and down movements of the resulting FFT plots that were saved during measurement. The movements are very dramatic when the choice of measurement parameters is not right for the measurement such that there is a significant mismatch in the rate at which the USRP B210 is producing samples to the rate at which the host PC is processing samples. Sometimes during the research, it was corrected by dropping more samples as they came to reduce this mismatch between the rate at which samples were received and the rate at which they were processed. The measurement attained a possible range of RBW during the research, hitting as low as 3.906 kHz and as high as 602.5 kHz for a 617 MHz bandwidth.
Among the findings highlighted, the most significant in wideband sensing are the time resolution and RBW. In these two aspects the results in the proposed design have a close correlation with that presented by Liu, et al. (2011). In the test carried out by Liu, et al. (2011), the measurement was done in the 2.4 GHz ISM band with frequency span of 100 MHz. Using the swept spectrum analyser that was designed in their research, they attained a time resolution of 6 sweeps per second and a resolution bandwidth of 98 kHz which were better values compared to the Airmagnet spectrum adapter that was used (Liu, et al., 2011). In this study, the corresponding values of time resolution and RBW used were 0.125 sweep per second (or 1 sweep in 8 seconds) and 60.014 kHz for measurement in the 791 -960 MHz band (equivalent to a 617 MHz bandwidth). To make a fair comparison, the values of the measurement can be approximated for a 100 MHz bandwidth measurement. Such that the time resolution corresponds to 0.875 sweep per second and the RBW will be significantly lower as the frequency span has reduced. The results show that the time resolution, though comparable to that of the Airmagnet (1 sweep per second) is still a fair value for high POI and the RBW that the study achieves is much better without a commensurate effect on the sweep time. Since at 100 MHz measurement, the RBW of 60.014 kHz for the 617 MHz bandwidth will be far less than its current value, therefore the RBW achieved by this study will be lower than that achieved by Liu et al. (2011) at 98 kHz.

Conclusion
The study presented a highly flexible sensing solution based on USRP B210 and GNU Radio. The study made observations of the design through comparison with narrowband measurement of the same band and showed that it is capable of achieving high resolution in the frequency domain. On the other hand, the hardware is relatively small and cheap compared to professional spectrum analysers, yet powerful enough to achieve real-time wide-band sensing.