About data validation

Source: Internet
Author: User
Tags check character

1. What is data validation

In layman's terms, it is to ensure the integrity of the data, using a specified algorithm for the original data calculated by a checksum value. The receiver computes a checksum with the same algorithm, indicating that the data is complete if it is the same as the checksum provided with the data.

2. The simplest test

Implementation method: The simplest checksum is to compare the raw data with the data to be compared directly to see if it is the most secure and accurate method. It is also the least efficient.

Scope of application: simple and minimal data traffic.

Application example: Dragon Bead CPU Online Debugging tool Bbug.exe. It and Dragon Bead CPU communication, Bbug send a byte CPU return received bytes, Bbug confirm is just send bytes before continuing to send the next byte.

3. Parity Check Parity

Implementation method: In the data storage and transmission, an extra bit bit in the byte to verify the error. The check digit can be calculated or computed by the data bit.

Application Example: Single chip computer serial port communication has a mode is 8 bits of data communication, plus the 9th bit for the check value.

4.BCC iso-or-checksum method (Block check character)

Implementation method: A lot of communication based on the serial port using this simple and quite accurate method. It is to have all the data and a specified initial value (usually 0) different or once, the final result is the checksum value, usually

Send her to the end of the communication data. When the receiver receives the data, it also calculates an XOR or checksum value, and if it is consistent with the received checksum, it indicates that the data received is complete.

The code for the checksum value is similar to the following:

Unsigned ucrc=0;//checksum initial value

for (int i=0;i<datalenth;i++) ucrc^=data[i];

Scope of application: For most of the data communication is not high requirements.

Application Example: IC Card interface Communication, a lot of single-chip computer system serial communication are used.

5.CRC cyclic redundancy check (cyclic redundancy check)

Implementation method: This is the use of division and the remainder of the principle of error detection. Divide the received code group into Division operations

, if it is done, the transmission is correct, and if not, the transmission is wrong. CRC Checksum

With the ability of automatic error correction.

The CRC test mainly has the computation method and the Look-up table method Two kinds of methods, on-line many implements the code.

Scope of application: CRC-12 code is usually used to transmit 6-bit strings; CRC-16 and Crc-ccitt codes are used to transmit

8-bit characters. CRC-32: Hard disk data, network transmission, etc.

Application example: RAR, Ethernet card chip, MPEG decoder chip

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.