# BER for BPSK-OFDM in Frequency Selective Channel

As the data rates supported by wireless networks continue to rise the bandwidth requirements also continue to increase (although spectral efficiency has also improved). Remember GSM technology which supported 125 channels of 200KHz each, which was further divided among eight users using TDMA. Move on to LTE where the channel bandwidth could be as high as 20MHz (1.4MHz, 3MHz, 5MHz, 10MHz, 15MHz and 20MHz are standardized).

This advancement poses a unique challenge referred to as frequency selective fading. This means that different parts of the signal spectrum would see a different channel (different amplitude and different phase offset). Look at this in the time domain where the larger bandwidth means shorter symbol period causing intersymbol interference (as time delayed copies of the signal overlap on arrival at the receiver).

The solution to this problem is OFDM that divides the wideband signal into smaller components each having a bandwidth of a few KHz. Each of these components experiences a flat channel. To make the task of equalization simple a cyclic prefix (CP) is added in the time domain to make the effect of fading channel appear as circular convolution. Thus simplifying the frequency domain equalization to a simple division operation.

Shown below is the Python code that calculates the bit error rate (BER) of BPSK-OFDM which is the same as simple BPSK in a Rayleigh flat fading channel. However there is a caveat. We have inserted a CP which means we are transmitting more energy than simple BPSK. To be exact we are transmitting 1.25 (160/128) times more energy. This means that if this excess energy is accounted for the performance of BPSK-OFDM would be 1dB (10*log10(1.25)) worse than simple BPSK in Rayleigh flat fading channel.

Note:

1. Although we have shown the channel as a multiplicative effect in the figure above, this is only true for a single tap channel. For a multi-tap channel (such as the one used in the code above) the effect of the channel is that of a filter which performs convolution operation on the transmitted signal.
2. We have used a baseband model in our simulation and the accompanying figure. In reality the transmitted signal is upconverted before transmission by the antennas.
3.  The above model can be easily modified for any modulation scheme such as QPSK or 16-QAM. The main difference would be that the signal would have a both a real part and an imaginary part, much of the simulation would remain the same. This would be the subject of a future post. For a MATLAB implementation of 64-QAM OFDM see the following post (64-QAM OFDM).
4. Serial to parallel and parallel to serial conversion shown in the above figure was not required as the simulation was done symbol by symbol (one OFDM symbol in the time domain represented 128 BPSK symbols in the frequency domain).
5. The channel model in the above simulation is quasi-static i.e. it remains constant for one OFDM symbol but then rapidly changes for the next, without any memory.

# Rayleigh Fading Envelope Generation – Python

When wireless signals travel from a transmitter to a receiver they do so after reflection, refraction, diffraction and scattering from the environment. Very rarely is there a direct line of sight (LOS) between the transmitter and receiver. Thus multiple time delayed copies of the signal reach the receiver that combine constructively and destructively. In a sense the channel acts as an FIR (finite impulse response) filter. Furthermore since the transmitter or receiver may be in motion the amplitude and phase of these replicas varies with time.

There are several methods to model the amplitude and phase of each of these components. We look at one method called the “Smiths Fading Simulator” which is based on Clark and Gans model. The simulator can be constructed using the following steps.

1. Define N the number of Gaussian RVs to be generated, fm the Doppler frequency in Hz, fs the sampling frequency in Hz, df the frequency spacing which is calculated as df=(2*fm)/(N-1) and M total number of samples in frequency domain which is calculated as M=(fs/df).
2. Generate two sequences of N/2 complex Gaussian random variables. These correspond to the frequency bins up to fm. Take the complex conjugate of these sequences to generate the N/2 complex Gaussian random variables for the negative frequency bins up to -fm.
3. Multiply the above complex Gaussian sequences g1 and g2 with square root of the Doppler Spectrum S generated from -fm to fm. Calculate the spectrum at -fm and +fm by using linear extrapolation.
4. Extend the above generated spectra from -fs/2 to +fs/2 by stuffing zeros from -fs/2 to -fm and fm to fs/2. Take the IFFT of the resulting spectra X and Y resulting in time domain signals x and y.
5. Add the absolute values of the resulting signals x and y in quadrature. Take the absolute value of this complex signal. This is the desired Rayleigh distributed envelope with the required temporal correlation.

The Matlab code for generating Rayleigh random sequence with a Doppler frequency of fm Hz is given below.

# Sum of Sinusoids Fading Simulator

We have previously looked at frequency domain fading simulators i.e. simulators that define the Doppler components in the frequency domain and then perform an IDFT to get the time domain signal. These simulators include Smith’s Simulator, Young’s Simulator and our very own Computationally Efficient Rayleigh Fading Simulator. Another technique that has been widely reported in the literature is Sum of Sinusoids Method. As the name suggests this method generates the Doppler components in the time domain and then sums them up to generate the time domain fading envelope. There are three parameters that define the properties of the generated signal.

1) Number of sinusoids – Higher the number better the properties of the generated signal but greater the computational complexity
2) Angle of arrival – This can be generated statistically or deterministically, spread from –pi to pi.
3) Phase of the arriving wave – This is uniformly distributed between –pi and pi.

