implementing a data communication system using error detection codes with small overhead and simple design.

3 次查看(过去 30 天)
Consider data communication system where sender (source) tries to send data protected with error detection codes to the destination (receiver) by using gray picture size (256x256). The requirements as below:
-small overhead (i.e. the added number of redundancy bits should be smaller than the number of bits for data word)
-low complexity or simple design
Show the output results in term of snapshot of sample signals, calculation bit error rate (obtain by comparing output bits against input bits)

回答(1 个)

Ayush Modi
Ayush Modi 2024-1-13
Hi,
I understand you would like to create a simple system where sender sends the data to the receiver, protecting it with error detection codes. Here is an example to demonstrate how you can achieve this:
SENDER:
% Convert the image to a binary stream
% Calculate parity bits for each 8-bit word
numWords = length(imageBinary) / 8;
parityBits = zeros(numWords, 1);
for i = 1:numWords
dataWord = imageBinary((i-1)*8 + (1:8));
parityBits(i) = mod(sum(dataWord), 2); % Even parity bit
end
% Append parity bits to the data stream (for simplicity, we append at the end)
transmittedData = [imageBinary; parityBits];
receivedData = transmittedData;
errorIndices = randperm(length(imageBinary), 10); % Introduce 10 random errors in the data part
receivedData(errorIndices) = ~receivedData(errorIndices);
RECEIVER:
% Separate the data and parity bits from receivedData for error checking
receivedDataBits = receivedData(1:length(imageBinary));
receivedParityBits = receivedData(length(imageBinary) + 1:end);
% Check for errors using parity bits
receivedParityBits = receivedData(end-numWords+1:end);
receivedData = receivedData(1:end-numWords);
numErrorsDetected = 0;
for i = 1:numWords
dataWord = receivedData((i-1)*8 + (1:8));
if mod(sum(dataWord), 2) ~= receivedParityBits(i)
numErrorsDetected = numErrorsDetected + 1;
end
end
numBitErrors = sum(imageBinary ~= receivedDataBits);
totalBits = length(imageBinary);
BER = numBitErrors / totalBits;
I hope this helps!

类别

Help CenterFile Exchange 中查找有关 Communications Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by