0% found this document useful (0 votes)
30 views4 pages

Data Communication Lab Reports-02

Uploaded by

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

Data Communication Lab Reports-02

Uploaded by

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

Green University of Bangladesh

Department of Computer Science and Engineering (CSE)


Faculty of Sciences and Engineering
Semester: (Spring, Year:2024), B.Sc. in CSE (EVE)

LAB REPORT NO # 02
Course Title: Data Communication Lab
Course Code: CSE 308 Section: 221_E1

Lab Experiment Name: Implement of Hamming code correction approach.

Student Details

Name ID
1. Motiur Rahman 192915002

Lab Date : 03 April 2024


Submission Date : 29 April 2024
Course Teacher’s Name : Md.Romzan Alom

[For Teachers use only: Don’t Write Anything inside this box]

Lab Report Status


Marks: ………………………………… Signature:.....................
Comments:.............................................. Date:..............................
l. TITLE OF LAB REPORT EXPERIMENT
Implement of Hamming code correction approach.

2. OBJECTIVES/AIM

Character Stuffing and Destuffing


To attain knowledge on the Hamming code and how it works.
To implement Hamming code error detection.

3. INTRODUCTION

• This C program demonstrates the Hamming code correction approach for 7-bit codewords, addressing
single-bit errors in data transmission. The hamming correct function computes syndrome bits from the
received codeword, identifies errors, and corrects them. Through user input, the main function prompts
for the received codeword, then utilizes hamming correct to rectify any detected errors. This
implementation showcases the practical application of Hamming codes in maintaining data integrity,
particularly in communication systems susceptible to transmission errors.

4. PROCEDURE

• Include Libraries: Import <stdio.h> for I/O operations.


• Define Correction Function: Implement hamming correct to identify and correct errors in a 7-bit
codeword.
• Calculate Syndrome Bits: Determine error status using syndrome bits.
• Identify Error Position: Convert syndrome bits to decimal to find the error position.
• Correct Error: If detected, flip the erroneous bit and display the corrected codeword.
• Main Function: Prompt user for the received codeword.
• Input Codeword: Read each bit into the array.
• Call Correction Function: Pass the codeword for error correction.
• Return: Terminate program execution.
• .
5. IMPLEMENTATION
#include <stdio.h>
int* hamming_correct(int codeword[7])
{ int syndrome[3];
syndrome[0] = (codeword[0] + codeword[2] + codeword[4] + codeword[6]) % 2;
syndrome[1] = (codeword[1] + codeword[2] + codeword[5] + codeword[6]) % 2;
syndrome[2] = (codeword[3] + codeword[4] + codeword[5] + codeword[6]) % 2;
int error_position = syndrome[0] + syndrome[1]*2 + syndrome[2]*4;
if (error_position > 0) {
printf("Error detected at position %d\n", error_position);
codeword[error_position - 1] ^= 1;
printf("Corrected codeword: ");
for (int i = 0; i < 7; i++)
printf("%d", codeword[i]);
printf("\n");
} else {
printf("No error detected.\n");
}
return codeword;
}
int main() {
int received_codeword[7];
printf("Enter the received 7-bit codeword:\n");
for (int i = 0; i < 7; i++) {
scanf("%d", &received_codeword[i]);
}
int *corrected_codeword = hamming_correct(received_codeword);
return 0;
}
6. TEST RESULT / OUTPUT

Character Stuffing and Destuffing:

Output:

7. ANALYSIS AND DISCUSSION

The additional lab exercise on Hamming code significantly bolstered my comprehension.


Through hands-on implementation in C, I grasped the intricate details of error detection and
correction. By scrutinizing the calculation of syndrome bits and error positions, I gained a
deeper understanding of how the algorithm identifies and rectifies errors. This practical
experience instilled confidence in my ability to apply Hamming code concepts effectively,
fulfilling my objective of understanding this error-correction technique comprehensively.

8. SUMMARY:
The hands-on implementation of Hamming code in C through a lab exercise greatly
enhanced my understanding of error detection and correction. Delving into the calculation
of syndrome bits and error positions provided insight into the algorithm's workings. This
practical experience instilled confidence in applying Hamming code effectively. Overall, it
deepened my comprehension of this error-correction technique, fulfilling my objective of
understanding it comprehensively.

You might also like