Soft Real Time Implementation of a Cognitive Radio ...

10 downloads 16621 Views 1MB Size Report
achieve this with a soft-real time technique which enables a fully software .... The PSD vector with float values is then sent to a sink block. The sink block ... Conversion. Windowing & ..... our setup by transmitting video and achieved good quality ... Radio,” http://gnu.cs.pu.edu.tw/software/gnuradio/doc/exploring-gnuradio.html.
Soft Real Time Implementation of a Cognitive Radio Testbed for Frequency Hopping Primary Satisfying QoS Requirements Adarsh Jain1 , Vinod Sharma and Bharadwaj Amrutur Dept. of ECE, Indian Institute of Science Bangalore 560012, India Email: [email protected], {vinod, amrutur}@ece.iisc.ernet.in Abstract—The Cognitive Radio (CR) is a promising technology which provides a novel way to subjugate the issue of spectrum underutilization caused due to the fixed spectrum assignment policies. In this paper we report the design and implementation of a soft-real time CR MAC, consisting of multiple secondary users, in a frequency hopping (FH) primary scenario. This MAC is capable of sensing the spectrum and dynamically allocating the available frequency bands to multiple CR users based on their QoS requirements. As the primary is continuously hopping, a method has also been implemented to detect the hop instant of the primary network. Synchronization usually requires real time support, however we have been able to achieve this with a soft-real time technique which enables a fully software implementation of CR MAC layer. We demonstrate the wireless transmission and reception of video over this CR testbed through opportunistic spectrum access. The experiments carried out use an open source software defined radio package called GNU Radio and a basic radio hardware component USRP. Keywords: Cognitive radio (CR), Frequency hopping (FH), GNU Radio, Opportunistic Spectrum Access, Python, Spectrum sensing, Universal Software Radio Peripheral (USRP).

I.

I NTRODUCTION

Frequency spectrum scarcity is currently one of the most challenging issue in the field of wireless communications. The access to this limited resource is regulated by the government agencies all around the world. New wireless communication services require more bandwidth and hence need extra spectrum. Consequently, the frequency spectrum has become scarce. However the utilization of the assigned spectrum is between 15% to 85% [1]. A possible solution to this problem is opportunistic Spectrum Access, realized by the use of Cognitive Radio technology [2]. Cognitive radios have the ability to detect unused spectrum segments and adapt to it dynamically in an intelligent way. Its underlying enabling technology is software defined radio (SDR), which is a radio communication system where components that have been typically implemented in hardware are instead implemented by means of software on a personal computer or embedded system. The CR user or secondary user can utilize the available bandwidth for transmission of its own data immediately after 1 author is with Space Applications Centre, ISRO, Ahmedabad, India. This work was done in IISc, Banglore while author was doing his master’s degree.

c 2014 IEEE 978-1-4799-2361-8/14/$31.00

the spectrum sensing. Because of the strong signal from its own transmitting antenna and proximity to the receiving antenna, it cannot sense the presence of licensed or primary user over the same frequency band to which it is transmitting. It is an important issue in the design of any CR system because backing off, when the primary comes to the same band, is one of the prime objectives of the CR users. This can be achieved by stopping transmission from secondary periodically and check whether the primary is back in the channels that were earlier identified as free. This method can be applied to a FH primary signal that changes its channel occupancies periodically with a period known to secondary users. It is a widely used technique in secured applications such as military communications. There is very little open literature available that discusses CR implementation for these kind of FH primary signals. The authors in [3] demonstrate a CR MAC implementation for a FH primary using a embedded FPGA platform provided by Lyrtech. We extend this work to implement the CR MAC on a more generic SDR platform, USRP [4], which is lower cost and hence is more widely used. The key challenge of synchronization is overcome by using a soft-real time approach in our work, which enables a purely software implementation of the CR MAC. We demonstrate that multiple secondary users can co-exist with a FH primary, without affecting its operation. The USRP [4], a general purpose processor based SDR platform, in conjuction with a software tool named GNU Radio [5][6] is used for experimental work. We have focused on the design and implementation of a spectrum sensing engine, synchronization among primary and secondary users and a MAC layer to setting up the secondary network which does the channel allocation based on the QoS requirements of the secondary users. A soft real time clock concept has been incorporated in our design to achieve the time accuracy very close to the embedded FPGA based architecture. The wireless transmission and reception of video through opportunistic spectrum access has also been demonstrated over CR testbed. This paper is organized as follows. Section II presents the implementation details for spectrum sensing and experimental results. In Section III we describe the design of CR MAC for FH primaries. A technique, used to identify the hop instant of the primary, is also presented. Section IV presents the experimental setup and test results. Section V describes the mechanism developed for video transmission through opportunistic spectrum access. Finally, we conclude the paper in

