0% found this document useful (0 votes)
14 views17 pages

CN Documentation

Cn lab manual

Uploaded by

Arshad
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)
14 views17 pages

CN Documentation

Cn lab manual

Uploaded by

Arshad
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/ 17

Cyclic Redundancy Check

Computer Network Project


Submitted
in partial fulfillment of the requirements for the completion of
Bachelor of Technology V Semester
in
Computer Science and Engineering
by
Syed Arshad Ali

(22261A0549)

and
Irshad Ahmad Kumar
(23265A0502)

Under the guidance of

Dr. B Madhava Rao

(Assistant Professor)

Department of Computer Science and Engineering

MAHATMA GANDHI INSTITUTE OF TECHNOLOGY(A)


GANDIPET, HYDERABAD-500075, TELANGANA
(INDIA) 2023-2024
MAHATMA GANDHI INSTITUTE OF TECHNOLOGY(A)
Gandipet, Hyderabad-500075, Telangana (India)

CERTIFICATE

This is to certify that the Project entitled “Cyclic Redundancy Check” is being
submitted by Syed Arshad Ali bearing roll no.22261A0549 and Irshad Ahmad
Kumar bearing roll no.23265A0502 in partial fulfillment for completion of
Bachelor of Technology V Semester in Computer Science and Engineering to
Mahatma Gandhi Institute of Technology is a record of bonafide work carried out
under the guidance and supervision. The results embodied in this project have not been
submitted to any other University or Institute for the award of any degree or diploma.
The report is based on the work done entirely by us and not copied from any other
source.

Project Guide Head of the Department

Dr. B Madhava Rao Dr. C. R. K. Reddy


Asst. Professor,Dept of CSE Professor & Head

1
2
DECLARATION

This is to certify that the work reported in this Project titled “Cyclic Redundancy
Check” is a record of work done by us in the Department of Computer Science and
Engineering, Mahatma Gandhi Institute and Technology, Hyderabad. No part of the
work is copied from books/journals/internet and wherever the portion is taken, the
same has been duly referred to in the text. The report is based on the work done
entirely by us and not copied from any other source.

SYED ARSHAD ALI


(22261A0549)

IRSHAD AHMAD KUMAR


(23265A0502)

3
ACKNOWLEGEMENT
The satisfaction that accompanies the successful completion of any task would be incomplete without the
mention of people who made it possible because success is the abstract of hard work and perseverance, but
steadfast of all is encouraging guidance. So, I acknowledge all those whose guidance and encouragement
served as a beacon light and crowned my efforts with success.

We would like to express my sincere thanks to Prof. G. Chandra Mohan Reddy, Principal, MGIT, for
providing the working facilities in the college.

We wish to express my sincere thanks and gratitude to Dr. C. R. K. Reddy, Professor and HOD,
Department of CSE, MGIT for all the timely support and valuable suggestions during the period of project.

We are extremely thankful to Dr. B Madhava Rao Assistant Professor, Department of CSE, MGIT,
Project Coordinator for their encouragement and support throughout the project.

Finally, we would also like to thank all the faculty and staff of the CSE Department who helped us directly
or indirectly to complete this project.

SYED ARSHAD ALI


(22261A0549)

IRSHAD AHMAD KUMAR


(23265A0502)

4
ABSTRACT
The Cyclic Redundancy Check (CRC) is a robust error-detection technique widely used in
data communication and storage to ensure data integrity. This project explores the
implementation and optimization of CRC algorithms, analyzing their ability to detect single-
bit and burst errors across diverse applications, including networking protocols and
embedded systems. By leveraging software simulations and hardware platforms, the project
demonstrates the efficiency of various CRC variants (e.g., CRC-8, CRC-16, CRC-32) and
highlights techniques like table-based computation to improve performance. While
emphasizing CRC's reliability and low computational overhead, the study also discusses its
limitations, such as the inability to correct errors, and proposes potential enhancements for
future applications in fields like telecommunications and data storage.

5
1. INTRODUCTION
In the digital age, the reliability of data transmission and storage is critical to the
functioning of modern systems. However, errors caused by noise, interference, or
hardware failures can compromise data integrity, leading to significant issues in
communication networks, embedded systems, and storage devices. The Cyclic
Redundancy Check (CRC) is a widely adopted error-detection method that helps ensure
data accuracy by identifying corruption during transmission or storage. CRC's efficiency,
low computational overhead, and ability to detect a wide range of errors make it
indispensable in fields like telecommunications, automotive systems, and digital
communications.

