Commnication Lab Manual 2021 Scheme
Commnication Lab Manual 2021 Scheme
R.T.E. SOCIETY’S
RURAL ENGINEERING COLLEGE,HULKOTI-582 205.
Ph No. 08372-289097, 289253 Fax: 08372-289427
(Approved by A.I.C.T.E, New Delhi /Affiliated to V. T. U. Belagavi)
Prepared By
Mrs Ashwini K, Assistant Professor/ ECE/ REC
Hulkoti.
5.Write a MATLAB program to encode binary data using Huffman code and decode it.
Aim: To write a MATLAB program to encode and decode binary data using Huffman code.
Theory:
Huffman coding is a widely used method for lossless data compression, named after David A.
Huffman who introduced it in 1952. It's a variable-length prefix coding algorithm used to
compress data, where the most frequent symbols are represented using shorter codes and the
least frequent symbols are represented using longer codes.
Encoding the information before transmission is necessary to ensure data security and efficient
delivery of the information. The MATLAB program presented here encodes and decodes the
information and also outputs the values of entropy, efficiency and frequency probabilities of
characters present in the data stream.
Huffman coding & deciding algorithm is used in compressing data with variable-length codes.
The shortest codes are assigned to the most frequent characters and the longest codes are
assigned to infrequent characters.
Procedure:
PROGRAM
%Write a MATLAB based program for encoding and decoding of Huffman code% (variable
length source coding )
clc;clear all; close all;
symbol =[1:5]; % Distinct data symbols appearing in
p = [0.4 0.2 0.2 0.1 0.1]; % Probability of each data
[dict,avglen]=huffmandict(symbol,p)
samplecode = dict{5,2} % Codeword for fifth signal value
dict{1,:}dict{2,:}dict{3,:}dict{4,:}dict{5,:}
hcode = huffmanenco(symbol,dict);
dhsig = huffmandeco(hcode,dict); % Decode the code.
disp('encoded msg:');
disp(hcode);
disp('decoded msg:');
disp(dhsig);
code_length=length(hcode)
sum=0;
for m=1:5
H=sum+(p(m)*log2(1/p(m)));
end
disp('H=');
disp(H);
Efficiency=(H/avglen)*100
Description
The function returns a cell array dict, which is a Huffman dictionary containing symbols and
their corresponding Huffman codewords.
This program defines two functions: huffmanenco is used to encode data using the Huffman
coding technique based on a given Huffman dictionary. Huffman encoding replaces each
symbol with its corresponding Huffman codeword from the dictionary, resulting in a
compressed representation of the data. and huffmandeco is used to decode data that has been
encoded using the Huffman coding technique, based on a given Huffman dictionary. It takes
the encoded data and the Huffman dictionary as input, returning the decoded data.
Output:
Manual verification:
Conclusion: Thus, Huffman coding efficiently represents the input data using variable-length
codes, achieving compression by using shorter codes for more frequent symbols.
6.Write a MATLAB program to encode binary data using a (7,4) Hamming code and
decode it.
Aim: To write a MATLAB program to encode binary data using a (7,4) Hamming code and
decode it.
Theory: The (7,4) Hamming code is an error-correcting code that allows the correction of
single-bit errors and the detection of two-bit errors. It operates on 4 bits of data and adds 3
parity bits to form a 7-bit codeword.
Let's go through the steps to encode and decode a (7,4) Hamming code:
1. Data Preparation: Let's assume we have a 4-bit data sequence (D3, D2, D1, D0).
2. Calculate Parity Bits (P0, P1, P2):
● P0 is the parity bit for bits: D0, D1, D3
● P1 is the parity bit for bits: D0, D2, D3
● P2 is the parity bit for bits: D1, D2, D3
3. Insert Parity Bits: Place the calculated parity bits at their respective positions in the 7-bit
codeword.
4. Form the Codeword: The codeword is now composed of the original 4 bits of data and the 3
parity bits.
Procedure:
Let's consider a 4-bit data: 1011 (D3, D2, D1, D0).
PROGRAM
%Simulation for encoding and decoding of a [7,4] Hamming code. The decoder
%can correct one error as shown and as theory states. The table at the end
%of the file shows the various outputs with different error positions and
%message bits. One error can be placed at any of the 7 bit locations and
%corrections made.
clc;clear all; close all;
n = 7%# of codeword bits per block
k = 4%# of message bits per block
A = [ 1 1 1;1 1 0;1 0 1;0 1 1 ];%Parity submatrix-Need binary(decimal combination of
7,6,5,3)
G = [ eye(k) A ]%Generator matrix
H = [ A' eye(n-k) ]%Parity-check matrix
% ENCODER%
msg = [ 1 1 1 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_decoded=msg_decoded(1:4)
In MATLAB, the eye function is used to create an identity matrix, which is a square matrix
with ones on the main diagonal and zeros elsewhere. Where n is the number of rows (and
columns) in the resulting identity matrix.
Output
n=
k=
G=
1 0 0 0 1 1 1
0 1 0 0 1 1 0
0 0 1 0 1 0 1
0 0 0 1 0 1 1
H=
1 1 1 0 1 0 0
1 1 0 1 0 1 0
1 0 1 1 0 0 1
msg =
1 1 1 1
code =
1 1 1 1 1 1 1
recd =
1 0 1 1 1 1 1
syndrome =
1 1 0
correctedcode =
1 1 1 1 1 1 1
msg_decoded =
1 1 1 1
Manual verification:
Conclusion: Thus a MATLAB program is written to encode and decode binary data using a
(7,4) Hamming code and results have been verified.
Aim: To write a program to encode binary data using a ((3,1,2)/suitably designed) Convolution
code and decode it.
Theory: Creating a complete MATLAB program for encoding and decoding using a specific
convolutional code requires a significant amount of code and understanding of the specific
code parameters (rate, constraint length, generator polynomials, etc.). I'll provide you with a
general outline and steps to create the encoding and decoding processes for a (3,1,2)
convolutional code.
Procedure: let's define the generator polynomials for a (3,1,2) convolutional code:
Generator polynomials:
● g1=[1,0,1]
● g2=[1,1,1]
Encoding:
1. Define the input binary data.
2. Set up the convolutional code parameters (generator polynomials, rate, constraint length,
etc.).
3. Use the convenc function to perform convolutional encoding on the input data.
Decoding:
1. Define the received encoded data (potentially with added noise or errors).
2. Set up the Viterbi decoder parameters (trellis structure, traceback depth, etc.).
3. Use the vitdec function to perform Viterbi decoding on the received encoded data.
% Display results
disp('Original Data:');
disp(input_data);
disp('Encoded Data:');
disp(encoded_data);
disp('Received Data:');
disp
In this example, convenc is used for encoding, and vitdec is used for decoding with a Viterbi
decoder. Make sure to adjust the input data, generator polynomials, and other parameters based
on your specific requirements for the convolutional code.
or
% Simulate channel noise (you can modify this based on your requirements)
noisy_encoded_bits = mod(encoded_bits + randi([0 1], size(encoded_bits)), 2);
% Display results
disp('Input Bits:');
disp(input_bits);
disp('Encoded Bits:');
disp(encoded_bits);
disp('Noisy Encoded Bits:');
disp(noisy_encoded_bits);
disp('Decoded Bits:');
disp(decoded_bits);
Manual verification:
OUTPUT:
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
Aim: To obtain the CRC code for a given data using CRC-CCITT polynomial and to Verify
the program for the cases a) Without error b) With error
Theory: The cyclic redundancy check, or CRC, is a technique for detecting errors in digital
data, but not for making corrections when errors are detected. It is used primarily in data
transmission.
This Cyclic Redundancy Check is the most powerful and easy to implement technique. CRC
is based on binary division. In CRC, a sequence of redundant bits, called cyclic redundancy
check bits, are appended to the end of data unit so that the resulting data unit becomes exactly
divisible by a second, predetermined binary number. At the destination, the incoming data unit
is divided by the same number. If at this step there is no remainder, the data unit is assumed to
be correct and is therefore accepted. A remainder indicates that the data unit has been damaged
in transit and therefore must be rejected. The CCITT CRC-16 polynomial (used in a variety of
applications) is represented by the polynomial x16+x12+x5+1, which corresponds to the hex
value 0x1021. We'll create a MATLAB program to generate the CRC code for a given input
data and then simulate both cases: without error and with error in the received data.
Procedure:
1. Generate CRC for the given data using the CRC-CCITT polynomial.
2. Introduce an error in the data.
3. Recalculate CRC for the erroneous data.
4. Verify if the CRC detects the error.
1111
----------------
0001010111011010 000
The division is completed once the dividend is all zeros. The complete division, including the
above two steps, is
1101100111011010 000
1111
0010100111011010 000
1111
0001010111011010 000
1111
0000101111011010 000
1111
0000010011011010 000
1111
0000001101011010 000
1111
0000000010011010 000
1111
0000000001101010 000
1111
0000000000010010 000
1111
0000000000001100 000
1111
0000000000000011 000
11 11
0000000000000000 110
The remainder bits, 110, are the check value for this message.
PROGRAM
crc=r(length(msg)+1:end)
frame = bitor(mseg,r)
% the remainder bits using a bit-wise OR. Introduce an error into the message
% by flipping one of the bit values with bitset.
remainder = bitshift(message,divisorDegree);
remainder = bitor(remainder,CRC_check_value);
remainder = bitset(remainder,6);
br=dec2bin(remainder)
for k = 1:messageLength
if bitget(remainder,messageLength+divisorDegree)
remainder = bitxor(remainder,divisor);
end
remainder = bitshift(remainder,1);
end
if remainder == 0
disp('Message is error free.')
else
disp('Message contains errors.')
end
OUTPUT:
CRC generation
Input Message sequence :[1 1 1 0 0 0 1 1]
Input Generator Polynomial :[1 1 0 0 1 1]
crc =
1 1 0 1 0
frame =
1 1 1 0 0 0 1 1 1 1 0 1 0
'1111000000000000'
sdd =
'1111000000000000000'
sdr =
'1101100111011010000'
scrc =
'110'
br =
'1101100111011110110'
In this program, bitshift is a MATLAB function that performs bitwise shifting on integer
values. It shifts the bits of an integer to the left or right by a specified number of positions.
dec2bin is a MATLAB function used to convert decimal (base-10) numbers to binary (base-2)
representation.
Manual verification:
Conclusion: The CRC code is obtained for a given data using CRC-CCITT polynomial and
the program is verified for the cases a) Without error b) With error.
The main concept of the leaky bucket algorithm is that the output data flow remains constant
despite the variant input traffic, such as the water flow in a bucket with a small hole at the
bottom. In case the bucket contains water (or packets) then the output flow follows a constant
rate, while if the bucket is full any additional load will be lost because of spillover. In a
similar way if the bucket is empty the output will be zero.
Each host is connected to the network by an interface containing a leaky bucket that is a finite
internal queue where all the incoming packets are stored in case there is space in the queue,
otherwise the packets are discarded. This arrangement can be built into the hardware interface
or simulated by the host operating system. The host is allowed to put one packet per clock into
the network. This mechanism turns an uneven flow of packet from the user process inside the
host into an even flow of packets onto the network, smoothing out bursts and greatly reducing
the chances of congestion.
In the following figure we can notice the main rationale of leaky bucket algorithm, for both the
two approaches (e.g. leaky bucket with water (a) and with packets (b)).
While leaky bucket eliminates completely bursty traffic by regulating the incoming data flow
its main drawback is that it drops packets if the bucket is full. Also, it doesn’t take into account
the idle process of the sender which means that if the host doesn’t transmit data for some time
the bucket becomes empty without permitting the transmission of any packet.
Algorithm:
Steps:
program:
leakybucket.c
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
int min(int x, int y)
{
if(x<y)
return x;
else
return y;
}
int main()
{
int drop=0, count=0, inp[25];
int mini, nsec, cap, i, process;
printf("\nSecond|PacketRecieved|PacketSent|PacketLeft|Packet Dropped|\n");
printf("--------------------------------------------------------------\n");
for(i=0;i<nsec;i++)
{
count+=inp[i];
if(count>cap)
{
drop=count-cap;
count=cap;
}
printf("%d",i+1);
printf("\t%d",inp[i]);
mini=min(count,process);
printf("\t\t%d",mini);
count=count-mini;
printf("\t\t%d",count);
printf("\t\t%d\n",drop);
drop=0;
}
for(;count!=0;i++)
{
if(count>cap)
{
drop=count-cap;
count=cap;
}
printf("%d",i+1);
printf("\t0");
mini=min(count, process);
printf("\t\t%d", mini);
count=count-mini;
printf("\t\t%d", count);
printf("\t\t%d\n", drop);
}
}
Output:
Compile and run
Second|PacketRecieved|PacketSent|PacketLeft|Packet Dropped|
---------------------------------------------------------------------------------
1 5 2 3 0
2 4 2 3 2
3 3 2 3 1
4 0 2 1 0
5 0 1 0 0
[root@localhost ]#
In distance vector routing, each router maintains a routing table indexed by, and containing one
entry for, each router in the subnet. This entry contains two parts: the preferred outgoing line
to use for that destination and a distance to that destination. The router is assumed to know the
“distance” to each of its neighbour.
Because each router depends on its neighbors for information, which the neighbors in turn may
have learned from their neighbors, and so on, distance vector routing is sometimes facetiously
referred to as "routing by rumor." The common Characteristics are
Periodic Updates
Periodic updates means that at the end of a certain time period, updates will be transmitted.
Neighbors
The starting assumption for distance-vector routing is that each node knows the cost of the link
to each of its directly connected neighborsIn the context of routers, neighbors always mean
routers sharing a common data link. Distance vector routing information may be, Network
ID, Cost and NextHop. These three essentials need to form a Distance vector’s routing table.
Design
Algorithm
Program: dist_vector.c
// Program for Distance Vector Routing algorithm
#include <stdio.h>
#include <stdlib.h>
#define nul 1000
#define nodes 10
int no=5;
struct node
{
int a[nodes][3];
}
router[nodes];
void init(int r)
{
int i;
{
int i;
printf("\n \t Enter distance to the node %d to other nodes", r);
printf("\n \t Please enter 999 if there is no direct route\n");
for(i=1; i<=no; i++)
{
if(i!=r){
printf("\n Enter distance to the node %d:", i);
scanf("%d", &router[r].a[i][2]);
router[r].a[i][3]=i;
}
}
}
void display(int r)
{
int i;
printf("\n\n The routing table for node %d is as follows", r);
printf("\n\t\tDest\t\tNext Hop\t\tDist");
for(i=1; i<=no; i++)
{
printf("\n\t\t%d\t%d \t\t%d", router[r].a[i][1],router[r].a[i]
[3],router[r].a[i][2]);
}
}
voiddv_algo(int r)
{
inti,j,z;
for(i=1; i<=no; i++)
{
if(router[r].a[i][2]!=999 && router[r].a[i][2]!=0)
{
for(j=1; j<=no; j++)
{
z=router[r].a[i][2]+router[i].a[j][2];
if(router[r].a[j][2]>z)
{
router[r].a[j][2]=z;
router[r].a[j][3]=i;
}
}
}
}
}
void find(int x, int y)
{
if(router[x].a[y][3]!=y)
{
find(x, router[x].a[y][3]);
printf("%d-->",router[x].a[y][3]);
find(router[x].a[y][3],y);
return;
}
}
int main()
{
int i,j,x,y,no;
int choice;
no = 5;
for(i=1; i<=no; i++)
{
init(i);
inp(i);
}
printf("\n The configuration of the nodes after initialization is as follows:");
for(i=1; i<=no; i++)
display(i);
while(1)
{
printf("\n\n Enter 1 to continue, 0 to quit:");
scanf("%d",&choice);
if(choice!=1)
break;
printf("\n Enter the nodes between which shortest path is to be found:");
scanf("%d%d",&x,&y);
printf("\n The shortest path is:");
printf("%d--->",x);
find(x,y);
printf("%d",y);
printf("\n The length of the shortest path is %d",router[x].a[y][2]);
}
return 0;
}
Output:
Compile and run
Aim: C Program for stop and wait protocol and Sliding Window Protocol
Stop and wait is the fundamental technique to provide reliable transfer under unreliable packet
delivery system. After transmitting one packet, the sender waits for an acknowledgment (ACK)
from the receiver before transmitting the next one. In this way, the sender can recognize that
the previous packet is transmitted successfully and we could say "stop-n-wait" guarantees
reliable transfer between nodes. To support this feature, the sender keeps a record of each
packet it sends. Also, to avoid confusion caused by delayed or duplicated ACKs, "stop-n-wait"
send each packet with unique sequence numbers and receive that numbers in each ACK. If the
sender doesn't receive ACK for previous sent packet after a certain period of time, the sender
times out and retransmit that packet again. There are two cases when the sender doesn't receive
ACK; one is when the ACK is lost and the other is when the frame itself is not transmitted. To
support this feature, the sender keeps timer per each packet.
The main disadvantage of this method is that it is inefficient. It makes the transmission process
slow. In this method single frame travels from source to destination and single
acknowledgment travels from destination to source. As a result each frame sent and received
uses the entire time needed to traverse the link. Moreover, if two devices are distance apart, a
lot of time is wasted waiting for ACKs that leads to increase in total transmission time.
ALGORITHM
Step 2: Generate random that gives the total number of frames to be transmitted.
Step 7: If an acknowledgement is not received for a particular frame retransmit that frame alone
again.
Step 8: Repeat the steps 5 to 7 till the number of remaining frames to be sent becomes zero.
program:
stopnwait.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int i,j,noframes;
int x,x1,x2;
}
printf("\n Acknowledgement received for frame %d\n",j);
noframes = noframes-1;
i++;
j++;
}
printf("\n End of stop and wait protocol");
return 0;
}
Output:
Compile and run
[root@localhost ]# gcc stopnwait.c
[root@localhost ]# ./a.exe
No of frames is 6
Sending frame 1
Acknowledgement for frame 1
Sending frame 2
Acknowledgement for frame 2
Sending frame 3
Acknowledgement for frame 3
Sending frame 4
Acknowledgement for frame 4
Sending frame 5
Waiting for 1 second
Sending frame 5
Acknowledgement for frame 5
Sending frame 6
Waiting for 1 second
Sending frame 6
Acknowledgement for frame 6
[root@localhost ]#
Theory:
In computer networks sliding window protocol is a method to transmit data on a network.
Sliding window protocol is applied on the Data Link Layer of OSI model. At data link layer
data is in the form of frames. In Networking, Window simply means a buffer which has data
frames that needs to be transmitted.
Both sender and receiver agree on some window size. If window size=w then after sending w
frames sender waits for the acknowledgement (ack) of the first frame.
As soon as sender receives the acknowledgement of a frame it is replaced by the next frames
to be transmitted by the sender. If receiver sends a collective or cumulative acknowledgement
to sender then it understands that more than one frames are properly received, for eg:- if ack of
frame 3 is received it understands that frame 1 and frame 2 are received properly.
In sliding window protocol the receiver has to have some memory to compensate any loss in
transmission or if the frames are received unordered.
η = (W*tx)/(tx+2tp)
W = Window Size
tx = Transmission time
tp = Propagation delay
Sliding window works in full duplex mode
It is of two types:-
1. Selective Repeat: Sender transmits only that frame which is erroneous or is lost.
2. Go back n: Sender transmits all frames present in the window that occurs after the
error bit including error bit also.
Algorithm:
1. Start the program
2. Read the window size
program:
slidingwindow.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int w,i,f,frames[50];
printf("\nWith sliding window protocol the frames will be sent in the following
manner (assuming no corruption of frames)\n\n");
for(i=1;i<=f;i++)
{
if(i%w==0)
{
printf("%d\n",frames[i]);
printf("Acknowledgement of above frames sent is received by
sender\n\n");
}
else
printf("%d ",frames[i]);
}
if(f%w!=0)
printf("\nAcknowledgement of above frames sent is received by
sender\n");
return 0;
}
Output
Output:
-------------------------------------------------------------------------------------------------------
Case-1: For Window Size < No. of Frames
6 7 8 9 10
Acknowledgement of above frames sent is received by sender
----------------------------------------------------------------------------------------------------------------
-------
Case-2: For Window Size = No. of Frames
EXTRA:
Error Detecting Code Using CRC-CCITT (16-bit)
This Cyclic Redundancy Check is the most powerful and easy to implement technique. CRC
is based on binary division. In CRC, a sequence of redundant bits, called cyclic redundancy
check bits, are appended to the end of data unit so that the resulting data unit becomes exactly
divisible by a second, predetermined binary number. At the destination, the incoming data unit
is divided by the same number. If at this step there is no remainder, the data unit is assumed to
be correct and is therefore accepted. A remainder indicates that the data unit has been damaged
in transit and therefore must be rejected.
● CRC-8:
x8+x2+x+1 Used in: 802.16(along with error correction)
● CRC-CCITT:
x16+x12+x5+1 Used in: HDLC, SDLC, PPP default
Performance:
CRC is a very effective error detection technique. If the divisor is chosen according to the
previously mentioned rules, its performance can be summarized as follows:
Algorithm
program: crc.c
// Program for CRC Algorithm
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
if (mode) {
for ( i = 0; i < strlen(poly); i++)
strcat(op, "0");
}
/* Perform XOR on the msg with the selected polynomial */
for (j = 0; j < strlen(ip); j++) {
if (op[j] == '1') {
for (k = 0; k < strlen(poly); k++) {
if ((op[j + k] == '0') && (poly[k]=='0') || (op[j+k] == '1') && (poly[k] =='1'))
op[j + k] = '0';
else
op[j +k] = '1';
}
}
}
return 1;
return 0;
}
int main()
{
inti,n,flag;
charip[50], op[50], recv[50];
char poly[] = "10001000000100001";
if(flag){
printf ("Invalid input message\n:");
exit (0);
}
crc(ip, op, poly, 1);
printf("The transmitted message is: %s%s\n",ip,op/*+strlen(ip)*/);
printf("Enter the received message in binary\n");
scanf("%s", &recv);
if(!crc(recv, op, poly, 0))
printf("No error in data\n");
else
printf("Error in data transmission has occurred\n");
return 0;
}
Output:
[root@localhost ]
Aim:
To design and study the working of FSK modulation and demodulation with the help of a suitable
circuit.
Theory:
As its name suggests, a frequency shift keyed transmitter has its frequency shifted by the
message. Although there could be more than two frequencies involved in an FSK signal, in this
experiment the message will be a binary bit stream, and so only two frequencies will be
involved. The word „keyed‟ suggests that the message is of the „on-off‟ (mark-space) variety,
such as one (historically) generated by a morse key, or more likely in the present context, a
binary sequence. Conceptually, and in fact, the transmitter could consist of two oscillators (on
frequencies f1 and f2), with only one being connected to the output at any one time. Unless
there are special relationships between the two oscillator frequencies and the bit clock there
will be abrupt phase discontinuities of the output waveform during transitions of the message.
Bandwidth:
Practice is for the tones f1 and f2 to bear special inter-relationships, and to be integer multiples of
the bit rate. This leads to the possibility of continuous phase, which offers advantages, especially
with respect to bandwidth control. FSK signals can be generated at baseband, and transmitted over
telephone lines (for example). In this case, both f1 and f2 (of Figure 2) would be audio frequencies.
Alternatively, this signal could be translated to a higher frequency. Yet again, it may be generated
directly at carrier frequencies.
Design:
⮚ Modulator.
RC=VCC-VCE/(IC)=1kΩ
𝑉𝑖𝑛−𝑉𝑏𝑒
RB= =10KΩ
𝐼𝑏
⮚ Demodulator.
Low pass filter
fc=2KHz, C=0.1µf
1
fc=
2𝜋𝑅𝐶
R=7.9KΩ (Choose 10KΩ)
Envelope Detector.
1 1
≪ 𝑅𝐶 ≪ 𝑓𝑐
𝑓𝑚
fm=200Hz, fC=10KHz.
Hence C=0.1µf, and R=10KΩ
Circuit Diagram:
Procedure:
1. Rig up the modulator circuit as shown in the figure.
2. Apply carrier of amplitude 2 V(P- P) and frequency 1 kHz.
3. Apply carrier of amplitude 2 V(P- P) and frequency 2 kHz.
4. Apply message signal of amplitude 10 V(P - P) and frequency of 250 Hz. .
5. Observe ASK outputs at each collector of transistor, and also observe FSK output at pin
6 of op-amp.
6. Connect demodulator circuit.
7. Observe the demodulated output on CRO.
Waveforms:
Result:
Aim: To design and study the working of PSK modulation and demodulation using suitable
circuit.
Theory:
Phase shift keying is one of the most efficient digital modulation techniques. It is used for very
high bit rates. In PSK, the phase of the carrier is modulated to represent Binary values. In
BPSK, the carrier phase is used to switch The phase between 00 and1800 by digital polar
Format. Hence it is also known as phase reversal keying. The modulated carrier is given by:
Binary 1: S (t) = Ac max. Cos. (2πfct)
Binary 0: S (t) = Ac max. Cos. (2πfct + 180)
= - Ac max. Cos. (2πfct)
Design:
For modulator :
Ib>Ic/β…i.e 4.2/RB>1.8/Rcβ
For demodulator:
3.3ms>RC>1ms
Circuit Diagram:
Modulation:
Demodulation:
Procedure:
Result:
VIVA QUESTIONS
1. Question: What is a convolutional code, and how does it differ from block codes?
Answer: A convolutional code is an error-correcting code where each output bit is generated
based on a linear combination of the current input bit and a fixed number of previous input
bits. Unlike block codes that process a fixed number of bits at a time, convolutional codes
operate on a continuous stream of input bits.
2. Question: Describe the parameters (n, k, r) for a convolutional code (n, k, r).
● n is the number of output bits produced per input bit (constraint length).
● k is the number of input bits used to produce each output bit.
● r is the rate of the code, given by k/n.
3. Question: What is the generator matrix in a convolutional code, and how is it used for
encoding?
Answer: The generator matrix in a convolutional code defines the linear combinations used to
generate the output bits from the input bits. It consists of several rows, each corresponding to
a specific output bit and defined by the connections to the previous input bits. The encoding
process involves matrix multiplication of the generator matrix with the input bit vector to obtain
the encoded output.
Answer: The Viterbi algorithm is a maximum likelihood decoding algorithm used for
convolutional codes. It utilizes a trellis diagram to explore all possible paths through the code.
At each step, the algorithm calculates the metrics (typically Hamming distances) for each path
and selects the most likely path based on these metrics. It performs a traceback through the
trellis to determine the most likely sequence of transmitted bits.
Answer: The trellis diagram visually represents all possible states and transitions for a
convolutional code. Each node in the trellis corresponds to a unique combination of the
encoder's memory contents, and the edges represent valid transitions between these states. The
trellis facilitates the Viterbi decoding algorithm by providing a structured way to compute the
most likely path through the code.
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
1.
2. Convolutional Codes: a. What is a convolutional code? b. Explain the generator
polynomials in convolutional coding. c. How is the rate of a convolutional code determined?
d. Describe the constraint length in convolutional coding.
3. Viterbi Decoding: a. What is Viterbi decoding and what is its purpose in communication
systems? b. Explain the trellis structure used in Viterbi decoding. c. What is traceback depth,
and how does it affect Viterbi decoding performance? d. Discuss the difference between hard
decision and soft decision Viterbi decoding.
4. CRC Calculation: a. What is CRC (Cyclic Redundancy Check), and why is it used in
communication systems? b. Explain the concept of polynomial division in CRC calculation.
c. What are the advantages of using CRC-CCITT for error detection? d. How does the choice
of CRC polynomial affect the error detection capability?
5. MATLAB Programming: a. How can you encode data using a convolutional code in
MATLAB? b. Explain the MATLAB functions convenc and vitdec and their usage in
encoding and decoding, respectively. c. How would you simulate an error in received data in
MATLAB for testing error correction or detection? d. What MATLAB functions are used to
perform CRC calculations, and how do you use them?
6. Error Detection and Correction: a. How does a convolutional code provide error correction
capabilities? b. What is the role of the Viterbi decoder in error correction for convolutional
codes? c. How does CRC help in error detection, and what types of errors can it detect? d.
Explain the trade-offs between error detection and correction in communication systems.