Naive CRC Analysis

CRC – Cyclic Redundancy Check

CRC – Cyclic redundancy check, error detection, and error correction in some cases, it a common functionality used in many areas of computer science, communication protocol such as USB, IP4, TCP, Modbus, and many other protocol and formats and etc. This functionality is extremely important to reduce the number of errors, though they will not guarantee 100 percent in every cases. However, can reduce it significantly.

This is achieved by the CRC being expressed as a polynomial and taking advantage of remainder theory and etc. See the following youtube video for in-depth on how CRC works on a mathematical level.

There is a mathematical approach to solve how high the integrity capability is, or rather the probability of collision between different messages. However, the following command tool is a simple empirical way of determining how much collision can be expected for specific message size and number of bits flipped.,

There are however many algorithms with various levels of error detection strength, related to both computation time complexity and as well its size.


The Naive CRC Analysis program is a simple command-line tool for checking the quality of many common CRC algorithms and determines the probability of the collision.

The program works by generating a random message/data block of a specified size. Followed by creating a copy of the message, flips n-number of bits (corrupts the message), compute the CRC of the correct and corrupted data, if the CRC is equal, implies a collision, that is to say, on the receiving end of communication protocol, it would not be able to determine if the message has been corrupted or not, since the checksum matches.

The software is written to utilize multi-core systems, allowing to run on all threads on the system, separately independently, allowing for improved throughput, by using a task scheduler,


The following is the help message, for all the command line arguments and etc.

Naive CRC Analysis
A simple program for checking error detection
  CRCAnalysis [OPTION...]

  -v, --version                Version information
  -h, --help                   helper information.
  -c, --crc arg                CRC Algorithm (default: crc8)
  -p, --message-data-size arg  Size of each messages in bytes. (default: 5)
  -e, --error-correction       Perform Error Correction.
  -s, --samples arg            Samples (default: 1000000)
  -t, --tasks arg              Task (default: 2000)
  -b, --nr-of-error-bits arg   Number of bits error added to each message 
                               (default: 1)
  -f, --forever                Run it forever
  -l, --show-crc-list          List of support CRC and Checksum Alg

By running without any argument will execute the default config

CRC: crc8, [1999/2000] NumberOfSamples 999500, collision: [0,0.000000] nr-error-bit 1

The following example specifies to use USB CRC of 5 bits, the message of 64 bytes, flip 2 random bits n the message. Perform analysis on 800000000 random messages, on cross 10000 individual tasks, that will evenly distribute all the samples.

CRCAnalysis --crc crc5_usb -p 64 -b 2 -s 800000000 --tasks 10000
CRC: crc5_usb, [9999/10000] NumberOfSamples 799920000, collision: [24313090,0.030394] nr-error-bit 2