1.1 Problem Statement


Despite its widespread use, CRC is not without challenges. One of the main problems is
that while CRC can detect errors effectively, it lacks the capability to correct them. This
means additional mechanisms must be employed to handle corrupted data, adding
complexity to system design. Moreover, the selection of appropriate CRC algorithms
(e.g., CRC-8, CRC-16, or CRC-32) for specific applications can be non-trivial, requiring
careful consideration of error detection capabilities and computational resources.
Addressing these limitations is essential to further improving the reliability and efficiency
of CRC in diverse use cases.

1.2 Objectives
The primary objectives of this project are to explore the principles and algorithms
underlying CRC, evaluate its effectiveness in detecting errors across various data
transmission environments, and optimize its implementation for better performance.
Additionally, the project aims to identify potential enhancements, such as integrating
CRC with error correction techniques, to address its limitations. By analyzing CRC's
applications and proposing innovative solutions, this study seeks to contribute to the
development of more robust and reliable digital systems.

6
2. EXAMPLE
Data word to be sent – 100100
Key – 1101 [or generator polynomial x^3 + x^2 + 1]

Sender Side:

7
Therefore, the remainder is 001 and hence the encoded
Data sent is 100100001.

Receivers Side:
Code word received at the receiver side 100100001

Therefore, the remainder is all zeros. Hence, the


data received has no error.

8
3. IMPLEMENTATION
C : Code
1. #include<stdio.h>
2. #include<string.h>
3. #define N strlen(gen_poly)
4. char data[28];
5. char check_value[28];
6. char gen_poly[10];
7. int data_length,i,j;
8. void XOR(){
9. for(j = 1;j < N; j++)
10. check_value[j] = (( check_value[j] == gen_poly[j])?'0':'1');
11. }
12. void receiver(){
13. printf("Enter the received data: ");
14. scanf("%s", data);
15. printf("\n-----------------------------\n");
16. printf("Data received: %s", data);
17. crc();
18. for(i=0;(i<N-1) && (check_value[i]!='1');i++);
19. if(i<N-1)
20. printf("\nError detected\n\n");
21. else
22. printf("\nNo error detected\n\n");
23. }
24. void crc(){
25. for(i=0;i<N;i++)
26. check_value[i]=data[i];
27. do{
28. if(check_value[0]=='1')
29. XOR();
30. for(j=0;j<N-1;j++)

9
31. check_value[j]=check_value[j+1];
32. check_value[j]=data[i++];
33. }while(i<=data_length+N-1);
34. }
35. int main()
36. {
37. printf("\nEnter data to be transmitted: ");
38. scanf("%s",data);
39. printf("\n Enter the Generating polynomial: ");
40. scanf("%s",gen_poly);
41. data_length=strlen(data);
42. for(i=data_length;i<data_length+N-1;i++)
43. data[i]='0';
44. printf("\n----------------------------------------");
45. printf("\n Data padded with n-1 zeros : %s",data);
46. printf("\n----------------------------------------");
47. crc();
48. printf("\nCRC or Check value is : %s",check_value);
49. for(i=data_length;i<data_length+N-1;i++)
50. data[i]=check_value[i-data_length];
51. printf("\n----------------------------------------");
52. printf("\n Final data to be sent : %s",data);
53. printf("\n----------------------------------------\n");
54. receiver();
55. return 0;
56. }

Output: 1

Enter data to be transmitted: 100100


Enter the Generating polynomial: 1101
----------------------------------------
Data padded with n-1 zeros : 100100000

10
----------------------------------------
CRC or Check value is : 001
----------------------------------------
Final data to be sent : 100100001
----------------------------------------
Enter the received data: 100100001
-----------------------------
Data received: 100100001
No error detected

Output: 2
Enter data to be transmitted: 1001110
Enter the Generating polynomial: 0110
----------------------------------------
Data padded with n-1 zeros : 1001110000
----------------------------------------
CRC or Check value is : 110
----------------------------------------
Final data to be sent : 1001110110
----------------------------------------
Enter the received data: 1001110110
-----------------------------
Data received: 1001110110
No error detected

