Python Program to Cyclic Redundancy Check

For detecting errors in digital data CRC is used, this is a good technique in detecting the transmission errors. In this technique mainly binary division is applied.

In these technique,cyclic redundancy check bits are present which is a sequence of redundant bits,these bits are appended to the end of data unit so that the resulting data unit becomes exactly divisible by a second which is predetermined binary number.

At the destination side, the incoming data is divided by the same number, if there is no remainder then assumed that data is correct and it’s ready to accept.

A remainder indicates that something happen during transition, data unit has been damaged. So this data unit is not accepted.

Cyclic Redundancy Check

Example Code

frompycrc.crclib import *
def main():
#Sender Side
div = str(input("Input divisor in binary type: "))
#user_dataword = str(raw_input("Input dataword in binary type: "))
userdataword = '1001'
print ("\nSender:")
sen = Sender(bin2dec(userdataword), div)
print ("arg_dataword:", sen.arg_dataword2)
print ("remainder:", sen.remainder2)
print ("codeword:", sen.codeword2)
print ("\nChannel:")
ch = Channel(sen.codeword)
print ("Through to the channel get channel codeword:", dec2bin(ch.ch_codeword))
#Receiver Side
print ("\nReceiver:")
rcv = Receiver(ch.ch_codeword, div)
print ("syndrome:", rcv.syndrome2)
print ("Discard or not?", rcv.discard)
print ("rx_dataword:", rcv.rx_dataword2)
if __name__ == '__main__':


Input dataword in binary type 1010000
remainder: 011
Discard or not? N

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 30-Jul-2019

5K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started