The MATLAB code below gives three similar sum of sinusoids techniques for generating a Rayleigh faded envelope [1].

```%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SUM OF SINUSOIDS FADING SIMULATORS
% fd - Doppler frequency
% fs - Sampling frequency
% ts - Sampling period
% N - Number of sinusoids
%
% www.raymaps.com
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear all
close all

fd=70;
fs=1000000;
ts=1/fs;
t=0:ts:1;
N=100;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Method 1 - Clarke
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x=zeros(1,length(t));
y=zeros(1,length(t));

for n=1:N;n
alpha=(rand-0.5)*2*pi;
phi=(rand-0.5)*2*pi;
x=x+randn*cos(2*pi*fd*t*cos(alpha)+phi);
y=y+randn*sin(2*pi*fd*t*cos(alpha)+phi);
end
z=(1/sqrt(N))*(x+1i*y);
r1=abs(z);

plot(t,10*log10(r1))
hold on

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Method 2 - Pop, Beaulieu
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x=zeros(1,length(t));
y=zeros(1,length(t));

for n=1:N;n
alpha=2*pi*n/N;
phi=(rand-0.5)*2*pi;
x=x+randn*cos(2*pi*fd*t*cos(alpha)+phi);
y=y+randn*sin(2*pi*fd*t*cos(alpha)+phi);
end
z=(1/sqrt(N))*(x+1i*y);
r2=abs(z);

plot(t,10*log10(r2),'r')
hold on

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Method 3 - Chengshan Xiao
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x=zeros(1,length(t));
y=zeros(1,length(t));

for n=1:N;n
phi=(rand-0.5)*2*pi;
theta=(rand-0.5)*2*pi;
alpha=(2*pi*n+theta)/N;
x=x+randn*cos(2*pi*fd*t*cos(alpha)+phi);
y=y+randn*sin(2*pi*fd*t*cos(alpha)+phi);
end
z=(1/sqrt(N))*(x+1i*y);
r3=abs(z);

plot(t,10*log10(r3),'g')
hold off

xlabel('Time(sec)')
ylabel('Envelope(dB)')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
```

All the three techniques given above are quite accurate in generating a Rayleigh faded envelope with the desired statistical properties. The accuracy of these techniques increases as the number of sinusoids goes to infinity (we have tested these techniques with up to 1000 sinusoids but realistically speaking even 100 sinusoids are enough). If we want to compare the three techniques in terms of the Level Crossing Rate (LCR) and Average Fade Duration (AFD) we can say that the first and third technique are a bit more accurate than the second technique. Therefore we can conclude that a statistically distributed angle of arrival is a better choice than a deterministically distributed angle of arrival. Also, if we look at the autocorrelation of the in-phase and quadrature components we see that for the first and third case we get a zero order Bessel function of the first kind whereas for the second case we get a somewhat different sequence which approximates the Bessel function with increasing accuracy as the number of sinusoids is increased.

The above figures show the theoretical Bessel function versus the autocorrelation of the real/imaginary part  generated by method number two. The figure on the left considers 20 sinusoids whereas the figure on the right considers 40 sinusoids. As can be seen the accuracy of the autocorrelation sequence increases considerably by doubling the number of sinusoids. We can assume that for number of sinusoids exceeding 100 i.e. N=100 in the above code the generated autocorrelation sequence would be quite accurate.

[1] Chengshan Xiao, “Novel Sum-of-Sinusoids Simulation Models for Rayleigh and Rician Fading Channels,” IEEE TRANSACTIONS ON WIRELESS COMMUNICATIONS, VOL. 5, NO. 12, DECEMBER 2006.

In the previous posts we had discussed generation of a correlated Rayleigh fading sequence using Smith’s method [1] and Young’s modification of Smith’s method [2]. The main contribution of Young was that he proposed a mechanism where the number of IDFTs was reduced by half. This was achieved by first adding two length N IID zero mean Gaussian sequences filtered by the filter F[k] and then performing the IDFT on the resulting complex sequence.

This was different to Smith’s method where the IDFT was performed simultaneously on two branches and then the outputs of these branches were added in quadrature to achieve the desired sequence with Rayleigh distributed envelope and Uniformly distributed phase. Another problem with Smith’s method was that the outputs of the two arms after performing IDFTs was assumed to be real which is not always the case in implementation and depends upon the combination of Doppler frequency (fm) and length of Gaussian sequence (N).

Young’s technique is shown graphically in the above figure. Also shown is the definition of filter F[k] which depends upon N, fm and km (please note that the fm in the above equation is normalized by the sampling frequency fs). Here km = N*(fm/fs). We propose three modifications to Young’s technique which significantly reduces computation and at the same time maintains the statistical properties of the generated sequence. The modifications we propose are.