Java: Code
import java.util.Arrays;
class Program {
static String Xor(String a, String b)
{
String result = "";
int n = b.length();
for (int i = 1; i < n; i++) {

11
if (a.charAt(i) == b.charAt(i))
result += "0";
else
result += "1";
}
return result;
}
static String Mod2Div(String dividend, String divisor)
{
int pick = divisor.length();
String tmp = dividend.substring(0, pick);
int n = dividend.length();
while (pick < n) {
if (tmp.charAt(0) == '1')
tmp = Xor(divisor, tmp)
+ dividend.charAt(pick);
else
tmp = Xor(new String(new char[pick])
.replace("\0", "0"),
tmp)
+ dividend.charAt(pick);
pick += 1;
}
if (tmp.charAt(0) == '1')
tmp = Xor(divisor, tmp);
else
tmp = Xor(new String(new char[pick])
.replace("\0", "0"),
tmp);

return tmp;
}
static void EncodeData(String data, String key)
{

12
int l_key = key.length();
String appended_data
= (data
+ new String(new char[l_key - 1])
.replace("\0", "0"));

String remainder = Mod2Div(appended_data, key);


String codeword = data + remainder;
System.out.println("Remainder : " + remainder);
System.out.println(
"Encoded Data (Data + Remainder) :" + codeword
+ "\n");
}
static void Receiver(String data, String key)
{
String currxor
= Mod2Div(data.substring(0, key.length()), key);
int curr = key.length();
while (curr != data.length()) {
if (currxor.length() != key.length()) {
currxor += data.charAt(curr++);
}
else {
currxor = Mod2Div(currxor, key);
}
}
if (currxor.length() == key.length()) {
currxor = Mod2Div(currxor, key);
}
if (currxor.contains("1")) {
System.out.println(
"there is some error in data");
}
else {

13
System.out.println("correct message received");
}
}
public static void main(String[] args)
{
String data = "100100";
String key = "1101";
System.out.println("\nSender side...");
EncodeData(data, key);

System.out.println("Receiver side...");
Receiver(data+Mod2Div(data+new String(new char[key.length() - 1])
.replace("\0", "0"),key),key);
}
}

Output
Sender side...
Remainder: 001
Encoded Data (Data + Remainder) :100100001

Receiver side...
correct message received

Implementation Time Complexity Space Complexity


Bitwise (C or Java) O(n⋅m)O(n \cdot O(1)O(1)O(1)
m)O(n⋅m)
Table-based (C or Java) O(n)O(n)O(n) O(2k)O(2^k)O(2k)

14
4. CONCLUSION

In conclusion, the Cyclic Redundancy Check (CRC) is a highly effective and efficient
error-detection technique that plays a crucial role in ensuring data integrity across
various communication and storage systems. Its ability to detect a wide range of
errors, combined with low computational overhead and simplicity of implementation,
makes it ideal for applications in networking, embedded systems, and digital
communications. However, CRC's limitations, such as its inability to correct errors
and vulnerability to certain intentional corruptions, necessitate the use of additional
mechanisms for comprehensive error management. Despite these drawbacks, CRC
remains a cornerstone in error detection, offering a balance of performance,
reliability, and ease of use in modern digital systems.

15
5. REFERENCES

1. TutorialsPoint. (n.d.). Cyclic Redundancy Check (CRC). Retrieved from


https://www.tutorialspoint.com/cyclic-redundancy-check-crc

2. GeeksforGeeks. (2021). CRC – Cyclic Redundancy Check. Retrieved from


https://www.geeksforgeeks.org/crc-cyclic-redundancy-check

3. Stack Overflow. (n.d.). What is Cyclic Redundancy Check (CRC)?. Retrieved from
https://stackoverflow.com/questions/2357356/what-is-cyclic-redundancy-check-
crc

4. IBM. (2020). Cyclic Redundancy Check (CRC) in Data Transmission. Retrieved


from https://www.ibm.com/docs/en/aix/7.2?topic=terms-cyclic-redundancy-
check-crc

5. Wikipedia. (2023). Cyclic Redundancy Check. Retrieved from


https://en.wikipedia.org/wiki/Cyclic_redundancy_check

6. Electronics Tutorials. (n.d.). Cyclic Redundancy Check – CRC. Retrieved from


https://www.electronics-tutorials.ws/io/crc.html

16

You might also like