×

Cyclic Redundancy Check Example

What is Cyclic Redundancy Check?

A cyclic redundancy check (CRC) is a type of error-detecting code commonly used in digital networks and storage devices to detect accidental changes to raw data. Blocks of data entering these systems get a short check value attached, based on the remainder of a polynomial division of their contents. On retrieval, the calculation is repeated, and in the event, if the check values do not match, corrective action can be taken against data corruption.

CRC is a type of hash function that is used to produce a checksum, which is a small number of bits, from a larger block of data, such as a packet of network traffic or a block of a computer file. The checksum is calculated by applying a mathematical algorithm to the data, and it is designed to detect any changes to the data that occur during transmission or storage.

The most common algorithm used in a CRC is a polynomial function, which operates on the binary data as if it was a single large binary number. The data is divided by a fixed polynomial, and the remainder is used as the checksum. When the data is received or read, the same polynomial is used to perform the division again, and the remainder is compared to the original checksum. If the remainder is different, it indicates that the data has been corrupted.

CRCs are widely used in digital communications, such as in Ethernet and other networking protocols, as well as in storage devices like hard drives and flash drives. Because of their simplicity and efficiency, they are also used in many other applications such as in digital audio and video, financial transactions, and industrial control systems.

CRCs are not foolproof and can't guarantee error-free data transfer, but they significantly increase the chances of detecting errors and can be very useful in detecting accidental errors caused by noise on a communication channel or other sources.

Data Integrity in CRC

CRCs are often used to ensure the integrity of data, which means that the data has not been tampered with or corrupted during transmission or storage. By attaching a checksum to the data and then checking the checksum when the data is received or read, a CRC can detect any changes to the data that have occurred during transmission or storage.

However, the data integrity provided by CRCs can be limited in some ways. For example, if an attacker knows the algorithm used to calculate the checksum, they can potentially change the data in such a way that the checksum still matches the original, meaning the integrity check would pass despite the data being tampered. This is known as a "CRC attack" or "CRC collision". To mitigate this issue, a more secure hash function such as SHA-256 is often used in conjunction with the CRC to ensure the integrity of the data.

Another limitation of the CRC is that it can only detect errors, it can't correct them. The receiver must request retransmission of the corrupted data. Additionally, the length of the check value is typically much smaller than the data, which means that it is not guaranteed to detect all errors. The longer the check value, the more errors it can detect, but also the more storage space it will take.

It is also worth noting that a CRC is not a cryptographic hash function, it is a checksum algorithm, meaning that it is not designed to be resistant to tampering, but to detect accidental errors. For cryptographic purposes, it is recommended to use cryptographic hash functions such as SHA-256, SHA-512, etc.

Examples of CRC

There are many examples of the use of cyclic redundancy check (CRC) in different types of systems and protocols. Some common examples are as follows:

  • Ethernet: The most common use of CRC is in Ethernet networks, where the CRC is used to detect errors in packets of data that are transmitted over the network.
  • USB: USB flash drives and other USB storage devices use CRCs to detect errors in the data that is written to and read from the device.
  • File formats: Some file formats, such as PNG and Gzip, use CRCs to detect errors in the data that makes up the file.
  • Disk storage: Hard drives and other types of disk storage use CRCs to detect errors in the data that is written to and read from the disk.
  • Industrial control systems: In many industrial control systems, such as those used in factories and power plants, CRCs are used to detect errors in the data that is sent between different components of the system.
  • Digital audio and video: Some digital audio and video formats use CRCs to detect errors in the data that makes up the audio or video file.
  • Financial transactions: Some financial transaction systems use CRCs to detect errors in the data that is sent between different components of the system.

Algorithm of CRC

The following steps are used in CRC algorithm:

  • The data to be transmitted or stored is divided into a number of fixed-size blocks.
  • A fixed-size check value, or "CRC code," is calculated for each block of data using a polynomial function. This is typically done by performing a bitwise exclusive-or (XOR) operation on the data and a predefined polynomial.
  • The calculated check value is appended to the end of each block of data.
  • The data, including the check value, is transmitted or stored.
  • When the data is received or read, the check value is recalculated using the same polynomial function.
  • The recalculated check value is compared to the original check value. If the two values are the same, the data is considered to be intact and error-free. If the two values are different, it indicates that an error has occurred and corrective action can be taken.