1. First modification has to do with the generated Gaussian sequence. It is observed that the filter F[k], at very high sampling rates, is mostly zero and there are very few points which have some non-zero value. So when we multiply the Gaussian sequence with the filter we mostly get zeros at the output. So we propose that the filter response in the frequency domain must be calculated first and the the Gaussian random sequence must be generated for only those points where the filter F[k] is non-zero e.g. for a sampling frequency of 7.68 MHz (standard sampling frequency for a BW of 5 MHz in LTE) and Doppler frequency of 70 Hz (corresponding to medium Doppler case in LTE) the filter F[k] has 99.9982% zeros in its frequency response and it would be a highly wasteful to calculate Gaussian RVs for all those values.

2. Secondly according to Clarke [3] the Doppler Spectrum measurements have “Marked disagreement at very low frequencies and at frequencies in the region of the sharp cut-off associated with the maximum Doppler frequency shift. At very low frequencies the spectral energy is always observed to be higher than that predicted by theory”. He goes on to add “The reason for this is that neither theoretical model takes into account the large scale variations in total energy which result from the changing topography between transmitter and mobile receiver”. This suggests that the Classical Doppler Spectrum might not be the best choice under all scenarios. This has also been noted in [4] where a flat fading model is evaluated in terms of its Level Crossing Rate and Average Fade Duration. Such a flat spectrum is especially suited to indoor scenarios as noted in [5] and [6].

We propose a filter that gives equal weight to all the frequencies up to the maximum Doppler frequency. So our filter is a box-type filter which applies a constant scaling factor to all the frequencies in the pass-band and zeros out all the frequencies in the stop-band. So in fact the Gaussian sequence that is generated in the in-phase arm may directly be added with the Gaussian sequence from the other arm without applying the frequency domain filter and then IDFT of the complex sequence is taken. We will look into the deviation from ideality  that this causes later.

3. The third modification that we propose is in the implementation of the IDFT. Here again we take into consideration that the complex sequence being fed to the IDFT is filled with zeros (as we noted earlier 99.9982% zeros for 7.68 MHz and even more for higher frequencies) so we can avoid a lot multiplications and summations. The IDFT is defined below and also given is our modification to it.

Further improvement in computation time is achieved by implementing the above as a matrix multiplication. The matrix multiplication is implemented as H*X where H is the IDFT coefficients of size N x 2(km+1) and X is a vector of size 2(km+1) x 1 upon which the IDFT has to be performed.

Now let us look at the output sequence generated by using the above techniques. We consider the case of Medium Doppler Frequency of 70 Hz (EVA channel) as defined by LTE specifications. Sampling frequency is fixed at 10 kHz giving a normalized Doppler frequency of 0.007.  This was done due to limitation of memory on the machine. The author also experimented with a sampling frequency of 7.68 MHz but this did not yield enough samples for statistically accurate results. We did use a sampling frequency of 7.68 MHz for our bit error rate simulation which is shown in the end.

It is observed for fm=70 Hz the envelope of the output sequence using the proposed technique matches quite well with the envelope of the output sequence generated by the ideal filter proposed by Young. Also the phase and envelope of the sequence generated using the proposed technique has the desired distribution. Some of the other metrics that we can look at are the level crossing rate (LCR) and average fade duration (AFD) as well as the Auto Correlation of the real and imaginary parts of the complex sequence generated.

 Parameter Young Modified LCR (ideal) 48.1086 48.1086 LCR (sim) 48.1506 39.4348 AFD (ideal) 0.0018 0.0018 AFD (sim) 0.0018 0.0022

If we look at the results for LCR and AFD we see that the simulated results match reasonably well with the results predicted by theory. These results correspond to 100 snapshots of the fading sequence. It was important to take the average of several snapshots as results varied with each simulation run. Sometimes Young’s technique produced more accurate results while at other times the proposed technique was better. Again the limitations of computer memory and processing power dictated the length of the sequence that could be generated.

In general Young’s technique produced better results than our proposed technique. It was found that product of LCR and AFD for both cases matched quite well with the theoretical value. So the total time spent in a fade state per second was equal in both the cases. In the proposed method the duration of a single fading event was higher,  whereas the number of fading events per second was lower. This can be attributed to the fact that in our proposed technique higher weighting is given to lower frequency components and the fading sequence is smoothed out by these low frequency components. One technique to overcome this is spectral broadening as suggested by [4] but this is not the subject here and we postpone its discussion to another article.

Auto Correlation of Real Part fm=70Hz

The Auto Correlation of the real and imaginary parts of the generated sequences are also calculated for a Doppler frequency of 70 Hz. It is found that the Auto Correlation sequence for the two techniques matches quite well. However, the Auto Correlation sequence deviates from the theoretical value as calculated the by Bessel function of the first kind and zero order. Since we have used a flat spectral mask the Auto Correlation function resembles the sinc(x) function which is the same as zeroth order Spherical Bessel Function of the first kind (which is related to 1/2 order Bessel Function of the first kind).