II.

I MPLEMENTATION OF S PECTRUM S ENSING

In our testbed FFT Averaging Ratio (FAR) algorithm, as described in [7], is used for spectrum sensing. It is a blind spectrum sensing method based on energy detection which is insensitive to the noise variance. Implementation of FAR algorithm can be illustrated with the help of flow graph, presented in Fig.1, which gives the detailed design description in a progressive way. After initialization of USRP source by passing the required parameters like sampling rate, frequency band of operation, gain etc., it fetches the RF signal of the desired frequency from real time environment. The signal is then passed through USRP which outputs a stream of complex samples, which are then converted into vectors of size same as that of the FFT length. In the next step data is passed through a windowing function prior to FFT computation. The complex FFT vector is then converted into a float vector, which represents the power spectral density (PSD) in each FFT bin. The PSD vector with float values is then sent to a sink block. The sink block, written in a separate C++ module, is the heart of the algorithm design and is mainly responsible to perform wideband spectrum sensing by automatically tuning the USRP to sweep a large bandwidth in steps. As USRP2/N210 hardware is capable of scanning a maximum bandwidth of 25 MHz at a time, if we want to sense a wide band greater than 25 MHz it is required to tune the USRP’s center frequency by passing tuning parameters such as tune delay and dwell delay to the sink function. It also computes the averaging of FFT frames over a time period determined by the dwell delay parameter. The number of FFT frames over a period of dwell delay can be calculated as,

Start Tune center freq. (wait for 10 ms)

Initialization

Stream to Vector Conversion

USRP Source

Windowing & FFT

Sink (averaging & buffering)

Magnitude Squared

NO Decision (H0 / H1)

Sense all channels ?

Get data (call back function)

YES End

Fig. 1.

Flow chart indicating spectrum sensing implementation TABLE I.

M AIN PARAMETERS FOR I MPLEMENTATION

Name BW Freq. band FFT length No. of FFT frames Dwell delay (sensing duration) SNR

Value 25 MHz 700 to 725 MHz 64 ∼390 1 ms 10 dB

ROC curves 1

0.9

10 dB 5 dB 0 dB −5 dB −15 dB −20 dB

0.8

0.7

0.6

Pd

Section VI.

0.5

0.4

No. of FFT frames = (dwell delay * sampling rate)/ FFT size (1)

0.3

0.2

After calculating the average it composes a message consisting of a counter and a vector obtained after averaging of FFT frames. The message is then stored in a message queue. The value of the k th index of vector represents the averaged energy in that bin. After that, the message vector is called from the sink using a callback function and the decision statistics is formed for the FAR algorithm, which is then compared to a threshold to determine channel occupancy vector. The channel occupancy vector is a combination of 1’s and 0’s which represents the primary presence and absence respectively. The hardware also introduces a spike at the center frequency due to DC offset and can be eliminated by dropping the central FFT bin while doing channelization. The main parameters for implementation are tabulated in Table I. The dwell delay is the time period over which samples are taken to form FFT frames for sensing after discarding tune delay samples. Dwell delay is the actual sense time and chosen to be 1 ms. The tune delay is the time needed to change the center frequency of the USRP receiver while tuning. When we command the USRP to change its center frequency to perform wideband sensing, we have to wait until correct ADC samples arrive to our FFT block. This is done by dropping the incoming received samples over a time period specified by tune delay, found to be 10 ms, is omitted from our implementation as we are not tuning the frequency of USRP. This sensing algorithm

0.1

0

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

Pfa Fig. 2.

ROC curves for different SNR values

is a modified version of the usrp spectrum sense.py which can be found in GNU Radio example programs. The sensing duration obtained with this original energy detection algorithm was somewhere around 11 − 20ms for a single frame, that too was varying from system to system. This is mainly due to the tuning functionality embedded with this algorithm. The sensing duration even without tuning was around 1 − 10ms for a single frame. Because we wanted to operate over 25 MHz bandwidth for this work, we have completely removed the tuning part and wrote the C++ as well as python module in a new way to incorporate the functionality of averaging of FFT frames and to make sensing more robust and fast. In this way we have achieved the sensing duration of 1 ms for nearly 390 frame averaging, which is a huge improvement over earlier inconsistent duration of 1 − 10ms. Fig.2 shows ROC curves (i.e. Pd versus Pf a ) for different SNRs. The characterization of SNR is done through the FFT/ Waterfall plot which is a readily available sink block in GNU radio companion (GRC).

