Implementing A Simulator of Wireless Cognitive Radio Network

International Journal of Applied Engineering Research ISSN 0973-4562 Volume 11, Number 2 (2016) pp 967-975
© Research India Publications. http://www.ripublication.com
Implementing A Simulator of Wireless Cognitive
Radio Network Primary Users
Nancy Y. Gélvez G
Department of System Engineering
Distrital Francisco José de Caldas University,
Bogotá Colombia, South America.
E-mail: [email protected]
Danilo A. López S
Department of Electrical Engineering,
Distrital Francisco José de Caldas University,
Bogotá, Colombia, South America.
E-mail: [email protected]
Edwin R. Trujillo
Department of Electronic Engineering
Distrital Francisco José de Caldas University,
Bogotá, Colombia, South America.
E-mail: [email protected]
Abstract
The purpose of this paper is to present to the academic
community the design of a possible simulator for Wireless
Cognitive Radio Network Primary Users. Throughout the paper
we present the flowcharts developed in Matlab in order to design
and build the simulator. In conclusion, the simulator is built and
will be used in the future for the development of a decision
making predictive model in CR.
Keywords: Cognitive radio, Matlab, Wireshark, Primary users. Introduction
This document details how the cognitive radio primary user (PUs)
[1] simulator is implemented. This Simulator enables: creating
multiple modulated signals to save them, or load them.
To create a simulation, a Wireshark file must first be generated to
be used to generate the transmission and non-transmission
periods. Simulations provide an output composed of multiple time
series, all with the same length. This length corresponds to the
modulating wave frequency times the simulation time. A time
series is the timestamp represented by a floating point number
representing the second of simulation, useful to know the times of
the remaining time series. Another time series corresponds to the
modulated signal that emulates detection by the receiver. In
addition to the sum of the amounts of the PUs modulated time
serials, white noise may be included if desired by the user. The
modulation used is BPSK. Finally, as many time series are
provided as PUs have been added to the simulation. Each of these
time series represents the transmission binary value at each
timestamp. A -1 Implies there is no transmission, a 1, that one bit
is being transmitted with a value of 1 and a 0, that one bit is being
transmitted with value 0.
Additionally, these time series are delivered in a matrix, each
column being a timestamp and each row a time series. There may
be 3 to 7 rows. The first row is timestamps, the second row is the
modulated signal and rows 3 to 7 are the transmission signals of
each of the Pus [2].
generating a new one which allows saving it at the end of the
process, and giving the possibility of printing graphs during
the process enabling the user to receive visual information of
the generating/charging process.
B. Signal Generator: This module will be used if you want to
generate a new signal. This process consists in loading the
wireshark file, specifying the carrier frequencies for each
signal you want to include (up to five) and generating the
square signal and subsequent modulation for each. Finally all
modulated signals are added and the user is prompted to
specify if he wants to include white noise in the resulting
signal, and if he wants to save it.
C. Square Signal Generator: This module generates a square
transmission signal from a single PU wireshark file. A
wireshark file fragment will be used, which can be selected
by an offset either random or user-defined. The square signal
generated will have a value of -1 in the no-transmission
sections and 1 for transmission sections.
D. Modulate Signal: In this module we specify the process of
modulating a square signal generated previously using
BPSK. In the no-transmission sections a value of 0 is
proposed for the output signal and in the transmission
sections, for each temporary space, it is randomly decided to
transmit a 1 or a 0. If it is 1, the output signal will follow the
equation:
(1)
and if 0, the following formula will be used:
General contextualization of the wave Simulator
(2)
This module also provides the transmission binary value time
series, defining the -1 values to not transmit, 1 for
transmitting one bit at 1 and 0 for transmitting one bit with
value 0. Next we explain in more detail the composition of
each PU signal generating modules (primary or licensed
users) [3].
The simulator consists of four modules:
A. Signal Selector: This module explains the overall application
design, which consists in loading a previously saved graph, or
Since this is the main module of the system, the most
important functions of the application are described.
967
Signal Selector
International Journal of Applied Engineering Research ISSN 0973-4562 Volume 11, Number 2 (2016) pp 967-975
© Research India Publications. http://www.ripublication.com
Figure 1: Selector signal generator flowchart.
A description of the flowchart shown in Figure 1 is included:
1. In the first point, the user is asked if he wishes to use a
previously created simulation. If he answers yes, the file with the
simulation is loaded (paragraph 2 in the flowchart shown in
Figure 1), if not, a new simulation (section 4) will be generated.
2. The user is asked for the filename where the simulation was
saved (file is saved in paragraph 6). The question will be repeated
(without extension) until the user enters a valid name that can be
loaded properly.
3. Next the graphic is printed and the user is prompted to use it. If
positive, the application will terminate its execution, leaving the
time series loaded into the working environment for later use. If
negative he returns to paragraph 2.
4. In case he wishes to create a new graph, the user is asked which
wireshark file he wants to use. The file is read and loaded into the
system. In case of an error in the loading process, the user will be
asked for a new filename.
968
5. The Signal Generator module is called, which generates a
new simulation. Subsequently the graph of the simulation
performed is printed.
6. The user is asked if he wants to save the simulation in a
file. If affirmative, the user must enter a filename without
extension in which the simulation is saved. The extension
.dat. will be automatically added to the name chosen by the
user.
7. Later the graphic is printed and the user is prompted to use
it. If affirmative, the application will terminate its execution,
leaving time series loaded into the working environment for
later use. If negative he returns to paragraph 5.
Signal Generator
This module is in charge of generating a modulated signal
using BPSK, which can be the result of a single temporary
serial representing a PU transmission of a combined signal of
up to five time series [4]. The flowchart of this part of the
system is shown in Figure 2.
International Journal of Applied Engineering Research ISSN 0973-4562 Volume 11, Number 2 (2016) pp 967-975
© Research India Publications. http://www.ripublication.com
Figure 2: Flowchart of the signal generator.
Operation of the model is as follows:
1. Wireshark data extracted in the Signal Selector module are
obtained.
2. The user is prompted to enter a length in milliseconds to
specify the length of the simulation.
3. He is asked if he wants to reduce sampling and how much.
This value can be 1 10 or 100. 1, this means the sampling is
real (12MHz), however 10 implies that 1.2 MHz will be used
and 100, that 120 KHz will be used. This division will also
apply on the carrier signals. It is worth noting that lower
sampling means less memory requirement for the output file
and speeds up simulation running time.
4.
5.
User is asked for the carrier signal frequency for the signal to
be created. The carrier signal is selected from a selected list
of frequencies.
Square Signal Generator is called to generate a binary signal
representing whether there is transmission or no transmission
in each of the milliseconds of simulation duration.
969
6.
Signal Modulator is called, which adds in the
transmission periods, a one or a zero randomly for each
cycle defined by the carrier signal, and then passes this
resultant signal to BPSK.
7. The graph of the square signal and the modulated signal is
printed and the user is prompted to add this signal to the
simulation. If negative he returns to paragraph 5. If
positive, paragraph 8 is accessed.
8. The signal is added to the simulation. The Square signal is
added to the list of PUs square signals and the modulated
signal [5] is added to the total simulation modulated
signal. The carrier signal used for the frequency list is
removed so that it cannot be chosen again in paragraph
4.
9. Check if all bands (carrier frequencies) are busy. If
positive we go to paragraph 11. If negative we go to
paragraph 10.
10. User is asked if he wants to include another signal. If not
we go to paragraph 11 and if positive we return to
paragraph 4 to insert another PU to the simulation.
International Journal of Applied Engineering Research ISSN 0973-4562 Volume 11, Number 2 (2016) pp 967-975
© Research India Publications. http://www.ripublication.com
11. A white noise value is requested. Values between -100 and
100 are allowed. 0 means not to introduce white noise. The
method for introducing white noise is to apply a z noise to
each point x by means of a normal distribution with zero
mean and variance v, v being the value specified in this
section.
giving as output a time series with a timestamp for each
millisecond that the value -1 will contain if there is no
transmission or 1 if there is transmission. To define whether
there is transmission or no-transmission, the previously
loaded wireshark data are used.
Square Signal Generator
This module (Figure 3) is responsible for generating a square
wave with a duration defined in the Signal Generator module,
Figure 3: Square Signal Generator Flowchart.
3. A time series is created with as many timestamps as
milliseconds the simulation lasts, giving a total value of -1 to
all.
Its operation is:
1. An offset for the wireshark file is requested. This offset
may be a random number or a user-defined value. The user
can enter a value that does not exceed the recording time of
the file that wireshark provides (this value is calculated by the
program). Should it be random, this offset will be chosen
randomly with equal probability among all possible values.
4. For each packet extracted in paragraph two its starting and
end is calculated relative to the simulation time The relative
start would be absolute start less offset defined in paragraph 1
and the relative end would be absolute end minus the offset.
The value 1 is entered to all timestamps that fall between the
relative start and the relative end of the time series set out in
paragraph 3. This means that during that period of time the
PU is transmitting.
2. All packets with transmission over a defined time period
will be extracted from the wireshark file. The beginning of
this period is defined by the offset requested in this section
and at the end of that period it will be that offset plus the
length of the simulation (value specified in the Signal
Generator module).
Modulate Signal
This module (Figure 4) receives as input the square signal
generated in the Square Signal Generator module and is
responsible for modulating the signal in BPSK format.
970
International Journal of Applied Engineering Research ISSN 0973-4562 Volume 11, Number 2 (2016) pp 967-975
© Research India Publications. http://www.ripublication.com
Figure 4: Square Signal Generator Flowchart.
1. First the duration of each bit is calculated relative to the carrier
and modulating signals.
iv. Check if there are bits to modulate. If positive we return to
subparagraph a, if negative the module returns the signal and
the modulated signal.
2. Two time series with x timestamps are created. X is defined by
the modulating frequency multiplied by the length of the
simulation in seconds. One will save the modulated signal and the
other will save its corresponding square signal.
Use of the simulator
3. For each bit:
i. Check for transmission. If there is no transmission we move to
subparagraph d.
ii. If there is transmission we calculate randomly with equal
probabilities if the bit that is transmitted is a 0 or a 1. These
values are added to the timestamps containing the bit in the
square time series created in paragraph 2.
iii. On each of the timestamps containing the bit in the modulated
time series set out in paragraph 2 the corresponding BPSK
function is applied: If it is 1, the output signal will follow the
formula
and if it is 0 the following
formula is used
. Carrier is the
frequency of the carrier signal and t represents the temporary
distance in seconds from the start of the simulation to the
timestamp.
971
The wave simulator is a tool programmed in Matlab tool that
enables users to generate modulated waves BPSK. The
application contains the following features:
• Create a simulated waveform with a sampling
frequency of 12MHz.
• Include up to five channels with base frequencies of
1MHz, 2MHz, 3MHz, 4MHz and 5MHz.
• Use a csv wireshark file to simulate the signal.
• Choose the length of the simulation in milliseconds.
• Reduce the sampling frequencies and the carrier.
1. Extract wireshark file
To enter the data that will define the simulator signal we will
use the Wireshark tool in the 32-bit 1.4.6 version.
• Load the wireshark application.
• Select the interface (Figure 5) with which we want
to capture packets, recommend using WiFi.
International Journal of Applied Engineering Research ISSN 0973-4562 Volume 11, Number 2 (2016) pp 967-975
© Research India Publications. http://www.ripublication.com
A new window opens where you can watch the packets being
recorded. In this section we wait for one minute until wireshark
receives all packets.
Figure 5: Wireshark application environment [6].
Se abrirá una ventana para guardar el fichero. Se seleccionará el
nombre de fichero que se desee, y el “Tipo” de fichero será:
“CSV (Comma Separated Values summary) (*csv)” (Figura 6).
.
Figure 6.Type of file [6].
This process provides the real WiFi signal to be used in the
simulator. You may create as many files as you wish.
2. Running the simulator
The simulator will be called from the RC Simulator script from a
Matlab window [7]. It is important to ensure being located in the
972
proper folder and that the file has both wireshark and all
scripts within that folder (if you want to load a graph must
have it in the same directory and should end in .mat). The
script will offer as first choice to load a simulation already
generated or generate a new one.
3. Generate a new simulation
To generate a new simulation the following steps are taken:
i. Run CRSimulator.
ii. On the question: "Do you want to use a previously saved
temporary serial?". If you choose NO, a random signal is
generated. S/N: click N and then press enter.
iii. Next we will be asked for the wireshark file that we want
with the following question "Indicate the wireshark exported
file you wish to use". We write the Wireshark file that we
want (with extension) and press enter. Example: prueba.csv
iv. The program will request the length of the simulation in
milliseconds with the question "Enter the length of the rime
series in milliseconds." Enter a number between 10 and
10000 (it is not recommended to enter very high values since
the system could run out of memory). Example: 100
v. At this point we will be asked if we want to reduce the
sampling "Do you want to reduce the sampling frequency and
the carrier?” Only the values 1 (to use real sampling), 10 or
100 are allowed: introduce sampling reduction.
Three values can be chosen:
• 1: Sampling will be the original.
• 10: The sampling will be divided by 10 so that the
sampling frequency will be 1.2MHz and base
frequencies from 100KHz to 500KHz.
• 100: The sample will be divided by 100, so that the
sampling frequency will be 120kHz and base
frequencies from 10KHz to 50KHz.
vii. We will be asked for the sample rate we want to use for
the next signal "Enter the carrier signal frequency: 1 for
1MHz, 2 for 2MHz, 3 for 3MHz, 4 for 4MHz, 5 for 5MHz."
The input values are 1 2 3 4 or 5. Each carrier signal can be
used only once so that as we introduce more channels, the
values will be reduced to the possible.
viii. Next we will be asked for the signal offset. This value
will allows us to start at any time point in the wireshark file.
Maximum offset value 598772. "Enter the offset of the time
series in milliseconds or 0 for random". The value that we
will be allowed to introduce will be between 0 and the
maximum record time of the wireshark input file (in
milliseconds). If 0 is entered a time point will be randomly
picked.
At this point, the simulator generates the simulated graph
showing a figure with the square signal and another with the
modulated (Figure 7). The square signal shows periods of
data transmission (values 1 and 0 randomly) and periods of
no data transmission (represented with a signal value of - 1).
On the other hand, the modulated signal will represent the
signal amplitude at each instant of time, being a BPSK sine
wave for periods of transmission and a value of 0 for periods
of non-transmission.
International Journal of Applied Engineering Research ISSN 0973-4562 Volume 11, Number 2 (2016) pp 967-975
© Research India Publications. http://www.ripublication.com
Figure 7: Result of the simulated signal.
ix. The next question will allow us to save the signal of Figure 7
(or other generated) or reshape the signal if not satisfied. The
question that the application will ask is: "Do you want to use this
signal (accompanying graph)?". If you choose NO a new signal
will be generated. S / N: We can enter the S or N values (then
press ENTER). If we choose N, we return to point "vii" to rebuild
the graph. If we choose S we move on to point "x”.
x. Next we wil be asked: "Do you want to add another signal
to the time series?". S / N: (if all channels are filled this
question will not be asked and we will move directly to item
11). If we choose S we will move to point "vi" to generate a
new signal that will be added to the previous one. If we
choose N we move to point "xi".
Figure 8: Signal obtained in item xii.
973
International Journal of Applied Engineering Research ISSN 0973-4562 Volume 11, Number 2 (2016) pp 967-975
© Research India Publications. http://www.ripublication.com
xi. Having the modulated signal generated with all the channels
we have entered, the simulator will ask to insert white noise.
Enter the amount of white noise that you want in dBm (-100 to
100). 0 to not insert noise and for any other valid value (integers
between-100 and 100), insert the white noise in decibels for each
time point.
xii. At this point Figure 8 is printed, in which we have the graph
showing the modulated signal (in Y axis the amplitude and in X
the time) and the remaining graphs (1 to 5 depending on how
many channels we have entered) the square signal.
The square signal shows data transmission periods (values 1 and 0
randomly) and periods of no data transmission (represented by a
signal value of -1). Furthermore, the modulated signal will
represent the signal amplitude at each instant of time (this being
the sum of the individual modulated signals and later the added
white noise).
xiii. Finally we are offered the option to save the signal by the
question "? save this signal for use in other executions" S/n: If we
choose N, the Simulator execution will end leaving the graph
loaded with the name signal in the workspace. If we choose S we
can save the signal following point xiv.
xiv. We will be asked for the file to save the time series by the
question "What name (without extension) how do you want to
name the file?" We choose the name (without extension) and
press enter. We will save the file name ending in .mat for use in
future executions of the simulator. Next the program will end
leaving the graph loaded with name signal in the workspace.
Example: test. This will generate a file called "test.mat".
4. Load the simulation
Once we have saved a simulation after having generated it we can
load it doing the following:
i. Run CRSimulator.
ii. In the question "Do you want to use a previously saved time
series?". If you choose "no" a random signal is generated. S/N:
click S and then press enter.
iii. We will be asked the name of the file to load with the question
"What filename (without extension) do you want to load?" We
choose the name (without extension) and press enter. The name of
the file ending in .mat will be loaded in the workspace. Example:
test. This will load the file named "test.mat". It is essential that the
files to be loaded were generated with the same simulator and
have not been modified with external tools.
iv. Next a graph will open exactly like the one in point "xii" and
we will be asked "Do you want to use this signal (accompanying
graph)?". If you choose "no", the reboot process of a new signal
will start from point "iii". S/N: If we answer S, the program will
end leaving the graph loaded with the name signal in the
workspace.
Using wireshark as a source to generate transmission patterns
we make sure to generate a simulated signal as close as
possible to a real environment.
The results provided by the simulator are realistic and enable
the development of sensing and characterization algorithms
with results close to what would be achieved in a real
environment.
To make the characterization on the modulated signal the
sending must be performed previously, although the
transmission values time series supplied by the simulator
allow skipping the sensing step and working directly on the
characterization. This point is important, as it was decided
later in the project that the sensing part was not necessary
because it was trivial in cognitive radio environments.
Therefore this simulator not only simulates a real signal to
test sensing algorithms but also allows researching with
characterization algorithms.
The simulator gives outputs that allow testing the sensing
accuracy, as the sensing output can be compared to the
transmission time series PU values.
If we do not want to include a demultiplexer in the sensing to
extract on the same simulated signal, different PU signals, a
simulation may be generated with a single PU, which would
focus on a sensing without demultiplexing. Furthermore the
white noise is also optional, facilitating the sensing task if
desired.
References
1.
2.
3.
4.
Conclusions
This simulator allows replaces the need for a receiver to return the
modulated signal in a real environment of cognitive radios. With
this simulator it is not necessary to invest in specialized
equipment to capture the values of a time series environment.
5.
6.
974
D. López, E. Rivas, and O. Gualdrón, Elementos
Fundamentales que Componen la Radio Cognitiva y
Asignación de Bandas Espectrales. Revista
Información Tecnológica [online], ISSN 0718-0764,
Volume.26, Issue1, pp. 23-40. 2015.
T. Weingart, D. C. Sicker, and D. Grunwald, A
statistical method for reconfiguration of cognitive
radios, IEEE Wireless Communications, Volume 14,
Issue 4, pp. 34–40, August 2007.
B. Canberk, I. F. Akyildiz, and S. Oktug, Primary user
activity modeling using first-difference filter
clustering and correlation in cognitive radio network,
IEEE/ACM Transaction. Networks, Volume 19, Issue
1, pp. 170–183, February. 2011.
M. Kaplan, F. Buzluca, A dynamic spectrum decision
scheme for heterogeneous cognitive radio networks,
Computer
and
Information
Sciences,
24th
International Symposium on IEEE, Guzelyurt, pp. 697
– 702, 14-16 Sept, 2009.
D. López, E. Rivas, and O. Gualdrón, Proposed
methodology for assignment of spectral bands in
wireless cognitive radio networks, Revista Tecnura,
ISSN: 0123-921X, Volume 18, Special Edition
Doctorate, pp. 61-69, 2014.
Wireshark, https://www.wireshark.org/, 2015.
International Journal of Applied Engineering Research ISSN 0973-4562 Volume 11, Number 2 (2016) pp 967-975
© Research India Publications. http://www.ripublication.com
7.
Matlab (Mathworks), http://www.mathworks.com/products
/matlab/?requestedDomain=www.mathworks.com, 2015.
Author:
1.
2.
3.
Danilo Alfonso López Sarmiento Electronic Engineer,
Master in Telematics, Full Time Professor at
Universidad Distrital Francisco José de Caldas, PhD
Student in Engineering at Universidad Distrital
Francisco José de Caldas. Bogotá (Colombia-South
America).
Nancy Yaneth Gelvez García System Enginner, Master
in Telematics, Full Time Professor at Universidad
Distrital Francisco José de Caldas Bogotá (ColombiaSouth America).
Edwin Rivas Trujillo Electrical Engineer, Master in
System Power Generation, PhD in Electrical
Engineering, Full Time Professor at Universidad
Distrital Francisco José de Caldas. Bogotá (ColombiaSouth America).
975