Sunteți pe pagina 1din 37

FUZZY BASED DECISION FUSION FOR CO-OPERATIVE SPECTRUM SENSING IN COGNITIVE RADIO

PROJECT REPORT Submitted in partial fulllment of the requirements for the award of the degree of Bachelor of Technology in ELECTRONICS AND COMMUNICATION ENGINEERING of MAHATMA GANDHI UNIVERSITY by SIJO JOSEPH(201054) MITHUN MATHEW(201015) NITHIN CLEETUS(201027) PAUL JAMES(201029)

Department of Electronics and Communication Engineering Rajagiri School of Engineering and Technology Rajagiri Valley, Kakkanad, Kochi, 682039 2012-2013

Rajagiri Valley, Cochin - 682 039


DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

CERTIFICATE

Certied that this a bonade report of the project titled FUZZY BASED DECISION FUSION FOR CO-OPERATIVE SPECTRUM SENSING IN COGNITIVE RADIO Sijo Joseph (201054) of eighth semester Electronics and Communication Engineering in partial fulllment of the requirement for the award of degree of Bachelor of Technology in Electronics and Communication Engineering of the Mahatma Gandhi University, Kottayam, during the academic year 2012-2013.

Mr. Jaison Jacob Project Guide

Mr.Jaison Jacob Head of Department

Place: Kakkanad Date:

ACKNOWLEDGEMENTS

I wish to take this opportunity as our privilege to thank all whose persistent contributions have helped me in the fulllment of this project. First and foremost I would like to thank almighty God whose grace was there throughout the course of the project. I would like to express my deep gratitude to our guide Mr.Jaison Jacob, HOD, Dept. of Electronics, RSET for his proper guidance and unstinted support and also for providing us with valuable suggestions during the course of this project. I would also like to thank my teachers Dr.Jobin K Antony and Mr Rony Antony A.P. for their valuable guidance throughout the course of this project. Last but not the least I would like to thank for the help and support given by my friends without whom this endeavour would not have been a success.

ABSTRACT

With the proliferation of wireless communication technologies, the unlicensed bands available for communication purposes are becoming more and more limited. Also, surveys state that the licensed bands are under-utilized. Cognitive Radio systems sense the under-utilized parts of the spectrum and allocate them for wireless communication to other users, thereby increasing the ecient usage of the spectrum. Spectrum sensing refers to the process cared out by the system to check whether the primary user is using the spectrum at an instant of time. It is one of the most challenging issues in Cognitive Radio Systems. This project focuses on co-operative spectrum sensing and decision making using fuzzy logic. Co-operative sensing technique is used in order to reduce the eect of fading and shadowing in decision making about the presence of the primary user in the spectrum. This is done by considering parameters such as SNR and power from multiple nodes before a decision is made. To simulate the working of the system, the primary users transmitter, channel and cognitive radio terminals receiver section is modeled in Matlab. A Rayleigh channel model is used to create a scenario that closely represents fading in urban environments which is caused due to high rise buildings. Parameters such as Probability of Fault Detection and Probability of Detection are computed to evaluate the performance of the system. These parameters are also plotted for single node sensing, OR and AND Rule, to compare the results with fuzzy based decision-making. The results indicate that the decision obtained through fuzzy logic boasts a high probability of detection and low probability of fault detection, when compared with single node decision making. In addition, the accuracy of the results and drawbacks of fuzzy based decision making are discussed.

List of Figures

2.1 2.2 2.3 4.1 4.2 4.3 4.4 4.5 6.1 6.2 6.3 6.4 6.5

Block Diagram of Energy Detection Method . . . . . . . . . . . . . . . . . Block Diagram of Cyclostationary Method . . . . . . . . . . . . . . . . . . Block Diagram of Matched Filter Method . . . . . . . . . . . . . . . . . . Block Diagram of Transmiter Block Diagram of Channel . . Block Diagram of Receiver . . Fuzzy Fusion Center . . . . . Membership Function . . . . . Area Under Consideration . . Zoomed View . . . . . . . . . Generated Waveforms . . . . Probability Of Fault Detection Probability Of Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4 4 5

. 9 . 9 . 11 . 13 . 13 . . . . . 24 25 25 26 27

iv

List of Tables

4.1

Fuzzy Rule Base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

Contents

Acknowledgements Abstract List of Figures List of Tables 1 INTRODUCTION 2 LITERATURE SURVEY 2.1 COGNITIVE RADIO . . . . . . 2.2 SPECTRUM SENSING . . . . . 2.2.1 Energy Detection Method 2.2.2 Cyclostationary Method . 2.2.3 Matched Filter Method . . 2.3 FUZZY LOGIC . . . . . . . . . .

