0% found this document useful (0 votes)
70 views23 pages

21ECL55 - Communication Lab-II

Uploaded by

adnagaprasad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views23 pages

21ECL55 - Communication Lab-II

Uploaded by

adnagaprasad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Communication Lab-II

B.E: Electronics & Communication Engineering / B.E: Electronics & Telecommunication


Engineering
NEP, Outcome Based Education (OBE) and Choice Based Credit System (CBCS)
(Effective from the academic year 2021 – 22)
V Semester
Course Code 21ECL55 CIE Marks 50
Teaching Hours/Week (0:0:2:0) SEE Marks 50
(L: T: P: S)
Credits 1 Exam Hours 03

Course objectives:
This laboratory course enables students to
 Design and demonstrate communication circuits for different digital modulation techniques.
 To simulate Source coding Algorithms using C/C++/ MATLAB code.
 To simulate Error correcting and detecting codes using C/C++/ MATLAB code.
 Simulate the networking concepts and protocols using C/C++/ Network simulation tool.
 Understand entropies and mutual information of different communication channels.
Sl. No. Experiments
Implement the following using discrete components
1 FSK generation and detection
2 PSK generation and detection
3 DPSK Transmitter and receiver
4 QPSK Transmitter and receiver
Implement the following in C/C++/MATLAB/Scilab/Python or any other Suitable software
5 Write a program to encode binary data using Huffman code and decode it.
6 Write a program to encode binary data using a (7,4) Hamming code and decode it.
Write a program to encode binary data using a ((3,1,2)/suitably designed)
7
Convolution code and decode it.
For a given data, use CRC-CCITT polynomial to obtain the CRC code. Verify the
8
program for the cases a) Without error b) With error
Implement the following algorithms in C/C++/MATLAB/Network simulator
9 Write a program for congestion control using leaky bucket algorithm.
Write a program for distance vector algorithm to find suitable path for
10
transmission.
11 Write a program for flow control using sliding window protocols.
Configure a simple network (Bus/star) topology using simulation software OR
12
Configure a simple network (Ring/Mesh) topology using simulation software.
Demonstration Experiments (For CIE)
13 Configure and simulate simple Wireless Local Area network.
Simulate the BER performance of (2, 1, 3) binary convolutional code with
generator sequences g(1) =(1 0 1 1) and g(2) =(1 1 1 1) on AWGN channel. Use
14 QPSK modulation scheme. Channel decoding is to be performed through Viterbi
decoding. Plot the bit error rate versus SNR (dB), i.e. Pe,b versus Eb/N0. Consider
binary input vector of size 3 lakh bits. Also find the coding gain.
Simulate the BER performance of (7, 4) Hamming code on AWGN channel. Use
QPSK modulation scheme. Channel decoding is to be performed through
maximum-likelihood decoding. Plot the bit error rate versus SNR (dB), i.e. Pe,b
15 versus Eb/N0. Consider binary input vector of size 5 lakh bits. Use the following
parity check matrix for the (7, 4) Hamming code. Also find the coding gain.

[ ]

Simulate the BER performance of rate 1/3 Turbo code. Turbo encoder uses two

recursive systematic encoders with ( ) [ ], and pseudo-random

interleaver. Use QPSK modulation scheme. Channel decoding is to be performed


16
through maximum a-posteriori (MAP) decoding algorithm. Plot the bit error rate
versus SNR (dB), i.e. Pe,b versus Eb/N0. Consider binary input vector of size of
around 3 lakh bits and the block length as 10384 bits. Also find the coding gain.

Course outcomes (Course Skill Set):


On the completion of this laboratory course, the students will be able to:
1. Design and test the digital modulation circuits and display the waveforms.
2. To Implement the source coding algorithm using C/C++/ MATLAB code.
3. To Implement the Error Control coding algorithms using C/C++/ MATLAB code.
4. Illustrate the operations of networking concepts and protocols using C programming and
network simulators.
Assessment Details (both CIE and SEE)
The weightage of Continuous Internal Evaluation (CIE) is 50% and for Semester End Exam
(SEE) is 50%. The minimum passing mark for the CIE is 40% of the maximum marks (20
marks). A student shall be deemed to have satisfied the academic requirements and earned
the credits allotted to each course. The student has to secure not less than 35% (18 Marks out
of 50) in the semester-end examination (SEE).

Continuous Internal Evaluation (CIE):


