scieee AI-readable full text Open interactive document viewer

Design and implementation of an OFDM-based communication system for the GNU Radio platform

Majo Boter, Marcos

Abstract

Català: El processament de senyal en temps real mitjançant software és un camp que s'està expandint molt gràcies a la capacitat de processament dels ordinadors actuals. L'objectiu d'aquest treball ha estat el disseny i la implementació d'una Ràdio Definida en Software (SDR) que funcioni amb tecnologia OFDM, similar a la utilitzada en les comunicacions mòvils de 4a generació, per a la plataforma GNU Radio.

Full text

Design and implementation of an OFDM-based communication system for the GNU Radio platform Master Thesis Author Marcos Majó Submission date December 18, 2009 Supervisors Dipl.-Ing. Matthias Kaschub Dipl.-Ing. Christian Müller Dipl.-Ing. Magnus Proebster Dipl.-Ing. Thomas Werthmann Dipl.-Ing. Martin Schmidt Institut für Kommunikationsnetze und Rechnersysteme ·Universität Stuttgart Prof. Dr.-Ing. Andreas Kirstädter Prof. em. Dr.-Ing. Dr. h.c. mult. P. J. Kühn Pfaffenwaldring 47 ·D-70569 Stuttgart ·Germany Abstract As technologies quickly evolve and computers and devices become more powerful and economical, paths of research appear allowing a new mass of researchers the chance to work on technologies that were only available to few. This is the case for wireless communications technologies. The practical research was very costly in terms of time and also money, sometimes even being necessary to build prototype circuit boards for testing a possible model. Actual commodity computers have become powerful enough to be able to undertake the signal processing tasks that have always been done by dedicated devices. Cheap computers like the ones we use at home are now able to do the necessary computation that these dedicated devices are doing. This is what Software Defined Radio (SDR) is all about. The translation of the signal processing into software run by a regular computer opens up a huge number of possibilities at an affordable price. Now we can access to all the parameters that were embedded and invariable before. Thanks to SDR now we can analyze and change every value of the system. This project will try to get a grip of the state of the art in both wireless communication technology and SDR projects. With that objective in mind, in this project an implementation of a wireless communications system will be made. For the physical layer of this system Orthogonal Frequency-Division Multiplexing (OFDM) was chosen as the transmission multiplexing method. This choice has been made because of the advantages that OFDM has shown in terms of channel capacity. It has proven its importance by gaining relevance in two of the most important technologies for the 4th generation of wireless communications: WiMAX and LTE. The software toolkit that has been used for the implementation of the prototype has been GNU Radio; an open source project that is being used by many researchers and manufacturers all over the world, and that is growing steadily in source code available and in active members and projects using it. The implemented prototype communication system has been a prove of concept that has shown that it is possible to run a communication system of a certain complexity all in software with not much more than commodity equipment. The prototype has shown a very good behaviour in some parts of the system such as the synchronization, and has also shown weaknesses in other parts, like the return channel or the equalization. The data rate achieved in one channel has been 95.2 Kbps, which is a positive result given the context it is in. Kurzfassung Durch die rasante Weiterentwicklung der Technologie und dadurch dass Computer und Geräte immer leistungsfähiger und billiger werden, ergeben sich heute viele neue Forschungswege die früher nur wengigen Forscher vorbehalten waren. Dies gilt auch im Gebiet der drahtlosen Kommunikationstechnik. Die praktische Forschung in diesem Gebiet war früher sehr teuer und zeitaufwändig. Manchmal war es sogar notwendig neue Hardware-Prototypen zu bauen um neue Technologien zu testen. Gewöhnliche standard PC’s, wie die die wir Zuhause benutzen, sind heute in der Lage die komplette Signalverarbeitung zu übernehmen welche früher von speziellen Geräten erledigt wurde. Die Signalverarbeitung in Software wird als Software Defined Radio (SDR) bezeichnet. Durch die Verwendung von standard PC’s hierfür eröffnen sich eine große Zahl an neuen preiswerten Möglichkeiten für die Forschung. Dank SDR ist es nun möglich alle Parameter frei zu wählen welche vorher fest in einem Gerät definiert waren, des Weiteren können alle Werte des gesamten Systems analysiert und verändert werden. In diesem Projekt wird versucht die neuste Technologie in den Bereichen der drahtlosen Kommunikationstechnik sowie von SDR-Projekten aufzunehmen. Mit diesem Ziel vor Augen wurde in diesem Projekt ein drahtloses Kommunikationssystem aufgebaut. Für die physikalische Übertragungsschicht wurde OFDM als Mehrkanalübertragungsmethode gewählt. Diese Auswahl wurde getroffen, da es bei OFDM viele Vorteile hinsichtlich der hohe spektrale Effizienz gibt. In der vierten Generation der drahtlosen Datenübertragungstechniken gibt es zwei maßgebliche Standards wie WiMAX und LTE die sich durchgesetzt haben. Das Software-Toolkit das für die Implementierung des Prototypen verwendet wurde ist GNU Radio, ein Open-Source Projekt das von vielen Entwicklern und Herstellern auf der ganzen Welt verwendet wird und das ständig an Möglichkeiten und aktiven Mitgliedern wächst. Der entwickelte Prototyp hat gezeigt dass es möglich ist ein komplexes Kommunikationssystem mittels Software zu beschreiben und mit handelsüblichem Equipment zu betreiben. Der Prototyp zeigt ein gutes Verhalten in einigen Bereichen des Systems wie zum Beispiel bei der Synchronisation. Auch wurden Schwachstellen aufgezeigt in anderen Bereichen des Systems wie zum Beispiel beim Rückkanal und der Entzerrungsphase. Die ereichte Datenrate in einem Kanal beträgt 95.2 Kbps was ein positives Ergebnis hinsichtlich der Möglichkeiten darstellt. Contents 1 Introduction 1 1.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 Tasks and contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2 Theoretical concepts 3 2.1 Software Defined Radio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.1.1 Basic principle and differences to analog radios . . . . . . . . . . . . . 3 2.1.2 Different software defined radios available . . . . . . . . . . . . . . . . 5 2.2 OFDM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.2.1 Multiple subcarriers and orthogonality . . . . . . . . . . . . . . . . . . 5 2.2.2 Delay spread and cyclic prefix . . . . . . . . . . . . . . . . . . . . . . 7 2.2.3 Synchronization and channel equalization . . . . . . . . . . . . . . . . 8 2.2.4 Phase modulation in the subcarriers . . . . . . . . . . . . . . . . . . . 10 2.3 Reliable transmission . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.3.1 Forward Error Correction (FEC) . . . . . . . . . . . . . . . . . . . . . 10 2.3.2 Retransmission of data . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3 Architecture of the used platform 14 3.1 GNU Radio concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.2 Requirements of GNU Radio . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 3.2.1 The USRP2 peripheral . . . . . . . . . . . . . . . . . . . . . . . . . . 16 3.3 GNU Radio’s graphical interface . . . . . . . . . . . . . . . . . . . . . . . . . 18 3.4 Basic example application: moving peak . . . . . . . . . . . . . . . . . . . . . 19 4 Implementation 22 4.1 Objectives, resources and limitations . . . . . . . . . . . . . . . . . . . . . . . 22 4.2 OFDM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 4.2.1 GNU Radio’s OFDM modules . . . . . . . . . . . . . . . . . . . . . . 23 4.2.2 OFDM modulator’s implementation . . . . . . . . . . . . . . . . . . . 26 4.2.3 OFDM demodulator’s implementation . . . . . . . . . . . . . . . . . . 27 4.3 Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 4.3.1 Pseudorandom Noise implementation . . . . . . . . . . . . . . . . . . 30 4.3.2 Maximum Likelihood synchronization implementation . . . . . . . . . 30 4.3.3 Synchronization Performance and Measurements . . . . . . . . . . . . 31 4.4 Forward error correction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 4.4.1 GNU Radio’s trellis library . . . . . . . . . . . . . . . . . . . . . . . . 33 4.4.2 Implemented modules for FEC . . . . . . . . . . . . . . . . . . . . . . 34 4.4.3 Performance and measurements for the FEC . . . . . . . . . . . . . . 35 4.5 Automatic repeat request protocol . . . . . . . . . . . . . . . . . . . . . . . . 37 4.5.1 The uplink channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 4.5.2 Protocol implementation . . . . . . . . . . . . . . . . . . . . . . . . . 39 4.6 Performance measurements and comparisons . . . . . . . . . . . . . . . . . . 40 I 5 Summary and outlook 42 Appendix A: Advanced GNU Radio concepts 46 A.1 Creation of new C++ signal processing modules . . . . . . . . . . . . . . . . 46 A.2 Flowgraphs and scheduler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Appendix B: Lists and Registers 48 B.1 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 B.2 List of Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 B.3 List of Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 B.4 List of Abbreviations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 II 1 Introduction This chapter gives an overview of the objectives of this project, as well as the different tasks that will be necessary to fulfill these objectives. The chapter is divided in the motivation section 1.1 and the tasks and contents section 1.2. In the motivation I explain the interests that made us decide for this project, introducing also the context in which it has been thought. The tasks and contents section will explain the different proposed tasks for this project and will locate them in the different chapters and sections of the project. 1.1 Motivation This project has been conceived as the result of putting many ideas in the practice. It started with the objective of covering and gaining experience in some fields of interest in wireless communications such as SDR or the implementation of a communications system based on the OFDM modulation. The first idea that starts shaping this project is the importance that SDR has acquired in the last years. As of today it has become a tool that allows researchers great freedom at a very moderate price. Some years ago, the leap between the theoretical part of a technology and its practical implementation was very big, both in terms of requirements and specially costs. The proliferation of SDR projects, specially based on open source software, and the interest from the academic and industrial community for its utilization have created a relatively simple and comparatively very affordable solution for the implementation and testing of a very large number of wireless technologies. One of the objectives of this project is to gain knowledge about actual SDR projects, its state of the art and the possibilities it offers. Another important point for the development of this project, more specifically its practical part, is our interest for the GNU Radio project, the chosen implementation platform and one of the most developed and active toolkits for the development of SDR applications as of today. This thesis will allow us to gain experience and get acquainted with GNU Radio: its structure, its programming, its advantages and its limitations. The implementation of the communication system in the GNU Radio environment is the perfect way of getting to understand this tooklit. In order to finish shaping this project the content of the implementation should be decided. The most attractive technology for us was OFDM. It has a very good behaviour in terms of spectral efficiency and it is a very hot technology that has found its way into the most important standards for wireless communications in this new generation called 4G, in which the main standards are the IEEE 802.16 (Worldwide Interoperability for Microwave Access (WiMAX)) and the 3GPP’s Long Term Evolution (LTE). 1 1 Introduction Finally, a motivation point that has a slight futuristic component is the inclusion of the implemented prototype in one of the lectures or laboratory courses of out institute, allowing students to experiment with these technologies. The simple mechanics of software radio can give the prototype high learning potential for its versatility and possibilities of costumization. 1.2 Tasks and contents For this project a communications system will be implemented. This communications system will include a physical layer based on the OFDM multiplexing method, thus being comparable to actual technologies such as WiMAX or LTE. This communications system will be enhanced with a reliable communications channel based on a Forward Error Correction (FEC) mechanism and a retransmission of wrongly received packets protocol (Automatic Repeat reQuest (ARQ)). The first part of this thesis is the theoretical part, in which the technologies that will be used during the implementation are explained. I will try to project the role that these technologies will play in the implementation throughout the theoretical explanation. These part is included in chapter 2. Chapter 3 is dedicated to introduce the concepts and ideas behind the chosen software toolkit for the implementation: GNU Radio. This chapter will explain the structure of GNU Radio with the objective of giving the reader a general idea of the possibilities of GNU Radio. This chapter can be specially useful for people interested in starting a SDR project that are considering GNU Radio as their platform. The implementation chapter 4 details the steps followed for the set up and creation of the prototype. First of all an estimation is made of the possibilities of successfully implementing such a system. Then each of the steps followed for the implementation of the system is explained, with its key points with the results extracted after each step. In the end, chapter 5 summarizes the work done and provides some suggestions for the future development of this project. 2 2 Theoretical concepts This chapter explains the theory behind this project. First of all, in section 2.1 I will explain the basic concepts and ideas behind SDR, as well as some brief information about the state of the art in available SDR platforms. Afterwards, in section 2.2 I will explain the different concepts that OFDM is built upon as well as the reasons that made us choose OFDM as the multiplexing method that will be implemented. Finally, in section 2.3 I will explain the mechanisms used to provide a reliable channel in the communications, which are the FEC protocol and the ARQ protocol. 2.1 Software Defined Radio SDR is a concept that has been used since the early nineties. Its original purpose was the creation of a device capable of emulating many radios working at different frequencies. However, it has evolved and is still doing so into a tool which has a much broader use. Software defined radio nowadays is a tool that helps the wireless and mobile communications industry in many aspects. 2.1.1 Basic principle and differences to analog radios The basic principle of SDR is the reduction to the minimum of the hadware dedicated to signal processing parts and its translation into software that should be runnable by an all-purpose commodity PC. The signal should be generated digitally and dealt with in the PC as much as possible, undergoing modulators, filters, FFT blocks and even amplifiers, all of them done in software, until the signal is ready to be sent. Then, the software gives place to the hardware, which has the function of transforming the digital samples in an analog signal and modulating the baseband signal to the desired carrier frequency to be sent. The last stage would be sending it to the antenna. The concept of SDR is very different to the traditional radios that we have been using until now. Traditional radios rely on dedicated hardware for all its functions and each hardware part has a very concrete and fixed function. The same processor in the PC used by SDR will take care of all the signal processing, and it will be the software the one responsible of dictating the function that will be computed. Figure 2.1 show a block diagram of a software defined radio. Not having dedicated hardware has a very important advantage in relation to traditional radios. All parameters that the radio uses are set in software, and they are all configurable through software. This makes the development and research of new applications a lot easier, faster and cheaper, as we can use software radio as a prototype where we can test all kinds of variations and configurations. We will not need to make or order hardware in order to try new 3 2 Theoretical concepts Figure 2.1: Module diagram of a SDR sender and receiver configurations or variations of any kind. Another advantage is the possibility of having a radio that can work as many radios, as the same device can use different radio technologies without any change in the hardware. This application was one of the first objectives of software radio, but for a number of reasons that I will explain in the next paragraphs, it is still not a very interesting solution. Software radio has some hardware requirements. It will require some ADC and DAC hardware, as well as RF module dedicated to the modulation to the desired transmission or receiving frequency. These elements and a PC with enough computational power to run the software are the only hardware that we need. If we need to speak in numbers, we should differentiate if the radio will be used for narrow band applications or for wide band. For narrow band applications a regular Pentium PC should have more than enough capacity to meet the requirements. If, however, the application that we want to implement uses up a bigger part of the spectrum for example, a receiver of multiple FM channels at the same time, the requirements get much bigger and we might need powerful PCs in order to process all the data that we are using in the required time [17]. In our application we will be implementing a communications system based on OFDM, which is also a wide band application. We will see in a latter chapter 4 the impact of the computation in the amount of spectrum that can be used. Not all aspects of software radio are positive. There are also a number of challenges that have been reducing the use of SDR to a limited number of applications. The first of them all is the power consumption of a SDR device. As we have seen in the hardware requirements, we will in many cases need powerful computers to run an application. This means that we will need an amount of power that would never be achievable by a handheld device. The power consumption of SDR devices is not comparable to the power needed by the radios that nowadays work in hardware. Another important drawback is that even if the power needed could be reduced, the size of the hardware needed to process the signal is also much bigger than the dedicated hardware of the traditional radios. This is why the project of having a portable device based on SDR that can be used as many different radios has not evolved very much, and the use of SDR has been reduced to research or applications in the base station, instead of the mobile terminal, where the power requirements are not so critical at the moment. 4 2 Theoretical concepts hundreds of bytes) and apply redundancy that contains information about the whole block of data. Therefore, each block is independent from all other blocks. Convolutional coding operates on serial data. It will take data in continuously and the redundancy will use a number of bits (called constraint length and represented with the letter Lor K) to generate the output bits. Another important value is the code rate, which shows the relationship between input and output bits. All FEC implementations can be characterized by the parameters n, k and m. The following formulae show the relationship between the constraint length or the code rate and these three basic parameters. •n= number of output bits •n= number of output bits •m= number of memory registers L=k(m−1) (2.1) code rate = k n(2.2) Choosing the value of the parameters chosen for the FEC system we want to implement is a very important task in the design of a communications system. There are several issues that must be taken into account. First of all, the characteristics of the channel that we will work on should be known. Then a set of parameters must be chosen in order to find the best performance. The first trade-off that we will face is the threshold SNR of the channel. FEC implementations usually work well in environments with up to a certain SNR. If the SNR falls lower than that threshold the performance of the FEC algorithm is likely to fall down to a point of not performing well at all, outputting data worse than the received in its input in most cases. The second fact that we need to take into account is that adding more redundancy will increase the amount of data to be sent, and that will affect directly the throughput of the channel. Finally, bigger values of malso increase the complexity of the decoder exponentially. To give a general idea of this magnitude, most applications use constraint lengths up to a value of 9 bits (data from 1999) [12]. The FEC implementation of this project will use a convolutional code encoding with a Viterbi decoding mechanism. Viterbi decoding was developed by Andrew J. Viterbi and first published in IEEE Transactions on Information Theory in 1967 [8]. Viterbi decoders are one of the two mechanisms to decode data encoded with convolutional codes. The other mechanism is sequential decoding. The main advantage of Viterbi decoders is that the decoding takes a fixed amount of time to conclude. That helps us estimate the feasibility of its inclusion in our system. It is also well suited for hardware implementations. Viterbi decoding can work on soft bits and hard bits. The data that it works with can be almost analog and the outputted data will be digital. If we use hard bits as input for the Viterbi decoder there must be a decision block before the decoder that takes analog received data in 11 2 Theoretical concepts its input and outputs one of the possible symbols received, which will probably be the one that is closest to the analog data received. When the Viterbi decoder works with soft bits it will quantify the analog data first and then work with the quantified values directly, which usually improves its performance. Explaining the way the Viterbi decoder works is not a target of this thesis, but I will try to explain very briefly its basic idea in this paragraph. For more information refer to [12]. The main idea of the Viterbi decoding algorithm is to find the stream of data that was sent among all possible streams sent. This is calculated in a rather simple way thanks to the way the data is encoded by the convolutional code algorithm. Each symbol received at the decoder will be followed by another symbol with a fixed known probability. This way, if we receive two symbols that should not come one after the other we detect a possible error. Each time a new symbol comes a path is drawn for all the possible sequences of received symbols and its count of possible errors. In the end the path that accumulated the least amount of errors is the path chosen. According to the success rate of the received data, the use of FEC algorithms can be seen as an increase of the channel’s SNR. As an example, a convolutional code with rate 1 2with constraint length of 7 can be seen as an increase of 5dB in the channel’s SNR. This way of analyzing the behaviour of the algorithm can be useful for knowing the increase of the performance that we achieve by using the FEC. Then we can decide on its need or we can modify some of its parameters if necessary. 2.3.2 Retransmission of data The need of a reliable channel requests the use of some algorithm to make sure all data is received correctly. Therefore a retransmission algorithm is needed in the data link layer, which will be used once the data packets have been received and after they have been validated with a redundancy check mechanism such as Checksum or CRC. There are many different algorithms that can be used for this purpose. The most simple one is the ARQ protocol, which starts a timer in the receiver that waits for the next data packet to be received. If the data packet is received on time the receiver sends an acknowledgement message requesting the next data packet. After a certain time, if the expected packet has not been received the receiver will consider the expected packet lost and will send a message to the sender requesting the same packet that was expected. This is the basic idea. From this simple idea many enhancements have been made in the field of retransmission of lost packets. Some of them are meant to reduce the number of messages sent by inserting the acknowledging messages in the uplink channel, which is called piggybacking. Another protocol for resending lost packets is the Sliding Window Protocol [11]. It has not been implemented in this project but it is a very broadly used protocol for retransmission that is present is many wireless communication systems. This protocol will acknowledge many received packets at the same time by sending only one acknowledge message. In this case, if the packets have not been received before the time out, the acknowledge message will only acknowledge the 12 2 Theoretical concepts last packet received before the first missing packet. This protocol also saves traffic of acknowledge messages in the system. 13 3 Architecture of the used platform This chapter presents the platform used for the implementation of the communication system. This platform is GNU Radio, a free software toolkit that allows the implementation of SDR. It is distributed under the GNU General Public License. GNU Radio’s target users are hobbyists, academics and researchers. GNU Radio was started in 2001 by John Gillmore and Eric Blossom, and it has been growing in members and amount of source code. Nowadays it has a large and active community and provides many examples and reference systems and applications for Global System for Mobile communications (GSM), OFDM, High-definition television (HDTV), etc. In section 3.1 I will explain the concept and basic ideas behind GNU Radio. Then, in section 3.2 I will explain the requirements of all GNU Radio based systems, and I will also explain the hardware peripheral that is most commonly used for the RF part of the system, the Universal Software Radio Peripheral (USRP). After introducing GNU Radio in a theoretical way, and in order to consolidate the previously explained ideas I will present an example application and finally, in section 3.3 I will introduce GNU Radio Companion (GRC), the graphical interface of GNU Radio. Additionally, in appendix A 5 I will give some insight on advanced concepts for developing more complex implementations. 3.1 GNU Radio concept GNU Radio is a software toolkit designed to allow users to create SDR implementations. It provides mechanisms and tools to create customized and also a great amount of source code modules that can be used as a part of a customized radio as well as stand-alone examples. GNU Radio is used by a large community of hobbyists, academic researchers and commercial companies, specially for prototyping and testing possible implementations. The software in GNU Radio is divided in modules. These modules can be divided in two large groups. The modules that take care of the signal processing needed in the system are programmed in C++. These signal processing modules can be signal filters, equalizers, FFT modules and so on. The other group of modules include the software needed to interconnect these signal processing modules and configure them according to out needs. These last ones are programmed in Python and they act as some kind of glue that makes the whole system one unit [14]. The possibilities that Python provides for configuration without the need of compiling every time a change is made in a parameter are very convenient for quick reconfigurations and tests. GNU Radio modules are able to operate with infinite streams of data of a certain type. The most common types of data that we will use are complex, short and float. Many GNU Radio applications keep running forever, when the streams of data are infinite. If the stream 14 3 Architecture of the used platform Figure 3.1: Graph representation of a GNU Radio application has a finite number of bytes the application will finish once the data has been consumed out of the system. In a GNU Radio application the software modules can also be differentiated in three classes: Source modules, which provide a stream or signal into the system. Examples of source modules are file sources, that get data from a file and insert in into the system, or random data generators, that generate and output a stream of data according to some criteria established by us. The second group of modules are sink modules. They are the contrary of source modules. They receive an a stream of data and consume it. Some examples for these modules are the trivial null sink, which consumes the signal without doing anything, file sinks that insert the data from the stream into a file or even graphical spectrum analyzers, that convert the signal received into spectral data and present it to the user in a graphical way as a real spectrum analyzer would do. The last kind of modules are the modules with both input and output ports. They receive streams from their input ports, convert it into a different stream by applying a conversion or a filter and output the result through their output ports. Examples of these modules are band pass filters, Fourier transformation modules, operators or data converters. We are able to create GNU Radio applications by joining blocks. The union of these blocks creates a graph. We can see a simple example of one of these graphs in Figure 3.1. In the figure we can see various modules with their parameters and the connections between them. The graph representation is important to understand how GNU Radio executes each module in the system. All GNU Radio applications have one thing in common. All applications have a top block class that contains an initialization method that will create the instances on the needed modules, build the graph and initialize the parameters of these modules. This initialization method will be called from the main method when we run the application and only after it finishes its execution the system created will be ready to be used. When the application is running GNU Radio will execute the code of the blocks sequentially according to the graph. In the case of the application in Figure 3.1 we would need a Python script to create instances of all these modules, initialize all the parameters that we can see and join them with the connect to build the graph. 15 3 Architecture of the used platform 3.2 Requirements of GNU Radio Software Defined Radio applications are meant to substitute most of the signal processing in the system with software that will run in commodity computers, but they still need interfaces able to send and/or receive data that travels wirelessly through the air. This section explains what we can do with GNU Radio, and why we need to do it. First of all, if we have an application running infinitely this means that a regular processor will have to deal with the signal or signals in real time. Each application will have a certain degree of complexity and of signal processing to be done that will be translated in requirements. That is why requirements are a critical factor in SDR and, therefore in GNU Radio. SDR has gained popularity during the last ten years due to the fast increase in computation speed in commodity computers. The requirements of a simple GNU Radio application like the one we have seen in Figure 3.1 are basically any computer, as there are no complicated operations to be done, such as Fourier transformations, and a sound card that will be the responsible of acting as the RF interface. However more complicated applications, such as the implementation made for this project, have much higher computational requirements, because they use many signals and algorithms at the same time and are they must work in real time. The transmissions at higher frequencies also requires special hardware. GNU Radio is meant to work with additional hardware that takes care of translating the software generated digital signal into an analog signal centred in the desired frequency. For a small number of applications working at frequencies up to a few KHz a sound card would be enough, but for most other applications an external device is needed for this function. There is not a very large market for such devices, as there is not too many people working with SDR. However, GNU Radio implements software modules for one of these devices, the USRP. With a USRP we will be able to implement radios operating on frequencies up to some GHz. I will explain the characteristics and possibilities of the USRP in the next subsection. Another issue related to the computational requirements of GNU Radio applications is the duality of using Python generated code and C++. There is a fraction of the GNU Radio users that find the fact of using both languages at the same time a cause of performace loss. According to the developers of GNU Radio Python should only be used to create and configure the graph, and then the rest of the work should be done by the C++ modules. However there is an ongoing initiative meant to allow GNU Radio applications to run only in C++. This can speed up certain applications, but apparently, it would not represent a very big improvement to well programmed applications that use Python and C++. 3.2.1 The USRP2 peripheral The USRP is a device designed by Ettus Research with the objective of providing the conversion between the digital baseband signal that is processed in the host computer and the analog intermediate frequency (IF) signal when necessary. It is also responsible of modulating and demodulating the signal to and from the carrier frequency for sending and receiving [10]. The USRP has been specifically developed for SDR and it is highly compatible with GNU Radio. It 16 3 Architecture of the used platform Figure 3.2: Front view of a USRP2 device is also used in other SDR projects such as SDR4All [23]. Actually there are two different versions of the USRP in the market: the USRP and the USRP2. For this project two USRP2 devices have been used. The USRP consists of a motherboard, which contains an FPGA that takes care of the high bandwidth math and some ADCs and Digital to Analog Converters (DACs) able to provide bandwidths of around 30 MHz. The FPGA’s software can be programmed and stored in an SD card that is inserted in the slot on the front panel on the USRP2. The front view of the USRP2 can be seen in Figure 3.2. The motherboard will be connected to a daughterboard, that will take care of the analog part of the transmission and reception; the closest stage to the antenna. There are several daughterboards available for the USRP family [3]. Each one of them is able to operate at a certain range of frequencies. Actually, we can find daughterboards that operate in frequencies that span from the 0 Hz to the 5.85 GHz. All USRPs’ daughterboards include a power supply and one or various antenna connectors, depending on its characteristics. The daughterboard used for this project in both USRP2 devices is the RFX2400 that operates in the industrial, scientific and medical (ISM) band. The FPGA in the motherboard of the USRP contains digital down converters (DDC) and digital up converters (DUC) that converts the IF signal to the base band and vice versa and decimates it to achieve data rates that are suitable for the PC. This achievable data rate is one of the main differences between the USRP and USRP2. The first version is connected to the PC through a USB 2.0 interface. This connection has proven to be a bottleneck in applications that require large data rates, and that is why the USRP2 has substituted this USB 2.0 connection with a Gigabit Ethernet interface. The USRP2 also includes higher speed and higher precision ADCs and DACs that allow the simultaneous sending and receiving of bandwidths up to 50 MHz. Finally the FPGA in USRP2 is also more powerful [2], which allow the use of the USRP2 as a standalone system that can be used without a host computer in some cases. Figure 3.3 shows the look of the USRP2 devices together with the host computers that they use in this project’s implementation. 17 3 Architecture of the used platform Figure 3.3: USRP2 devices with their host PCs 3.3 GNU Radio’s graphical interface A very useful extension that GNU Radio provides is called GRC and it provides a graphical interface that allows its users to easily create GNU Radio applications. GRC has a list of available modules that can be inserted in the application by only clicking on them. These modules can also be configured, and GRC even tells you if the configured parameters are correct. Then, the modules can be connected together also very easily. Afterwards, GRC will build the needed python code that will run the application. The use of GRC has both advantages and disadvantages, but if it is used correctly it can be a good tool to save a lot of time and to avoid unnecessary mistakes. The main advantages it offers are the simple setup of a system, thanks to its graphical and easy to understand interface, the real time verification of the configured parameters, as it shows the parameters that are not correctly configured and where they are, making it very easy to locate configuration problems. Another advantage is the easy way of inserting and testing new modules in the system; New modules can be added to the system very easily in order to test their behaviour. However GRC also has some disadvantages. GRC only works with the modules and parameters and offers almost no place for customization of a module out of the configuration of the parameters. During the implementation of a module GRC is not recommended, as every time the module is modified one should take care of also modifying the files that allow this module to be controlled from GRC. We can say that GRC is a very interesting tool in some environments but it should be left out in other environments. In an educational environment GRC would allow students to control and create GNU Radio applications with a very short learning period, and with very successful results, as students would be able to understand all the stages of the system, control the different parameters and see the results in a very short period of time. However, in a research context, where the researcher is adding and customizing modules in all levels GRC would not be recommended, as it adds overhead time to the research process, specially when the researcher already knows GNU Radio well. GRC would be only useful to build test applications and then use the Python code automatically generated by GRC as the starting point for the development 18 3 Architecture of the used platform of more complex applications. Custom made modules can be added to GRC by creating an XML file that describes the module. In the next section we will see a simple example GNU Radio application built with GRC, and in Figure 3.4 we will see how the GRC interface looks like for the sender in that application. 3.4 Basic example application: moving peak In order to get familiarized with the structure of a GNU Radio application, in this section I explain the first steps that we have to do with GNU Radio to set up a running application. Before starting I want to explain the equipment and software that has been used for this test application. A GNU/Linux PC with the Ubuntu 8.10 (intrepid ibex) distribution. The PC used has 2Gb of RAM memory with a double core Intel Core 2 Duo processor at 2,33 GHz (each processor). Two Gigabit Ethernet network interfaces connect two USRP2 devices with one daughterboard each: the RFX2400 2250 - 2900 MHz Transceiver. This daughterboard allows us to work in the ISM band between 2.4 GHz and 2.5 GHz. With this equipment, the PC works with an average occupation of memory below 50% and with both processors working at around 60%. The installation of GNU Radio can be done in various manners. Some Linux distributions include GNU Radio in its repositories. Ubuntu is one of them. The GNUradio version that can be found in Ubuntu’s repository is relatively old and it lacks some of the GNU Radio modules. However, instead of using the distribution’s repositories we use the GNU Radio repository, which hosts the last and complete version of the software. This repository can be found by using the software subversion. Then, the installation process is very simple. After all the required applications are available, the common installation commands suffice: ./configuration, make, make install. The application that I will show in this example will generate a simple sinusoidal signal that will have a time-varying frequency. This signal will then be sent to the USRP2, and another USRP2 will then act as a spectrum analyzer showing the spectrum where we will try to identify our sinusoidal signal. This signal will be a vector of 256 values that represent the spectre that I want to see in the receiver side. This vector will consist (in this example) of only one "1" value and the rest 0 values. This is meant to create a spectrum that consists of only one peak at a given frequency in an instant. The "1" symbol will occupy different positions in the vector as time goes by, so we will try to see this peak in the receiver side move according to the position of the "1" symbol in the inputted vector. The first considerations that we have to make are related to the hardware limitations that we have. The most important of all is that as we only have a daughterboard for the USRP2 that works at 2.250 to 2900 MHz. So the frequencies that I will be using will be around 2.4 GHz. The input data is taken from a file. This file contains values of type short (1 byte each) that will be inputted to an iFFT module. To do that first of all the raw short data stream will have to be converted into a vector of 256 complex values, which is the expected input of the iFFT module. For that purpose we will use a module to convert short data into float data, another 19 3 Architecture of the used platform Figure 3.4: Module layout of the sender built with GRC module will convert the stream of float data into a stream of complex data, and finally another module will take the stream of complex values and group them into groups of 256 values, thus creating the vector that will be used as the input of the iFFT module. The file source module has two important parameters that must be configured, as is the filename, the kind of data that we take from it (short: 1 byte, int: 2 bytes, float: 4 bytes, complex: 8 bytes) and repeat, which outputs the contents of the file repeatedly, giving the application infinite duration. The type conversion modules that convert the short data stream to the complex data stream are as simple as their names indicate. The module that transforms a stream of data into vectors is also very simple and you can only set the size of the outputted vector. The FFT module is more complex than the ones previously seen. It can compute the FFT and iFFT with the desired number of samples. The input can be float (only allowing forward FFT) or complex (allowing both forward and reverse FFT). Then there is also a configurable window parameter which is a Blackman-Harris 1024 by default. The last parameter that can be edited is the shift parameter, that will move the correspondence of the 1st value of the vector or the middle value to the reference frequency. The resulting timely signal that comes from the iFFT module will be sent to the USRP2 to be sent to the air. For this purpose the USRP2’s parameters must be configured correctly. In order to find the USRP2 in the system (Gigabit Ethernet interface), the first parameters that must be configured are the interface and the MAC address of the USRP2 board. Usually the interface name will suffice to identify the board, but both can be set. In order to use this interface the application that we run in GNU Radio will need root permissions. The next parameter is the kind of data that we are going to send to the USRP2. It can be a complex or short value. Then there is an interpolation rate, that modifies the behaviour of the FPGA of the USRP2 and will limit the usable bandwidth and the data rate. The usable bandwidth that we will output are 100MHz, that is set by the divided by the interpolation rate, which in this case is 16, so the resulting bandwidth will be 6.25 MHz. In Figure 3.4 we can see all these modules as they appear in GRC’s interface with it’s parameters. In order to see the resulting signal we will use one of the many sample applications that come with GNU Radio, which is a graphical software spectrum analyzer. We can see in the resulting spectrum in Figure 3.5. In order to show the total bandwidth available in the picture, Figure 3.5 20 4 Implementation The next module in ofdm.py is preambles and it is defined in the C++ file gr_ofdm_insert_ preambles.cc. This module is the responsible of adding one preamble to each OFDM frame that we want to send. The information in the preamble is a known sequence of symbols that is constructed from a vector of ones and negative ones that has been randomly generated and is stored in the file ofdm.py. The input of this module is made to fit with the output of the pkt_input module. This way, the first input port will contain OFDM symbols and through the second one it will receive the character that marks the beginning of the frame. If it is the case, it will buffer the OFDM data symbol, output a preamble and then output the buffered data symbol. This module has the same outputs as its previous module, but in this case only the first port will be used. The next step is the Fourier transformation and it is done by the iFFT module that is defined in the C++ file gr_fft_vcc.cc. This module takes a vector of complex values and computes the FFT. It is used both for the computation of the FFT and the iFFT just by editing its parameters. It also allows us to set other parameters such as the window used [18] or if the FFT should be shifted. After the Fourier transformation, the redundancy belonging to the cyclic prefix must be added to the OFDM signal. This is the job of the next module in the modulator, cp_adder. This module is also defined in C++ in the file gr_ofdm_cyclic_prefixer.cc. It does a very simple job. It takes the OFDM symbol from its input port and copies the last symbols (the number of symbols to copy is specified in the cp_size parameter) at the beginning of the symbol, thus creating a symbol with a size that is the sum of the size of the inputted symbol and the size of the cyclic prefix. Finally, after the FFT, the OFDM symbols are amplified by a multiplication with a constant value. The resulting signal contains the payload, which has been transformed into a data packet, then the redundancy corresponding to the preambles for the synchronization and equalization, then the redundancy corresponding to the cyclic prefix and finally some amplification. The OFDM signal is now ready to be sent to the channel in the uppermost layer of the application, which, in our case, will be the air by using the USRP2 that will send the modulated baseband signal at the transmit frequency, which is 2.5 GHz. 4.2.3 OFDM demodulator’s implementation The demodulator is made of many C++ and Python files. Each of the files that make the demodulator plays a role in the complete demodulation process. This section explains how all the files that make the demodulator are joined and what is their job. In other sections I will give some more detailed information about certain parts of the demodulation process, such as synchronization. Like the modulator, the demodulator is firstly defined in the file ofdm.py. The demodulator has both input and output. Its input comes, in most cases, from the output of the channel. Its output port will contain the demodulated signal. However, the most commonly used output mechanism is the parallell mechanism to the send function that is explained for the modulator. 27 4 Implementation Figure 4.2: Block diagram of the ofdm_receiver module The output data will be sent to a handler via a callback function. There is a function running in a separate thread that monitors the queue of demodulated data packets. Once a new packet enters this queue it will be taken by this function that will check the correctness of the data in the packet by looking at the CRC code. Afterwards it will call the previously mentioned callback function with the payload as a parameter. The callback function will be executed in the uppermost level of the blocks hierarchy, in the ofdm.py file. The inner structure of the demodulator has two big parts, corresponding to the two blocks that are defined in ofdm.py and that can be seen in Figure 4.1. One of them, ofdm_receiver, takes care of the synchronization and equalization of the CRC signal, while the second module, ofdm_frame_sink, is a state machine that demaps the symbols into bits, checks the validity of the synchronized frames and sends them to a superior layer by adding them to the queue of received data packets. The demodulator’s ofdm_receiver module is defined in a Python file that includes a number of modules. The fact that the demodulator has one extra layer of Python files is a hint of the complexity of the demodulator. Figure 4.2 shows the blocks that make the ofdm_receiver module. The blue arrow in the figure shows the path the signal follows, while the black arrows carry other kinds of data that are not the actual OFDM signal. The first module of the receiver is a simple Fourier filter on the input signal coming from the antenna that takes the bandwidth corresponding to the number of carriers that contain actual data, which is usually less than the size of the FFT and in our implementation it was 200 used subcarriers for an FFT of 256 subcarriers. Once the signal has been filtered it is fed into the synchronization block. There some calculations will be made to find the right frequency offset and the beginning of the frames. The synchronization block will be explained in the next section. The synchronized signal will then travel in vectors of the size of the FFT to the Fourier transformation module that will output a signal in the frequency domain. Each frequency is a subcarrier and contains information in its phase according to the digital modulation applied to each of the subcarriers; in our case, all of them are modulated with BPSK. The last part of the synchronization will be finding the beginning of the frames and equalizing each subcarrier. The second module that makes the OFDM demodulator is less complex than its preceding one. The frame_sink module is defined in C++ and looks more or less like a state machine. This state machine has three states. One of them is sync search, in which the algorithm looks 28 4 Implementation Figure 4.3: Block representation of the state machine in the frame_sink module for the flag in the second input indicating the beginning of the frame. Once it is found it will arrive in the have sync state. Then it will let the preamble through. Afterwards the algorithm will demap the symbols and check the bytes corresponding to the header of the data. The header is built in a way that the first and the last half are exactly the same, so this is the way it validates the header. If the header is correct, the state machine will move to the next state, which is called have header. There, the algorithm will demap the rest of the frame and insert the resulting data bits in the output queue. As I explained before, that queue is monitored by a thread that will take the data, validate it and send the results to the upper layers of the system. Throughout the duration of the have sync and have header states, the algorithm will constantly look for beginning of frame flags in its input port. In case it finds one it will detect an error and reset the state machine to the sync search state. Figure 4.3 shows the behaviour of the state machine in the frame_sink module. 4.3 Synchronization GNU Radio has three different synchronization mechanisms implemented for OFDM. One of them is the Maximum Likelihood (ML) synchronization [5], the other one is based in the correlation of pseudorandom noise (PN) numbers [7].The third one is an enhanced version of the PN mechanism that uses initial cross-correlation. This enhanced PN synchronization is still showing some flaws and it is not fully usable. One last synchronization method called fixed synchronization is also in development, but its use is not recommended and there is no 29 4 Implementation documentation for it, so I will not comment on it. This leaves us with two main synchronization mechanisms that will be explained in the next subsections. PN and ML. 4.3.1 Pseudorandom Noise implementation The chosen synchronization mechanism for the prototype has been the PN synchronization. The synchronization takes place in the ofdm_receiver module, and it affects most of its modules. The first thing that is done is finding the frequency deviation of the frames from the carrier frequency. Then, the signal will be sampled according to the frequency deviation and then this signal in the time domain will be transformed to the frequency domain with the FFT. The last stage is finding the start of the frame by using the information contained in the preambles and equalizing each subcarrier in amplitude and phase to correct the distortion caused by the channel. If we observe Figure 4.2 we can see that the input of the ofdm_sync_pn module is the signal, but the output doesn’t include the signal. Looking at the Python source code and knowing the functionality of its modules we can see that the outputs will be on the one hand a timing signal coming from a peak detection and on the other hand the frequency correction value. The process that the synchronizer follows to find the frequency offset is as follows. First it correlates the input signal with its own conjugate with a delay of half the size of the FFT. The result of this operation will give a maximum when the correlation members are the first and second half of the preamble. The angle of the correlated complex signal will then be extracted. This angle is used for frequency correction by using a sample and hold module controlled by the peak detector. When a peak is detected, the sample and hold will output the angle, which is the frequency offset of the signal. The ofdm_sampler module will use that frequency offset to sample the signal that comes straight from the channel. The output of the ofdm_sampler is the signal sampled in vectors of the size of the FFT. These vectors will be transformed in the FFT module. Then they will go to the ofdm_frame_acquisition module. This module will find the start of the frame based on two known symbols, that will be BPSK PN sequences. PN sequences look like random sequences but are deterministically generated. The input signal will be correlated with these known symbols. This uses the information provided by the indication of the beginning of a preamble that the module receives from its second input. The maximum correlation will give the start of the frame. After this, the same frame_acquisition module will use one of the known symbols to estimate the channel response and apply a 1-tap equalization on all subcarriers. This is supposed to help correct amplitude and phase distortion caused by the channel. The synchronized and equalized signal will then exit the ofdm_receiver ready to be demapped in the next stage of the demodulation process. 4.3.2 Maximum Likelihood synchronization implementation The ML synchronization method is another working synchronization method that GNU Radio provides. It works differently to the previously explained PN synchronization method. As 30 4 Implementation this method has not been used for the implementation, it will not be explained in such detail. However, a module scheme is available in [20], and the theoretical documentation is in [5]. First of all, changing between one synchronization module and another is as simple as changing the value of a variable in the ofdm_receiver.py Python file. The ML is one of the synchronization modules that is supported by GNU Radio, so it doesn’t require any special configuration. However, some aspects will need to be taken into account. The ML synchronization module uses the redundancy in the cyclic prefix to find the synchronization instead of using the preambles. This means that we need to keep in mind the length of the cyclic prefix, as it is a very important parameter in the robustness of the synchronization. The order of magnitude of the length of the cyclic prefix to achieve good performance of both time and frequency estimators is about 4 or 5 samples for good SNR environments (more than 15dB) or 12 to 15 samples for low SNR channels (4dB) [5]. The estimation of the channel would improve by adding pilots to the OFDM signal for the synchronizer to use, but at the moment it is still not implemented in the GNU Radio ML synchonization. 4.3.3 Synchronization Performance and Measurements The PN synchronization mechanism has proven to be a good algorithm for our system. It has shown robustness in finding the beginning of the frames correctly. However, there are some indicators that bring us to think that the equalization process could be improved, as we are receiving the symbols with a very low SNR and with some important phase deviation. This can also be caused by the channel, but the equalization is one of the parts of the system that has a weak performance. Figure 4.4 shows a constellation diagram of the received symbols after the equalization stage. There we can see the poor performance of the equalization in both amplitude and phase. Another parameter that has a direct relationship with the performance of the synchronization is the cyclic prefix. The size of the cyclic prefix is a key factor in the performance of the system, as it can occupy up to 20% or 30% of the overall sent data of the system. Figure 4.5 shows how the size of the prefix affects the overall throughput of the system. Looking at 4.5 we can see how the size of the cyclic prefix influences the throughput in the system. The measurements have all been made during the same amount of time and with the same packet size. It can be seen that in out environment there is not a minimum size of the cyclic prefix to make the system work. The system will work correctly even if there is only one bit of cyclic prefix, which is the minimum size allowed by the software. Usually, such a graph would show the opposite behaviour, because the effect of the CP helps the successful synchronization, but in this case the CP is is most cases a factor that adds overhead making frames larger instead of a beneficial factor that helps improve the correct synchronization. This fact can be explained by the behaviour of the channel in our laboratory environment. The possible multipath echoes received in the receiver side will have extremely low delays or low power delay spread that will almost not cause any interference between SNR symbols. This would be very different in an open air environment with far scatter effects. These results are fitting with the throughput 31 4 Implementation Figure 4.4: Constellation diagram with sent symbols (in red) and received symbols (in blue) 0 20 40 60 80 100 120 140 450 500 550 600 650 700 750 800 850 Cyclic Prefix size (bits) Data packets received correctly Figure 4.5: Dependence of the size of the cyclic prefix in the throughput of the system 32 4 Implementation results that we will see in the next section, where we see that the loss of synchronization is not a major cause of transmission errors, proving that the synchronization is robust in the system. 4.4 Forward error correction In order to improve the throughput in our communication system we need to add a FEC system that will try to solve the transmission errors caused by the channel. GNU Radio provides some modules that are specifically created for this purpose. This section explains how these modules work and how they have been assembled in the communication system, as well as the improvements achieved by using FEC. 4.4.1 GNU Radio’s trellis library The FEC modules are implemented in software package called trellis because it includes modules that use trellis codes for FEC. This library is an implementation of a Finite State Machine (FSM) that works for all the offered FEC possibilities. This FSM has been implemented in GNU Radio with the objective of simplifying the implementation of any FEC method in any system. This way once the FSM is added to a system, changing the encoding and decoding for the FEC will only be a matter of configuring the FEC. The actual possibilities that the trellis library offers are trellis encoders that use convolutional codes (CC) for the encoding and Viterbi decoders [12]. There is an attempt of adding a turbo code (TC) based FEC option in the trellis library, but it is still not recommended or well documented, so it has not been used. The configuration that has been used is a trellis encoder with a Viterbi decoder. The trellis encoder’s FSM needs to be defined with the parameters it will use. There are basically two ways of defining these parameters: one of them is to define the number of input symbols, the number of output symbols and the next state and the output state matrix. The other way of defining the FSM is by giving the size of the modulation and the number of shift registers used. This second method is more understandable in a hardware way, but even if we use it the constructor of the class will translate those parameters into the input, output and matrixes parameters. Our implementation uses two possible input symbols, four possible states and four possible output symbols. This means that a hardware implementation would need to use two shift registers for that purpose. With this parameters the FEC encoder is characterized. Now we have to add this module in the sender in order to send encoded OFDM frames. The Viterbi decoder is also implemented in the trellis library and is also characterized as a FSM. For this reason, the parameters used by the decoder are very similar to the ones used by the encoder, with the exception that the decoder needs to understand the symbols that come to its input port. This means that another needed parameter for the Viterbi decoder is the constellation used in the input. In our case, the BPSK constellation. 33 4 Implementation Figure 4.6: Layered structure of the sender’s module chains Figure 4.7: Layered structure of the receiver’s module chains 4.4.2 Implemented modules for FEC The modular structure of the implementation of both the sender and the receiver and the implementation of the FEC modules show that there are (both in the case of the sender and in the case of the receiver) two chains of modules. The sender and the receiver have each a chain of modules that starts with the payload bits and ends in the antenna (in the case of the sender) or the opposite in the case of the receiver. Then, there is the chain of modules that is needed for FEC. Figure 4.6 and Figure 4.7 show how the module chains will be assembled; both for the sender and for the receiver. As we can see in the Figures 4.6 and 4.7, the chains of modules are not assembled into a single chain. Instead, the used strategy has been to run through one chain, return the resulting data to the Python script, and then sending this data to the next chain of modules. This has both advantages and disadvantages. The advantages it offers is a very good modularity, as the FEC works more or less as a plugin that can be added or removed without disrupting the modulator 34 4 Implementation Figure 4.8: Fraction of data packet size dedicated to payload (blue) and frame error rate (pink) in the prototype. The rest is occupied by the header, CRC32 and the preamble or the demodulator. On the other hand, it might also be source of delays in the system, as data is buffered and not passed from one module chain to the other until a whole frame has been processed, and then it is enqueued before being processed by the other chain of modules. In order to use the FEC modules in this independent way I have created two modules. One of them is a message queue that will receive a message from a send function and will send it to the next module without applying any transformation to the input data. The name of this module is marcos_msg_q. The other module does the opposite function. It stores the messages in a queue that will trigger a callback function in the Python script. The name of this module is marcos_frame_sink. These two modules act like a door to and from a module chain. They are not only usable for FEC, they can be used in any system in order to move data from a Python script to a module chain and vice versa. Both modules are implemented in C++ and can be found in the gnuradio-core library. 4.4.3 Performance and measurements for the FEC The performance of the communications system has some meaning after the implementation of the FEC. This section analyzes the performance of the system and shows the measurements done to it that are related to the FEC. We will see the impact of the low SNR observed in the received signal and how the FEC improves the throughput. Figure 4.8 shows a plot in which we can see some relevant parameters that depend on the chosen size of the payload. The first plot that we can see is the plot showing two measurements. First of all, in blue, we can see the graph with the fraction of the data packet dedicated to payload. In this implementation the data dedicated to synchronization and CRC is fixed. For each frame one OFDM symbol will be dedicated to synchronization and equalization and four bytes will be dedicated to the CRC. This means that the bigger the frame is, the better it will perform in terms of useful data to 35 4 Implementation Figure 4.9: Throughput achieved by the prototype depending on the size of the payload of the frames redundancy ratio. Unfortunately, the size of the frames can not be pushed to the limit because of various reasons. First of all, a big frame can takes longer to be transmitted, and by the time the transmission comes to an end, the synchronization could be lost. If this should happen, the throughput would fall. This would be a problem in channels that change rapidly. An example of these channels would be a channel in which the mobile terminal is moving. In our test scenario, the channel is the air and the environment is the laboratory, an indoor space with very few disruptions. The only cause that can interfere is the wireless LAN in the room, but it would not change the channel’s impulse response for good. It would just generate interference when there is activity in the network. This is why the graph shows that for bigger frame sizes we approach to the limit of 0.5. This is because the used FEC has a rate of 1 2, meaning that for each bit that we want to send, two bits will be generated by the FEC encoder. The pink graph is the frame error rate achieved, this is the number of frames that have been decoded correctly by the FEC decoder. This graph shows that the error rate becomes higher with the frame size. This results can be easily understood. The cause of this increase in the frame error rate with the size can be caused by two factors. One of them is the possible loss of synchronization, and the other one is the presence of a burst of interference that causes enough erroneous bits to make the FEC decoder fail in the decoding process. Although both of these reasons are logical and understandable, the synchronization failure seems more unlikely, as it depends on the overall channel behaviour more than on the interferences. If the loss of synchronization should be the problem, there should be a clear increase in frame loss from the point the synchronization starts to fail. Also, knowing that the channel is more or less invariant and knowing that the sychronization and channel estimation has been proven robust in most of the tests it makes us think that the reason are the interferences caused by the low SNR of the signal that we receive. Another factor that can be extracted from the graph is that the increase of the frame error rate is lower than the increase of the frame size. It brings us to push the frame size bigger. Figure 4.9 will show how that is translated into throughput. 36 5 Summary and outlook Figure 5.1: Spectrum of the OFDM signal with 1’s and 0’s in its subcarriers The next step was the implementation of a transmitter that would send constant values in each of the subcarriers of an OFDM signal. This example was implemented in order to see how the OFDM signal was transmitted by the USRP2 boards and to check the bandwidth limitations that we would probably have. The SNR in the subcarriers was also analyzed by comparing subcarriers with and without signal. The results where positive and helped us see that the centre frequencies and the edges of the used spectrum would probably have a worse behaviour. Figure 5.1 shows a capture of this spectrum where these facts can be seen. After studying the previous applications a working version of the real OFDM transmitter was implemented. It used BPSK in all of its subcarriers. The receiver was at that time implemented in the same process as the sender, as we were using one of the Python Scrips included with GNU Radio, so it required the separation of the application for sender and receiver and the setup of the synchronization phase. It presented some complications mostly because of the badly documented synchronization modules, that had to be understood mostly through their source code. In this case the modules started to get complicated and a deeper understanding of how GNU Radio works was necessary. In Figure 5.2 we can see how the preambles were found by the correlation in the synchronization process. With the synchronization successfully running the next step was the implementation of the FEC algorithm. This task proved to be the most complicated. Unfortunately the implementation of the trellis package of GNU Radio didn’t support FEC with soft bits with BPSK in the subcarriers. This fact and the fact that the OFDM modules were bound together in a way that it was hard to insert new modules between them made the implementation of the FEC algorithm complicated. In the end, the ARQ protocol was implemented, but the problems that GNU Radio has with TDD and the lack of bandwidth that would allow us to use FDD forced the protocol to run through an auxiliary wired connection encapsulated in Ethernet frames. Additionally the performance shown by the use of the dual channel was deceiving and it was left as a pending issue due to lack of more time to dedicate to that cause. The most interesting enhancement that can be made to the implementation is the implementation of the duplex mode via wireless. From my experience I could say that the way that looks 43 5 Summary and outlook 0 0.2 0.4 0.6 0.8 1 26000 28000 30000 32000 34000 36000 38000 40000 Correlation of the Preamble Samples Synchronization Figure 5.2: Synchronization of the preambles more realistic is by implementing it by using FDD. GNU Radio supports FDD so the GNU Radio architecture wouldn’t need any changes. Then, there should be a balance point between the bandwidth dedicated to the transmitted OFDM signal, the free bandwidth that would avoid interference between the sending and receiving signal and the computational resources used. Another interesting enhancement for the system would be the possibility to allow multiple users to be transmitting to the same receiver, and also the use of different modulations for each of the subcarriers. This would make the system interesting allowing us to test the channel capacity and the behaviour of the system in different load situations. Finally, this communications system can be used for lectures or practical courses, allowing users to rapidly understand many of the concepts explained in the lessons that are critical in wireless communications. For that purpose I would propose the inclusion of this prototype in the modules that can be controlled by GNU Radio’s graphical interface, the GRC. By doing that the learning time needed to understand the usage of the application would be shortened a great deal, allowing lecturers and students to spend their time optimally in the concepts related to the wireless communications and not in learning how to interpret Python code. 44 Author’s statement Hereby I certify that I know and I accept that I have no right to exploit the results of my Master Thesis by any means without the written permission of the Institute of Communication Networks and Computer Engineering (IKR). Furthermore, I certify that I have realized this work on my own, and that all sources that I have used or consulted are duly noted herein. Marcos Majó 45 Appendix A: Advanced GNU Radio concepts This section briefly explains some concepts that are not necessary to know for the basic usage of GNU Radio, but they become necessary as we start developing new modules or when we want to understand in detail the behaviour of each of the modules in terms of buffering, CPU load or time it takes to complete it’s job. First I will give some insight into the creation of new C++ signal processing modules. Afterwards I will explain some concepts about GNU Radio’s scheduler. A.1 Creation of new C++ signal processing modules As GNU Radio is free software it allows its users to modify and create everything about it. However, it tries to encourage its users to create new software modules by providing some documentation for it [4]. For the creation of new modules a few things must be taken into account by the programmer. First of all the modules will have to be defined in C++ and they must be derived classes of the class gr_block or one of its subclasses. This procedure converts the class into a GNU Radio block by defining things like its name or inputs and outputs in a standardized way. Secondly, all modules must contain a method called general_work that will compute the results that will be outputted from the data read from the input streams. After creating the C++ block following these guidelines we also need to create a file that acts as a kind of glue between Python and C++ code. It is the Simplified Wrapper and Interface Generator (SWIG) .i file. This file looks like a header file and it is used by Python to understand the module’s ports and parameters, as well as its default values. The creation of a new module is not a complicated task, but it can become tricky because of the few documentation for it. The same way the creation of a new module requires to follow some rules, if we want to create a new package we must also learn how to do it by looking at other modules and doing reverse engineering. My experience working on this project made me come to the conclusion that customizing GNU Radio is easiest by using a simple module as an example and editing its contents. It has proven to be the easiest and quickest way to have a custom module in the system. A.2 Flowgraphs and scheduler For applications that have significant constraints, let it be time constraints or computational ones, we will understand that the performance of each module according to these constraints is a key factor for the success of our application. GNU Radio has been working on the scheduling algorithm, as it has been very commented due to its impact on the performance of applications. 46 Appendix A: Advanced GNU Radio concepts Originally the whole flow graph of GNU Radio was run through one single thread, but since 2008 a new scheduler has been implemented in order to allow one thread per block, thus increasing the control over the scheduler. It is important to keep in mind the scheduling problems that can occur in the programming stage. A good application will keep a balance throughout the modules and its buffers in order to avoid modules becoming bottlenecks. 47 Appendix B: Lists and Registers B.1 References [1] High Performance Software Defined Radio. URL: http://openhpsdr.org/. [2] Ettus Research LLC, ed. USRP2: The Next Generation of Software Radio Systems. Mountain View, CA, USA. [3] Ettus Research LLC, ed. Transceiver Daughterboards for the USRP Software Radio System. Mountain View, CA, USA. [4] Radio Ware from University of Notre Dame.Writing A Signal Processing Block for GNU Radio. URL: https : //radioware.nd.edu/documentation/advanced - gnuradio/ writing-a-signal-processing-block-for-gnu-radio-part-i. [5] Jan-Jaap van de Beek,Magnus Sandell, and Per Ola Boerjesson. “ML Estimation of Time and Frequency Offset in OFDM Systems”. In: IEEE Transactions on Signal Processing 45.7 (July 1997). Pp. 1800–1805. DOI: 10.1109/78.599949. [6] Kyung-Ho Kim. “Key technologies for the next generation wireless communications”. In: Hardware/software codesign and system synthesis, 2006. CODES+ISSS ’06. Proceedings of the 4th international conference. 2006. Pp. 266–269. DOI: 10.1145/1176254.1176319. [7] T. M. Schmidl and D. C. Cox. “Robust frequency and timing synchronization for OFDM”. In: Communications, IEEE Transactions on 45.12 (1997). Pp. 1613–1621. DOI: 10.1109/26.650240. URL: http://dx.doi.org/10.1109/26.650240. [8] Trudy E. Bell. “The Quiet Genius: Andrew J. Viterbi”. In: The Bent of Tau Beta Pi (2006). Pp. 17–21. URL: http://viterbi.usc.edu. [9] IEEE.802.16-2009. IEEE Standard for Local and metropolitan area networks Part 16: Air Interface for Broadband Wireless Access Systems. Technical standard specification. IEEE, 2009. DOI: 10.1109/IEEESTD.2009.5062485. URL: http://ieeexplore.ieee. org/servlet/opac?punumber=5062428. [10] Firas Abbas Hamza.The USRP under 1.5X Magnifying Lens! 2008. URL: www. scribd.com/doc/9688095/USRP-Documentationd. [11] A. S. Tanenbaum.Computer networks. Upper Saddle River, NJ, USA: Prentice-Hall, Inc., 1988. Pp. 202–218. ISBN: 0-13-162959-X. [12] Chip Fleming.A Tutorial on Convolutional Coding with Viterbi Decoding. tutorial. Derwood, MD, USA. July 2002. [13] Eric W. Weisstein, ed. Doppler Effect. URL: http://scienceworld.wolfram.com/ physics/DopplerEffect.html. [14] Eric Blossom. “GNU Radio: Tools for Exploring the RF Spectrum”. In: Linux Journal (122 2004). URL: http://www.gnu.org/software/gnuradio/doc/ exploring-gnuradio.html. 48 Appendix B: Lists and Registers [15] Eric Blossom.GNU Radio. URL: http://gnuradio.org. [16] Jesper M. Kristensen. “GNU Radio; An Introduction”. Presentation handout. Aalborg University. Denmark. Mobile Developer Days 2007. 2007. [17] Eric Blossom.Interview to Eric Blossom on GNU Radio. Ed. by Slashdot. Sept. 27, 2002. URL: http://tech.slashdot.org/article.pl?sid=02/09/27/1420201. [18] LDS group, ed. Understanding FFT Windows. URL: http://www.ee.iitm.ac.in/ ~nitin/_media/ee462/fftwindows.pdf. [19] Hassan Yaghoobi. “Scalable OFDMA Physical Layer in IEEE 802.16 WirelessMAN”. In: Intel Technology Journal 8.3 (Aug. 2004). ISSN: 1535-864X. [20] Matt Ettus,Thomas W. Rondeau, and Robert McGwier. “OFDM Implementation in GNU Radio”. Presentation handout. 2007 Virginia Tech Symposium on Wireless Personal Communications. June 6, 2007. [21] Kiichi Niitsu. “Reconfigurable RF System for Software-Defined Radio”. Presentation handout. Keio Univ. Kuroda Laboratory, Japan. 2006. [22] University of Manchester, ed. The Shannon-Hartley Theorem. Manchester, UK 2006. [23] Pierre Jallon and Mérouane Debbah.Software Defined Radio for all. URL: www. sdr4all.eu. 49 Appendix B: Lists and Registers B.2 List of Figures 2.1 Module diagram of a SDR sender and receiver . . . . . . . . . . . . . . . . . . 4 2.2 OFDM modulator module diagram . . . . . . . . . . . . . . . . . . . . . . . . 7 2.3 OFDM demodulator module diagram . . . . . . . . . . . . . . . . . . . . . . . 7 2.4 Signal in the presence of ISI . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.5 The effect of adding a cyclic prefix to a signal . . . . . . . . . . . . . . . . . . 8 3.1 Graph representation of a GNU Radio application . . . . . . . . . . . . . . . . 15 3.2 Front view of a USRP2 device . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 3.3 USRP2 devices with their host PCs . . . . . . . . . . . . . . . . . . . . . . . . 18 3.4 Module layout of the sender built with GRC . . . . . . . . . . . . . . . . . . . 20 3.5 Resulting signal of the moving peak example . . . . . . . . . . . . . . . . . . . 21 4.1 OFDM System’s module hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . 24 4.2 Block diagram of the ofdm_receiver module . . . . . . . . . . . . . . . . . . . 28 4.3 Block representation of the state machine in the frame_sink module . . . . . 29 4.4 Constellation diagram with sent symbols (in red) and received symbols (in blue) 32 4.5 Dependence of the size of the cyclic prefix in the throughput of the system . . 32 4.6 Layered structure of the sender’s module chains . . . . . . . . . . . . . . . . . 34 4.7 Layered structure of the receiver’s module chains . . . . . . . . . . . . . . . . 34 4.8 Fraction of data packet size dedicated to payload (blue) and frame error rate (pink) in the prototype. The rest is occupied by the header, CRC32 and the preamble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 4.9 Throughput achieved by the prototype depending on the size of the payload of the frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 4.10 Distribution of the data sent for each OFDM frame . . . . . . . . . . . . . . . 41 5.1 Spectrum of the OFDM signal with 1’s and 0’s in its subcarriers . . . . . . . . 43 5.2 Synchronization of the preambles . . . . . . . . . . . . . . . . . . . . . . . . . 44 B.3 List of Tables 4.1 OFDM standard parameters table . . . . . . . . . . . . . . . . . . . . . . . . . 23 4.2 Parameters of the implemented system and measurements . . . . . . . . . . . 37 50 Appendix B: Lists and Registers B.4 List of Abbreviations 3GPP ........ 3rd Generation Partnership Project ADC.......... Analog to Digital Converter ARQ.......... Automatic Repeat reQuest BPSK ........ Binary Phase-Shift Keying CC............ Convolutional Code CDM ......... Code Division Multiplexing CP............ Cyclic Prefix CPU.......... Central Processing Unit CRC.......... Cyclic Redundancy Check DAB.......... Digital Audio Broadcasting DAC.......... Digital to Analog Converter DDC.......... Digital Down Converter DUC.......... Digital Up Converter DVB-H ....... Digital Video Broadcasting - Handheld DVB-T ....... Digital Video Broadcasting - Terrestrial FDD.......... Frequency-Division Duplexing FDM ......... Frequency-Division Multiplexing FEC .......... Forward Error Correction FFT .......... Fast Fourier Transform FM ........... Frequency Modulation FPGA ........ Field-Programmable Gate Array FSM .......... Finite State Machine GRC.......... GNU Radio Companion GSM ......... Global System for Mobile communications HDTV........ High-Definition TeleVision HPSDR ...... High Performance Software Defined Radio ICI............ Inter-Carrier Interference IEEE ......... Institute of Electrical and Electronics Engineers IF ............. Intermediate Frequency iFFT.......... Inverse Fast Fourier Transform ISI ............ InterSymbol Interference ISM .......... Industrial, Scientific and Medical LAN .......... Local Area Network LLC .......... Limited Liability Company LTE........... 3GPP Long Term Evolution MAC ......... Media Access Control ML ........... Maximum Likelihood OFDM ....... Orthogonal Frequency-Division Multiplexing OSI ........... Open Systems Interconnection PC............ Personal Computer PN............ Pseudorandom Noise PSK .......... Phase-Shift Keying QAM ......... Quadrature Amplitude Modulation 51 Appendix B: Lists and Registers QPSK . . . . . . . . Quadrature Phase-Shift Keying RAM ......... Random Access Memory RF ............ Radio Frequency SC-FDMA . . . Single Carrier Frequency Division Multiple Access SD ............ Secure Digital SDR .......... Software Defined Radio SNR .......... Signal to Noise Ratio SWIG ........ Simplified Wrapper and Interface Generator TC............ Turbo Code TDD.......... Time-Division Duplexing USB .......... Universal Serial Bus USRP ........ Universal Software Radio Peripheral USRP2 ....... Universal Software Radio Peripheral 2 WiMAX...... Worldwide interoperability for Microwave Access XML ......... eXtensible Markup Language 52