The polynomial function and length of the check value can vary depending on the specific implementation of the CRC algorithm. Some of the most commonly used polynomial functions include the following:

  • CRC-16 (16-bit),
  • CRC-32 (32-bit) and
  • CRC-64 (64-bit)

These polynomials are widely used and standardized, and the choice of polynomial can affect the probability of undetected errors. Additionally, some implementations include additional steps such as bit-reversal or complementing the data before the CRC calculation.


Related Topics

Data link layer in OSI model

This article will help you in getting a good understanding of the topic called the Data link layer in the OSI model. It is the second bottom most layer in the...

3 minutes read.

Unicast Routing Protocol

Unicast Routing Protocol: Unicast is a point to point communication arrangement that only occurs between the sender and receiver. Routing Information Protocol RIP is an open standard protocol that can work with...

3 minutes read.

Decoding in Communication Process

The use of codes is necessary for all forms of communication. The sender, transmitter, and receiver are the three major components of more conventional communication paradigms. The sender is in...

4 minutes read.

TCP vs UDP

Transmission Control Protocol (TCP) and User Datagram Protocol are the two most popular Internet protocols (IPs). TCP is a connection-oriented protocol, which means that once a connection has been made,...

4 minutes read.

Multiple Access Control

Multiple Access Control: The data link layer is separated into two sub-layers. The upper sub-layer is responsible for flow control and error control that is called the logical link control...

5 minutes read.

Network Layer in OSI Model

This article will help you in getting a good understanding of the Network Layer in the OSI model. The network layer is the third layer of the OSI Model from the...

4 minutes read.

Classification of Routing Algorithms

Introduction Before going to the classification of routing algorithms, we must find out what routing is. So, routing can be defined as the process of establishing the paths that the data...

3 minutes read.

Advantages and Disadvantages of Fibre Optics Cable

What is Fibre Optics Cable? A fibre optics cable is made of plastic or fibre, which is used to transmit the data. In fibre optics cable, the data is sent along...

3 minutes read.

Application Layer in OSI Model

This article will help you in getting a better understanding of the Application layer in the OSI model. It is the uppermost layer in the OSI Model. The application layer establishes...

4 minutes read.

Session Layer in OSI Model

This article will help you in getting a better understanding of the Session layer in the OSI model. The session layer is the fifth layer from the bottom in the OSI...

4 minutes read.

Define Framing in Computer Network

Framing is a function of the data link layer, which provides a way for a sender to transmit a set of bits that should be meaningful to the user. The...

7 minutes read.

Fixed and Flooding Routing Algorithms

Introduction Before going to study fixed and flooding routing algorithms, we have to take a look back to revisit the topic of routing. Routing can be defined as Routing: What is it? Routing...

3 minutes read.

Star Topology in Computer Networks

Star topology comes from or is a part of the network topology which was invented by Dr.Howard Frank. It is also to be known as star network because of its...

4 minutes read.

What is Computer Network?

 A computer network is a collection of interconnected devices, such as computers, servers, routers, and switches, that are connected together to share resources and exchange data. These devices use a...

6 minutes read.

Advantages and Disadvantages of LAN

Before we move to advantages and disadvantages of LAN, first we discuss about what is LAN. Local area network is referred to by its abbreviation, LAN. A system that connects PCs...

3 minutes read.

TCP/IP model in Computer Network

An essential foundation for computer networking is the TCP/IP model. It stands for Transmission Control Protocol and Internet Protocol which are the two major Internet protocols. This model outlines the...

6 minutes read.

Data Link Layer Protocols

 Data Link Layer Protocols Bluetooth Low EnergyZ-WaveZigBee Smart EnergyLoRaWANWirelessHARTLTE-A  1. Bluetooth Low Energy Bluetooth Low Energy or Bluetooth is a short-range communication protocol with the physical layer and medium access control layer. It is widely used in IoT...

3 minutes read.

Stream Control Transmission Protocol

Stream Control Transmission Protocol: SCTP stands for Stream Control Transmission Protocol. SCTP was developed by the Internet Engineering Task Force (IETF). It is a reliable message-oriented protocol of the transport...

3 minutes read.

Working of ARP

The majority of computer programmes and applications send and receive messages using logical addresses (IP addresses), but the actual communication takes place over physical addresses (MAC addresses), which is found...

4 minutes read.

Aloha

Aloha Norman Abramson and his colleagues were developed aloha at the University of Hawaii in the 1970s. ALOHA is a Multiple Access Protocol which is used for random access in the...

3 minutes read.