CIE marks for the practical course is 50 Marks.
The split-up of CIE marks for record/ journal and test are in the ratio 60:40.
 Each experiment to be evaluated for conduction with observation sheet and record
write-up. Rubrics for the evaluation of the journal/write-up for hardware/software
experiments designed by the faculty who is handling the laboratory session and is
made known to students at the beginning of the practical session.
 Record should contain all the specified experiments in the syllabus and each
experiment write-up will be evaluated for 10 marks.
 Total marks scored by the students are scaled downed to 30 marks (60% of maximum
marks).
 Weightage to be given for neatness and submission of record/write-up on time.
 Department shall conduct 02 tests for 100 marks, the first test shall be conducted after
the 8th week of the semester and the second test shall be conducted after the 14th
week of the semester.
 In each test, test write-up, conduction of experiment, acceptable result, and procedural
knowledge will carry a weightage of 60% and the rest 40% for viva-voce.
 The suitable rubrics can be designed to evaluate each student‟s performance and
learning ability. Rubrics suggested in Annexure-II of Regulation book
 The average of 02 tests is scaled down to 20 marks (40% of the maximum marks).
The Sum of scaled-down marks scored in the report write-up/journal and average marks of
two tests is the total CIE marks scored by the student.

Semester End Evaluation (SEE):


SEE marks for the practical course is 50 Marks.
SEE shall be conducted jointly by the two examiners of the same institute, examiners are
appointed by the University
 All laboratory experiments are to be included for practical examination.
 (Rubrics) Breakup of marks and the instructions printed on the cover page of the
answer script to be strictly adhered to by the examiners. OR based on the course
requirement evaluation rubrics shall be decided jointly by examiners.
 Students can pick one question (experiment) from the questions lot prepared by the
internal /external examiners jointly.
 Evaluation of test write-up/ conduction procedure and result/viva will be conducted
jointly by examiners.
 General rubrics suggested for SEE are mentioned here, writeup-20%, Conduction
procedure and result in -60%, Viva-voce 20% of maximum marks. SEE for practical
shall be evaluated for 100 marks and scored marks shall be scaled down to 50 marks
(however, based on course type, rubrics shall be decided by the examiners).
Change of experiment is allowed only once and 15% Marks allotted to the procedure part to
be made zero.
The duration of SEE is 03 hours.
Rubrics suggested in Annexure-II of Regulation book

Suggested Learning Resources:


1. Simon Haykin, “Digital Communication Systems”, John Wiley & sons, First Edition,
2014, ISBN 978-0-471-64735-5.
2. K Sam Shanmugam, “Digital and analog communication systems”, John Wiley India
Pvt. Ltd, 1996.
3. Forouzan, “Data Communications and Networking”, 5th Edition, McGraw Hill, 2013,
ISBN: 1-25-906475-3.
5. Write a program to encode binary data using Huffman code and decode it.
Example 5.1
An information source produces a sequence of independent symbols having following
probabilities:
A B C D E F G
1/3 1/27 1/3 1/9 1/9 1/27 1/27
Construct binary code using Huffman encoding procedure and find its efficiency.
Solution: Step 1: To find the value of „n‟

Step 2: As „n‟ is an integer, there is no need of adding any dummy symbols.


Step 3 - 7: Encoding procedure using Huffman coding
Sym Prob Stage
1 2 3 4 5
A 1/3 1 1 1 1 1 0 1
1/3 1/3 1/3 1/3 2/3
C 1/3 00 00 00 00 00 1
1/3 1/3 1/3 1/3 1/3
D 1/9 011 011 011 010 01
1/9 1/9 2/9 1/3
E 1/9 0100 0100 0100 011
1/9 1/9 1/9
B 1/27 01011 01010 0101
2/27 1/9
F 1/27 010100 01011
1/27
G 1/27 010101

The final code-word of the symbol using Huffman coding is


Symbol Prob ( ) Code-word Length ( )
A 1/3 1 1
C 1/3 00 2
D 1/9 011 3
E 1/9 0100 4
B 1/27 01011 5
F 1/27 010100 6
G 1/27 010101 6
Average length

̅ ∑

Entropy
( ) ∑

Efficiency
( )
̅

Redundancy

