You are on page 1of 26

NETAJI SUBHAS UNIVERSITY OF TECHNOLOGY

NEW DELHI

DEPARTMENT OF ELECTRONICS AND COMMUNICATIONS


ENGINEERING

DATA COMMUNICATION

Practical File

NAME: Rishabh
ROLL NO: 2020UCD2144
INDEX

Expt No. Experiment Signature

1. To plot the spectrum of a pulse of width 10

To verify following properties of Fourier


2. Transform-Time, Frequency, Convolution
Shift
Study of uniform, exponential and
3. Gaussian distributed random variables.
Draw their pdf and CDF.
4. Study of linear and non-linear quantization.

Study of passband digital communication


5. technique BPSK. Calculate the BER of the
BPSK modulated signal.
Find Code Set C for given Generator Matrix
6. G and also determine the
generator matrix G′ of the appropriate
systematic (separable) code C’.
Model a single- queue single-server system
7. with a single traffic source and an infinite
storage capacity.
Model a single- queue single-server system
8. that has a Poisson arrival process and a
server with constant service time.
Experiment 1) To plot the spectrum of a pulse of width 10

Theory
The rectangular function (also known as the rectangle function, rect function, Pi
function, gate function, unit pulse, or the normalized boxcar function) is defined as

Code

clc;
clear all;
close all;
t1 = -10:0.1:10;
y = 5 * rectpuls(t1,10);
figure(1)
plot(t1,y)
figure(2)
z = fft(y);
plot(fftshift(abs(z)))

Graph
Experiment 2 ) To verify following properties of Fourier Transform:
i. Time Shifting,
ii. Frequency shifting,
iii. Convolutional
Theory
i) Time Shifting: The time shifting property of Fourier transform states that if a signal 𝑥(𝑡) is
shifted by 𝑡0 in the time domain, then the frequency spectrum is modified by a linear phase
shift of slope (−𝜔𝑡0). Therefore, if,

Then, according to the time-shifting property of Fourier transform,

ii) Frequency Shifting: The linearity property of Fourier transform states that the Fourier
transform of a weighted sum of two signals is equal to the weighted sum of their individual
Fourier transforms. Therefore if,

Then, according to the linearity property of Fourier transform,

Where a and b are constants.

iii) Convolution Shift: The convolution of two signals in time domain is equivalent to the
multiplication of their spectra in frequency domain. Therefore, if

Then, according to time convolution property of Fourier transform,


Code:-

a) Time shift

clc;
clear all;
close all;
N=20;
n=0:1:(N-1);
x=(0.8).^n;
subplot(2,1,1);
title('x(n)')
xlabel('n')
ylabel('x(n)')
stem(n,x);
m= -3;
x1=circshift(x,N);
n1=mod(n-m,N);
subplot(2,1,2);
stem(n1,x1);
b) Frequency shift

clc; clear all; close all;


% Frequency Shifting Propert of Fourier Transform:
x=input('Enter the Sequence x:');
l=input('Enter no Shifted by 1:');
N=length(x); Y=fft(x);
Y3=abs(Y);
for n=1:N
x1(n)=x(n)*exp(-1j*2*pi*1/N);
end
Y1=fft(x1);
Y2=abs(Y1);
for n=1:N
z(n)=atan(real(Y(n))/imag(Y(n)));
z1(n)=atan(real(Y1(n))/imag(Y1(n)));
end
subplot(2,2,1);
stem(Y3);
ylabel('Amplitude');
xlabel('DFT coefficent numbers');
title('Magnitude Spectrum');
subplot(2,2,2);
stem(Y2);
ylabel('Amplitude');
xlabel('DFT coefficent numbers');
title('Magnitude Spectrum');
subplot(2,2,3);
stem(z);
ylabel('Angle');
xlabel('DFT coefficent numbers');
title('Phase Spectrum');
subplot(2,2,4);
stem(z1);
ylabel('Angle');
xlabel('DFT coefficent numbers');
title('Phase Spectrum');

Enter the Sequence x:


[1,2,3,4,5,6]
Enter no Shifted by 1:
2
c) Convolution

CODE :-

clc; clear all; close all;


n1 = 1:10;
u = sin(n1);
n2 = 1:10;
v = cos(n2);
x = conv(u,v);
N = length(x);
f = fft(x,N);
w = 2*pi/N:2*pi/N:2*pi;
subplot(2,1,1);
stem(f);
N1 = length(u);
f1 = fft(u,N1);
N2 = length(v);
f2 = fft(v,N2);
y = f1.*f2;
N3 = length(y);
subplot(2,1,2);
stem(y);
EXPERIMENT 3 ) Study of exponential distributed random variables. Draw their
pdf and CDF.

