FEC Forward Error Correction on GNU Radio


In previous posts I examined the possible use of OFDM for HF messaging (Ref.1/2/3) and for voice (Ref.4). I introduced several channel models using Scicos: an 8 channel discrete model and a 64 channel model using IFFT/FFT. In this post I will focus on using FEC Forward Error Correction to improve the transmission performance.

HF Error Detection & Correction

Fig.1 HF FEC Forward Error Correction & CRC Error Detection

HF modems may or may not contain error detection and correction. PSK31 for example is essentially keyboard to keyboard transmission with no error detection or correction. Figure 1 illustrates the concepts. If the modem is sending critical data such as emails etc, then the overall transmission has to be error free. CRC codes are used to detect whether errors have occurred. If a data frame is sent and received correctly, then an ACK is sent back to the transmitter to indicate the frame was received correctly and the next frame can be sent. If an error(s) occurred and the FEC was able to correct it, then an ACK is also sent back. However, if errors occurred and were not able to be corrected, then a NAK is returned to the transmitter to indicate to resend the data frame.

Error Detection

Fig.2 CRC-4 No Transmission Errors
Fig.3 CRC-4 Transmission Errors

Figure 2 shows a simple static Simulink model with a CRC-4 code used to detect errors on a simple 2byte=16bit data frame. No errors are made so the detector syndrome is “0”. Figure 3 shows transmission errors on the first and last bit. The detector syndrome indicates “1” for error(s) detected. Normally CRC-16/32 is used in communications.

FEC Forward Error Correction

Fig.4 BCH (15,5) Code 3 Transmission Errors Corrected
Fig.5 BCH(15,5) Code 4 Transmission Errors Not Corrected

Figure 4 shows a static Simulink model of a BCH (15,5) code (Ref.5). This a particular case of a so called (n,k) block codes with a total of n bits, k information bits and n-k parity bits. The parity bits are chosen in such a way as to correct particular transmission errors. In this case there are errors in the 1st, 2nd and last bits, these are corrected. In Figure 5 there are four errors and these cannot be corrected as this is beyond the error correcting ability of the code. Note that adding parity bits increases the data load from 5bits to 15 in this case. Each application has to be analyzed for overall data throughput on a real channel vs NAK/ARQ transmissions etc. This is where simulation can play an important role to model the different types of channels anticipated.

BER Bit Error Rate Measurement

Fig.6 Baseband Data Channel + AWGN

Figure 6 shows a data signal being passed through a baseband channel where AWGN Additive White Gaussian Noise is added. A BER Bit Error measurement is made comparing the sampled signal+noise with the original signal. If the sample > 0.5V, then a 1 is declared. If the sample <= 0.5 then a 0 is declared (signal amplitude 0V-1V). This is compared against the original signal and if different, an error is declared. Figure 7 shows theoretical BER vs. SNR curves for BPSK (Ref.6/7).

BER Measurement on GNU Radio

Fig.8 GNU Radio Schematic to Measure BPSK BER (File)
Fig.9 GNU Radio Schematic: noise_stdev – Noise – Signal+Noise – BER
noise_stdevBERSNR=10log((E/stdev)^2) dbTheory dB
Fig.10 GNU Radio Schematic noise_stdev vs BER

Figure 8 shows a GNU Radio schematic used to evaluate BPSK baseband BER (Ref.8) The Random Source produces 0’s and 1’s. The Map block maps the 0’s to -1’s and 1’s to 1’s creating a bipolar BPSK signal. Gaussian noise is added with the Fast Noise Source. The Bit Slicer samples at the sample time and creates a 1 if >0V and 0 if <=0V. This drives the BER block. To measure <10^-6, the QT Number sink time has to be adjusted >1sec. Figure 9 shows the noise_stdev slider, noise amplitude and signal+noise amplitude and BER result. Figure 10 shows a table of results that are close to theoretical values.

BER Measurement with FEC on GNU Radio

Fig.11 GNU Radio gr-fec Polar Coder Schematic
Fig.12 Polar Coded vs. Uncoded Response 0 errors vs. 10^-4

Working with FEC on GNU Radio is much more complicated than static models on Simulink or Octave. This is because it can be used with real hardware, streaming actual data. This is well described in Ref.8. Figure 11 is an example taken from gr-fec for a polar coder (../GNURadio-3.8/share/gnuradio/examples/fec/polar_code_example.grc). Figure 12 shows the response with the uncoded data receiving transmission errors at BER=10^-4, whereas coded data has no errors. Note there exists a hierarchy of blocks in order to simplify and abstract the coding:

Polar Code Configurator
Polar Encoder Definition
FEC Extended Encoder
Polar Decoder SC Definition
FEC Extended Decoder

Fig.13 YouTube Video FEC Forward Error Correction on GNU Radio

GNURadio Companion Basics Course:

Please send your comments, questions and suggestions to:

YouTube Channel
YouTube Channel


#1. – “HF Messaging with OFDM_c”

#2. – “HF Messaging with OFDM_b”

#3. – “HF Messaging with OFDM_a”

#4. – “OFDM for SSB_USB”

#5. – “An Introduction to Error-Correcting Codes”, Shu Lin, Prentice-Hall, 1970, LCC 76-124417

#6. – “BER”,

#7. – “BPSK BER”,

#8. – “Protect Your Bits: Introduction to gr-fec A look into the error-correction capabilities of GNU Radio”, Martin Braun

By Jeremy Clark

Jeremy Clark is a Senior Telecommunications Engineer and Advanced Amateur Radio Operator VE3PKC. He is the author of E-Books on Telecommunications, Navigation & Electronics.