ii iii iv v 1 2 2 2 3 3 4 5 7 8 8 9 9 10 11 11 12 12 12

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

3 SPECTRUM SENSING USING FUZZY LOGIC 4 COMMUNICATION SYSTEM MODELLING 4.1 PRIMARY USER . . . . . . . . . . . . . . . . . 4.2 CHANNEL MODELLING . . . . . . . . . . . . 4.2.1 Additive White Gaussian Noise (AWGN) 4.2.2 Rayleigh Fading Model . . . . . . . . . . 4.3 COGNITIVE RADIO SECTION . . . . . . . . 4.3.1 Band Pass Filter . . . . . . . . . . . . . 4.3.2 Energy Detector . . . . . . . . . . . . . 4.3.3 Demodulator . . . . . . . . . . . . . . . 4.3.4 Fuzzy Block . . . . . . . . . . . . . . . .

. . . . . . . . . . Channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

5 SOFTWARE IMPLEMENTATION 14 5.1 MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 vi

5.2 5.3

MATLAB PROGRAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 FUZZY FILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

6 STIMULATION AND RESULTS 24 6.1 INITIAL SCENARIO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 6.2 SIMULATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 7 CONCLUSION REFERENCES 28 29

Chapter 1 INTRODUCTION

Recent studies by FCC (Federal Communications Commission) have shown that there is scarcity of spectrum available and also underutilisation of licensed spectrum. Cognitive radio was developed with an aim to compensate for these problems. Cognitive radio is an intelligent transceiver which can detect vacant radio spectrum and communicate through that spectrum. Cognitive radio thereby increases the eciency of spectrum utilisation. Spectrum sensing is a key aspect of cognitive radio to detect the presence of Primary Users transmission. Our project uses Fuzzy logic to make the spectrum sensing decision. Spectrum sensing is done with inputs from neighbouring nodes so as to increase the probability of correct decision. Entire communication system has to be modelled in Matlab in order to simulate the cognitive radio network. Hence, transmitter, receiver and channel modelling are done. Channel modelling is done so as to incorporate channel eects on a primary signal. These eects include fading and white noise. In our simulation we use Rayleigh fading so as simulate signal propagation in urban area where there is no line of sight communication. Transmitter acts as the Primary user, and receiver acts as the Cognitive radio. Spectrum sensing is done in the cognitive node by energy detection method. Final decision is made by combining other neighbouring nodes inputs in fuzzy logic.

Chapter 2 LITERATURE SURVEY

2.1

COGNITIVE RADIO

Cognitive Radio smartly senses and adapts with the changing environment by altering its transmitting parameters, such as modulation, frequency, frame format etc. The concept was rst originated by Defense Advance Research Products Agency (DARPA) scientist, Dr. Joseph Mitola and the result of that concept is IEEE 802.22, which is a standard aimed at using cognitive radio for Wireless Regional Area Network (WRAN) using white spaces in the TV frequency spectrum while assuring that no harmful interference is caused to the incumbent operation, i.e., digital TV and analog TV broadcasting, and low power licensed devices. 2.2 SPECTRUM SENSING

A major challenge in cognitive radio is that the secondary users need to detect the presence of primary users in a licensed spectrum and quit the frequency band as quickly as possible if the corresponding primary radio emerges in order to avoid interference to primary users. This technique is called spectrum sensing. Spectrum sensing detects the availability of the radio frequency spectrum in a real-time fashion, which is essential and vital to cognitive radio. It detects the availability of the spectrum for secondary users in the CR network. The eectiveness of spectrum sensing largely determines the overall spectrum utilization[4]. A good spectrum sensing algorithm should oer high probability of detection at low probability of false alarm for a wide range of signal to noise ratio (SNR). Spectrum Sensing can be done either as Single node sensing or as Cooperative sensing. In single node sensing, only one CR is involved in the entire decision making process. Results from neighboring CR are not considered. In cooperative sensing, the CR takes

results of the neighboring CR as input to make the nal decision[2]. Cooperative sensing can be Distributed or Centralized. In distributed sensing the decisions of each CR are shared among themselves and each CR can make use of neighboring CRs result to take the nal decision. In cooperative sensing, the neighboring nodes decision are passed to a center node where it is combined to get a nal decision[2]. Various methods of spectrum sensing: 1. Energy Detection Method. 2. Cyclostationary Method. 3. Matched Filter Method.
2.2.1 Energy Detection Method

