EEE8077 Simulation of Wireless Communications Dr. Charalampos C. Tsimenidis Newcastle University School of Electrical and Electronic Engineering
October 2013
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
1 / 78
Motivation
Performance evaluation of wireless communication systems: Theoretical or analytical approach (desired solution), Semi-analytical approach (alternative solution), Simulation-based approach (practical solution).
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
2 / 78
Example: Theoretical Performance Bit-error rate (BER) performance of Binary Shift Keying (BPSK) modulation in Rayleigh fading in the presence Additive White Gaussian Noise (AWGN) channel. System Model: xn = hn dn + wn
dn
hn
wn
where hn are the complex-valued Rayleigh fading coefficients with variance 2σ2h , dn = ±1 are the BPSK symbols, wn are the complex-valued AWGN samples. Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
3 / 78
Theoretical Performance (Cont.) Theoretical BER (closed-form solution): ! r Γ 1 1− Pe (Γ) = 2 1+Γ where Γ is the average signal to noise ratio (SNR) given as Γ=
Eb 2 2σ N0 h
Eb is the bit energy N0 and σ2w are the noise energy and variance N0 = 2σ2w Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
4 / 78
Theoretical Performance (Cont.) 0
10
BPSK in AWGN BPSK in Rayleigh
−1
10
−2
P e (Γ) =
Pe
10
1 2
q 1 2 Γ 1 − 1+Γ
−3
10
−4
10
−5
10
P e (γ) = Q
!√
2γ
"
−6
10
−5
0
10
20 30 Average SNR Γ (dB)
Dr. Charalampos C. Tsimenidis
40
50
EEE8077 Simulation of Wireless Communications
5 / 78
Theoretical Performance (Cont.) 1 2 3 4
%--BPSK in AWGN-gamma_dB=-4:0.1:10; gamma_lin=10.ˆ(gamma_dB/10); ber_AWGN=qfunc(sqrt(2*gamma_lin));
5 6 7 8 9
%--BPSK in Rayleigh-Gamma_dB=-4:0.1:40; Gamma_lin=10.ˆ(Gamma_dB/10); ber_Rayleigh=0.5*(1-sqrt(Gamma_lin./(Gamma_lin +1)));
10 11 12 13
% Plot results semilogy(gamma_dB,ber_AWGN,’r-’,... Gamma_dB,ber_Rayleigh,’b--’);
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
6 / 78
Semi-analytical Performance Semi-analytical BER with N sufficiently large: 1 N Pe (γ) = ∑ Q N n=1
q 2γ |hn |2
Average effect of hn on γ. BER in AWGN is given as Pe (γ) = Q
p 2γ
γ is the signal to noise ratio given as γ= Dr. Charalampos C. Tsimenidis
Eb N0
EEE8077 Simulation of Wireless Communications
7 / 78
Semi-analytical Performance (Cont.) 0
10
−1
10
−2
P e (γ) =
10
1 N
BPSK in AWGN BPSK in Rayleigh Semi−analytical N 1p 2 X 2γ |hn |2 Q
Pe
n=1
−3
10
−4
10
−5
10
P e (γ) = Q
!√
2γ
"
−6
10
−5
0
10
20 30 Average SNR Γ (dB)
Dr. Charalampos C. Tsimenidis
40
50
EEE8077 Simulation of Wireless Communications
8 / 78
Semi-analytical Performance (Cont.)
1 2 3 4 5 6 7 8 9 10
N=1e6; gamma_dB_2=-5:5:45; gamma_lin=10.ˆ(gamma_dB_2/10); L=length(gamma_dB_2); ber_Semi_Rayleigh=zeros(1,L); for i=1:L h=1/sqrt(2)*(randn(1,N)+1j*randn(1,N)); Pe=qfunc(sqrt(2*gamma_lin(i)*abs(h).ˆ2)); ber_Semi_Rayleigh(i)=sum(Pe)/N; end
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
9 / 78
Simulated Performance
Implement system using: Transmitter by generating bn and mapping it to dn Channel by generating hn and wn and computing for different SNR values xn = hn dn + wn Receiver by implementing decision rule and BER computation. Display simulation results.
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
10 / 78
Simulated Performance (Cont.) xn = hn dn + wn
dn
hn BPSK Transmitter Data
bn
Tx
wn hn , wn
dn
Comm. Channel
Receiver
xn
Estimated Data
Rx
ˆbn
Compute BER
Pe = f (SN R)
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
11 / 78
Simulated Performance (Cont.) 0
10
BPSK in AWGN BPSK in Rayleigh Simulation q 1 2 Γ P e (Γ) = 21 1 − 1+Γ
−1
10
−2
Pe
10
−3
10
−4
10
−5
10
P e (γ) = Q
!√
2γ
"
−6
10
−5
0
10
20 30 Average SNR Γ (dB)
Dr. Charalampos C. Tsimenidis
40
50
EEE8077 Simulation of Wireless Communications
12 / 78
Digital Modulation Digital information is transmitted by varying the information of either amplitude a(t), frequency fi (t) or phase φ(t) of a sinusoid: s(t) = a(t) sin[2π fi (t)t + φ(t)] Modulation types: Amplitude Shift Keying (ASK): a(t) conveys information, while fi (t) and φ(t) constant. Frequency Shift Keying (FSK): fi (t) conveys information, while a(t) and φ(t) constant. Phase-shift keying (PSK): φ(t) conveys information, while a(t) and fi (t) constant. Quadrature Amplitude Modulation (QAM): Two parameters are varied, i.e. amplitude a(t) and phase φ(t). Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
13 / 78
Bandpass and Complex-Baseband Signals The information bearing signal is referred to as the complex-baseband or lowpass equivalent signal, sl (t), given as sl (t) = a(t)e jφ(t) = xI (t) + jxQ(t) Bandpass signal is only required to reduce the effective antenna size required. It is given as s(t) = Re{sl (t)e j2π fct }
= Re{[xI (t) + jxQ (t)]e j2π fct } = xI (t) cos(2π fct) − xQ (t) sin(2π fct)
sl (t) is much lower frequency (typically ≤ 20 MHz) than s(t) which can be up to 60 GHz. Thus, it is computationally inefficient to include the carrier in the simulations. Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
14 / 78
Bandpass and Complex-Baseband Signals (Cont.) The entire system is simulated in most cases at the symbol rate to minimize simulation times. The symbol-rate, sampled complex-baseband signal is given as sl (nT ) = a(nT )e jφ(nT ) = xI (nT ) + jxQ (nT ) In simulations, we only need xI (nT ) and xQ (nT ) or a(nT ) and φ(nT ), with T being the symbol duration, which can be also dropped for clarity. System/signal bandwidth and sampling frequency are only required for normalizing the times of multipath arrivals and for Doppler effect simulations in time-varying systems Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
15 / 78
Typical Program Structure
1 2
% Short description of simulation clear, clc, close all
3 4 5 6
% Simulation parameter definitions M=16; % Constellation size ...
7 8 9
% Reset BER variable BER=zeros(1,?);
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
16 / 78
Typical Program Structure (Cont.) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
for m=... % SNR loop total_errors=0; for n=... % Averaging loop % Transmitter ... % Communications channel ... % Receiver ... % Bit error computation new_errors=... total_errors=total_errors+new_errors; end BER=... end Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
17 / 78
Typical Program Structure (Cont.)
1 2 3
% Plot results semilogy(?,?) ...
4 5 6
% Store results in a file save ...
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
18 / 78
16-Point Quadrature Amplitude Modulation (16-QAM) The theoretical bandwidth efficiency is 4 bit/s/Hz k = 4 bits are grouped to create a symbol Constellation consists of M = 2k bits = 24 = 16 points M-QAM alphabet: {±(2k − 1)d ± j(2k − 1)d}, where √ M k ∈ {1, . . . 2 } For 16-QAM, with M = 16 and k = 4 we obtain 4 values for the I and Q channel, i.e. I, Q ∈ {−3d, −d, d, 3d} d is an arbitrary value, typically d = 1 or d = This corresponds to 2 bits per channel. Dr. Charalampos C. Tsimenidis
1 3
EEE8077 Simulation of Wireless Communications
19 / 78
Constellation of Binary-Coded 16-QAM
4 2 3 4 5 6 7 8
C=[-3+3j, -3+1j, -3-1j, -3-3j, -1+3j, -1+1j, -1-1j, -1-3j, 1+3j, 1+1j, 1-1j, 1-3j, 3+1j, 3+1j, 3-1j, 3-3j];
3 2 Quadrature
1
1 0 −1 −2 −3 −4 −4
Dr. Charalampos C. Tsimenidis
0000
0100
1000
1100
0001
0101
1001
1101
0010
0110
1010
1110
0011
0111
1011
1111
−3
−2
−1
0 1 In−phase
2
3
EEE8077 Simulation of Wireless Communications
4
20 / 78
Constellation of Gray-Coded 16-QAM
4 2 3 4 5 6 7 8
C=[-3+3j, -3+1j, -3-3j, -3-1j, -1+3j, -1+1j, -1-3j, -1-1j, 3+3j, 3+1j, 3-3j, 3-1j, 1+3j, 1+1j, 1-3j, 1-1j];
3 2 Quadrature
1
1 0 −1 −2 −3 −4 −4
Dr. Charalampos C. Tsimenidis
0000
0100
1100
1000
0001
0101
1101
1001
0011
0111
1111
1011
0010
0110
1110
1010
−3
−2
−1
0 1 In−phase
2
3
EEE8077 Simulation of Wireless Communications
4
21 / 78
Constellation of Gray-Coded 16-QAM (Cont.) For a constellation point z = x + jy, the bit allocation, b0 b1 b2 b3 , is as follows First bit, b0 b0 = 0 if Re{z} ≤ 0 b0 = 1 if Re{z} > 0
Second bit, b1 b1 = 0 if Re{z} ≤ −2 or Re{z} ≥ 2 b1 = 1 if Re{z} > −2 or Re{z} < 2
Third bit, b2
b2 = 0 if Im{z} ≥ 0 b2 = 1 if Im{z} < 0
Forth bit, b3 b3 = 0 if Im{z} ≤ −2 or Im{z} ≥ 2 b3 = 1 if Im{z} > −2 or Im{z} < 2 Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
22 / 78
MATLAB Implementation for 16 QAM Tx
By writing our own code using look-up table: D(k) = C(bk + 1) where C is the constellation vector and sk is the symbol index, e.g. k = 0, 1, 2, ..., M − 1. To generate bk use: randi(?,?,?) Help: >> doc randi
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
23 / 78
Random Number Generation
MATLAB by default generates always the same random numbers at the start of each session. To obtain different random values in different MATLAB sessions include at the top of your code, right after clear, the following: 1 2 3
RN=sum(100*clock); RS=RandStream(’mt19937ar’,’seed’,RN); RandStream.setGlobalStream(RS);
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
24 / 78
Code Developement Lab 2 Develop a 16-QAM modulator using look-up table approach to generate a frame of 2048 16-QAM symbols. Add complex-valued random AWGN noise with small standard deviation (e.g. 0.25) and plot the resulting constellation. 4 3
Quadrature
2 1 0 −1 −2 −3 −4 −4
−3
−2
Dr. Charalampos C. Tsimenidis
−1
0 1 In−phase
2
3
4
EEE8077 Simulation of Wireless Communications
25 / 78
Time-Frequency Relationship The time-bandwidth product is defined as: B T = 1 The Fourier spectrum of a rectangular pulse t FT pT (t) = A rect( ) ←→ PT ( f ) = A T sinc ( f T ) T sin(πx) x
where the sinc( .) function defined as: sinc(x) = 1
T T 4
0.75
PT (f)
T 4
0.5 0.25
T
0 −8 −7 −6 −5 −4 −3 −2 −1
0
1
2
3
4
5
6
7
8
f (Hz)
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
26 / 78
Principle of OFDM B
Channel Frequen y Response
Single Carrier
Multi Carrier
∆f =
Dr. Charalampos C. Tsimenidis
B N
f
EEE8077 Simulation of Wireless Communications
27 / 78
Advantages of OFDM
Efficient spectrum usage. Resilience to frequency selective multipath channels. Simplified receiver design: FFT + one-tap equalizer. Less sensitive to symbol timing and impulsive noise. Bit and power loading at subcarrier level possible.
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
28 / 78
Disadvantages of OFDM
OFDM signal exhibits high Peak-to-Average Power Ratio (PAPR). Very sensitive to carrier frequency offsets (CFO). Very sensitive to intercarrier interference (ICI) due to FFT leakage.
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
29 / 78
OFDM Transmitter Model
Insert Pilots 16−QAM Symbols
[0, 1, . . . , 15]
Modulator 16−QAM
S/P
IFFT
Insert Cyclic Prefix
P/S
OFDM Symbol
x(n)
d(n)
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
30 / 78
OFDM Signal Model Definitions: 2πkn 1 N−1 d[n] = √ ∑ D[k]e j N , n = 0, 1, . . ., N − 1 N k=0
N−1 2πkn ˆ = √1 ∑ d[n]e− j N , k = 0, 1, . . ., N − 1 D[k] N n=0
D[n] is the 16-QAM modulated data sequence + Pilots 1 + j. N is the length of the IDFT / DFT transform. n is the time sample index of the transmitted OFDM symbol. k is the subcarrier index in frequency domain. Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
31 / 78
MATLAB Implementation
2πkn 1 N−1 D[k]e j N , n = 0, 1, . . ., N − 1 d[n] = ∑ N k=0 1
d=ifft(D);
N−1
ˆ = D[k]
∑ d[n]e− j
2πkn N
n=0 1
, k = 0, 1, . . ., N − 1
D_est=fft(d);
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
32 / 78
MATLAB Implementation (Cont.)
IDFT vs IFFT and DFT vs FFT If N is a power of 2, MATLAB employs FFT, otherwise a slower DFT is used. ifft() and fft() accept a second a argument to specify the transform size and use zero-padding. No need to zero-pad manually. Useful oversampling of the channel impulse response, h(k) in order to obtain the correct frequency response H(n).
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
33 / 78
Oversampling Effect (Channel Estimation, PAPR) H=fft(h,Nfft);
1.5
0.2 0.15
1
|d[n]|
|d[n]|
1
0.5 0
0.1 0.05
0
5 10 15 20 25 32 a) Without oversampling.
Dr. Charalampos C. Tsimenidis
0
0
50 100 150 200 256 b) With oversampling by 8.
EEE8077 Simulation of Wireless Communications
34 / 78
Addition of Cyclic Prefix Copy last K samples CP
1 2
OFDM Symbol
CP
d=ifft(D); x=[d(?:?) d]; K is the cyclic prefix length added to reduce multipath
effects.
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
35 / 78
Cyclic Prefix (Cont.)
DFT Property: replication in one domain corresponds to interpolation in the other. Thus, if a signal is replicated by M in time domain, its DFT is zero interpolated by M (and scaled). The use of CP converts a frequency selective channel into a set of parallel flat-fading independent channels. Some papers suggest alternatively zero-padding (ZP) instead of CP.
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
36 / 78
Energy Normalization
Asymmetric energy transform implementation with respect to time-frequency domain transition. Problem with required noise power computation for given SNR. Signal energy normalization required. Implementation: √ either by multiplying x with N before adding Gaussian noise, or by scaling the noise √ standard deviation appropriately by 1/ N.
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
37 / 78
Code Developement Lab 3
Develop the code to implement The 16-QAM OFDM transmitter, insertion of K-sample cyclic-prefix using concatenation, Energy normalization of the OFDM waveform.
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
38 / 78
Channel Simulation x(n)
y(n) = x(n) + w(n)
w(n) Complex additive Gaussian noise: 1
w=sigma(?)*(randn(?,?)+1j*randn(?,?))
randn() generates zero-mean unity variance noise samples. Appropriate scaling using the standard deviation sigma(?) is required. Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
39 / 78
Gaussian Probability Density Function (PDF) Models the statistics of thermal noise in receivers known as additive white Gaussian noise (AWGN). Appears in closed-form BER solutions for the performance over AWGN channels. The PDF of a Gaussian distribution is defined as − (x−µw ) 1 e 2σ2w fw (x) = √ 2πσw
2
where µw is the mean value and σ2w is the variance. σw is called the standard deviation. It is also referred to as normal, N . To indicate that a random variable w has a Gaussian or normal pdf fw (x), we write w → N (µw , σ2w ) Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
40 / 78
Gaussian pdf
1.6 µw µw µw µw µw
1.4 1.2
R∞
−∞ fw (x)dx
=1
= 0, σw2 = 1 = 0, σw2 = 0.5 = 0, σw2 = 0.25 = 1, σw2 = 1 = −1, σw2 = 1
fw (x)
1 0.8 0.6 0.4 0.2 0 −4
−3
−2
−1
0
1
2
3
4
x Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
41 / 78
Gaussian Cumulative Density Function (CDF) In general, the CDF is defined as Fw (x) = P(w ≤ x) = CDF properties
Z x
−∞
fw (u)du
Fw (x) ≥ 0, ∀x
Fw (−∞) = 0, Fw (∞) = 1 The CDF of a Gaussian distribution is given as 1 1 x − µw Fw (x) = + erf √ 2 2 2σw 1 1 x − µw = − erfc √ 2 2 2σ w x − µx = 1−Q σ Simulation of Wireless Communications Dr. Charalampos C. Tsimenidis EEE8077w
42 / 78
Gaussian CDF and PDF Gaussian cdf and pdf for µ w = 0, σw2 = 1 1.5 fw (x) Fw (x)
fw (x), Fw (x)
Fw (∞) = 1 1
0.5
Fw (−∞) = 0 0 −4
−3
−2
−1
0
1
2
3
4
x Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
43 / 78
The erf(x), erfc(x) and Q(x) Functions The error function x 2 2 erf(x) = √ e−t dt π 0 The complementary error function Z ∞ 2 2 erfc(x) = √ e−t dt π x Relationship: erfc(x) = 1 − erf(x)
Z
The Q( .) function:
∞ −t 2 1 Q(x) = √ e 2 dt 2π x Relationship between Q(x) and erfc(x): x 1 Q(x) = erfc √ 2 2
Z
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
44 / 78
SNR Computation The SNR is computed as follows: SNR =
Eb N0
The average bit energy Eb computed from the constellation: Es Eb = log2 (M) The noise energy is computed as: N0 = 2σ2w We need to solve for σw = Dr. Charalampos C. Tsimenidis
√
...
EEE8077 Simulation of Wireless Communications
45 / 78
Es Computation Es is computed as follows: 1 M−1 |cn |2 ∑ M n=0 1 = 4 |3d + j3d|2 + 8 |3d + jd|2 + 4 |d + jd|2 16 160 2 1 72d 2 + 80d 2 + 8d 2 = d = 16 16 = 10 d 2
Es =
Reminder complex numbers: z ∈ C z = a + jb ⇒ |z|2 = Dr. Charalampos C. Tsimenidis
p
a2 + b2
2
= a2 + b2
EEE8077 Simulation of Wireless Communications
46 / 78
16-QAM BER in AWGN For M = 2 (2-QAM/BPSK) and M = 4 (4-QAM/QPSK): r 2Eb Pb = Q N0 For M >> 4, k = log2 (M) Pb =
PM k
where PM ≈ 1 − (1 − P√M )2 with
s ! 1 3k E b Q P√M = 2 1 − √ M − 1 N M 0 Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
47 / 78
16-QAM BER in AWGN (Cont.) 0
10
BPSK in AWGN 16−QAM in AWGN
−1
10
−2
Pe
10
−3
10
−4
10
−5
10
P e (γ) = Q
!√
2γ
"
−6
10
0
2
4
6
8 γ=
Dr. Charalampos C. Tsimenidis
Eb N0
10 (dB)
12
14
16
EEE8077 Simulation of Wireless Communications
48 / 78
Code Developement Lab 4
Develop MATLAB code that Computes the standard deviation for 16-QAM in AWGN, for a given SNR value given in dB. Generates random AWGN noise wn scaled by the correct σw and adds it to the OFDM signal. Generates the BER vs Eb /N0 plots for BPSK and 16-QAM in AWGN.
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
49 / 78
Receiver Structure for AWGN
Received OFDM Symbol
Remove Cyclic Prefix
S/P
FFT
16−QAM Demodul.
P/S
16−QAM Symbols
CP is discarded at the receiver to avoid interblock interference. DFT/FFT is performed. Channel estimation is not required for AWGN channel. 16-QAM demodulation using custom code.
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
50 / 78
Demodulator Input Signal
Eb N0
= 16 dB
γ= 5
4
4
3
3
2
2 Quadrature
Quadrature
γ= 5
1 0 −1
0 −1 −2
−3
−3
−4
−4 −4
−3
−2
−1
0 1 In−phase
2
3
4
Dr. Charalampos C. Tsimenidis
5
= 6 dB
1
−2
−5 −5
Eb N0
−5 −5
−4
−3
−2
−1
0 1 In−phase
2
3
EEE8077 Simulation of Wireless Communications
4
5
51 / 78
16-QAM Demodulator Decision metric: bˆ k = arg min(|Ci − Dˆ k |), i = 0, 1 . . . , M − 1, M = 16 i
where |Ci − Dˆ k | is the Euclidean distance defined as q 2 2 ˆ Re(Ci ) − Re(Dˆ k ) + Im(Ci ) − Im(Dˆ k ) |Ci − Dk | = Im{C}
C0
C4
C12
C8 ˆk D
C1
C5
C13
C9
C3
C7
C15
C11
C2
C6
C14
C10
Dr. Charalampos C. Tsimenidis
Re{C}
EEE8077 Simulation of Wireless Communications
52 / 78
Displaying Information about Simulation
1 2
str=sprintf(’SNR=%0.1f,BER=%0.6f\n’,10.5,0.1); disp(str);
3 4
SNR=10.5,BER=0.100000
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
53 / 78
Measuring Simulation Time 1 2 3
tic ... toc
4 5 6 7 8
% or t_start=cputime; ... cputime-t_start
9 10 11
% or (not recommended) t_start = clock;
12 13
etime(clock, t_start)
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
54 / 78
Parallel Configuration (Menu) Parallel −→ Manage Cluster Profiles
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
55 / 78
Parallel Computing with parfor
1 2 3
% Start default worker pool using matlabpool open %...
4 5 6
% Outer loop parfor m=...
7 8
end
9 10 11
% Close worker pool matlabpool close
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
56 / 78
Code Developement Lab 5 Develop MATLAB code that Removes the CP and computes the FFT of the received noisy signal. Estimates using the minimum Euclidean distance the transmitted 16-QAM symbols. Computes and displays the BER vs. SNR performance by averaging P-times per SNR point. Displays information about simulation during code execution. Measures the total simulation time elapsed. Simulates the performance using the parallel configuration. Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
57 / 78
Multipath Channel Scenario
Reflector Cluster Single Reflector
Impulse Response
τ41
h(τ ; t) a1 e−j2πfc τ1 a2 e−j2πfc τ2 a3 e−j2πfc τ3
τ42 τ32
a4 e−j2πfc τ4
τ31 τ1 τ21
Base Station (BS)
τ22
τ1 τ2 τ3 τi = τi1 + τi2
τ4
τ
i = 2, 3, 4
Mobile Station (MS)
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
58 / 78
Channel Impulse Response (CIR) The complex-baseband impulse response of the channel is given L
h(τ;t) =
∑ al (t)e− jφl (t)δ(t − τl (t))
l=1
The phase shifts are φl (t) are proportional to the corresponding time delays τl (t), that is φl (t) = 2π fc τl (t) where fc is the carrier frequency.
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
59 / 78
Simplified CIRs Constant arrival times: τl (t) = τl L
h(τ,t) =
∑ al (t)e− jφl (t) δ(t − τl )
l=1
Static multipath: τl (t) = τl , al (t) = al , φl (t) = φl L
h(τ) =
∑ al e− jφl δ(t − τl )
l=1
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
60 / 78
Multipath Channel Implementation Multipath channel treated as linear time-invariant system: Multipath Channel
x(n)
y(n) h(n)
z(n) = y(n) + w(n) = h(n) ∗ x(n) + w(n)
w(n)
Discrete convolution (filtering): ∞
y(n) = h(n) ∗ x(n) =
∑
m=−∞
h′ (m)x(n − m)
If x(n) ∈ C1×N and h(n) ∈ C1×L then length of y(n) ∈ C1×M is M = N +L−1 Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
61 / 78
Multipath Channel Implementation (Cont.) Preferred MATLAB Implementation: 1 2 3 4 5 6
% Initial filter state zf=[]; ... % Multipath channel [y,zf]=filter(h,1,x,zf); z=y+w; % Add WGN
This implementation keeps track of the channel state between OFDM symbols. Interblock interference can be simulated. Documentation: >>doc filter In general, y=conv(h,x)+w; can be utilized, but not as useful. Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
62 / 78
ITU Channel for Mobile WiMAX Multipath magnitudes hi need to be obtained from P = [0 -0.9 -4.9 -8.0 -7.8 -23.9];
Appropriate zero-padding is required between the paths. ITU Pedestrian B Ch. 103 0
P (dB)
−5
−10
−15
−20
−25
0
5
18
27
52
84
Delay spread (Samples) Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
63 / 78
Channel Normalization The channel magnitudes are obtained as q hi =
Pi
10 10
Channel profile needs to be normalized to unity energy L
∑ |hi|2 = 1
i=1
{hi }Li=1
If are the unnormalized channel coefficients then in order to normalize we use: s L
U=
∑ |hi|2
i=1
hi =
hi , i = 1, 2, 3, . . ., L U
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
64 / 78
Theoretical Performance in Multipath for BPSK Identical to semi-analytical BER since channel is static. For BPSK that is q 1 N 2 Pe (γ) = ∑ Q 2γ |Hn | N n=1 where Hn is the frequency response of the ITU channel. N is here the FFT length. The frequency response is obtained applying the FFT on the vector {hi }Li=1 by oversampling by N. γ is the signal to noise ratio given as γ= Dr. Charalampos C. Tsimenidis
Eb N0
EEE8077 Simulation of Wireless Communications
65 / 78
Theoretical Performance in Multipath for 16QAM For 16QAM, with M = 16, k = log2 (M) = 4, that is s ! N 1 1 3k E b P√M = 2 1 − √ |Hn|2 Q ∑ N M − 1 N M 0 n=1 with PM ≃ 1 − (1 − P√M )2 and Pb ≃
Dr. Charalampos C. Tsimenidis
PM k
EEE8077 Simulation of Wireless Communications
66 / 78
Code Developement Lab 6-7 Develop MATLAB code that with regard to the ITU multipath channel: Implements and normalizes its impulse response. Filters the OFDM signal through the channel and adds complex-valued AWGN noise for a given SNR value in dB. Computes and displays its frequency response. Computes and displays the theoretical BER vs. Eb /N0 performance for BPSK and 16-QAM through this channel. Computes and displays the simulated BER vs. Eb /N0 performance for 16-QAM through this channel using a receiver without equalizer. Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
67 / 78
Generic Receiver Structure
Received OFDM Symbol
Remove Cyclic Prefix
S/P
FFT
One−tap Equalizer
16−QAM Demodul.
P/S
16−QAM Symbols
CP is discarded at the receiver to avoid interblock interference. DFT/FFT is performed. One-tap per subcarrier zero-forcing design to remove channel effect. Channel estimation: impulse response known or unknown. 16-QAM demodulation using custom code (same code as in AWGN case). Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
68 / 78
Mathematical Model of the Received Signal The received signal at the FFT output can be given as Y (k) = D(k)H(k) +W (k), k = 0, 1, 2, ...N − 1 To remove the channel effects, we need to divide Y (k) by the complex-valued channel coefficient, H(k), of the channel frequency response. Thus, the decision variable becomes W (k) ˆ D(k) = D(k) + , k = 0, 1, 2, ...N − 1 H(k) | {z } W˜ (k)
˜ (k) is no longer Gaussian. The noise term W Noise enhancement occurs if channel frequency response exhibits spectral nulls. Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
69 / 78
Equalizer for Known Channel We assume h(n) is perfectly known. H(k) is derived from the impulse response h(n) via DFT/FFT. Oversampling of H(k) is required to match the length of an OFDM symbol. 1 2 3
N=2048; ... H=fft(h,N);
Detection variable after CP removal, FFT and zero forcing: Y (k) ˆ D(k) = H(k) ˜ (k), k = 0, 1, 2, ...N − 1 = D(k) + W Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
70 / 78
Code Developement Lab 8-9
Develop MATLAB code that Computes the zero-forcing equalizer coefficients (computation is required only once as the channel is time-invariant). Implements the modified 16-QAM receiver using one-tap equalizer. Computes and displays the simulated BER vs Eb /N0 performance.
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
71 / 78
Equalizer for Unknown Channel Insert 1 pilot for every 8 subcarriers at the transmitter: 1 Data Pilots Estimates
|Hest (k)|
0.8 0.6 0.4 0.2 0 −1
0
1
2
3
4
5
6 7 8 9 10 11 12 13 14 15 16 17 18 subcarrier index, n
Estimate unknown channel at pilot indices H(p). Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
72 / 78
Linear Interpolation Interpolate to obtain in-between channel values. Line equations connecting two points: y − y1 x − x1 = y2 − y1 x2 − x1 y Hp (m + 1) y2 Hp (m)
y1
x1 n m Dr. Charalampos C. Tsimenidis
x2 n+L m+1
x n (OFDM index) m (Pilot index)
EEE8077 Simulation of Wireless Communications
73 / 78
Linear Interpolation (Cont.)
Interpolation equation: l Hest (k) = H p (m) + [H p(m + 1) − H p(m)] L Indices: m = 1, 2, . . ., N p − 1, l = 1, 2, . . ., L − 1, k = (m − 1)L + l + 1
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
74 / 78
Linear Interpolation (Cont.) For the data subcarriers after the N p th pilot we need to extrapolate the equation from the last two pilots, e.g. H p (N p − 1) and H p(N p ) and l = l + L. Hest (n) extrapolate
Hp (Np ) Hp (Np − 1)
Np − 1 L (Np − 2)
Dr. Charalampos C. Tsimenidis
Np L (Np − 1)
N
m (Pilot index) n (OFDM index)
EEE8077 Simulation of Wireless Communications
75 / 78
Estimated Frequency Response
| H(k)| , | Hest(k)|
2.5 | H(k)| | Hest(k)|
2
1.5 1
0.5 0
0
500
1000 1500 subcarrier index
Dr. Charalampos C. Tsimenidis
2000
EEE8077 Simulation of Wireless Communications
76 / 78
Equalizer for Unknown Channel
Zero forcing equalizer: Y (k) ˆ D(k) = , k = 0, 1, 2, ...N − 1, k 6= m Hest (k) BER should not be computed at the pilot locations, e.g. k = m Total number of bits should be adjusted to account for the pilot overhead.
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
77 / 78
Code Developement Lab 10-12 Develop MATLAB code that Estimates the frequency response of the multipath channel using pilots and computes the zero-forcing equalizer coefficients. Implements the modified 16-QAM receiver using one-tap equalizer and channel estimation. Computes and displays the BER vs Eb /N0 performance with channel estimation. Computes the mean-squared error as the function of SNR in dB between the estimated and actual frequency response of the channel.
Dr. Charalampos C. Tsimenidis
EEE8077 Simulation of Wireless Communications
78 / 78