Theory
In probability theory and statistics, the exponential distribution is the probability distribution
of the time between events in a Poisson point process, i.e., a process in which events occur
continuously and independently at a constant average rate. It is a particular case of the
gamma distribution.

The probability density function (pdf) of an exponential distribution is

Here λ > 0 is the parameter of the distribution, often called the rate parameter. The distribution
is supported on the interval [0, ∞). If a random variable X has this distribution, we write X ~
Exp(λ).
The exponential distribution exhibits infinite divisibility.
Code

clear all
close all
clc
x = 0 : 0.1 : 100;
lambda = 0.5;
fx = lambda * exp(-lambda * x);
subplot(211);
plot(x, fx);
xlim([0 20]);
title("PDF of exponential distribution");
Fx = 1 - exp(-lambda * x);
subplot(212);
plot(x, Fx);
xlim([0 20]);
title("CDF of exponential distribution");
n = 10000;
R = rand(1, n);
U = (R - min(R)) / (max(R) - min(R)) + 0.001;
X = -1 / lambda * log(U);
fX = zeros(1, n);
bins = 10;
Min = min(X);
Max = max(X);
interval = (Max - Min) / bins;
for i = 1 : n
j = floor((X(i) - Min) / interval) + 1;
fX(j) = fX(j) + 1;
end
fX = fX / n;
figure(2)
subplot(311);
plot(0 : n - 1, fX);
xlim([0 10]);
title("PDF of inverse exponential transform of uniform R.V.");
FX = zeros(1, n + 1);
Sum = 0;
for i = 1 : n
Sum = Sum + fX(i);
FX(i + 1) = Sum;
end
subplot(312);
plot(0 : n, FX);
xlim([0 10]);
title("CDF of inverse exponential transform of uniform R.V.");
subplot(313);
plot(x, Fx);
xlim([0 10]);
title("CDF of exponential distribution");
Experiment4) Study of linear and non- linear quantization.

Theory
The analog-to-digital converters perform this type of function to create a series of digital
values out of the given analog signal. The following figure represents an analog signal. This
signal to get converted into digital, has to undergo sampling and quantizing.
The quantization of an analog signal is done by discretizing the signal with a number of
quantization levels. Quantization is representing the sampled values of the amplitude by a
finite set of levels, which means converting a continuous-amplitude sample into a
discrete-time signal.
The following figure shows how an analog signal is quantized. The blue line represents
analog signal while the brown one represents the quantized signal.

Qb = linearQuant(-0.4);
Qbm = linearQuantMid(-0.4);

function Q = linearQuant(x)
N = -4; % Number of bits of quantizer
L = 2^N; % Number of levels
Vmax = 5; % Max input
Vmin = -5; % Min input
delta = (Vmax - Vmin)/L;
for i = -L/2 + 1:1:L/2
if x < -L/2
Q = -L/2 + 1;
elseif x > L/2
Q = L/2;
elseif (i)*delta <= x && x < (i+1)*delta
Q = i;
end
end
end

function Q = linearQuantMid(x)
N = 3; % Number of bits of quantizer
L = 2^N; % Number of levels
Vmax = 5; % Max input
Vmin = -5; % Min input
delta = (Vmax - Vmin)/L;
for i = -L/2 + 1:1:L/2
if x <= -L/2 + delta
Q = -L/2 + 1;
elseif x > L/2 - delta
Q = L/2;
elseif (i - 0.5)*delta <= x && x < (i+0.5)*delta
Q = i;
end
end
End
Experiment 5) Study of passband digital communication technique BPSK.
Calculate the BER of the BPSK modulated signal.

Theory

In a BPSK system the received signal can be written as:


y=x+n
where x ∈ {−A, A}, n ∼ CN (0, σ2 ) and σ 2 = N0. The real part of the above equation is yre = x + nre
where nre ∼ N (0, σ2/2) = N (0, N0/2). In the BPSK constellation dmin = 2A and γb is defined as Eb/N0
and sometimes it is called SNR per bit. With this definition we have:

So the bit error probability is:

This equation can be simplified using Q-function as:

where the Q function is defined as:

Code