III.

START

CR MAC DESIGN FOR FH PRIMARIES

The cognitive radio MAC should be very flexible and can provide adequate services to secondary users while enforcing protection mechanisms for primary. In general a cognitive radio MAC should fulfil the following functions. • Scheduling spectrum sensing and avoidance of interference to the primary network • Formation of secondary network • Channel allocation and guaranteeing a certain Quality of Service(QoS) • Efficient utilization of the spectrum opportunities

A

Hop instant identification

initialize n (nn) again comes the network entry phase where new slave nodes can join the network by requesting master node for channel allocation.

B. Soft Real time design for the CR MAC The USRP is a general purpose processor based SDR platform and therefore a user cannot play with the system clock when using this platform. To maintain the timing accuracy is thereby highly critical as compared to the embedded FPGA based SDR platform. In this work we have considered the FH primary with a hopping period of Th = 100ms. So for the implementation of a MAC protocol in this scenario, timing accuracy of the order of ms is needed. The simple and straightforward way to include timing information is to use time/ wait/ sleep functions available with the python. But these functions are based on the CPU timing and have accuracy of the order of 10’s of ms. With these functional blocks the program run time also varies from system to system. Therefore the system implementation, where MAC layer plays an important role and to maintain timing is very critical, cannot be relied upon these functions. To achieve the timing accuracy very close to the embedded FPGA based architecture, a soft real time clock concept has been incorporated into the secondary design along with the functionality of a MAC protocol. The real time data comes continuously from the USRP board, the spectrum sensor takes only 1ms to output a channel occupancy vector. The spectrum sensor design as described previously is based on a python module, C++ module and a callback function. Whenever it is needed to sense the spectrum, a callback function is used from the python to get the message vector out from the C++ module containing channel occupancy vector and a counter. Every time when the callback function is used, the counter value is incremented by one which corresponds to the 1 ms time duration and is used to keep track of timing. 25 Msps USRP Source

Stream to Vector conversion

Windowing & FFT

Magnitude Squared

Sink (averaging & buffering)

(receiver sensing chain) 2 Msps Band Pass Filter (BPF)

Resampler

Demodulator

Callback function

(receiver demodulator chain) 2 Msps Modulator

USRP Sink

(Transmitter chain)

Fig. 7.

C. Hop instant identification Hop instant identification to achieve the synchronization with the FH primary is essential to minimize the interference to the primary due to secondary users and to reduce throughput loss to secondary. This can be achieved if the secondary senses the channel at the start of each hop, starts transmitting in free channels and stops before the start of the next hop. If the spectrum sensing is done immediately after the hop instant, it can be ensured that the primary occupancy pattern will not change for the remaining Th − Tss duration where Tss denotes the sensing duration. A method to identify the hop instant of FH primary is described in [3], which closely parallels that of [8] in which a method of estimation of FH signal boundary is presented. We carried out hop instant identification for 10 hops, leads to an array index value above the threshold. This value corresponds to the offset between primary and secondary user and hence the time stamping in accordance to this value is used to achieve the synchronization. IV.

Sink (C++ module)

Data packets

are scanning a bandwidth of 25 MHz at a time. Whereas the demodulator chain operates on a very low data rate such as 2/4 Msps because of the channelization plan of secondary users. Here one important practical observation is that, because of the hopping scenario if we keep switching the USRP sampling rate between these two values, we will get the garbled data initially for some frames. This results in a erroneous channel occupancy vector. Similarly demodulator chain also does not work properly for the reception of packets, immediately after changing the sampling rate. So to overcome this problem, demodulator chain is designed in parallel to the sensing chain such that there is no need of changing USRP sampling rate. A resampler is used to down convert the USRP sampling rate to desired value and for frequency tuning a BPF is used. Similarly for the transmitter side, sensing chain is used to achieve the precise control of timing. Suppose transmitter wants to transmit data for a duration of 90ms then this timing can be set accurately by making use of the sensing chain.

Block diagram showing soft-real time design for secondary user