It was found that when the Rayleigh fading sequence is generated by the program provided in Young’s thesis the shape of the Auto Correlation function depends upon the sampling frequency. At a normalized Doppler frequency of 0.05 and N=2^16 Young’s technique produces quite accurate results. We also measured the mean squared error (MSE) between the two Auto Correlations sequences and found it to be a function of the Normalized Doppler Frequency. It was found that as the Normalized Doppler Frequency was increased from 0.00007 to 0.0007 the MSE error dropped from 0.0277 to 0.0041. The relationship between the Normalized Doppler Frequency and MSE, for a fixed sequence length, seems to be resembling an exponential function. For more accurate results, at higher sampling frequencies, the number of samples would have to be increased considerably. In fact it was found that if the variable km (km=N*fm/fs) is maintained at around 20 the error between the two correlation sequences is less than 1% for all possible sampling rates.

We also compared the bit error rate (BER) performance of different QAM modulation schemes using both the techniques for fading envelope generation and found these to be matching quite well. A single tap was used which results in a flat fading channel. This is a simplistic channel model but it gives us some confidence that the proposed approach does have the desired statistical properties. A good test of a temporally correlated Rayleigh fading sequence is to test it on a system that implements interleavers and channel coders whose performance strongly depends upon factors such as the LCR and AFD e.g. a certain forward error correction (FEC) code might work well in high LCR and low AFD as this distributes out errors in different blocks and allows the code to correct them. In simulations done so far (not shown here) we have found that for a 1/2 rate convolutional encoder with Hard Viterbi Decoding the BER for the two schemes matches quite well. In general the results for correlated fading are much worse than uncorrelated fading.

In future we would also like to evaluate the bit error rate (BER) performance of an M-QAM OFDM system with Frequency Selective Rayleigh fading as described by the LTE fading channels EPA, EVA and ETU. This is probably a good scenario to compare the accuracy of the two techniques used to generate Rayleigh fading sequences above. One challenge in this regard is that the LTE channel taps are described in increments of 10 nsec whereas the LTE signal sampling rate is defined on a different scale (minimum Ts=32.5521 nsec corresponding to a sampling rate of 30.72 Msps). So we would have to do sample rate conversion to implement a time varying frequency selective Rayleigh fading channel.

[1] John I. Smith, “A Computer Generated Multipath Fading Simulation for Mobile Radio”, IEEE Transactions on Vehicular Technology, vol VT-24, No. 3, August 1975.

[2] David J. Young and Norman C. Beaulieu, “The Generation of Correlated Rayleigh Random Variates by Inverse Discrete Fourier Transform”, IEEE Transactions on Communications vol. 48 no. 7 July 2000.

[3] R. H. Clarke, A Statistical Theory of Mobile Radio Reception”, Bell Systems Technical Journal 47 (6), pp 957–1000, July 1968.

[4] Rosmansyah, Y.; Saunders, S.R.; Sweeney, P.; Tafazolli, R., “Equivalence of flat and classical Doppler sample generators,” Electronics Letters , vol.37, no.4, pp.243,244, 15 Feb 2001.

[5] JTC (Joint Technical Committee T1 RIP1.4 and TIA TR46.3.3/TR45.4.4 on Wireless Access): “Draft final report on RF channel characterization”. Paper no. JTC(AIR)/94.01.17-238R4, January 17, 1994.

[6] ETSI (European Telecommunications Standards Institute): “Universal mobile telecommunications system (UMTS); selection procedures for the choice of radio transmission technologies of the UMTS (UMTS 30.03 version 3.2.0)”. Technical Report, TR 101 112 V3.2.0 (1998-04), http://www.etsi.org, 1998.

# Fading Model – From Simple to Complex

1. The simplest channel model just scales the input signal by a real number between 0 and 1 e.g. if the signal at the transmitter is s(t) then at the receiver it becomes a*s(t). The effect of channel is multiplicative (the receiver noise on the other hand is additive).

2.   The above channel model ignores the phase shift introduced by the channel. A more realistic channel model is one that scales the input signal as well rotates it by a certain angle e.g. if s(t) is the transmitted signal then the received signal becomes a*exp(jθ)*s(t).

3. In a realistic channel the transmitter, receiver and/or the environment is in motion therefore the scaling factor and phase shift are a function of time e.g. if s(t) is the transmitted signal then the received signal is a(t)*exp(jθ(t))*s(t). Typically in simulation of wireless communication systems a(t) has a Rayleigh distribution and θ(t) has a uniform distribution.

4. Although the above model is quite popular, it can be further improved by introducing temporal correlation in the fading envelope. This can be achieved by the Smith’s simulator which uses a frequency domain approach to characterize the channel. The behavior of the channel is controlled by the Doppler frequency fd. Higher the Doppler frequency greater is the variation in the channel and vice versa [1].

5. Finally the most advanced wireless channel model is one that considers the channel to be an FIR filter where each tap is defined by the process outlined in (4). The channel thus performs convolution on the signal that passes through it. In the context of LTE there are three channel models that are defined namely Extended Pedestrian A (EPA), Extended Vehicular A (EVA) and Extended Typical Urban (UTU) [2].

Note: As an after thought I have realized that this channel model becomes even more complicated with the introduction of spatial correlation between the antennas of a MIMO system [3].

# MIMO Capacity in a Fading Environment

