Why is crc used
Successful communication between devices is key to having a properly functioning embedded system. Embedded systems rely on and function using protocols , or a set of rules that govern the transmission, synchronization, and error checking of data sent and received between devices. Because the protocol is an essential component to a working embedded system , it is crucial that it operates properly. A CRC is used to flag corrupt data and prevent it from being sent over the bus.
Communications protocols often use two CRCs in a packet - one to protect the header of the packet and another to protect the data portion of the packet.
While the implementation of the CRC varies between protocols, the purpose remains the same — to create a method for the system to detect errors and initiate a request to retransmit the data or ignore it.
How does the CRC get generated and how does it work? It is all based on an algorithmic calculation that is used to detect inconsistencies between the data being transmitted and received. Essentially, the CRC is a value calculated from a number of data bytes to form a unique polynomial key which is appended to the outgoing message. The same process is performed on the receiving end.
The receiver then divides the message by the same polynomial the transmitter used and if the result of this division is zero, then the transmission was successful. However, if the result is not equal to zero, this would indicate that an error occurred. In USB 2. In USB 3. The CAN protocol, or Controller Area Network, is known for its robust and reliable communication, as it contains multiple error checking mechanisms, including bit error detection, format error detection, fill error detection, response error detection, and CRC error detection.
The CRC fields are contained within the data and remote frames. The receive end performs the same calculation to check whether the data changes. CRC was first proposed by W. Wesley Peterson, a mathematician and computer scientist, in CRC has advantages over other error detection methods in terms of speed, cost, and correctness. Therefore, CRC has become the most commonly used error detection method in the computer information and communications fields.
For example, a standard Ethernet frame ends with a 4-byte frame check sequence FCS for error detection. CRC enables the transmit end to append an R-bit check code to the K-bit data to be sent, generate a new frame, and send the frame to the receive end.
When receiving the new frame, the receive end checks whether the received data is correct based on the received data and check code. The check code needs to ensure that the generated new frame is divisible by a specific number that is selected by both the transmit end and receive end modulo-2 division.
The receive end divides the received new frame by the selected divisor. Because a number has been added before the data frame is sent to remove the remainder, there should be no remainder. If there is a remainder, an error occurs during the transmission of the frame. An R-bit check code is appended to the K-bit data, and the entire code length becomes N bits. This type of code is also referred to as N,K code. The algorithm is based on the GF 2 polynomial arithmetic, as shown in the following figure.
Different CRC generator polynomials have different error detection capabilities. The result of the XOR operation remainder is n-1 bits, which is used for the next step after 1 extra bit is pulled down to make it n bits long.
When there are no bits left to pull down, we have a result. The n-1 -bit remainder which is appended at the sender side. Receiver Side: Code word received at the receiver side Therefore, the remainder is all zeros. Hence, the data received has no error. Example 2: Error in transmission Data word to be sent - Key - Sender Side: Therefore, the remainder is and hence the code word sent is Receiver Side Let there be an error in transmission media Code word received at the receiver side - Since the remainder is not all zeroes, the error is detected at the receiver side.
Implementation Below implementation for generating code word from given binary data and key. If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to contribute geeksforgeeks.
See your article appearing on the GeeksforGeeks main page and help other Geeks. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Skip to content. Change Language. Related Articles. Table of Contents. Save Article. Improve Article.
0コメント