Simulator for Cognitive Radio

Embed Size (px)

Citation preview

  • 7/31/2019 Simulator for Cognitive Radio

    1/95

    A Simulator for Cognitive Radio

    DENNIS SUNDMAN

    Masters Degree Project

    Stockholm, Sweden

    XR-EE-KT 2008:004

  • 7/31/2019 Simulator for Cognitive Radio

    2/95

    1

  • 7/31/2019 Simulator for Cognitive Radio

    3/95

    Abstract

    The goal of this thesis is to produce a simulator for cognitive radio.The licensed frequency spectrum is getting filled with customers. If

    the trend continues, there will soon not be any frequencies left to use fornew wireless data transmission applications. However, it has been shownthat although many frequencies are bought, in reality they are not alldeployed. As an attempt to exploit this, the technique of cognitive radiohas been proposed. Cognitive radios are radio devices that are clever andcan listen to the surrounding. They sense for different frequency bandsand if they find any that is unoccupied they adjusts their inner parametersto transmit/receive with this frequency. This technique could be used fora wide range of wireless radio applications.

    A problem is that sometimes a radio device is located in a radio-shadow, for example behind a concrete wall. It will then believe thatthe shadowed frequency is free, and hence use that one. What then

    happens is of course that the device causes interference to the surroundingenvironment.The simulator in this project is built in order to simulate what could

    happen if we just allowed these cognitive users to transmit freely in reality.The biggest task of the thesis is to develop the simulator, where the

    other part is to evaluate it with some realistic values.Conclusions drawn from the final tests are that although the simulator

    itself is a bit simple and might not simulate reality perfectly, it seems thatcognitive users could be introduced in the digital television transmissionsystem. Doing the same for the mobile phone communication systemwould however, without some adjustments, cause too much interference.

    2

  • 7/31/2019 Simulator for Cognitive Radio

    4/95

    Contents

    1 Introduction 61.1 Digital communication systems . . . . . . . . . . . . . . . . . . . 61.2 What is cognitive radio? . . . . . . . . . . . . . . . . . . . . . . . 6

    1.2.1 Frequency spectra . . . . . . . . . . . . . . . . . . . . . . 61.2.2 Cognitive radio - The use of frequency spectra holes . . . 81.2.3 Wireless Sensor Network (WSN) . . . . . . . . . . . . . . 8

    1.3 Benefits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.4 Problem statement . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    1.4.1 Preliminaries . . . . . . . . . . . . . . . . . . . . . . . . . 101.5 Basic outline of the thesis . . . . . . . . . . . . . . . . . . . . . . 10

    2 Theory 112.1 Cellular network . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

    2.1.1 Base stations . . . . . . . . . . . . . . . . . . . . . . . . . 112.1.2 The hexagon . . . . . . . . . . . . . . . . . . . . . . . . . 112.1.3 Antenna diagram . . . . . . . . . . . . . . . . . . . . . . . 122.1.4 Reuse factor . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    2.2 Propagation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132.3 10th percentile . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142.4 Three different communication systems . . . . . . . . . . . . . . . 14

    2.4.1 Digital-TV communication system . . . . . . . . . . . . . 142.4.2 Mobile phone communication system . . . . . . . . . . . . 152.4.3 Satellite communication system . . . . . . . . . . . . . . . 16

    3 Simulator 163.1 H system ob ject . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

    3.2 H cell object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173.3 Base station ob ject . . . . . . . . . . . . . . . . . . . . . . . . . . 193.4 Antenna ob ject . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193.5 User object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

    3.5.1 Primary user . . . . . . . . . . . . . . . . . . . . . . . . . 193.5.2 Secondary user . . . . . . . . . . . . . . . . . . . . . . . . 20

    3.6 IT++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203.7 Reliability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

    3.7.1 Line of primary users with interference . . . . . . . . . . . 213.7.2 Line of secondary users . . . . . . . . . . . . . . . . . . . 233.7.3 Change of interference for a primary user . . . . . . . . . 25

    4 Results 27

    4.1 General introduction . . . . . . . . . . . . . . . . . . . . . . . . . 274.2 General conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . 274.3 Verification of a paper - TV system . . . . . . . . . . . . . . . . . 28

    4.3.1 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . 294.3.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 29

    3

  • 7/31/2019 Simulator for Cognitive Radio

    5/95

    4.3.3 Assumptions . . . . . . . . . . . . . . . . . . . . . . . . . 294.3.4 System calibration . . . . . . . . . . . . . . . . . . . . . . 30

    4.3.5 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304.3.6 Influence of secondary users . . . . . . . . . . . . . . . . . 304.3.7 Conclusions of our results . . . . . . . . . . . . . . . . . . 314.3.8 Comments on the simulation and model . . . . . . . . . . 31

    4.4 Running a simulation on the GSM net . . . . . . . . . . . . . . . 324.4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 324.4.2 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . 334.4.3 Assumptions . . . . . . . . . . . . . . . . . . . . . . . . . 334.4.4 System calibration . . . . . . . . . . . . . . . . . . . . . . 334.4.5 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334.4.6 Influence of secondary users . . . . . . . . . . . . . . . . . 354.4.7 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . 364.4.8 Possible improvements . . . . . . . . . . . . . . . . . . . . 36

    4.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

    5 Future work 36

    6 Summary and conclusions 38

    7 Appendix A 40

    8 Appendix B 42

    9 Appendix C 44

    10 Appendix D 46

    4

  • 7/31/2019 Simulator for Cognitive Radio

    6/95

  • 7/31/2019 Simulator for Cognitive Radio

    7/95

  • 7/31/2019 Simulator for Cognitive Radio

    8/95

    Designation FrequencyELF, extremely low frequency 3Hz to 30Hz

    SLF, superlow frequency 30Hz to 300HzULF, ultralow frequency 300Hz to 3000HzVLF, very low frequency 3kHz to 30kHzLF, low frequency 30kHz to 300kHzMF, medium frequency 300kHz to 3000kHzHF, high frequency 3MHz to 30MHzVHF, very high frequency 30MHz to 300MHzUHF, ultrahigh frequency 300MHz to 3000MHzSHF, superhigh frequency 3GHz to 30GHzEHF, extremely high frequency 30GHz to 300GHz

    Figure 2: Frequencies.

    propagation. At super-high frequencies, not even a line-of-sight with the trans-mitter assures good transmission performance (basically due to the air that isnot as clean as vacuum). Just considering the physical propagation propertiesof different frequencies makes you believe that lower frequencies yields bettersignals. But just because the propagation is good, does not mean that the datarate is good. In fact, higher data rates are possible with higher frequencies dueto the fact that during a given amount of time we have more periods of thewave at higher frequencies. Because of this, different applications will requiredifferent physical properties of the radio wave. If the data rate is not so im-portant, but propagation is, you certainly need a lower frequency and the otherway around. Of course the poor data rate in low frequency bands can also becompensated by choosing a wider band. Most systems are compromises.

    However, practical measurements have shown that although the spectra ofavailable frequencies is more or less bought up, at specific locations, a majorityof frequencies are not used at all [1]. This can easily be seen in Figure 3, whichshows measurements made at Berkeley from some suburban area.

    Figure 3: Frequency use.

    The idea of cognitive radio is to find means to use these gaps or holes in

    7

  • 7/31/2019 Simulator for Cognitive Radio

    9/95

    the frequency spectra and do something useful of the frequencies floating aroundunused.

    1.2.2 Cognitive radio - The use of frequency spectra holes

    In an attempt to find a way to use the holes, one has come up with the termCognitive radio. This word was first coined by Joseph Mitola in an articlefrom 1992 [1]. However, after working more with the concept, he suggest, in hisDissertation [2], the following definition:

    The term cognitive radio identifies the point in which wireless personal digi-tal assistants (PDAs) and the related networks are sufficiently computationallyintelligent about radio resources and related computer-to-computer communi-cations to:

    a) detect user communications needs as a function of use context, and

    b) to provide radio resources and wireless services most appropriate to thoseneeds.

    So cognitive radio is the name of a technique where different sorts of wirelesscommunication devices somehow work dynamically and change frequencies andother parameters over time. We will in this report use the term cognitiveradio alongside secondary user, having the same meaning.

    This may sound a bit like science fiction, but with todays modern technol-ogy, we can actually construct these radio devices, i.e. transmitters and receiversthat can operate on a quite wide range of different frequencies.

    There are many ways in which this could work. Sensing the surroundingcan be made immediately, meaning that the cognitive user itself searches thefrequency spectra and looks for frequency holes. This is the method that will beimplemented in the simulator constructed in this thesis. However, the sensing ofthe surrounding environment is in reality quite hard, sensors can only measurethe energy of a wide frequency range and they show a poor performance forlow SNRs [3]. By low performance we refer to high possibility of mis-detection.This has not been taken into account in this project. Instead the devices areoptimal in the sense that they can feel all frequencies in all SNRs.

    1.2.3 Wireless Sensor Network (WSN)

    There are also other options for detection. For example something called Wire-less Sensor Network (WSN). Here the idea is that one construct a sensor networkthat constantly analyzes the frequency spectrum and provides this information

    to potential secondary users. This would mean that the secondary user connectsto the sensor network and checks for free frequencies in the desired region.

    A special case of the Wireless Sensor Network would be to let the secondaryusers form the sensor network by sharing information concerning the the fre-quency spectrum among their neighbors. They will then form an ad-hoc net-

    8

  • 7/31/2019 Simulator for Cognitive Radio

    10/95

    work. This implies that we will be able to do a better decision if more secondaryusers are present within the radius of our communication.

    All these different techniques have their pros and cons. What will be inves-tigated in this thesis is not the WSN, nor is it the ad-hoc network. We will herefocus on the simplest case of cognitive radio, where each device is responsiblefor sensing its own environment without help of any additional information.

    Problems that could theoretically be solved using a Wireless Sensor Networkare:

    Shadowing of a single sensor. If a single sensor is in a radio shadow of acertain frequency, this will not cause any problem to the main system ifthe WSN can tell it which frequencies should be occupied.

    Improved robustness and agility. The improved sensing over a wider areamakes the bad sensing in poor SNR less problematic. Also, if the sensing

    of a device is broken, this will still not cause too much problem if there isa WSN around that can give directions.

    1.3 Benefits

    As always in the modern world, benefits often lie within the economical bound-aries. If we could use cognitive radio, we would be able to:

    Make use of the most suitable frequency for the purpose of our transmis-sion.

    Be able to re-use many frequencies and therefore extend the existingwireless communication systems.

    If the frequencies are not going to run out, prices on the licensed spectrumwill naturally drop, which in end will yield better consumer prices.

    Cognitive radio provides new business models. A service provider couldbe a manager for the resources.

    1.4 Problem statement

    Cognitive radio seems to be a promising concept. However, it still needs toprove its feasibility. As a first step we must realize that few, in fact none, ofthe current radio devices out on the market are cognitive radios. Therefore,the introduction of the secondary users must happen without these old radiodevices being interfered, and if they are interfered, we would have to find a way

    of pricing this interference in the primary system.Many papers have been written on this topic, but few have taken the ap-proach in this thesis. We will create a big-scaled simulator, simulating radiotraffic for certain frequencies in environments the size of cities or big country-sides. The simulator will be constructed with the cognitive radio and cellular

    9

  • 7/31/2019 Simulator for Cognitive Radio

    11/95

    construction models in mind. To make the final work easily expandable we willuse object-oriented techniques.

    As one part of this thesis is focused on the construction of this simulatorand of showing that it works, the other part is focused on trying to run a some-what realistic simulation setup. In the paper Cognitive Radio in a FrequencyPlanned Environment: Can it Work?, by Erik Larsson and Mikael Skoglund,it is concluded that:

    If a reasonable size of the cognitive operation area is desired (say 25% of thenetwork size), then the aggregate cognitive user powerMP must be 1-2 orders ofmagnitude less than the primary powerP0. For example, if there areM = 100cognitive users, then each of them must transmit with a power less than -35 dBbelow P0. This is not impossible if P0 is of the order of kW (TV broadcast-ing, for example) andP is in the order of a few hundred mW (sensor node, orWLAN card, for instance). [4]

    What this basically means is that secondary users can not exist everywherein the network. They must transmit with a power much less than the ones ofoperating base stations in the area and they also conclude that this would bepossible with a TV net.

    Hence we will try to set up a similar system and then introduce secondaryusers trying to confirm their statement.

    1.4.1 Preliminaries

    Some knowledge that could be good to refresh before you go deep into this thesisare the following:

    Object oriented programming languages. The biggest challenge in thisproject was to actually construct the simulator, and in order to understandhow this is done, a basic knowledge about object-oriented programminglanguages is required.

    Basic geometry knowledge.

    The work in this report is based on results from [4], reading this reportfirst is suggested but not required.

    1.5 Basic outline of the thesis

    In this thesis you will, after this introductory chapter, find a section describingbasic theory deployed in the project. This will be kept rather basic and not gotoo much into details. In this chapter you will also find a basic description ofthe fundamentals of some different wireless communication systems.

    After this you will find the simulator chapter (chapter 3), where we in generalterms describe how the computer program itself is built up. You will in theend of this chapter also find three different simulator runs which will show the

    10

  • 7/31/2019 Simulator for Cognitive Radio

    12/95

    functionality of the code. Also note that we in Appendix D have attached acode-manual generated by doxygen.

    In chapter 4 you will find our attempt to put the simulator in a more realisticperspective. We have used the result of other researchers to verify their resultsand also draw new conclusions of problems/possibilities with cognitive radios.

    In the very end we have suggested a list of future work that could be donein the same topic followed by references.

    2 Theory

    2.1 Cellular network

    The characteristics of a cellular network is that the base stations are placedin a pattern that is best reassembled with a hexagonal grid. The main reason

    for this is that it is easiest to produce a base station with constant gain in alldirections. To represent this in a model, it is obvious that the hexagon is theone closest to a circle of all symmetric tilings available, see Figure 4. This is,maybe not surprisingly, also the most common tiling found in nature (think ofa bees nest).

    Figure 4: The three tilings; triangle, square and hexagon, respectively.

    2.1.1 Base stations

    The only thing taken for granted about the base stations in a cellular system isthat they are placed in a cellular grid (and even this is, in practice, not alwayssymmetric). They can have many types of antennas, such as sector antennas(different antenna sectors cowering the cell), omni antennas (one antenna ele-ment with constant gain) and beam forming antennas. In this report we willmostly talk about the sector and omni antennas. In Figure 5, you can seeone hexagonal cell with an omni-directional and one sectored base station, alsoshowing two different antenna diagrams.

    2.1.2 The hexagon

    When working with hexagonal cells you soon notice that there is a demandingneed to know the geography of the cell. The symmetry of the hexagon makes itpossible to get all the necessary sizes from the cell by just storing one variable.In the program, the radius defined in the picture is the variable that is stored,and it is stored in such a way that the cell itself does not know its own size.You can see a definition of sizes in the hexagon as shown in Figure 6.

    11

  • 7/31/2019 Simulator for Cognitive Radio

    13/95

    Figure 5: An omnidirectional base station and a sectored one with three sectors.

    Figure 6: A hexagon.

    As described in [5], the important sizes can be calculated as follows:h = sin(30) sr = cos(30) sb = s + 2 ha = 2 rObserve that the radius r is not the same as b/2, i.e. a = b.

    2.1.3 Antenna diagram

    All antennas are characterized by a so-called antenna diagram. The antenna

    diagram is a way of describing the gain going out from the antenna in differentangles (both horizontally and vertically). We will here only talk about antennadiagrams with no height, i.e. vertically constant. In the simulations found inthis report we will restrict ourselves to a constant gain also in the horizontalplane. Again, look at Figure 5 for antenna diagram examples.

    12

  • 7/31/2019 Simulator for Cognitive Radio

    14/95

    2.1.4 Reuse factor

    A cellular network is built in a way so that all frequencies in use are beingdeployed in a repetitive way. The cluster size (also sometimes called reusefactor) is a term to measure this. It works as:

    N = i2 + i j + j2 (1)

    Where N is the actual cluster size. i and j explain how the reuse is located. Bylooking at Figure 7, starting at (0, 0), i is the number of steps you go in all ofthe directions 30, 90, 150, 210, 270 or 330 from the starting node. Whenthose steps are walked, turn 60 either to the right or left from the first directionand continue j steps in this way. When finished, place the same frequency inthe cell you got to as you had in the one you started from.

    Figure 7: Closeup of the grid with coordinates (k,l)

    2.2 Propagation

    When a signal is transmitted from an antenna, it has a certain gain or strength.However, as it propagates through space it will decrease as a function of distancefrom the transmitting antenna. It will also be affected by objects, such asbuildings, cars, etc., which may yield a shadowing effect. It can due to reflectionsalso become stronger due to additive interference. This can be modeled in many

    13

  • 7/31/2019 Simulator for Cognitive Radio

    15/95

    ways. One of these models is the distance-dependent log normal shadow fading,which is the one used here, see Equation 2.2.

    (x) = x 10/10 (2)

    is the path loss exponent and will model the distance-dependent part ofthe equation. This is in a typical crowded city set to about 4. In vacuum, freespace, line-of-sight this would be 2.

    is the random part of the equation and this variable will be distributed asN(0, ), where is the standard deviation of the log normal fading [dB]. Thiswould in a typical city be about 6, and in free space 0. This is the part thatmodels the shadowing (in case 10/10 < 1) and additive interference (10/10 >1).

    This model will be used to describe all signal propagation, interfering signals

    and primary signals.

    2.3 10th percentile

    The 10th percentile in a cumulative function is the spot at 10 percent in thegraph. We will use a graph with the nr. of users (in %) on the y-axis (inlogarithmic scale) and cumulatively the SNIR on the x-axis. This will give usa cumulative probability density function showing the probability for a user tohave more than a certain SNIR. The 10th percentile is of particular importancebecause most manufacturers construct their communication systems in such away that at least 90% of the users have a SNIR high enough for satisfyingconnection. This in turn, of course, leads to 10% of the users having unsatisfyingconnection. In this thesis we will only encounter cases where the limit for good

    connection is placed at 10 dB. This is also the order of magnitude commonlyapplied in practical implementations.

    2.4 Three different communication systems

    2.4.1 Digital-TV communication system

    The following introduction is mainly taken from [6] and teracoms web page [7].What we refer to as a typical TV system in this text is basically the one appliedin Sweden.

    The Digital-TV ground net is built in a cellular pattern. It is a broadcastingnet where all information is sent from the base stations and received at the TV-antennas most people have at home. The base stations placed in the hexagonal

    grid are normally quite big base stations, located at high towers or hills. Thesecan, due to radio-shadows and such not cover the entire area by themselves.Instead there are also smaller helping base stations placed here and there tosupport this backbone of transmitters. In Figure 8 this is pictured (taken fromthe web page of teracom).

    14

  • 7/31/2019 Simulator for Cognitive Radio

    16/95

    Figure 8: A real world map from teracoms web page, showing the area ofStockholm with surroundings. The yellow triangles are smaller base stations.

    Characteristics for the television communication system is that the receivingantennas often are directed and located in such a way that they have line of sightor close to line of sight propagation to the transmitting base station. Directedantennas are something that is not (yet) implemented in the cognitive radiosimulator, why we have to do some approximations when implementing thissystem.

    Typical transmission strengths for the big base stations are in orders oftenths to hundreds of kW. These have a coverage area of tenths of km. InSection 4.3 you will find a simulator test run for a TV-system.

    2.4.2 Mobile phone communication system

    The following introduction is mainly taken from [8] and [9].The mobile communication system is built as a cellular network, see 2.1. The

    base stations are generally categorized in three different classes, macro cells,micro cells and pico cells. The macro cells has a range of several kilometersand are often deployed on the country-side. They transmit with a strength of10-100 Watts depending on circumstances. These base stations are placed insteel lattice towers and are normally easily discoverable. The micro- and pico-cells however are not so easy to see. Normally these are placed in the moreurban areas as in cities. They have a much smaller range of coverage from afew hundred meters up to a kilometer and their transmission strengths varies

    15

  • 7/31/2019 Simulator for Cognitive Radio

    17/95

    normally between one up to a couple of Watts. These base stations are easilydisguised as building features.

    Each base station has antennas that are either panel-shaped sector antennasor pole-shaped omni antennas. In the case of sector-antennas there is a biggerpossibility to limit the range of transmissions and control which frequencies arebeing deployed in what direction. The omni-antennas however transmit andreceive equally in all directions.

    Normally you would find the different sizes and different deployments ofantennas used at the same time covering the same area, particularly in populatedcities. Handovers between base stations are something that happens when yougo with your mobile away from the coverage area of one base station to another.Then the first base station hands over the connection of your call to the otherone. This is not made without an effort and different technologies are appliedto make it easier. One of these are the so called umbrella cells which in citiesare layered above the normal system. This grid is made with much biggercells and is constructed to handle the calls of mobile devices traveling at highspeeds, such as connections with devices in cars, trains and even bicycles.

    2.4.3 Satellite communication system

    The following introduction is mainly taken from [10].Satellites have been used for communication since Sputnik I first left the

    ground in October 1957. However, as with all communication devices the tech-nology has gone from simple to more and more complex.

    A satellite can be placed on different distances from earth. The most com-mon ones are the Low Earth circular Orbits (LEO) closest to us, with a distanceranging 600-1500 km. After that there are the Medium circular Earth Orbits(MEO) with altitudes 8000-11 000 km and at last the GeoStationary Orbit(GSO) at about 40 000 km.

    The satellites can rotate in different speeds and different patterns, from beingstationary over one place (moving synchronized with earth) to moving at higheror lower velocities.

    This sort of system is something that at the moment is not well simulatedin the simulator described in this thesis.

    In this thesis we present a simulator that can simulate cellular or close tocellular communication systems. However, according to [10], we will probablysee more of the spatial frequency reuse (which is the characteristic feature ofa cellular net) even amongst satellites in the future and when this happens itcould be interesting to make an extension of the work in this report.

    3 Simulator

    When constructing this simulator a programming language had to be chosen.It had to be object-oriented, but also big enough to make it interesting to thepublic. That left us with java, c++ and c#. A very nice tool is a library called

    16

  • 7/31/2019 Simulator for Cognitive Radio

    18/95

    IT++. This library contains many statistical and signal-processing tools beingof great help when developing mathematical software, see Section 3.6. IT++ is

    a c++ library so this was the deciding factor.The simulator is built up around some main objects. These objects are:

    H system, H cell, Base station, User and Antenna, and they will in the following bedescribed into more detail. There are also other objects, mainly for supportingthese. In Figure 9 you see an UML class diagram showing how they are allconnected. For a more detailed description, look at Appendix D.

    3.1 H system object

    The H system class is quite heavy. It has all the other objects and also a lotof the logic for different equations/calculations. You may think of this class asThe World of which everything exists and where all the rules are set.

    One of the most important job being done by the H system is the managementof the grid. This includes placing cells in a clever way, but also managing theselection of frequencies for primary as well as secondary users. The hexagonalgrid is the one deployed in modern cellular constructions and will therefore alsobe used here.

    However, computationally it is not so easy to work with hexagonal grids. Alldata types in a computer are built with the regular cartesian coordinate systemin mind. If one is to use the hexagonal tiling some extra-work has to be done.There is a need to walk around in the grid to do calculations of different sortand the grid has to be stored in an efficient way.

    Think of a matrix as a grid with square tilings. Then imagine that everysecond row is shifted half a cell. This would be something similar to how a brick-wall is normally constructed. Then you can place the center of each matrix-

    square in the center of each hexagonal-cell. So keeping that image in mind, itis no problem to apply a regular matrix or a Cartesian coordinate system toarrange the cells. The result should be something like Figure 7, that we sawearlier. In the case of this simulator the coordinates of the system is constructedto reassemble the cartesian coordinate system rather than a matrix. The (0,0)cell will always be somewhere close to the center of the system and we will seeboth positive and negative numbers.

    The H system also contain other logic and information, for example it helpswith deciding what frequency each user/secondary user will connect/transmitwith. It is no use to describe all this here, instead have a look at the code itselffor more details.

    3.2 H cell object

    The H system grid is built up with nodes of H cells. These are what one couldcall un-intelligent, meaning that they have no real logic functions implemented.They have 1, 3 or 6 Base station objects, depending on what is chosen in theconfiguration file. This allows us to create base stations with sectored transmis-sion, as described in Section 2.1.1. The cell itself knows its position as of where

    17

  • 7/31/2019 Simulator for Cognitive Radio

    19/95

    Figure 9: UML class diagram for the simulator

    18

  • 7/31/2019 Simulator for Cognitive Radio

    20/95

    in the virtual matrix grid it is located (k,l), see Figure 7. However, it does notknow its position as of x/y or not even its own radius. However, using the built

    in functions get x(double radius) and get y(double radius), the actual position iscalculated from the grid.

    3.3 Base station object

    The Base station object is always placed in the middle of the cell. It has anAntenna, which has a span of transmission and an angle of direction. Thoseantenna variables are configurable through member functions in the Base station.

    There can be 1 Base station in the cell, but also 3 or 6 of them. Each willof course have its own Antenna. In practice it is more common to use three basestations in the cells than one. It seems that three base stations per cell willcause less interference to the system than one.

    3.4 Antenna object

    Each Base station has an antenna object, which can be thought of as an antennaelement. The antenna object has, as previously mentioned a span of trans-mission, variable transmission rate in each angle, but no position. In a moreadvanced system it would be possible to implement the Antenna also in primaryand secondary users in the system. For implementation of an antenna diagram,the Antenna is where you would like to place it.

    3.5 User object

    The user object has two types of constructors. One for constructing a sendingdevice (secondary) and another to construct a receiving device (primary).

    The reason is simply that there is a need to construct both of these types. Byplacing them in the same object, the possibility to implement a dynamic (bothsending and transmission) device would, if needed, be very straight-forward.

    3.5.1 Primary user

    What is interesting to know about the primary user is:

    It is connected to a base station.

    It has a position.

    The primary users are placed uniformly random according to Figure 10.Observe that the user can not come too close to the base station (which normally

    applies in reality as well).In Figure 10, nodes is a c++ std::vector. Hence, nodes.size() returns the size

    of the vector, nodes.at() returns the node at a certain index. The com-mand randu() is a function from the library IT++, giving a uniformly randomvariable between 0 and 1. Also observe that the primary user can not be locatedexactly on the base station.

    19

  • 7/31/2019 Simulator for Cognitive Radio

    21/95

    1: for every user do

    2: int node = nodes.size() * randu();

    3: double x const = nodes.at(node).get x();4: double y const = nodes.at(node).get y();

    5: double x = 0;

    6: double y = 0;

    7: while get distance(0,0,x*width*2, y*width*2) < radius*0.1 do

    8: x = randu() - 0.5;

    9: x = randu() - 0.5;

    10: end while

    11: end for

    12: place user at(x + x*width*2, y + y*height*2);

    Figure 10: Pseudo code for user placement.

    3.5.2 Secondary user

    The secondary user is not connected to any base station. However, it has afrequency with which it transmits. The frequency is chosen in such way that itsenses all available frequencies and chooses the frequency that at the momentis weakest. This implies optimal spectrum sensing.

    It is constructed from the same object as the primary user, but with anotherconstructor than the later.

    3.6 IT++

    IT++ [11] is a library containing tools for math and signal processing, but alsotools for easy connectivity with matlab. It is an open-source library which isdeveloped by many people and based on c++. In this simulator we use functionsand classes repeatedly in the code. We particularly use the tools for readingand writing files to matlab, to easily plot data and also calculate statistics. Ifyou are interested in this library, just go to the homepage [11] and you can readmore.

    3.7 Reliability

    A very justified question right now is weather all this really works or not? Inan attempt to answer this we have set up three simulator test-runs. The codesfrom the test-runs can all be found in Appendix A, B and C.

    In the first test-run we try to show that the primary users connect to theappropriate base station. By letting a user move its way through a setup,we can see how it will change the base station to which it is connected.

    We have also introduced a secondary user in this setup, to show that theprimary user using the same frequency experience a small interference andthose of another frequency are unaffected.

    In the second test-run we show that the secondary users chose a frequencythat causes as little interference as possible. This means in reality that

    20

  • 7/31/2019 Simulator for Cognitive Radio

    22/95

    they are supposed to, in some sense, use the frequency of the base stationfurthest aways.

    In the third test-run we show how the distance between a primary userand a secondary user affect the strength of the interference.

    3.7.1 Line of primary users with interference

    In this test we try to show the reliability of the primary users.We have placed a line of primary users according to Figure 11. This can be

    illustrated as a single user walking its way through the cells. What you see inthis picture are seven base stations placed in a typical fashion. The hexagonalgrid shows where the borders for each base station lies. The circle around thebase stations show the antenna diagram currently in use. The round small dotsare primary users and the diamond dot up in the right corner is the secondary

    user. The colors are put there to make it easier to see which frequency the basestations and the different users employ. A green dot indicates that the userhas connected to the green base station. We can clearly see that each user hasconnected to the base station that is located closest to it.

    Also note that there are no users placed directly on top of the base station.This is just because it in reality cannot happen.

    You can find the code for this program in Appendix B.

    Figure 11: Walking primary user

    The output from a typical test run is as follows (this is also the run that ispainted in the picture):

    21

  • 7/31/2019 Simulator for Cognitive Radio

    23/95

    dennis@dennis-laptop simulator $ ./puser walk

    Simulator program for cognitive radio.

    Secondary user frequency: 104

    Primary users from bottom left up to top right:

    DL frequency: 104;

    Signal strength: 0.338613;

    Interference: 2.12103e-06;

    DL frequency: 104;

    Signal strength: 0.0900384;

    Interference: 4.38612e-05;

    DL frequency: 104;

    Signal strength: 0.00421271;

    Interference: 3.37021e-05;

    DL frequency: 100;

    Signal strength: 0.150852;

    Interference: 0;

    DL frequency: 100;

    Signal strength: 0.43175;

    Interference: 0;

    DL frequency: 101;

    Signal strength: 0.0910177;Interference: 0;

    DL frequency: 101;

    Signal strength: 0.234449;

    Interference: 0;

    DL frequency: 101;

    Signal strength: 1.8719;

    Interference: 0;

    cell frequency: 100; at: (0, 0)

    cell frequency: 101; at: (17.3205, 10)

    cell frequency: 102; at: (17.3205, -10)cell frequency: 103; at: (0, -20)

    cell frequency: 104; at: (-17.3205, -10)

    cell frequency: 105; at: (-17.3205, 10)

    cell frequency: 106; at: (0, 20)

    22

  • 7/31/2019 Simulator for Cognitive Radio

    24/95

    3.7.2 Line of secondary users

    When introducing the secondary users, these should take the frequency of thebase station located furthest away. Of course we have to account for the shadowfading, and since neighboring cells far away yield similar strengths, the shadow-ing effect will be big.

    Figure 12: A walking secondary user

    In order to better explain the behavior of the system, we have set up three

    histograms. You can find them in Figure 13. On the X-axis we see the frequen-cies and on the Y-axis how many times the secondary user decide to use thisfrequency.

    In the first graph we can see the third secondary user, going from left toright in Figure 12. Obviously this user is placed at an equal distance from basestation with frequency 106 and 102. Accordingly, it should select these twofrequencies with equal probability (the same goes for 103 and 105). This isclear in the picture. The base station located furthest away, i.e. the one whichin average should have the weakest signal-strength should be the most favorablechoice most of the times, which is also clear. We also notice that some timesthe secondary user selects the frequencies being used by 100, 103 and 105. Thisis of course also because of the shadowing, but happens rather seldom.

    In the second graph, we have instead decided to look at the secondary userbeing placed in the center of cell using 100 as frequency. Clearly by Figure 12,all other base stations are located at the same distance from this point, so thesecondary user should choose all these frequencies with equal probability. Thisis also what we see. Because it is placed on top of the base station using 100 asfrequency, this will most likely always yield a very strong signal and hence the

    23

  • 7/31/2019 Simulator for Cognitive Radio

    25/95

    user will never (very seldom) choose this frequency.In the third, most colorful graph, what we see are all the users. Instead of

    just showing one bar at each frequency, we see 17 bars. Each bar representsone user and the bars are ordered in such a way that the bar most to the right(at each frequency) correspond to the result of the user located most to theright in Figure 12.

    Comparing Figure 13 with Figure 12, some interesting obsevrations can bemade. For example, in Figure 12, cell 103 and 105 as well as 106 and 102 shouldhave the same distributions. Cell 104 and 101 should have complementarydistributions, as well as 105 and 102, and 106 and 103. This is all confirmed inFigure 13.

    24

  • 7/31/2019 Simulator for Cognitive Radio

    26/95

    Figure 13: Histogram. Observe that the colors in this picture are independentfrom those in Figure12

    3.7.3 Change of interference for a primary user

    Let us look at a setup where a primary user is walking through an environmentwith two interfering users. By printing a graph, that shows the interference at

    25

  • 7/31/2019 Simulator for Cognitive Radio

    27/95

    each position and put it straight below the environment-picture, see Figure 14,we try to illustrate that the interference works.

    Figure 14: A primary user walking horizontally through a cell with two interfer-ing secondary users. Observe that the standard deviation in the random termis set to 0, hence no ripples in the curve. Also note that the two interferingusers are placed different distance from the X-axis, hence the two peaks in theInterference graph are of different magnitude.

    Again looking at Figure 14, there are clearly two peaks visible. The graphlooks pretty much as one could expect, with greater interference closer to asecondary user. Observe that we turned off the random factor in the propaga-tion function (putting the deviation to 0). This means that there will be no

    26

  • 7/31/2019 Simulator for Cognitive Radio

    28/95

    shadowing at all, which gives a realistic model for free-space propagation.One should also take into consideration that in reality we would exclusively

    work with systems of more than one frequency reuse. So the primary userswould never have to come this close to the secondary users, unless the secondaryuser happens to be in a very bad radio-shadow, of course. To illustrate how asimilar run would look with the standard deviation set to for example 6, whichcorresponds to a typical city scenario, look at Figure 15.

    4 Results

    4.1 General introduction

    In [4], E. Larsson and M. Skoglund set up something similar to a simulator. Thedifference is that they do not consider an entire system, but instead just one

    cell (and the 6 surrounding reuse-cells). Besides that the system is very sim-ilar, with distance-dependent path-loss and log-normal shadow fading definedin the same way to model obstacles. They introduce some different radiuses toillustrate where secondary users are allowed to communicate. This is of coursenot an entirely realistic assumption since the secondary user never really knowswhere it is located geographically, but instead only can measure signal strengthfrom possible base stations. It would be possible to achieve the same sort ofconclusion by introducing signal to noise thresholds. The difference is that in-stead of having a real distance, we then would have to work with SNRs, whichwill vary, due to the shadowing. E. Larsson and M. Skoglund use their radiusesto decide where, how and if secondary users are allowed. We have simplifiedthis drastically by just saying that the secondary users are allowed everywhere.This will have the drawback that the system will suffer a theoretical higher

    interference disturbance.

    4.2 General conclusion

    The general conclusions that can be drawn from these tests are:

    The test-results from the simulator corresponds well to what is expectedfrom earlier publications, here specifically with [4] taken into considera-tion.

    Simulating a real world system is complex and one will always have tomake assumptions. In the TV-system case this was particularly obvious.

    Secondary users can be implemented in the TV-system.

    Secondary users can not be implemented in the mobile phone system.

    27

  • 7/31/2019 Simulator for Cognitive Radio

    29/95

    Figure 15: A primary user walking horizontally through a cell with two inter-fering secondary users. Observe that since the shadowing term N(0, 6),shadowing will lead to amplification as well as attenuation. Here, in contra-diction to the previous example, the interfering users are placed at the samedistance from the X-axis.

    4.3 Verification of a paper - TV systemAn interesting task for this simulator would be to let it verify the paper byErik Larsson and Mikael Skoglund [4]. If their calculations are correct and thesimulator is working properly we would get similar answers as they.

    28

  • 7/31/2019 Simulator for Cognitive Radio

    30/95

    4.3.1 Conclusion

    This simulator is not optimal for running a real-world simulation as that in-cludes base stations of different sizes. When running a test run of the backbone(i.e. ignoring the small helping base stations and only focus on the big ones),you could easily introduce secondary users transmitting at very strong powerswithout any measurable losses in primary system.

    4.3.2 Introduction

    In [4] it is stated that it would be possible to introduce a digital communicationsystem when the strengths are such as in the digital television system. We willassume that this is the case and try to model a working digital-TV system.When it is up and running we will introduce the secondary users transmittingwith the power strengths suggested by E. Larsson and M. Skoglund. Then we

    will try to observe how much interference the secondary users cause.

    4.3.3 Assumptions

    We have to decide a bunch of variables. A quick look at the configuration filefor the simulator tell us what sort of variables we have to define. A dump:

    ideal basestation strength:?

    reuse factor:?

    step radius:?

    cell radius:?

    cell split:?

    primary users:?

    secondary user transmit power:?secondary users:?

    The reuse factor (cluster size) will be set to 16, to start with. Step radiuswill be set to 2, which means we will have a total of 7 clusters of size 16. Cellsplit will be set to 1, we only want one base station in each cell.

    Realistic values for the cell radius and the ideal basestation strength can befound in Digital-TV via mark, satellit och kabel [6]. A typical value for theUHF band (300MHz to 3GHz) is 40 kW (for UHF) in Sweden. Combine this gainwith the antenna-amplification and you will get about 1000 kW of transmission.However, as of today we are only using digital television in Sweden and thatoperates in 12 dB less power gain, i.e. 62.5 kW. The typical transmission radiusfor this set-up would be approximately 10 km.

    TV-systems are a bit different from the system we have built in this sim-ulator, therefore think of this system as a system similar to the TV net. Thepropagation, see Section 2.2, between the base station and primary user (i.e.TV-transmitter and your TV-antenna at home) would have almost free-space,line-of-sight. Therefore we have chosen the propagation from base station toprimary and secondary users to have (path loss exponent) set to 2.4 and to

    29

  • 7/31/2019 Simulator for Cognitive Radio

    31/95

    have a standard-deviation of 2 [dB]. Now this is not a perfect model, as the tele-vision system normally have directed receiving antennas. The primary user to

    secondary user path loss exponent and standard-deviation is set to the default4, 6 respectively.

    4.3.4 System calibration

    We assume, as in [4], that within the system we are working with noise-to-interference ratios within [-10 to +10] dB. Therefore we adjust the noise levelto be in average the same as the interference for the primary users. Accordingto [6], a typical TV-broadcast system has to have a receiving SNR of about 10[dB]. We have calibrated the system so as about 90% of the users have a SNRof 10 dB or better.

    After calibrating the system, we get the following configuration file:

    ideal basestation strength:62500

    reuse factor:16

    step radius:2

    cell radius:9000

    cell split:1

    primary users:10000

    secondary user transmit power:0

    secondary users:0

    4.3.5 Results

    The resulting system looks like Figure 16, which shows the cells represented byhexagons, the base stations placed as stars in the center of each cell and primary

    users represented as dots.The cumulative probability density function for the SNIR of this system can

    be found in Figure 17.

    4.3.6 Influence of secondary users

    When introducing the secondary users, we noticed that the graph turns outexactly the same as Figure 17. With the suggested strengths (see Section 1.4),we get no difference what so ever on the primary system. When increasingthe secondary users transmission strength up to the same strengths as the basestations we still get no interference. Showing a figure of this is useless as theyall look exactly like Figure 17. The reason for this is that:

    The propagation function has a much bigger path loss exponent (due tomuch worse placement) set between the secondary and primary users thanthe one used between base stations and primary users.

    The reuse factor is set to 16 (which had to be used to achieve the requiredproperties), which means there are many different frequencies and the

    30

  • 7/31/2019 Simulator for Cognitive Radio

    32/95

    Figure 16: The hexagonal system with primary users as dots and base stationsas stars.

    reuse of each frequency will be placed spatially very far away from eachother.

    4.3.7 Conclusions of our results

    When running a test run of the backbone (i.e. ignoring the small helping basestations and only focus on the big ones), you could easily introduce secondaryusers transmitting at very strong powers without any measurable losses in theprimary system.

    4.3.8 Comments on the simulation and model

    A valid question now would be if the results achieved in this test run are reallyrepresentative for reality. To the commonly big TV-antennas in your home,directed to the appropriate base station and placed outside you would probablyhave a good connection even in a noisy environment, as is the case here.

    We have assumed that the base stations are perfectly placed in a hexagonal

    grid and that the distances are big. This would probably correspond to the mainbase stations (backbone) in a real environment (see for example the frequencymaps from [7] in Figure 8). However, the net is also layered with smaller basestations transmitting at less strength and with smaller distances. If you wereconnected with one of those you would probably be much easier interfered with

    31

  • 7/31/2019 Simulator for Cognitive Radio

    33/95

    Figure 17: The cumulative probability density function for the SNIR of thissystem.

    the secondary net and also have worse propagation properties due to not asgood placement of the smaller base stations.

    The conclusion has to be that in order to fully simulate the TV-net the sim-ulator would need additional improvements with directed antennas and multiple

    system grids. We would also need more insight of real world characteristics ofthe system.

    4.4 Running a simulation on the GSM net

    We will here, just as in Section 4.3, run a similar test but this time on thecellular network of the GSM net.

    4.4.1 Introduction

    In a modern society, the frequencies used by the GSM and similar systems arehighly interesting because of their good physical properties, see Section 1.2.1.It is therefore interesting to consider the possibility of introducing secondaryusers in this band. The common belief (for example [4], [12]) is that this is hardto manage.

    32

  • 7/31/2019 Simulator for Cognitive Radio

    34/95

  • 7/31/2019 Simulator for Cognitive Radio

    35/95

    Figure 18: A picture of the system with primary users.

    Figure 19: The cumulative probability density function for the SNIR of theGSM system.

    34

  • 7/31/2019 Simulator for Cognitive Radio

    36/95

    4.4.6 Influence of secondary users

    We change the last two lines in the configuration file to introduce the secondaryusers:... secondary user transmit power:0.016

    secondary users:10000

    10000 secondary users in a system with 10000 primary users may seem quitea lot. Therefore we have run the simulation for 0, 100, 1000, 5000 and 10000secondary users as well, only changing the last line of the configuration file. Thecorresponding graphs are placed in the same diagram (Figure 20). It is obviousthat each secondary user added to the system contributes to a decrease in thenetwork performance.

    Figure 20: The cumulative probability density function for the SNIR of theGSM system after introduction of secondary users. From left to right we seethe graph produced by 10000, 5000, 1000, 100 and 0 secondary users.

    The secondary users are transmitting at a power of 0.016 W. This is about1/10 of modern base stations transmission effect of your home wifi system. Thiswould theoretically then give a transmission range of up to approximately 6-8meters, suitable for wireless devices for your computer, mobile phone, etc.

    35

  • 7/31/2019 Simulator for Cognitive Radio

    37/95

    4.4.7 Discussion

    As we can see in Figure 20 we go from 90% of the users with good enoughconnection (SNR of 10 dB) to 61% (10000 secondary users). This means thatinstead of 10% of the users talking in their mobile having some sort of troublewith the connection we get 39%. This is obviously not acceptable. However, wealso see that when having as few as 100 secondary users, the overall networksuffers very little loss in performance. The general conclusion would be thatsecondary users in the GSM net should not be allowed. However, if the marketis strong for these frequencies we could probably allow some secondary users(up to about 1% of the amount of primary users), to a high price and high cost.

    4.4.8 Possible improvements

    Is there anything we could do to improve the results? Obvious things would be

    like increasing base station strengths, decreasing cell sizes, increasing reuse factoror make use of cell splitting. The base stations are probably already transmit-ting at the highest allowable value and to relocate all the base stations in a citywould probably be very expensive. What could rather be done is be to increasethe reuse factor and split the cells in multiple sectors. This would mean that theprimary service provider have to upgrade their already existing base stations aswell as buying more frequencies to use in their system. To illustrate this, wechanged the following parameters of the worst system run (the one with 10000secondary users):... cluster size:14

    ... cell split:3

    ...

    The resulting graph turns out as Figure 21. Obviously we get another 9% of

    total amount of users back, which is an improvement of 9/39 = 23%. Althoughthese changes are some that could be done by the primary system, it is ques-tionable if the provider is ready to actually do them. It does however show thatthere are many parameters playing a role in the final performance and outcomeof the system and all of these parameters have to be taken into account.

    4.5 Conclusion

    It seems this simulator works as expected. It is however not at the momentoptimized to simulate the television net. This is also not completely surprisingas it was first built to simulate cellular networks more similar to the one of theGSM net.

    5 Future work

    A technical list of things that could be implemented in the simulator for betteruse in the future:

    36

  • 7/31/2019 Simulator for Cognitive Radio

    38/95

    Figure 21: The cumulative probability density function for the modified system,showing the graph of 10000 users.

    Finalize the implementation of antenna diagrams. Both at transmitterand receiver.

    Implement thresholds for sensing in low SNR environments.

    Implement tool-kits for different sorts of user placement and secondaryuser placement.

    Would it be possible to dynamically generate an operational system wheremain base stations are placed together with helping ones (as in theTV-case in this report) in such a way as to achieve a certain coveragepercentage?

    Implement functionality for layered networks.

    Implement features from Wireless Sensor Networks.

    Implement the functions of ad-hoc networks.

    It would also be interesting to run simulations for different sort of areas.It would be interesting to see how cognitive radios implemented in rural areas,i.e. the countryside perform. Cognitive radios would here probably be mostlydeployed for scientific use in measurement equipment, for example in differentsensor network technologies.

    37

  • 7/31/2019 Simulator for Cognitive Radio

    39/95

    6 Summary and conclusions

    In this thesis we have seen the development of a simulator constructed to dosimulations on cellular networks. It has been constructed with the particulargoal to model the interference an introduction of cognitive users will have onthe primary system.

    We have seen how this simulator can be built up in an object-oriented pro-gramming environment, with the specific ob jects being described in detail. Wehave also shown that the simulator actually does what it is supposed to do withvarious test, giving pictures and graphs. In the later parts of the report we alsodemonstrated how changes in parameters, such as cluster-size and sectorizingin the base stations can easily be made and effect our results.

    In the end we have put the simulator to a real test by trying to emulatedifferent reality scenarios. It has been seen that the concept of cognitive radioscould be implemented in communication systems similar to the TV-system, but

    probably not, with todays technology, in the GSM-system.

    References

    [1] R. W. Brodersen, A. Wolisz, D. Cabric, S. M. Mishra, and D. Willkomm,Corvus: A cognitive radio approach for usage of virtual unlicensed spec-trum, 2004.

    [2] J. Mitola, Cognitive radio: An integrated agent architecture for softwaredefined radio, Ph.D. dissertation, KTH, Royal Institute of Technology,Sweden, 2000.

    [3] R. Tandra and A. Sahi, Fundamental limits on detection in low snr undernoise uncertainty, WirelessCom, June 2005.

    [4] E. G. Larsson and M. Skoglund, Cognitive radio in a frequency plannedenvironment: Some basic limits,, 2007.

    [5] J. Modzel, http://www.codeproject.com/useritems/hexagonal part1.asp.

    [6] M. Rojne, Digital-TV, via mark, satellit och kabel, 2nd ed. Studentlitter-atur, 2006.

    [7] Teracom webpage, http://www.teracom.se/.

    [8] Health Protection Agency, http://www.hpa.org.uk/radiation/understand/information sheets/mobile telephony/base stations.htm.

    [9] T. S. Rappaport, Wireless Communications: Principles and Practice.Prentice hall ptr, 2001.

    [10] L. S. Golding, Satellite communications systems move into the twenty-firstcentury, 1998.

    38

  • 7/31/2019 Simulator for Cognitive Radio

    40/95

    [11] IT++ - A c++ library, http://itpp.sourceforge.net/.

    [12] N. Hoven and A. Sahai, Power scaling for cognitive radio.

    39

  • 7/31/2019 Simulator for Cognitive Radio

    41/95

    7 Appendix A

    This is the code generating a walking primary user and how it is affected by thetwo secondary users:

    #include #include #include #include

    #include "h_system.h"#include "h_cell.h"#include "drawing.h"

    using namespace std;using namespace itpp;using namespace sim;

    int main(){H_system hsys;

    cout

  • 7/31/2019 Simulator for Cognitive Radio

    42/95

    41

  • 7/31/2019 Simulator for Cognitive Radio

    43/95

    8 Appendix B

    The code for placing 7 base stations and see how the primary users connect tothe right base station.

    #include #include #include #include #include "h_system.h"#include "h_cell.h"#include "drawing.h"

    using namespace std;using namespace itpp;using namespace sim;

    int main(){H_system hsys;cout

  • 7/31/2019 Simulator for Cognitive Radio

    44/95

    return 0;

    }

    43

  • 7/31/2019 Simulator for Cognitive Radio

    45/95

    9 Appendix C

    The code where a line of secondary users are placed, to show that they chosethe same frequency as the base station furthest away.

    #include #include #include #include

    #include "h_system.h"#include "h_cell.h"#include "drawing.h"

    using namespace std;using namespace itpp;using namespace sim;

    int main(){

    cout

  • 7/31/2019 Simulator for Cognitive Radio

    46/95

    } */}

    //hsys.display_sys();

    // Declare the it_file classit_file ff;

    // Open a file with the name "it_file_test.it"ff.open("suser_walk.it");

    // Put the variable a into the file. The Name("a") tells the file class// that the next variable shall be named "a".ff

  • 7/31/2019 Simulator for Cognitive Radio

    47/95

  • 7/31/2019 Simulator for Cognitive Radio

    48/95

  • 7/31/2019 Simulator for Cognitive Radio

    49/95

  • 7/31/2019 Simulator for Cognitive Radio

    50/95

  • 7/31/2019 Simulator for Cognitive Radio

    51/95

  • 7/31/2019 Simulator for Cognitive Radio

    52/95

  • 7/31/2019 Simulator for Cognitive Radio

    53/95

  • 7/31/2019 Simulator for Cognitive Radio

    54/95

  • 7/31/2019 Simulator for Cognitive Radio

    55/95

  • 7/31/2019 Simulator for Cognitive Radio

    56/95

  • 7/31/2019 Simulator for Cognitive Radio

    57/95

  • 7/31/2019 Simulator for Cognitive Radio

    58/95

  • 7/31/2019 Simulator for Cognitive Radio

    59/95

  • 7/31/2019 Simulator for Cognitive Radio

    60/95

    < >

  • 7/31/2019 Simulator for Cognitive Radio

    61/95

  • 7/31/2019 Simulator for Cognitive Radio

    62/95

  • 7/31/2019 Simulator for Cognitive Radio

    63/95

    < >

    sim::Base_station

    sim::Primitive_device

  • 7/31/2019 Simulator for Cognitive Radio

    64/95

  • 7/31/2019 Simulator for Cognitive Radio

    65/95

    >

  • 7/31/2019 Simulator for Cognitive Radio

    66/95

  • 7/31/2019 Simulator for Cognitive Radio

    67/95

    < >

  • 7/31/2019 Simulator for Cognitive Radio

    68/95

    < >

  • 7/31/2019 Simulator for Cognitive Radio

    69/95

  • 7/31/2019 Simulator for Cognitive Radio

    70/95

  • 7/31/2019 Simulator for Cognitive Radio

    71/95

  • 7/31/2019 Simulator for Cognitive Radio

    72/95

    < >

  • 7/31/2019 Simulator for Cognitive Radio

    73/95

  • 7/31/2019 Simulator for Cognitive Radio

    74/95

    < >

    < >

    < >

  • 7/31/2019 Simulator for Cognitive Radio

    75/95

  • 7/31/2019 Simulator for Cognitive Radio

    76/95

  • 7/31/2019 Simulator for Cognitive Radio

    77/95

  • 7/31/2019 Simulator for Cognitive Radio

    78/95

  • 7/31/2019 Simulator for Cognitive Radio

    79/95

  • 7/31/2019 Simulator for Cognitive Radio

    80/95

    < >

  • 7/31/2019 Simulator for Cognitive Radio

    81/95

  • 7/31/2019 Simulator for Cognitive Radio

    82/95

  • 7/31/2019 Simulator for Cognitive Radio

    83/95

    < >

    sim::Primitive_device

    sim::Base_station sim::User

  • 7/31/2019 Simulator for Cognitive Radio

    84/95

  • 7/31/2019 Simulator for Cognitive Radio

    85/95

    < >

  • 7/31/2019 Simulator for Cognitive Radio

    86/95

  • 7/31/2019 Simulator for Cognitive Radio

    87/95

  • 7/31/2019 Simulator for Cognitive Radio

    88/95

    < >

    sim::User

    sim::Primitive_device

  • 7/31/2019 Simulator for Cognitive Radio

    89/95

  • 7/31/2019 Simulator for Cognitive Radio

    90/95

  • 7/31/2019 Simulator for Cognitive Radio

    91/95

  • 7/31/2019 Simulator for Cognitive Radio

    92/95

  • 7/31/2019 Simulator for Cognitive Radio

    93/95

  • 7/31/2019 Simulator for Cognitive Radio

    94/95

  • 7/31/2019 Simulator for Cognitive Radio

    95/95