The Shannon Capacity of a channel is the data rate that can be achieved over a given bandwidth (BW) and at a particular signal to noise ratio (SNR) with diminishing bit error rate (BER). This has been discussed in an earlier post for the case of SISO channel and additive white Gaussian noise (AWGN). For a MIMO fading channel the capacity with channel not known to the transmitter is given as (both sides have been normalized by the bandwidth [1]):

Shannon Capacity of a MIMO Channel

where NT is the number of transmit antennas, NR is the number of receive antennas, γ is the signal to interference plus noise ratio (SINR), INR is the NRxNR identity matrix and H is the NRxNT channel matrix. Furthermore, hij, an element of the matrix H defines the complex channel coefficient between the ith receive antenna and jth transmit antenna. It is quite obvious that the channel capacity (in bits/sec/Hz) is highly dependent on the structure of matrix H. Let us explore the effect of H on the channel capacity.

Let us first consider a 4×4 case (NT=4, NR=4) where the channel is a simple AWGN channel and there is no fading. For this case hij=1 for all values of i and j. It is found that channel capacity of this simple channel for an SINR of 10 dB is 5.36bits/sec/Hz. It is further observed that the channel capacity does not change with number of transmit antennas and increases logarithmically with increase in number of receive antennas. Thus it can be concluded that in an AWGN channel no multiplexing gain is obtained by increasing the number of transmit antennas.

We next consider a more realistic scenario where the channel coefficients hij are complex with real and imaginary parts having a Gaussian distribution with zero mean and variance 0.5. Since the channel H is random the capacity is also a random variable with a certain distribution. An important metric to quantify the capacity of such a channel is the Complimentary Cumulative Distribution Function (CCDF). This curve basically gives the probability that the MIMO capacity is above a certain threshold.

It is obvious (see figure above) that there is a very high probability that the capacity obtained for the MIMO channel is significantly higher than that obtained for an AWGN channel e.g. for an SINR of 9 dB there is 90% probability that the capacity is greater than 8 bps/Hz. Similarly for an SINR of 12 dB there is a 90% probability that the capacity is greater than 11 bps/Hz. For a stricter threshold of 99% the above capacities are reduced to 7.2 bps/Hz and 9.6 bps/Hz.

In a practical system the channel coefficients hij would have some correlation which would depend upon the antenna spacing. Lower the antenna spacing higher would be the antenna correlation and lower would be the MIMO system capacity. This would be discussed in a future post.

The MATLAB code for calculating the CCDF of channel capacity of a MIMO channel is given below.

```clear all
close all

Nr=4;
Nt=4;
I=eye(Nr);
g=15.8489;

for n=1:10000
H=sqrt(1/2)*randn(Nr,Nt)+j*sqrt(1/2)*randn(Nr,Nt);
C(n)=log2(det(I+(g/Nt)*(H*H')));
end

[a,b]=hist(real(C),100);
a=a/sum(a);
plot(b,1-cumsum(a));
xlabel('Capacity (bps/Hz)')
ylabel('Probability (Capacity > Abcissa)')
grid on```

[1] G. J. Foschini and M. J. Gans,”On limits of Wireless Communications in a Fading Environment when Using Multiple Antennas”, Wireless Personal Communications 6, pp 311-335, 1998.

# Computationally Efficient Rayleigh Fading Simulator

We had previously presented a method of generating a temporally correlated Rayleigh fading sequence. This was based on Smith’s fading simulator which was based on Clark and Gan’s fading model. We now present a highly efficient method of generating a correlated Rayleigh fading sequence, which has been adapted from Young and Beaulieu’s technique [1]. The architecture of this fading simulator is shown below.

This method essentially involves five steps.