clc;
clear all;
close all;
bit_number=10^6;
data=randn(1, bit_number)>0.5;
bpsk_data=2*data - 1;
noise=1/sqrt(2)*(randn(1, bit_number)+1i*randn(1, bit_number));
mean(abs(noise.^2))
SNR=0:9;
snr_lin=10.^(SNR/10);
y=zeros(length(SNR), bit_number);
for i=1:length(SNR)
y(i, :)=real(sqrt(snr_lin(i))*bpsk_data+noise);
end
err=zeros(length(SNR), bit_number);
Err=zeros(10, 2);
for i=1:length(SNR)
for j=1:bit_number
if y(i, j)>=0
y(i, j)=1;
else
y(i, j)=0;
end
end
err(i,:)=abs(y(i,:)-data);
Err(i,:)=size(find(err(i,:)));
end
ber=zeros(length(SNR), 1);
for i=1:length(SNR)
ber(i)=Err(i,2)/bit_number;
end
theoryBer=0.5*erfc(sqrt(snr_lin));
semilogy(SNR,ber,'b*-','linewidth',1);
grid on;
hold on;
semilogy(SNR,theoryBer,'r+-','linewidth',1);
grid on;
xlabel('Eb/NO');
ylabel('BER');
legend('Simulation', 'Theory');
toc;
Experiment 6) Given is a linear block code with the generator matrix G

G =[[1 1 0 0 1 0 1], [0 1 1 1 1 0 0], [1 1 1 0 0 1 1]]

a. Calculate the number of valid code words N and the code rate RC. Specify the
complete Code set C.
b. Determine the generator matrix G′ of the appropriate systematic (separable)
code C’.

Theory

Generally, generator matrix G is used to produce codewords from dataword. The relation between c, d
and G is given as:
C = dG

For a code (6,3), there will be 6 bits in the codeword and 3 in the dataword. In a systematic code, the
most common arrangement has a dataword at the beginning of the codeword. To get this, identity
submatrix is used in conjunction with parity submatrix and using the relation d.G, we can have

It is clearly shown that dataword is present as the first 3 bits of the obtained codeword while the rest 3
are the parity bits.

To decode the actual dataword from the obtained codeword at the receiver, transpose of the parity
matrix is done.
Further, the parity check matrix, H, is obtained by the combination of the transpose of the parity matrix
and the identity matrix.

For the matrix H, the decoder can analyze the parity bits from the obtained codewords. Here, the total
number of rows in the above matrix represents the number of parity bits i.e., n-k while the number of
columns shows the number of bits in the codeword i.e., n. In this particular example the number of
rows is 3, representing total 3 parity bits and the number of columns here is 6 showing in i.e., the total
bits in the codeword.
A fundamental property of code matrices states that,
𝑇
𝐺𝐻 = 0
𝑇
For a received codeword the verification of correction is obtained by multiplying the code with 𝐻 .

As we know that,

So, substituting dG in replace of c in second last equation, we will have,

If this product is unequal to 0 then this shows the presence of error. Generally, s called syndrome is
given as:

Code

G = [1,1,0,0,1,0; 0,1,1,1,1,0;1,1,1,0,0,1];
m = [0,0,1;0,1,0;0,1,1;1,0,0;1,0,1;1,1,0;];
C = mod(m*G, 2);
disp('The Complete code set C is:');
disp(C);
G(3,:)=mod(G(3,:)+G(1,:),2);
G(2,:)=mod(G(2,:)+G(3,:),2);
G(1,:)=mod(G(1,:)+G(2,:),2);
disp('The generator matrix G is');
disp(G);
P=[G(:,4) G(:,5) G(:,6)];
I = eye(6-3);
H = [P' I];
disp('The Syndrome Table S is:');
S = eye(6)*H';
disp(S);
Experiment 7) Model a single- queue single-server system with a single traffic
source and an infinite storage capacity.

Theory
This example shows how to model a single-queue single-server system with a single traffic source and
an infinite storage capacity. In the notation, the M stands for Markovian; M/M/1 means that the system
has a Poisson arrival process, an exponential service time distribution, and one server. Queuing theory
provides exact theoretical results for some performance measures of an M/M/1 queuing system and
this model makes it easy to compare empirical results with the corresponding theoretical results.
Structure
The model includes the components listed below:

● Time Based Entity Generator block: It models a Poisson arrival process by generating entities
(also known as "customers" in queuing theory).
● Exponential Interarrival Time Distribution subsystem: It creates a signal representing the
interarrival times for the generated entities. The interarrival time of a Poisson arrival process is an
exponential random variable. FIFO Queue block: It stores entities that have yet to be served.
● Single Server block: : It models a server whose service time has an exponential distribution.

Instrumentation

Results
Experiment 8) Model a single- queue single-server system that has a Poisson arrival
process and a server with constant service time.

Theory
According to queuing theory, the mean waiting time in the queue equals
where is the

arrival rate and is the service rate. This duration is half the theoretical mean waiting time in
the queue for the M/M/1 queuing system with the same arrival rate and service rate

model a single-queue single-server system that has a Poisson arrival process and a server with
constant service time. The queue has an infinite storage capacity. In the notation, the M stands
for Markovian; M/D/1 means that the system has a Poisson arrival process, a deterministic
service time distribution, and one server.

Diagram
Output:-

You might also like