The secondary receiver design as presented in Fig.7 consists of two chains viz. sensing and demodulator running in parallel. Apart from being used as a spectrum sensor, this sensing chain can also be utilized to maintain the timing accuracy. In other words suppose it is required for the demodulator chain to wait, say for 5ms, we make use of the callback function 5 times to achieve the timing very close to 5ms. The complex sampling rate of USRP is 25 Msps as we

E XPERIMENTAL S ETUP AND R ESULTS

The 25 MHz RF bandwidth ranging from 700 to 725 MHz is split into 25 primary channels and 12 secondary channels of 1 MHz and 2 MHZ respectively as shown in the channelization plan Fig.8. A FH primary hops among the 25 channels with an hopping duration of 100ms. The bands S1 to S12 are the data channels for the secondary network. The band S11 between 721 MHz and 723 MHz is the control channel. Fig.9 shows the setup used for implementing the primary and secondary network. One USRP device is used as the primary to generate the FH signal. Four other USRP platforms are used as secondary users, one of them acts as the master and others act as slave nodes. One more USRP device is used to obtain the spectrum occupancy plot of all the nodes in the network. To connect multiple USRP devices to the same PC, gigabit ethernet switches and CAT6 cables are used. Fig.10 and Fig.11 show the spectral occupancy plot for 25 MHz bandwidth centred around 712.5 MHz in a sequential and random hopping pattern respectively. The central frequency band of 1 MHz around 712.5 MHz is omitted because of higher spectral leakage to avoid false alarm. Initially the master takes 10 hops to achieve the synchronization with the

Primary Users Secondary Users

P2

P3

S12

S11 P22

P4

P24

P23

700 MHz

Fig. 8.

P25 725 MHz

Channel structure

primary. Immediately after the synchronization handshaking between the master and the multiple slave nodes takes place by transmitting beacon and network entry entry packets, as can be seen in the Fig.10. Here slave-3 is considered to have the higher QoS requirements and hence allocated a spectrum of 4 MHz for its transmission. All other secondary nodes occupy a bandwidth of 2 MHz. When the primary signal occupies channel P 22 or P 23 i.e. control channel is busy, the beacon packet is not sent on the control channel to avoid interference to the primary user and hence no secondary data communication happens. It can also be seen that secondary user transmission immediately switches to a new channel only when the primary hops to the same channel previously occupied by secondary user. In this way, we achieve the secondary network data communication without interrupting primary and also unnecessary switching for the secondary network is avoided. In the plot, the frequency bands with red color (higher power) are the primary and secondary user transmissions. Primary

705

710 715 Frequency (MHz)

720

725

Plot showing spectrum occupancy for primary and secondary users

No Transmission !!!

Control channel busy

No Transmission !!!

700

705

710 715 Frequency (MHz)

720

725

Plot showing spectrum occupancy for primary and secondary users

Slave-3 Master

Ethernet Switch

Host PC-3

Host PC-1 Host PC-2

V.

Fig. 10.

Fig. 11.

Slave-2

Slave-1

Fig. 9.

Master 700

Time

P1

S2

Beacon Pkts

Slave3 Pkts

Slave2 Pkts

Time

S1

Primary

Slave1 Pkts

Testbed for Cognitive Radio system

A V IDEO TRANSMISSION THROUGH O PPORTUNISTIC S PECTRUM ACCESS

The popularity of video streaming is soaring silently through the streaming media market. The cognitive Radio is a promising technology to fulfil this demand without even affecting the licensed user performance and hence thereby increasing spectrum utilization efficiency. The system design consist of two slave nodes, one acts as video transmitter and other as receiver. To produce the video stream using VLC player, H.264 encoding is used. The streamed data is sent to video transmission block. Video transmission block consists of a UDP source, buffer, packet encoder and GMSK modulator [9], which are readily available blocks in the GNU radio. The

encoded streaming data generated by VLC player is first sent to the UDP port. This UDP port, with the IP address of 127.0.0.1, acts as an interface between VLC player and the GNU Radio. The received encoded stream is then passed to a buffer. Whenever a slave node receives the beacon packet containing the channel allocation information, it picks the data from the buffer and passes it to packet encoder. Packet encoder then encodes the data using 1 bit/symbol and 2 samples/symbol. Then the packetized data, where each packet size is of 1500 bytes, is modulated by the GMSK modulator and sent out to USRP device through gigabit ethernet switch. For video reception another USRP device is used which acts as a receiver and performs all the operations through GNU radio as done in transmitter but in reverse order. Whenever a slave node receives a beacon packet containing the channel allocation information about reception, which is same as that of transmitter, tunes its antenna to that frequency and captures the data transmitted from another slave node. The data is then demodulated using GMSK demodulator and decoded into bit streams. This bit stream is then forwarded to UDP sink or file sink (buffer) and can be played on VLC player. A. Experimental Results To observe the variation in latencies associated with the general purpose processing, multiple packets have been transmitted at the time interval of 100ms. The received packets latency profile is shown in Fig.12, over three different times