Example 5.2
Consider a discrete memoryless source with S = (X, Y, Z) with the state probabilities
P = (0.7, 0.15, 0.15) for its output.
a) Apply Huffman encoding algorithm to find the code-words in binary. Find the source
efficiency and redundancy.
Solution: a) Step 1:

Step 2:‟n‟ is an integer. Hence, no need to add dummy symbols.


Step 3 - 7:
Sym Prob Stage
1
X 0.7 0 0
0.7 1
Y 0.15 10 1
0.3
Z 0.15 11

The final code-word using Huffman algorithm is


Symbol Prob ( ) Code-word Length ( )

X 0.7 0 1
Y 0.15 10 2
Z 0.15 11 2

Average length

̅ ∑

Entropy
( ) ∑

Efficiency
( )
̅
Redundancy
Program:
clc;
x = input('Enter symbols:'); %give 5
N = 1:x;
disp(N);
p = input('Enter probabilities:'); %give [0.1 0.1 0.2 0.2 0.4]
s = sort(p,'descend'); % Sort the probabilities in descending order
disp('sorted order');
disp(s);
dictionary = huffmandict(N,s);
avg=0;
for j=1:x
avg=avg+(p(j)*length(dictionary{j}));
end
disp('Average length of the code :');
disp(avg);
H = 0;
for i = 1:x
H = H+(p(i)*log2(1/p(i)));
end
disp('Entropy is');
disp(H);
disp('bits/msg');
Eff = (H/avg)*100;
disp('Efficiency is:');
disp(Eff);
codeword = huffmanenco(N, dictionary);
disp('The codewords are:');
disp(codeword);
decode = huffmandeco(codeword, dictionary);
disp('The decoded symbols are:');
disp(decode);
Output:
Enter symbols:3
1 2 3
Enter probabilities:[0.5 0.3 0.2]
sorted order
0.5000 0.3000 0.2000
Average length of the code :
1.5000
Entropy is
1.4855
bits/msg
Efficiency is:
99.032
The codewords are:
1 0 0 0 1
The decoded symbols are:
1 2 3

Enter symbols:7
1 2 3 4 5 6 7
Enter probabilities:[0.25 0.25 0.125 0.125 0.125 0.0625 0.0625]
sorted order
Columns 1 through 5:
0.250000 0.250000 0.125000 0.125000 0.125000
Columns 6 and 7:
0.062500 0.062500
Average length of the code :
2.6250
Entropy is
2.6250
bits/msg
Efficiency is:
100
The codewords are:
Columns 1 through 16:
0 0 0 1 1 0 0 1 0 1 1 1 1 1 1 0
Columns 17 through 21:
0 1 1 0 1
The decoded symbols are:
1 2 3 4 5 6 7
6. Write a program to encode binary data using a (7,4) Hamming code and decode it.

Example 6.1
Design ( ) Hamming code with minimum distance of and a message length of 4
bits.
Solution: Given , code length
If the inequality in above equation will be satisfied.
The code will be ( ) ( )
is given by,

[ ] [ ] [ ]

The parity matrix will be of dimension. The requirements for choosing matrix
are,
1) should not contain rows of 0‟s
2) No two rows of must be same. i.e. all seven rows of the must be distinct.
There are totally combinations of 3 bits numbers. Out of 8
combinations, 000 can not be used and identity matrix elements 100, 010, and 001 can not
be used. Therefore only 4 combinations left for matrix.
Any combination of 4 elements can be used. If we need to select less number of elements, we
can use only select the required elements. Omitting rest of the elements.

[ ]

[ ]

Parity check matrix is called as “Hamming Matrix” given by

[ | ]

It can be observed that no two rows of H add up to zero. But 3 columns(1,4,5th ) add up to
zero. .
| [ | ]

[ | ]

( )( )( )
Message Vector [D] Code Vector [C] [D] [C]
0000 0000 000 1000 1000 011
0001 0001 111 1001 1001 100
0010 0010 110 1010 1010 101
0011 0011 001 1011 1011 010
0100 0100 101 1100 1100 110
0101 0101 010 1101 1101 001
0110 0110 011 1110 1110 000
0111 0111 100 1111 1111 111

Error detection:

, t=1
Let the receiver vector with single error be given by,

which is present in the 3rd row of .


Hence error vector is

Which is a valid code-vector corresponding to message vector 1101.