1. Generate two Gaussian random sequences of length N each.
2. Multiply these sequences by the square root of Doppler Spectrum S=1.5./(pi*fm*sqrt(1-(f/fm).^2).
3. Add the two sequences in quadrature with each other to generate a length N complex sequence (we have added the two sequences before multiplying with the square root of Doppler Spectrum in our simulation).
4. Take the M point complex inverse DFT where M=(fs/Δf)+1.
5. The absolute value of the resulting sequence defines the envelope of the Rayleigh faded signal with the desired temporal correlation (based upon the Doppler frequency fm).

A point to be noted here is that although the Doppler spectrum is defined from -fm to +fm the IDFT has to be taken from -fs/2 to +fs/2. This is achieved by stuffing zeros in the vacant frequency bins from -fs/2 to +fs/2. The MATLAB code for this simulator is given below.

```%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% RAYLEIGH FADING SIMULATOR BASED UPON YOUNG'S METHOD
% N is the number of paths
% M is the total number of points in the frequency domain
% fm is the Doppler frequency in Hz
% fs is the sampling frequency in Hz
% df is the step size in the frequency domain
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all;
close all;

N=64;
fm=70;
df=(2*fm)/(N-1);
fs=7.68e6;
M=round(fs/df);
T=1/df;
Ts=1/fs;

% Generate 2xN IID zero mean Gaussian variates
g1=randn(1,N);
g2=randn(1,N);
g=g1-j*g2;

% Generate Doppler Spectrum
f=-fm:df:fm;
S=1.5./(pi*fm*sqrt(1-(f/fm).^2));
S(1)=2*S(2)-S(3);
S(end)=2*S(end-1)-S(end-2);

% Multiply square root of Doppler Spectrum with Gaussian random sequence
X=g.*sqrt(S);

% Take IFFT
F_zero=zeros(1, round((M-N)/2));
X=[F_zero, X, F_zero];
x=ifft(X,M);
r=abs(x);
r=r/mean(r);

% Plot the Rayleigh envelope
t=0:Ts:T-Ts;
plot(t,10*log10(r))
xlabel('Time(sec)')
ylabel('Signal Amplitude (dB)')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
```

The question now is that how do we verify that the generated Rayleigh fading sequence has the desired statistical properties. This can be verified by looking at the level crossing rate (LCR) and average fade duration (AFD) of the generated sequence as well as the PDF and Autocorrelation function. The LCR and AFD calculated for N=64 and fm=70 Hz and threshold of -10 dB (relative to the average signal power) is given below.

LCR
Simulation: 15.55
Theoretical: 15.46

AFD
Simulation: 453 usec
Theoretical:  508 usec

It is observed that the theoretical and simulation results for the LCR and AFD match reasonably well. We next examine the distribution of the envelope and phase of the resulting sequence x. It is found that the envelope of x is Rayleigh distributed while the phase is uniformly distributed from -pi to pi. This is shown in the figure below. So we are reasonably satisfied that our generated sequence has the desired statistical properties.

Rayleigh Fading Simulator Based on Young’s Filter

In the above simulation of Rayleigh fading sequence we reduced the computation load of Smith’s simulator by reducing the IFFT operations on two branches to a single IFFT operation. However, we still used the Doppler spectrum proposed by Smith. Now we use the filter with spectrum Fk defined by Young in [1]. The code for this is given below.

```
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% RAYLEIGH FADING SIMULATOR BASED UPON YOUNG'S METHOD
% N is the number of points in the frequency domain
% fm is the Doppler frequency in Hz
% fs is the sampling frequency in Hz
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all;
close all;

N=2^20;
fm=300;
fs=7.68e6;
Ts=1/fs;

% Generate 2xN IID zero mean Gaussian variates
g1=randn(1,N);
g2=randn(1,N);
g=g1-j*g2;

% Generate filter F
F = zeros(1,N);
dopplerRatio = fm/fs;
km=floor(dopplerRatio*N);
for k=1:N
if k==1,
F(k)=0;
elseif k>=2 && k<=km,
F(k)=sqrt(1/(2*sqrt(1-((k-1)/(N*dopplerRatio))^2)));
elseif k==km+1,
F(k)=sqrt(km/2*(pi/2-atan((km-1)/sqrt(2*km-1))));
elseif k>=km+2 && k<=N-km,
F(k) = 0;
elseif k==N-km+1,
F(k)=sqrt(km/2*(pi/2-atan((km-1)/sqrt(2*km-1))));
else
F(k)=sqrt(1/(2*sqrt(1-((N-(k-1))/(N*dopplerRatio))^2)));
end
end

% Multiply F with Gaussian random sequence
X=g.*F;

% Take IFFT
x=ifft(X,N);
r=abs(x);
r=r/mean(r);

% Plot the Rayleigh envelope
T=length(r)*Ts;
t=0:Ts:T-Ts;
plot(t,10*log10(r))
xlabel('Time(sec)')
ylabel('Signal Amplitude (dB)')
axis([0 0.05 -15 5])
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
```

The above code was used to generate Rayleigh sequences of varying lengths with Doppler frequencies of 5 Hz, 70 Hz and 300 Hz. The sampling frequency was fixed at 7.68 MHz (corresponding to a BW of 5 MHz). It must be noted that in this simulation the length of the Gaussian sequence is equal to the filter length in the frequency domain. It was found that to generate a Rayleigh sequence of reasonable length the length of the Gaussian sequence has to be quite large (2^20 in the above example). As before we calculated the distribution of envelope and phase of the generated sequence as well as the LCR and AFD. These were found to be within reasonable margins.

Note:

1. Level crossing rate (LCR) is defined as number of times per second the signal envelope crosses a given threshold. This could be either in the positive direction or negative direction.
2. Average fade duration (AFD) is the average duration that the signal envelope remains below a given threshold once it crosses that threshold. Simply it is the average duration of a fading event.
3. The LCR and AFD are interconnected and the product of these two quantities is a constant.

[1] David J. Young and Norman C. Beaulieu, "The Generation of Correlated Rayleigh Random Variates by Inverse Discrete Fourier Transform", IEEE Transactions on Communications vol. 48 no. 7 July 2000.

# Can We Do Without a Cyclic Prefix

Have you ever thought that Cyclic Prefix in OFDM is just a gimmick and we could do equally well by using a guard period i.e. a period of no transmission between two OFDM symbols. Well, one way to find out if this is true is by running a bit error rate simulation with and without a cyclic prefix (only a vacant guard period). We use the 64-QAM OFDM simulation that we developed previously. The channel is modeled as 7-tap FIR filter with each tap having a Rayleigh distribution.

BER with and without Cyclic Prefix

We simulate the case of a vacant guard period by inserting zeros in the time slot dedicated for the CP (32 samples). It is observed that there is a vast difference in the bit error rate (BER) for the two cases. In fact in the case of no CP the BER hits an error floor at around 20 dB. Increasing the signal to noise ratio does not improve the BER performance any further.

Now to answer the question “why does the CP work” we have to revisit the concept of circular convolution from our DSP course. It is well known that performing circular convolution of two sequences in the time domain is equivalent to multiplication of their DFT’s in the frequency domain. So if a wireless channel performed circular convolution we could do simple division to recover the signal after the FFT operation in the receiver.

Y(k)=X(k)*H(k) Effect of Wireless Channel

X(k)=Y(k)/H(k) Recovery of the Signal

But the wireless channel does not perform circular convolution, it performs linear convolution. So the trick is to make this linear convolution appear as circular convolution by appending a cyclic prefix. The result is that equalization can be performed at the receiver by simple division.

For a more elaborate discussion on this you may visit CP-1 or for a mathematical description you may visit CP-2.

Note: In a actual system there would be AWGN noise added to the received signal as well. Giving us the following relationships.

Y(k)=X(k)*H(k)+W(k) Effect of Wireless Channel

X(k)’=Y(k)/H(k)=X(k)+W(k)/H(k) Recovery of the Signal

As discussed previously an LTE channel can be modeled as an FIR filter. The filter taps are described by the EPA, EVA and ETU channel models.

If x(k) is the original signal then the signal at the output of the FIR filter y(k) is given as:

y(k)=x(k)*c(0)+x(k-1)*c(1)+…..+x(k-L+2)*c(L-2)+x(k-L+1)*c(L-1)

Since the wireless channel is time varying the channel taps c(0) c(1)…..c(L-1) are also time varying with either Rayleigh or Rician distribution. It is quite easy to generate Rayleigh random variables with the desired power and distribution, however, when these Rayleigh random variables are required to have temporal correlation the process becomes a bit complicated. Temporal correlation of these variables depends upon the Doppler frequency which is turn depends upon the speed of the mobile device. The Doppler frequency is defined as:

fd=v*cos(theta)/lambda

where

fd is the Doppler Frequency in Hz
v is the receiver velocity in m/sec
lambda is the wavelength in m
and theta is the angle between the direction of arrival of the signal and the direction of motion

A simple method for generating Rayleigh random variables with the desired temporal correlation was devised by Smith [1]. His method was based on Clark and Gans fading model and has been widely used in simulation of wireless communication systems.

The method for generating the Rayleigh random with the desired temporal correlation is given below (modified from Theodore S. Rappaport Text).

1. Define N the number of Gaussian RVs to be generated, fm the Doppler frequency in Hz, fs the sampling frequency in Hz, df the frequency spacing which is calculated as df=(2*fm)/(N-1) and M total number of samples in frequency domain which is calculated as M=(fs/df).

2. Generate two sequences of N/2 complex Gaussian random variables. These correspond to the frequency bins up to fm. Take the complex conjugate of these sequences to generate the N/2 complex Gaussian random variables for the negative frequency bins up to -fm.

3. Multiply the above complex Gaussian sequences g1 and g2 with square root of the Doppler Spectrum S generated from -fm to fm. Calculate the spectrum at -fm and +fm by using linear extrapolation.

4. Extend the above generated spectra from -fs/2 to +fs/2 by stuffing zeros from -fs/2 to -fm and fm to fs/2. Take the IFFT of the resulting spectra X and Y resulting in time domain signals x and y.

5. Add the absolute values of the resulting signals x and y in quadrature. Take the absolute value of this complex signal. This is the desired Rayleigh distributed envelope with the required temporal correlation.

The Matlab code for generating Rayleigh random sequence with a Doppler frequency of fm Hz is given below.

```%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% RAYLEIGH FADING SIMULATOR BASED UPON SMITH'S METHOD
% N is the number of paths
% M is the total number of points in the frequency domain
% fm is the Doppler frequency in Hz
% fs is the sampling frequency in Hz
% df is the step size in the frequency domain
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all;
close all;

N=10;
fm=300;
df=(2*fm)/(N-1);
fs=7.68e6;
M=round(fs/df);
T=1/df;
Ts=1/fs;

% Generate two sequences of N complex Gaussian random variables
g=randn(1,N/2)+j*randn(1,N/2);
gc=conj(g);
g1=[fliplr(gc), g];

g=randn(1,N/2)+j*randn(1,N/2);
gc=conj(g);
g2=[fliplr(gc), g];

% Generate Doppler Spectrum S
f=-fm:df:fm;
S=1.5./(pi*fm*sqrt(1-(f/fm).^2));
S(1)=2*S(2)-S(3);
S(end)=2*S(end-1)-S(end-2);

% Multiply the complex sequences with the Doppler Spectrum S, take IFFT
X=g1.*sqrt(S);
X=[zeros(1,round((M-N)/2)), X, zeros(1,round((M-N)/2))];
x=abs(ifft(X,M));

Y=g2.*sqrt(S);
Y=[zeros(1,round((M-N)/2)), Y, zeros(1,round((M-N)/2))];
y=abs(ifft(Y,M));

% Find the resulting Rayleigh faded envelope
z=x+j*y;
r=abs(z);

t=0:Ts:T-Ts;
plot(t,10*log10(r/mean(r)),'r')
xlabel('Time(sec)')
ylabel('Envelope (dB)')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
```

The above code generates a Rayleigh random sequence with samples spaced at 0.1302 usec. This corresponds to a sampling frequency of 7.68 MHz which is the standard sampling frequency for a bandwidth of 5MHz. Similarly, the sampling rate for 10 MHz and 20 MHz is 15.36 MHz and 30.72 MHz respectively.  The Doppler frequency can also be changed according to the scenario. LTE standard defines 3 channel models EPA, EVA and ETU with Doppler frequencies of 5 Hz, 70 Hz and 300 Hz respectively. These are also known as Low Doppler, Medium Doppler and High Doppler respectively.

The above code generated Rayleigh sequences of varying lengths for the three cases. But in all the cases it is in excess of 10 msec and can be used as the fading sequence for an LTE frame. Just to recall an LTE frame is of 10 msec duration with 20 time slots of 0.5 msec each. If each slot contains 7 OFDM symbols the total length of a fading sequence is 140 symbols.

It is seen that the fluctuation in the channel increases with Doppler frequency. The channel is almost static for a Doppler frequency of 5 Hz and varies quite rapidly for a Doppler frequency of 300 Hz. It is also shown above that the envelope of z is Rayleigh distributed and phase of z is Uniformly distributed. However, the range of phase is from 0 to pi/2. This needs to be further investigated. The level crossing rate and average fade duration can also be measured.

This is the process for generating one Rayleigh distributed channel tap. This step would have to be repeated for the number of taps in the channel model which could be 7 or 9 for the LTE channel models. A Ricean distributed channel tap can be generated in a similar fashion. MIMO channel taps can also be generated using the above described method, however, we would need to understand the concept of antenna correlation before we do that.

Level Crossing Rate and Average Fade Duration

Level crossing rate (LCR) is defined as number of times per second the signal envelope crosses a given threshold. This could be either in the positive direction or negative direction. Average fade duration (AFD) is the average duration that the signal envelope remains below a given threshold once it crosses that threshold. Simply it is the average duration of a fading event. The LCR and AFD are interconnected and the product of these two quantities is a constant. The program given below calculates the LCR and AFD of the above generated envelope r.

```
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PROGRAM TO CALCULATE THE LEVEL CROSSING RATE AND AVERAGE FADE DURATION
% Rth: Level to calculate the LCR and AFD
% Rrms: RMS level of the signal r
% rho: Ratio of defined threshold and RMS level
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Rth=0.30;
Rrms=sqrt(mean(r.^2));
rho=Rth/Rrms;

count1=0;
count2=0;

r=r/mean(r);
for n=1:length(r)-1

if r(n)<Rth && r(n+1)>Rth
count1=count1+1;
end
if r(n) < Rth
count2=count2+1;
end

end
LCR=count1/(T)
AFD=((count2*Ts)/T)/LCR

LCR_num=sqrt(2*pi)*fm*rho*exp(-(rho^2))
AFD_num=(exp(rho^2)-1)/(rho*fm*sqrt(2*pi))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
```

The program calculates both the simulated and theoretical values of LCR and AFD e.g. for a threshold level of 0.3 (-5.22 dB) the LCR and AFD values calculated for fm=70 Hz and N=32 are:

LCR simulation = 45.16

LCR theoretical = 43.41

AFD simulation = 0.0015 sec

AFD theoretical = 0.0016 sec

It can be seen that the theoretical and simulation results match quite well. This gives us confidence that are generated envelope has the desired statistical characteristics.

Note:

1. According to Wireless Communications Principles and Practice by Ted Rappaport “Perform an IFFT on the resulting frequency domain signals from the in-phase and quadrature arms to get two N-length time series, and add the squares of each signal point in time to create an N-point time series. Note that each quadrature arm should be a real signal after IFFT”. Now this point about the signal being real after IFFT is not always satisfied by the above program. The condition can be satisfied by playing around with the value of N a bit.

2. Also, we take the absolute value of both the time series after IFFT operation to make sure that we get a real valued sequence. However, taking the absolute value of both the in-phase and quadrature terms  makes z fall in the first quadrant and the phase of z to vary from 0 to pi/2. A better approach might be to use the ‘real’ function instead of ‘abs’ function so that the phase can vary from 0 to 2pi.

3. A computationally efficient method of generating Rayleigh fading sequence is given here.

[1] John I. Smith, “A Computer Generated Multipath Fading Simulation for Mobile Radio”, IEEE Transactions on Vehicular Technology, vol VT-24, No. 3, August 1975.