It is a non-coherent detection method that detects the primary signal based on the sensed energy .Due to its simplicity and no requirement on a priori knowledge of primary user signal, energy detection (ED) is the most popular sensing technique. In order to measure the energy of the received signal the output signal of bandpass lter with bandwidth W is squared and integrated over the observation interval T. Finally the output of the integrator is compared with a threshold to detect weather the primary or licensed user is present or not. It can also be computed in frequency domain by averaging bins of a Fast Fourier Transform. In this the processing gain is proportional to FFT size N and the averaging time T. Increase in the size of FFT improves the frequency resolution which is helpful in detecting narrowband signals. Also if we reduce the averaging time it improves the SNR by reducing the noise power. It estimates the presence of the signal by comparing the energy received with a known threshold derived from the statistics of the noise. One of the major advantage of energy detection method is that it does not require any prior knowledge about the primary users signal[4].
2.2.2 Cyclostationary Method

Modulated signals are in general coupled with sine wave carriers, pulse trains,repeating spreading, hoping sequences, or cyclic prexes which result in built -in periodicity. Even though the data is a stationary random process, these modulated signals are characterized as cyclostationary, since their statistics, mean and autocorrelation, exhibit periodicity. This periodicity is typically introduced intentionally in the signal format so that a receiver can exploit it for: parameter estimation such as carrier phase, pulse timing, or direction of arrival. These features are detected by analyzing a spectral correlation function[4].

Figure 2.1: Block Diagram of Energy Detection Method

Figure 2.2: Block Diagram of Cyclostationary Method


2.2.3 Matched Filter Method

A matched lter (MF) is a linear lter designed to maximize the output signal to noise ratio for a given input signal. However, a matched lter eectively requires demodulation of a primary user signal. This means that cognitive radio has a priori knowledge of primary user signal, e.g. modulation type and order, pulse shaping, packet format. Matched lter operation is equivalent to correlation in which the unknown signal is convolved with the lter whose impulse response is the mirror and time shifted version of a reference signal[4].

Y [n] =
k=

h [n k ] x [k ]

(2.1)

Where x is the unknown signal (vector) and is convolved with the h, the impulse response of matched lter that is matched to the reference signal for maximizing the SNR. Detection by using matched lter is useful only in cases where the information from the primary users is known to the cognitive users. For spectrum sensing, primarily three methods are proposed in literature: Matched lter, Energy Detection and Cyclo-stationary feature detection[3]. Matched ltering is optimal but requires detailed knowledge of primary signal. When no such knowledge is

Figure 2.3: Block Diagram of Matched Filter Method available an Energy Detector is optimal [4]. Hence we go for Energy detection sensing method in our project. Cooperative spectrum sensing where the decisions of dierent neighbouring nodes are fused to obtain the nal decision has been studied in [2]. Cooperative sensing improves the probability of detection when compared with single node sensing [2]. All the studies mentioned above uses dierent algorithms to combine the decisions from neighbouring nodes. 2.3 FUZZY LOGIC

A human has a remarkable capability to perform a wide variety of physical andmental tasks without any measurements and any computations.Fuzzy logic is a superset ofconventional(Boolean) logic that has been extended to handle the concept of partial truthtruthvalues between completely true and completely false.As its name suggests, itis the logic underlying modes of reasoning which are approximate rather than exact.Theidea of Fuzzy Logic was conceived by Pr. LOTFI A. ZADEH in the year 1965. The purpose of fuzzy logic is to realize sophisticated control systems consideringthat many times real problems cannot be eciently expressed by means of mathematicalmodels. So,fuzzy set theory models the vagueness that exists in realworld problems.According to this theory, when A is a fuzzy set and x is a relevant object, the propositionx is a member of A is not necessarily true or false, but it may be true or false only tosome degree, the degree to which x is actually a member of A. It is common to expressdegrees of membership in fuzzy sets by numbers on the closed interval [0,1]. The extremevalues in this interval, 0 and 1, then represent, respectively, the total denial or armationof the membership in the fuzzy set. In fuzzy logic, each object x can be labelled by a linguistic term, where a linguisticterm is a word such as small, medium, large, etc. so that, x is dened as a linguisticvariable. 5

Each linguistic variable is associated with a term set T(x), which is the set ofnames of linguistic values of x. Each element in T(x) is a fuzzy set. To implement decision making processes, fuzzy logic makes use of the so called FuzzyLogic Controllers (FLCs). The essential part of a FLC is a set of linguistic control rulesbased on expert knowledge in the form: IF (a set of conditions are satised) THEN (a set of consequences can be inferred) A general FLC consists of four modules: a fuzzy rule base, a fuzzy inference engineand a fuzzication/defuzzication module. A FLC operates by repeating a cycle of vesteps implemented by these four modules. First, measurements are taken of all variablesthat represent relevant conditions of the controlled process. Next, these measurements areconverted into appropriate fuzzy sets to express measurement uncertainties. This step iscalled fuzzication. The fuzzied measurements are then used by the inference engine toevaluate control rules stored in the fuzzy rule base. The result of this evaluation is a fuzzyset (or several fuzzy sets) dened on the universe of discourse of possible actions. Thisfuzzy set is then converted, in the nal step of the cycle, into a crisp value (or a vector ofvalues). This conversion is called defuzzication. The defuzzied values represent actionstaken by the FLC in individual control cycles[1]. Implementation of fuzzy logic in decision making was studied in [1]. In our project we are passing power and SNR as input parameters to fuzzy logic, each with 3 membership function. Output parameter is the decision with only 2 parameter. Various performance analysis were also done.