Program:
clc;
n = 7%No. of codeword bits per block
k = 4%No. of message bits per block
P = [ 0 1 1;1 0 1;1 1 0;1 1 1 ]%Parity submatrix-Need binary(decimal combination of 3,5,6,7)
G = [ eye(k) P ]%Generator matrix
H = [ P' eye(n-k) ]%Parity-check matrix
% ENCODER%
msg = [ 1 0 0 1 ] %Message block vector-change to any 4 bit sequence
code = mod(msg*G,2)%Encode message
% CHANNEL ERROR(add one error to code)%
%code(1)= ~code(1);
%code(2)= ~code(2);
%code(3)= ~code(3);
%code(4)= ~code(4);%Pick one,comment out others
%code(5)= ~code(5);
%code(6)= ~code(6);
code(7)= ~code(7);
recd = code %Received codeword with error
% DECODER%
syndrome = mod(recd * H',2)
%Find position of the error in codeword (index)
find = 0;
for ii = 1:n
if ~find
errvect = zeros(1,n);
errvect(ii) = 1;
search = mod(errvect * H',2);
if search == syndrome
find = 1;
index = ii;
end
end
end
disp(['Position of error in codeword=',num2str(index)]);
correctedcode = recd;
correctedcode(index) = mod(recd(index)+1,2);%Corrected codeword
%Strip off parity bits
msg_decoded=correctedcode;
msg_vector=msg_decoded(1:4);

Output: 7th Bit Error


n=7
k=4
P=
0 1 1
1 0 1
1 1 0
1 1 1
G=
1 0 0 0 0 1 1
0 1 0 0 1 0 1
0 0 1 0 1 1 0
0 0 0 1 1 1 1
H=
0 1 1 1 1 0 0
1 0 1 1 0 1 0
1 1 0 1 0 0 1
msg =
1 0 0 1
code =
1 0 0 1 1 0 0
recd =
1 0 0 1 1 0 1
syndrome =
0 0 1
Position of error in codeword=7

Output: 4th Bit Error


n=7
k=4
P=
0 1 1
1 0 1
1 1 0
1 1 1
G=
1 0 0 0 0 1 1
0 1 0 0 1 0 1
0 0 1 0 1 1 0
0 0 0 1 1 1 1
H=
0 1 1 1 1 0 0
1 0 1 1 0 1 0
1 1 0 1 0 0 1
msg =
1 0 0 1
code =
1 0 0 1 1 0 0
recd =
1 0 0 0 1 0 0
syndrome =
1 1 1
Position of error in codeword=4
7. Write a program to encode binary data using a ((3,1,2)/suitably designed)
Convolution code and decode it.
Example 7.1:
( ) ( ) ( )
Consider (3, 1, 2) convolutional code with ( ) ( ) ( )
a) Draw the encoder block diagram.
b) Find the Generator Matrix.
c) Find the code-word corresponding to the information sequence (11101) using the time
domain and transform domain approach.
Solution:
a) Encoder has 3 modulo-2 adders and 2 Flip=Flops.

Top Adder

Middle Adder ( )

Input
𝐷 ( ) FF FF ( )
C
( )

Bottom Adder

Figure 7.1 (3, 1, 2) Convolution Encoder


b) In general for 3 modulo-2 adder convolutional encoder, the generator matrix G is given
by

( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )

( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )

( ) ( ) ( )
[ ]
[G] matrix has L rows and ( ) columns. In the given encoder L
( ) ( ) ( )

[ ]
c) The output of the encoder is given by
[ ]

Using transform domain approach,


For ( )
( ) ( ) ( )
For ( )
( ) ( )
( ) ( )
( ) ( )
( ) ( )
The output polynomial for three adders is given by
( ) ( )
( ) ( ) ( )
For ( )
( ) ( )
( ) ( ) ( ) ( )( )
( ) ( )
( ) ( ) ( ) ( )( )
( ) ( )
( ) ( ) ( ) ( )( )
The output of the encoder is given by
( ) ( ) ( )
( ) ( ) ( ) ( )
( )
( )
Program:
clc;
data=[1 1 1 0 1]
g1=[1 1 0];
g2=[1 0 1];
g3=[1 1 1];
disp(['The first generator vector g(1) is ',num2str(g1)]);
disp(['The second generator vector g(2) is ',num2str(g2)]);
disp(['The third generator vector g(3) is ',num2str(g3)]);
code1=mod(conv(data,g1),2);
disp(['The code due to g(1) is ',num2str(code1)]);
code2=mod(conv(data,g2),2);
disp(['The code due to g(2) is ',num2str(code2)]);
code3=mod(conv(data,g3),2);
disp(['The code due to g(3) is ',num2str(code3)]);

