CN Documentation
CN Documentation
(22261A0549)
and
Irshad Ahmad Kumar
(23265A0502)
(Assistant Professor)
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.
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.
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.
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.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
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
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"));
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
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
3. Stack Overflow. (n.d.). What is Cyclic Redundancy Check (CRC)?. Retrieved from
https://stackoverflow.com/questions/2357356/what-is-cyclic-redundancy-check-
crc
16