Chapter 3 SPECTRUM SENSING USING FUZZY LOGIC

In this project, we are focusing on spectrum sensing using energy detection method and decision making using fuzzy logic. In order to simulate the working of the communication system, we modeled a transmitter, a communication channel, and a receiver. The transmitter acts a primary user and the receiver as the cognitive radio terminal.A Rayleigh channel model is used to create a scenario that closely represents fading in urban environments which is caused due to high rise buildings. Transmitter section consists of BPSK modulator. The signal produced in the transmitter is modulated and transmitted across the communication channel where eects of white Gaussian noise and Rayleigh fading are added.This Rayleigh faded signal is received at the receiver where a band pass lter is used to pass only the frequency band under consideration.Band pass lter also aids in noise rejection. The cognitive radio node uses energy detection method to nd the power of the received signal. In order to incorporate cooperative sensing, other cognitive nodes, i.e., the neighboring nodes are dened and thepowers received by them are also computed.These powersalong with SNR are taken as parameters for the fuzzy-based decision making. Output decision Yes or No is dened for all the combination of Power and SNR in Fuzzy rule base. Final output decision in Fuzzy is made with this rule base.To compare the results of fuzzy-based decision making, decisions from OR Rule, AND Rule and Single Node decision are considered. Performance analysis which include probability of detection and probability of fault detection for all these rules are plotted and compared.

Chapter 4 COMMUNICATION SYSTEM MODELLING

4.1

PRIMARY USER