for p=1:length(code1)
if code1(p)==0 && code2(p)==0 && code3(p)==0
final_code(4*p-3)='0';
final_code(4*p-2)='0';
final_code(4*p-1)='0';
final_code(4*p) =' ';
else if code1(p)==0 && code2(p)==0 && code3(p)==1
final_code(4*p-3)='0';
final_code(4*p-2)='0';
final_code(4*p-1)='1';
final_code(4*p) =' ';
else if code1(p)==0 && code2(p)==1 && code3(p)==0
final_code(4*p-3)='0';
final_code(4*p-2)='1';
final_code(4*p-1)='0';
final_code(4*p) =' ';
else if code1(p)==0 && code2(p)==1 && code3(p)==1
final_code(4*p-3)='0';
final_code(4*p-2)='1';
final_code(4*p-1)='1';
final_code(4*p) =' ';
else if code1(p)==1 && code2(p)==0 && code3(p)==0
final_code(4*p-3)='1';
final_code(4*p-2)='0';
final_code(4*p-1)='0';
final_code(4*p) =' ';
else if code1(p)==1 && code2(p)==0 && code3(p)==1
final_code(4*p-3)='1';
final_code(4*p-2)='0';
final_code(4*p-1)='1';
final_code(4*p) =' ';
else if code1(p)==1 && code2(p)==1 && code3(p)==0
final_code(4*p-3)='1';
final_code(4*p-2)='1';
final_code(4*p-1)='0';
final_code(4*p) =' ';
else if code1(p)==1 && code2(p)==1 && code3(p)==1
final_code(4*p-3)='1';
final_code(4*p-2)='1';
final_code(4*p-1)='1';
final_code(4*p) =' ';
end
end
end
end
end
end
end
end
end
disp(['The code vector is ',num2str(final_code)]);

Output:
data =
1 1 1 0 1
The first generator vector g(1) is 1 1 0
The second generator vector g(2) is 1 0 1
The third generator vector g(3) is 1 1 1
The code due to g(1) is 1 0 0 1 1 1 0
The code due to g(2) is 1 1 0 1 0 0 1
The code due to g(3) is 1 0 1 0 0 1 1
The code vector is 111 010 001 110 100 101 011
8. For a given data, use CRC-CCITT polynomial to obtain the CRC code. Verify the
program for the cases a) Without error b) With error

Example 8.1
For a (7, 4) single-error correcting cyclic code, ( ) and
( )( ). Using generator polynomial ( )
, find all 16 code-vectors of the cyclic code both in non-systematic and systematic
form.
In systematic form the first 3 bits are check bits and the last 4 bits are message bits. The
check bits are obtained from the remainder polynomial ( ) given by
( )
( ) ( )
( )
( )
( )

( )

For example, ( )

( )

R D

In a similar way, the systematic code-vector can be found by


Message Code-vector Message Code-vector
0000 0000000 1000 1101000
0001 1010001 1001 0111001
0010 1110010 1010 0011010
0011 0100011 1011 1001011
0100 0110100 1100 1011100
0101 1100101 1101 0001101
0110 1000110 1110 0101110
0111 0010111 1111 1111111

Program:
clc;
receivedcode=[0 1 0 1 1 1 0]
polynomial=[1 1 0 1]

[q r]=deconv(receivedcode,polynomial);
r=abs(r);
for i=1:length(r)
a=r(i);
if(mod(a,2)==0);
r(i)=0;
else
r(i)=1;
end
end

for j=1:length(r)
if(r(j)==0)
z=1;
else
z=0;
break;
end
end
if(z==1)
fprintf('Received vector is error free');
fprintf('\n');
else
fprintf('Received vector is erroneous');
fprintf('\n');
disp('The correct code word is');
frame=bitxor(receivedcode,r);
disp(frame);
fprintf('\n');
end

Output: Without Error


receivedcode =
0 1 0 1 1 1 0
polynomial =
1 1 0 1
Received vector is error free

Output: With Error


receivedcode =
0 1 0 1 1 1 1
polynomial =
1 1 0 1
Received vector is erroneous
The correct code word is
0 1 0 1 1 1 0

You might also like