×

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

Hamming Code Example

What is Hamming Code? Hamming code is an error-detecting and error-correcting code used in computer data storage and transmission to detect and correct errors caused by noise, interference, or data corruption....

4 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.

Computer Network Switching

Switching Many numbers of connected devices are called the network. Whenever a company has multiple devices, there has a problem of how to connected them to make the one to one...

5 minutes read.

User Datagram Protocol

User Datagram Protocol: UDP stands for the User Datagram Protocol. UDP was developed by David P Reed in 1980. It is a connection-less and unreliable protocol. In this protocol, when...

2 minutes read.

TCP Ports

What is TCP? TCP is a transport layer protocol that helps to establish connections. TCP means Transmission Control Protocol. It guarantees secure data transmission between two network-connected devices. The data can...

5 minutes read.

Session Layer and Presentation Layer

Session Layer and Presentation Layer Session Layer The fifth layer is the Session layer in the OSI model, which controls connections between many computers. It manages, establishes, and terminates the session connection...

2 minutes read.

Mesh Topology Diagram in Computer Network

Topology in simple terms can be defined asthe arrangement of a computer network, which is further divided into logical and physical arrangements. Logical arrangement refers to how the data flow...

4 minutes read.

Advantages and Disadvantages of MAN

Before we move to advantages and disadvantages of MAN, first we discuss about what is MAN and what are its examples. A network that encircles a city or a sizable university...

3 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.

Method of Joining and Fusion of Fiber Optic Cable

What is Fiber Optics Cable? Fiber optics cable transforms the information at a light pulse. We can transfer voice, data, and video through the fiber optics cable. The fiber optics cable...

3 minutes read.

Address Mapping

Address Mapping: Internet is made of a combination of physical networks connected together by internetworking devices such as routers. A logical address is an internetwork address. A physical address is...

4 minutes read.

Ring Topology in Computer Network

Ring topology is a topology that was invented by IBM in 1984 by the Institute of Electrical and Electronics Engineers. It is defined as a type of network topology where...

4 minutes read.

Data Link Control

Data Link Control Data-link control is the main function of the data link layer. It deals with the configuration and coordination for connection between two neighboring nodes: node-to-node communication. The task...

10 minutes read.

E-mail in Computer Network

E-mail E-mail stands for electronic mail. E-mail is an application layer service in which a user can transfer the messages and information with another user. E-mail is the most popular service...

2 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.

Digital Transmission

Line Coding Digital signal is converted in the digital data that process is known as the Line Coding. That data is stored in the computer in the form of text, audio,...

4 minutes read.

Computer Network Topology: Bus, Star, Ring, Tree and Hybrid

Network Topology: The Computer network topology refers to the layout of connected devices on a network. The network topology is the combination by which computer or network devices interconnected to...

4 minutes read.

Computer Network Architecture

Computer network architecture is a design in which all the computers are organized in a computer network. The architecture defines how computers must communicate with each other to obtain maximum...

4 minutes read.

Two Port Network in Computer Networks

A Two Port Network is a four-terminal electric network or circuit with 2 terminals on both sides, each connecting with more circuits or devices. Two terminals together make a port, one...

5 minutes read.

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.