The primary user acts as the transmitter. For simulation purposes, we have used the commonly used type of modulation, BPSK for the transmitted signal. A random bit stream of 10 bits is generated every time the program is executed. Each bit persists for a time period of 1ns. We have chosen a carrier signal of frequency 900MHz for BPSK modulation, as it represents one of the frequencies in the GSM range 890-915MHz. The sequence to be transmitted consists of 1s and 0s. 1 represents no phase change while 0 represents a phase change, in this modulation scheme. The bit stream is converted into bipolar format, ie, +1 for phase change, and -1 for same phase. x(t) = stream of 0s and 1s d (t) = {+1 f or x (t) = 1. d (t) = {1 f or x (t) = 0. The BPSK modulated signal takes either of the two forms s(t) = {Acos(W t) f or x(t) = 1. s(t) = {Acos(W t + pi) = Acos(W t) f or x(t) = 0. (4.3) (4.4) (4.1) (4.2)

Thus to obtain the modulated waveform, the carrier signal is multiplied with the bipolar information signal. s(t) = d(t)XAcos(W t). (4.5)

Figure 4.1: Block Diagram of Transmiter where A=sqrt(P) and P represents the power of the carrier waveform. 4.2 CHANNEL MODELLING

Figure 4.2: Block Diagram of Channel

4.2.1

Additive White Gaussian Noise (AWGN) Channel

Additive White Gaussian Noise (AWGN) is common to every communication channels, which is the statistically random radio noise characterized by a wide frequency range with regards to a signal in the communications channel. Gaussian noise comes from many natural sources, such as the thermal vibrations of atoms in conductors, shot noise, black body radiation from the earth and other warm objects[5]. AWGN shows following properties The noise is additive, i.e., the received signal equals the transmit signal plus some noise, where the noise is statistically independent of the signal.

The noise is white, i.e., the power spectral density is at, so the autocorrelation of the noise in time domain is zero for any non-zero time oset. The noise samples have a Gaussian distribution. This model does not account for dispersion, interference, fading, frequency selectivity or nonlinearity. Because of interference, multipath, terrain blocking etc., it is not suitable model for most terrestrial links. AWGN modies the transmitted signal according to the SNR value. For simulation purposes the SNR is randomly generated between -25dB and 10dB
4.2.2 Rayleigh Fading Model

Rayleigh fading is the name given to the form of fading that is often experienced in an environment where there is a large number of reections present. According to the assumption of this model a signal passes through such a transmission medium its amplitude will be changed randomly or in other words it will fade with respect to the distribution[5]. This model is normally viewed as a suitable approach to take when analyzing and prediction radio wave propagation performance for areas such as cellular communications in a well built up urban environment where there are many reections from buildings, etc. Rayleigh fading is a model that can be used to describe the form of fading that occurs when multipath propagation exists. In any terrestrial environment a radio signal will travel via a number of dierent paths from the transmitter to the receiver. The most obvious path is the direct, or line of sight path. However there will be very many objects around the direct path. These objects may serve to reect, refract, etc. the signal. As a result of this, there are many other paths by which the signal may reach the receiver. When the signals reach the receiver, the overall signal is a combination of all the signals that have reached the receiver via the multitude of dierent paths that are available. These signals will all sum together, the phase of the signal being important. Dependent upon the way in which these signals sum together, the signal will vary in strength. If they were all in phase with each other they would all add together .However this is not normally the case, as some will be in phase and others out of phase, depending upon the various path lengths, and therefore some will tend to add to the overall signal, whereas others will subtract. The Rayleigh fading model can be used to analyse radio signal propagation on a statistical basis. It operates best under conditions when there is no dominant signal (e.g.

10

direct line of sight signal), and in many instances cellular telephones being used in a dense urban environment fall into this category. Cognitive Radio is mainly applicable in urban environment. So chance for dominant line of sight between transmitter and receiver is not possible. That is why, we are going for Rayleigh fading model. y (n) = x(n) r(n) + n(n) (4.6)

y(n)Received signal x(n)Transmitted signal r(n)Rayleigh channel parameter n(n)AWGN noise 4.3 COGNITIVE RADIO SECTION

The transmitted signal is received by the cognitive node where the all the computation is done. The receiver section consists of a band pass lter, energy detector, fuzzy block and a demodulator section.

Figure 4.3: Block Diagram of Receiver

4.3.1

Band Pass Filter

Cognitive radio is concerned only with a band of frequency, i.e., particular frequency spectrum. Hence we go for a band pass lter which passes only the spectrum under consideration. In this project we have considered only one frequency band (GSM frequency band). A band pass lter with 3dB points at 800MHz to 1GHz was designed using matlab. The received signal was passed through this lter and hence only signals in this spectrum are used in power computation. Band pass lter also provide noise rejection thereby helping in signal demodulation.

11

4.3.2

Energy Detector

Spectrum sensing method used in this project is energy detection method. Energy Detection method is advantageous in the fact that we do not require any prior knowledge about the primary Users signal. In this method, the signal from band pass lter is passed to an energy detector. The band pass output is converted in frequency domain coecients using t function in matlab. Power of this signal is calculated by averaging the square of each coecient over N. 1 Y [n] = N
4.3.3 Demodulator
N

X (n)2
0

(4.7)

For demodulation, the carrier waveform is to be recovered from the received signal. For recovering the carrier, the received signal is squared, and sent through a band pass lter centered about twice the carrier frequency. The carrier frequency signal with phase delay caused by the channel is obtained by dividing this signal by 2, using a frequency divider. The obtained carrier signal is then multiplied with the received signal. Using an integrate and dump circuit along with a bit synchronizer, the demodulated bit stream is obtained. This bit stream is compared with the original bit stream to check whether there is any error.
4.3.4 Fuzzy Block

Final decision on whether or not the spectrum is free is made by using Fuzzy logic. In cooperative sensing, we make use of outputs from neighboring CR. Here, input parameters passed to fuzzy logic are given as Power, SNR from CR1 and Powers from 2 CRs (CR2 and CR3) which are CR1 neighbors. For fuzzication of power and SNR, three membership functions are dened for all the parameters. The membership functions represent three levels, LOW, MEDIUM and HIGH. These levels are dened based on data analysis signal power and SNR, which had been made prior to simulation. However, the output is a binary parameter which denotes the presence of the PU by 1 and the absence of the PU by 0. The fuzzy rule base contains of IF THEN clauses which is designed in such a way that the data from the CR terminal which is considered is given more importance than its neighbors. For example, if the CR terminal detects high power and high SNR, then the output is 1 regardless of the data on power that has been collected from the neighbors[1]. The rule base is dened for all the possible combination of inputs. With four inputs and

12

Figure 4.4: Fuzzy Fusion Center

Figure 4.5: Membership Function three possible levels for each input, there are 3 4=81 possible combinations. A part of the rule base is shown below. Table 4.1: Fuzzy Rule Base CR TERMINAL 1 POWER SNR LOW LOW MEDIUM MEDIUM HIGH HIIGH LOW LOW LOW HIGH MEDIUM HIGH CR TERMINAL 2 POWER LOW MEDIUM MEDIUM HIGH LOW HIGH CR TERMINAL 3 POWER LOW HIGH LOW HIGH MEDIUM HIGH OUTPUT NO NO NO YES YES YES

13

Chapter 5 SOFTWARE IMPLEMENTATION

5.1

MATLAB

MATLAB, short for MATrixLABoratory is a programming package specically designed for quick and easy scientic calculations and I/O. It has literally hundreds of built-in functions for a wide variety of computations and many toolboxes designed for specic research disciplines, including statistics, optimization, data analysis, DSP, communication, fuzzy etc. 5.2 MATLAB PROGRAM

clc; clearall; closeall; fismat=readfis(main.fis); %PU STATUS pu=input(Enter status of the PU (1=Present/0=Absent):); % SCATTER PLOT % Considering a geographic area with random number of CR terminals. Random % count is generated by the following function count=randi([25 50],1,1); % Random x-y co-ordinates are generated for all CR terminals X=randi([0 9],1,count)+0.01*randi([0 100],1,count);

14

Y=randi([0 9],1,count)+0.01*randi([0 100],1,count); % Scatter Plot showing location of all CR terminals scatter(X,Y,100,g); % The first CR terminal is selected as the central node and the distances % from all otehr terminals to the central node are calculated and stored in % an array for k=1:count distanceunsort(k)=sqrt(((X(1)-X(k))^2)+((Y(1)-Y(k))^2)); end; % The two closest neighbours are selected after sorting the distance array distance=sort(distanceunsort); for xx=1:3 forij=1:count if ( distance(xx)== distanceunsort(ij)) x(xx)=X(ij); y(xx)=Y(ij); end end end % Location of central node and neighbours in the scatter plot are % displayed for m=2:3 line([x(1),x(m)],[y(1),y(m)]); pause(0.5); end; % Zoomed view of central node and its neighbours figure; scatter(x,y,100,g); for m=2:3 line([x(1),x(m)],[y(1),y(m)]); pause(1); end;

15

% TRANSMITTER - PSK Modulator x=randint(1,10); xx=12; yy=10; b=2*x-1; T=0.01e-6; Eb=10*T/2; fc=9/T; t=linspace(0,10,1000); N=length(t); Nsb=N/length(x); dd=repmat(x,1,Nsb); bb=repmat(b,1,Nsb); dw=dd; dw=dw(:); bw=bb; bw=bw(:); %Random bit stream

% % % % % % %

Bit duration This will result in unit amplitude waveforms Carrier frequency Discrete time sequence between 0 and 10 (1000 samples) Number of samples Number of samples per bit Replicate each bit Nsb times

% Transpose the rows and columns % Convert dw to a column vector (colum by column) and convert % Data sequence samples

% Carrier waveform w=sqrt(2*Eb/T)*cos(2*pi*fc*t); bpsk_w=bw.*w; % PSK Modulated Wave % Plots Bit Sequence to be transmitted figure; subplot(6,1,1); plot(t,dw); axis([0 yy -2 2]) title(Bit Sequence to be Transmitted); % Plots transmitted signal subplot(6,1,2); plot(t,bpsk_w,.); axis([0 yy -xx xx]) title(Transmitted Signal (After PSK Modulation)); % Loop to account for channel modelling for two neighbours 16

for ii=1:3 % CHANNEL MODELING

c=rayleighchan(1/1000,100); % Rayleigh Fading Channel Model if(pu==1) y=filter(c,bpsk_w); % Convolution of transmitted signal with Rayleigh Fa else y=0; % No transmission (Absence of Primary User) end; % Random SNR generation between -25.00dB and 10.00dB snr=randi([-25 9],1,1)+0.01*randi([0 100],1,1); % Adding White Gaussian Noise with a defined value for SNR q=awgn(y,snr); % RECEIVER

% Band Pass Filter ww=fdesign.bandpass(N,F3dB1,F3dB2,2,0.7e9,1.1e9,10e10); % Design BPF by specifying Hd=design(ww,butter); % Butterworth filter z=filter(Hd,q); %Convoluted Output % Power Detector da=fft(z); % Taking FFT of received signal v=da.^2; % Squaring all terms % Taking average of all terms to obtain Power of received signal power(ii)=20*log10(abs(mean(v))); % Storing SNR of central node and neighbours snnr(ii)=snr; % Demodulator we=z.*cos(2*pi*fc*t); % Multiplying with carrier %Low Pass Butterworth Filter - Integrator wqq=fdesign.lowpass(N,Fc,4,1e9,10e10); Hd2=design(wqq,butter); zqq=filter(Hd2,we); %Convolution end; 17

% Plots Received Signal subplot(6,1,3); plot(t,q); title(Recieved Signal); axis([0 yy -xx xx]) % Plots Band Pass Output subplot(6,1,4); plot(t,z); title(Bandpass Output); axis([0 yy -xx xx])

if(evalfis([power(1) snnr(1) power(2) power(3)],fismat)>=0.5) %Regenerated Waveform subplot(6,1,5) plot(t,zqq); title(Regenerated Waveform); dec=real(zqq)./abs(real(zqq)); % Demodulated Signal subplot(6,1,6) plot(t,dec) title(Demodulated Signal); axis([0 yy -2 2]) % Obtaining Bit Stream through Sampling deccount=1; for k=100:100:1000 array(deccount)=(dec(k)+1)/2; deccount=deccount+1; end;

disp(Transmitted Bits : ); disp(x); disp(Receieved Bits : ); disp(array); 18

end; % FUZZY FILE disp(CR1 disp(CR1 disp(CR2 disp(CR3 Power SNR Power Power (in (in (in (in dB): dB): dB): dB): ); ); ); ); disp(power(1)); disp(snnr(1)); disp(power(2)); disp(power(3));

% Single Node Decision if (power(1)>30 &pu==1) % sncount=sncount+1; end; % Fuzzy Decision if(evalfis([power(1) snnr(1) power(2) power(3)],fismat)>=0.5) disp(PU is Present); else disp(PU is Absent); end;

5.3

FUZZY FILE

[System] Name=main Type=mamdani Version=2.0 NumInputs=4 NumOutputs=1 NumRules=81 AndMethod=min OrMethod=max ImpMethod=min AggMethod=max DefuzzMethod=centroid

19

[Input1] Name=PowerCR1 Range=[-200 100] NumMFs=3 MF1=Low:trimf,[-200 -50 5] MF2=Medium:trimf,[-30 10 40] MF3=High:trimf,[30 50 100] [Input2] Name=SNRCR1 Range=[-25 10] NumMFs=3 MF1=Low:trimf,[-38.9 -24.9 -7.4537037037037] MF2=Medium:trimf,[-14.8196296296296 -7.31462962962963 0.185370370370368] MF3=High:trimf,[-6.98944444444444 8.8655555555556 22.8655555555556] [Input3] Name=PowerCR2 Range=[-200 100] NumMFs=3 MF1=Low:trimf,[-200 -50 5] MF2=Medium:trimf,[-30 10 40] MF3=High:trimf,[30 50 100] [Input4] Name=PowerCR3 Range=[-200 100] NumMFs=3 MF1=Low:trimf,[-200 -50 5] MF2=Medium:trimf,[-30 10 40] MF3=High:trimf,[30 50 100] [Output1] Name=output1 Range=[0 1] NumMFs=2 MF1=No:trimf,[0 0.25 0.5] MF2=Yes:trimf,[0.5 0.75 1] 20

[Rules] 1 1 1 1, 1 1 1 2, 1 1 1 3, 1 1 2 1, 1 1 2 2, 1 1 2 3, 1 1 3 1, 1 1 3 2, 1 1 3 3, 1 2 1 1, 1 2 1 2, 1 2 1 3, 1 2 2 1, 1 2 2 2, 1 2 2 3, 1 2 3 1, 1 2 3 2, 1 2 3 3, 1 3 1 1, 1 3 1 2, 1 3 1 3, 1 3 2 1, 1 3 2 2, 1 3 2 3, 1 3 3 1, 1 3 3 2, 1 3 3 3, 2 1 1 1, 2 1 1 2, 2 1 1 3, 2 1 2 1, 2 1 2 2, 2 1 2 3, 2 1 3 1, 2 1 3 3, 2 2 1 1,

1 1 1 1 1 1 1 1 2 1 1 1 1 1 2 1 2 2 1 1 1 1 2 2 1 2 2 1 1 1 1 1 1 1 2 1

(1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1)

: : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 21

2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3

2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3

1 1 2 2 2 3 3 3 1 1 1 2 2 2 3 3 3 1 1 1 2 2 2 3 1 1 1 2 2 2 3 3 1 1 1 2 2 3

2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 3, 1, 2, 3, 1, 2, 3, 2, 3, 1, 2, 3, 2, 3, 1,

1 1 1 1 2 1 1 2 1 1 2 1 1 2 1 2 2 1 1 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

(1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1)

: : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 22

3 2 3 3 3 3 3

3 1 1 1 2 3 3

3 3 3 3 3 3 2

3, 2, 1, 2, 1, 2, 1,

2 1 2 2 2 2 2

(1) (1) (1) (1) (1) (1) (1)

: : : : : : :

1 1 1 1 1 1 1

23

Chapter 6 STIMULATION AND RESULTS

6.1

INITIAL SCENARIO

A geographical urban area of 10kmsquare considered, and 25-50 CR terminals are positioned randomly in the given area. One of the CR terminals is selected randomly and the power and SNR of that CR terminal are recorded. The powers received by the neighbouring two CR terminals which lie nearest to the selected terminal are fetched by the selected CR. The four parameters, power and SNR of CR1, power of CR2 and power of CR3 are the input parameters for the fuzzy based decision making stage.

Figure 6.1: Area Under Consideration

24

Figure 6.2: Zoomed View 6.2 SIMULATION

At the start of the simulation the status of the spectrum to be analyzed is set, i.e., whether the PU is using the spectrum or not.The Primary User transmits a random bit stream generated at the transmitter side.Thebit stream is modulated by carrier wave of 900Mhz. The transmitted wave is modied by the Rayleigh channel and additive white Gaussian noise. It is received and passed through a band pass lter and demodulated.

Figure 6.3: Generated Waveforms (a)Transmitted Bit Sequence (b) BPSK Modulated Signal (c) Recieved Signal (d) Band Pass Output (e) Regenerated Waveform (f) Demodulated Signal 25

The selected CR terminal detects the power in specied frequency band used by the PU, and notes its SNR value. Similarly the two nearest neighbours detects the power in the same band and sends the information to the selected CR. AT the selected CR, the fuzzy based decision is made based on the four inputs given. The output obtained from the fuzzy decision is compared with the status that was set at the beginning of the simulation. To compare the performance of the fuzzy based decision making system with other systems based on OR- Rule, AND-Rule and single node decision, probability of detection and probability of fault detection was plotted. False detection refers to the situation in which the spectrum is free (PU is not using the spectrum) but the decision made by the system indicates that the spectrum is in use by the PU. The probability of fault detection was computed by running the program 100 times and counting the number of times the PU was falsely detected when it was not using the spectrum. The probability of fault detection was observed for SNR values between -25 and 10, and the fuzzy based system returned the probability of fault detection as 0 in the given range of SNRs, which is ideal.

Figure 6.4: Probability Of Fault Detection

Successful detection refers to the situation in which the spectrum is being used by the PUand the decision made by the system is correct, indicating that the spectrum is 26

in use by the PU. The probability of detection was computed the same way as that of probability of false detection, i.e., by running the program 100 times and counting the number of times the PU was falsely detected when it was not using the spectrum. The probability of detection was observed for SNR values between -25 and 10. The plot portrays that the probability of detection for the fuzzy based system is higher than other three systems.

Figure 6.5: Probability Of Detection

27

Chapter 7 CONCLUSION

Our project dealt with the use of Fuzzy rule in the decision making process of co-operative sensing. From, the simulation results it is evident that fuzzy based decision making improves the performance of the spectrum sensing system in the typical range of SNR. The probability of false detection is ideally 0, and hence does not impair the ecient usage of the CR network. The detection rate is also higher than the other systems based on OR-Rule, AND-Rule and single node sensing. However, the system has its disadvantages. Due to its wide range of possibilities the computation time for a fuzzy decision is high compared to other systems. Furthermore, when the number of inputs to fuzzy system are increased, the number of rules to be included in the fuzzy rule base increases exponentially, which is a cumbersome task to the system designer. As a future expansion of this project, we can include more neighbouring nodes power and SNR in the decision making process. This will further increase the probability of detection. Also other weighing parameters such as distance can be included so that the inputs from far away nodes will have less eect on the decision making process.

28

REFERENCES

[1] Marja Matinmikko,Tapio Rauma,Miia Mustonen,Iikka Harjula,Heli Sarvanko Aarne Mammela Application of Fuzzy Logic To Cognitive Radio ,IEICE Trans Commun.,VOL.E92-B,NO.12 December 2009 [2] T.J. Harrold,P.C. Faris M.A. Beach,Distributed Spectrum Sensing Algorithm For Cognitive Radio , Centre for Communications Research, University of Bristol, United Kingdom. Email ccr-wireless@bris.ac.uk [3] Danijela Cabric,Shridhar Mubaraq Mishra Robert W. Brodersen Implementation Issues in Spectrum Sensing for Cognitive Radios, Berkeley Wireless Research Center, University of California, Berkeley [4] Tevk Yucek Huseyin Arslan A Survey of Spectrum Sensing Algorithms for Cognitive Radio Applications, IEEE Communicatios Surveys Tutorials, VOL. 11, NO. 1, First Quarter 2009 [5] Srinivas Nallagonda,Sanjay Dhar Roy Sumit Kundu Performance of Cooperative Spectrum Sensing in Log-normal Shadowing and Fading under Fusion Rules,International Journal of Energy, Information and Communications Vol. 3, Issue 3, August, 2012

29

S-ar putea să vă placă și