T1, T2 and T3. It can be seen that significant number of packets have been received at the time interval other than the target value of 100 ms. The latency variation is somewhere around ± 5ms which is mainly due to the randomness associated with GNU radio processing time and the bus delay. Because of this timing uncertainty, at the transmitter and the receiver side, we restrict the secondary user to communicate only for 60ms duration in a 100ms time slot. For the transmission of video, slave node sends the data at an average rate of approx. 0.5 Mbps. The quality of received video can be judged

Deviation (from value 100)

Fig. 14.

Received packets

Fig. 12.

Plot showing variation in latencies

through the snapshot of the received (Fig.14) and transmitted video sequence (Fig.13) and it can be seen that quite a faithful reproduction of video is achieved through opportunistic spectrum access over CR testbed without interfering with the primary. The measured packet loss at the receiver side was below 2 %.

Snapshot of received video sequence

achieved by using a call-back to the FAR sensing routine. A technique to identify the hop instant of a FH primary has also been implemented. Our MAC sets up the secondary network in the presence of FH primary, capable of channel allocation to CR users based on their QoS requirements. We evaluate our setup by transmitting video and achieved good quality reception by means of opportunistic spectrum access. The experiments were conducted using GNU Radio as a software tool and USRP as a hardware platform. Further research is needed for the design of MAC in case of multiple primary users which are not synchronized and hopping at a fast rate. Distributed secondary network and control channel design are also some of the remaining challenges. ACKNOWLEDGMENT The authors would like to thank the Defense Electronics Applications Laboratory (DEAL), Dehradun for their financial assistance. The first author would also like to acknowledge Space Applications Centre, Ahmedabad, for giving him the opportunity to pursue a master’s degree from IISc, Banglore. R EFERENCES [1]

[2]

[3]

Fig. 13.

Snapshot of transmitted video sequence

VI.

C ONCLUSION

We have presented the design and implementation of an optimized FAR spectrum sensing algorithm in the FH primary environments which achieves a sensing duration of 1ms for 390 frame averaging. This is a huge improvement over a simpler, naive python implementation which takes anywhere between 1 to 10 ms for a single frame. We have also presented the design of a soft - real time CR MAC which enables a fully software implementation on a generic SDR platform. This is

[4] [5] [6] [7]

[8]

[9]

I. F. Akyildiz, W. Y. Lee, M. C. Vuran, and S. Mohanty, “NeXt generation/ dynamic spectrum access / cognitive radio wireless networks: A survey,” Computer Networks Journal (Elsevier), Sept. 2006. Mitola III, J., Maquire Jr., G.Q. “Cognitive radio: making software radios more personal,” IEEE personal communications vol. 6, no. 4, pp. 13-18, August 1999. Prasanna R., Bharadwaj Amrutur, “Cognitive Radio Implementation for a Frequency Hopping Primary Signal,” in Proc. National Conference on Communications (NCC), New Delhi, India, Feb 2013. Matt Ettus, Universal software radio peripheral, http://www.ettus.com. gnuradio wiki, http://gnuradio.org/ E. Blossom, “Exploring GNU Radio,” http://gnu.cs.pu.edu.tw/software/gnuradio/doc/exploring-gnuradio.html Chen Zhe, Guo Nan and Qiu R.C., “Demonstration of Real-time Spectrum Sensing for Cognitive Radio,” in Proc. The Military Communications Conference, pp. 323-328, November 2010. A. Gok, S. Joshi, J. Villasenor, and C. Danijela, “Estimating the Number of Frequency Hopping Interferers using Spectral Sensing with Time and Frequency offset measurements,” in Proc. MILCOM, pp. 1-7, October 2009. F. Ge, C. Chiang, Y. Gottlieb, and R. Chadha et al. “GNU Radio-based digital communications: Computational analysis of a GMSK transceiver,” in Proc. IEEE Global Communications Conference (GLOBECOM), 2011.

Suggest Documents