Implementation of communication using Cyclic Redundancy Check

Similar documents
CYCLIC REDUNDANCY CHECKS IN USB. Introduction. Two-minute mathematical background

Data Link Layer Overview

The finite field with 2 elements The simplest finite field is

Sheet 7 (Chapter 10)

8-bit RISC Microcontroller. Application Note. AVR236: CRC Check of Program Memory

Data Link Layer(1) Principal service: Transferring data from the network layer of the source machine to the one of the destination machine

Error detection using CRC

The string of digits in the binary number system represents the quantity

A Practical Parallel CRC Generation Method

Review of Error Detection of Data Link Layer in Computer Network

Systems I: Computer Organization and Architecture

2011, The McGraw-Hill Companies, Inc. Chapter 3

Lecture 2. Binary and Hexadecimal Numbers

RS-485 Protocol Manual

Binary Adders: Half Adders and Full Adders

EE 261 Introduction to Logic Circuits. Module #2 Number Systems

The Answer to the 14 Most Frequently Asked Modbus Questions

Section 1.4 Place Value Systems of Numeration in Other Bases

Computer Networks. Data Link Layer

Cyclic Redundant Checker Calculation on Power Architecture Technology and Comparison of Big-Endian Versus Little-Endian

Erasure Codes Made So Simple, You ll Really Like Them

Application Note AN-00160

6.02 Fall 2012 Lecture #5

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

How To Fix A 3 Bit Error In Data From A Data Point To A Bit Code (Data Point) With A Power Source (Data Source) And A Power Cell (Power Source)

1.Eastron SDM220Modbus Smart Meter Modbus Protocol Implementation V1.0

Chapter 4 Register Transfer and Microoperations. Section 4.1 Register Transfer Language

BINARY CODED DECIMAL: B.C.D.

Manchester Encoder-Decoder for Xilinx CPLDs

Levent EREN A-306 Office Phone: INTRODUCTION TO DIGITAL LOGIC

Cryptography and Network Security. Prof. D. Mukhopadhyay. Department of Computer Science and Engineering. Indian Institute of Technology, Kharagpur

Digital Logic Design. Basics Combinational Circuits Sequential Circuits. Pu-Jen Cheng

Protocol Overhead in IP/ATM Networks

LLC: Frame Construction. Layer 2: Division into two Parts. Error-detecting and -correcting Codes. Error-correcting Codes

Solution for Homework 2

Enhancing High-Speed Telecommunications Networks with FEC

CS101 Lecture 11: Number Systems and Binary Numbers. Aaron Stevens 14 February 2011

Keywords Cloud Computing, CRC, RC4, RSA, Windows Microsoft Azure

Technical Information. Digital Signals. 1 bit. Part 1 Fundamentals

Chapter 3: Sample Questions, Problems and Solutions Bölüm 3: Örnek Sorular, Problemler ve Çözümleri

Binary Division. Decimal Division. Hardware for Binary Division. Simple 16-bit Divider Circuit

Chapter 2. Binary Values and Number Systems

How To Write A Hexadecimal Program

ESPA Nov 1984 PROPOSAL FOR SERIAL DATA INTERFACE FOR PAGING EQUIPMENT CONTENTS 1. INTRODUCTION 2. CHARACTER DESCRIPTION

Computer Science 281 Binary and Hexadecimal Review

CDA 3200 Digital Systems. Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012

Digital Design. Assoc. Prof. Dr. Berna Örs Yalçın

2. What is the maximum value of each octet in an IP address? A. 128 B. 255 C. 256 D. None of the above

CSI 333 Lecture 1 Number Systems

Some facts about polynomials modulo m (Full proof of the Fingerprinting Theorem)

Technical Specifications for KD5HIO Software

Base Conversion written by Cathy Saxton

ENTTEC Pixie Driver API Specification

Binary Numbers. Binary Octal Hexadecimal

Binary Representation. Number Systems. Base 10, Base 2, Base 16. Positional Notation. Conversion of Any Base to Decimal.

Reed-Solomon Codes. by Bernard Sklar

Today. Binary addition Representing negative numbers. Andrew H. Fagg: Embedded Real- Time Systems: Binary Arithmetic

Chapter 1: Digital Systems and Binary Numbers

IP - The Internet Protocol

PROGRAMMABLE LOGIC CONTROLLERS Unit code: A/601/1625 QCF level: 4 Credit value: 15 TUTORIAL OUTCOME 2 Part 1

1 Overview. T10/ revision 9

CPEN Digital Logic Design Binary Systems

= = 3 4, Now assume that P (k) is true for some fixed k 2. This means that

Process Control and Automation using Modbus Protocol

The mathematics of RAID-6

COMBINATIONAL CIRCUITS

Network Security. Security of Wireless Local Area Networks. Chapter 15. Network Security (WS 2002): 15 Wireless LAN Security 1 Dr.-Ing G.

Written examination in Computer Networks

A Programming Language for Mechanical Translation Victor H. Yngve, Massachusetts Institute of Technology, Cambridge, Massachusetts

Today s topics. Digital Computers. More on binary. Binary Digits (Bits)

Cyber Security Workshop Encryption Reference Manual

Moven Studio realtime. streaming

Lecture 9 - Message Authentication Codes

Error Control Coding and Ethernet

EE4367 Telecom. Switching & Transmission. Prof. Murat Torlak

WAN Data Link Protocols

Numbering Systems. InThisAppendix...

DATA COMMUNICATION (Basics of data communication, OSI layers.)

Network Layer. Introduction Datagrams and Virtual Circuits Routing Traffic Control. Data delivery from source to destination.

(Refer Slide Time: 02:17)

Applied Data Communication Lecture 14

Introduction to Algebraic Coding Theory

Switch Fabric Implementation Using Shared Memory

Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1

Ethernet. Ethernet. Network Devices

Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8

Lecture 8. IP Fundamentals

Streaming Lossless Data Compression Algorithm (SLDC)

Candidates should attempt FOUR questions. All questions carry 25 marks.

Chapter 2 Logic Gates and Introduction to Computer Architecture

CRC32 Based Signature Generation Methods for URL Routing

Number Representation

2003 HSC Notes from the Marking Centre Software Design and Development

Design and Implementation of Asymmetric Cryptography Using AES Algorithm

Let s put together a Manual Processor

The Keyed-Hash Message Authentication Code (HMAC)

AN1229. Class B Safety Software Library for PIC MCUs and dspic DSCs OVERVIEW OF THE IEC STANDARD INTRODUCTION

Lecture 6: Finite Fields (PART 3) PART 3: Polynomial Arithmetic. Theoretical Underpinnings of Modern Cryptography

Transcription:

Implementation of communication using Cyclic Redundancy Check Jyoti Wadhwani 1, Prof. Nitin Narkhede 2 1 Department of Electronics Engineering RCOEM, Nagpur, 2 Department of Electronics & Telecommunication Engineering, RCOEM, Nagpur Abstract- Cyclic redundancy checking is a method of checking for errors in data that has been transmitted on a communications link. The Cyclic Redundancy Check (CRC) is an efficient technique for detecting errors during digital data transmissions between a source and a destination. It is designed to be fast and easy to implement in a hardware by using logic XOR (exclusive OR) gates and shifters. The algorithm provides very good protection from burst errors, which are typical for transmission lines. Thanks to easy implementation, it is useful for error detection but cannot safely rely on data integrity verification. This paper describes the mathematical basis behind CRC in an intuitive fashion and then explains Algorithm for the serial CRC generating and checking at both transmitter and receiver side. This includes analyzing various types of error during transmission. Keywords- Checksum, Codeword, CRC standards, Generator polynomial, Syndrome. I. INTRODUCTION Every modern communication protocols uses one or more error-detection algorithms to achieve reliable communication between source and destination. CRC is by far the most popular. The ser and receiver agree on a certain fixed polynomial called the generator polynomial.crc properties are defined by length and coefficients of the generator polynomial.. The protocol specification generally defines CRC in hexadecimal or polynomial notation. Table 1 shows the generator polynomials used by some common CRC standards. The Hex column of the Table shows the hexadecimal representation of the generator polynomial; the most significant bit is omitted, as it is always 1. TABLE 1. GENERATOR POLYNOMIAL OF SOME CRC CODES[5] Comman Name r Polynomial Generotor Hex CRC-12 12 x 12 + x 11 + x 3 + x 2 +x+1 80F CRC-16 16 x 16 + x 15 + x 2 + 1 8005 CRC- CCITT 16 X 16 + x 12 + x 5 +1 1021 CRC-32 32 X 32 +x 26 +x 23 +x 22 +x 16 + x 12 +x 11 +x 10 +x 8 +x 7 +x 5 +x 4 +x 2 +1 04C11DB7 The CRC standards differ in ways other than the choice of generating polynomial. Most initialize by assuming that the message has been preceded by certain nonzero bits, others do no such initialization. Most transmit the bits within a byte least significant bit first, some most significant bit first. Most app the checksum least significant byte first, others most significant byte first. Some complement the checksum. CRC-12 is used for transmission of 6-bit character streams, and the others are for 8-bit characters, or 8-bit bytes of arbitrary data. CRC-16 is used in IBM s BISYNCH communication standard. The CRC-CCITT polynomial, also known as ITU-TSS, is used in communication protocols such as XMODEM, X.25, IBM s SDLC, and ISO s HDLC [Tanen]. CRC-32 is also known as AUTODIN-II and ITU-TSS (ITU-TSS has defined both 16- and a 32-bit polynomials). It is used in PKZip, Ethernet, AAL5 (ATM Adaptation Layer 5), FDDI (Fiber Distributed 228

Data Interface), the IEEE-802 LAN/MAN standard, and in some DOD applications. This application note describes the Cyclic Redundancy Check (CRC) theory and implementation. This application describes the implementation of the CRC-CCITT polynomial. II. WORKING OF CRC The CRC is based on polynomial arithmetic, in particular, on computing the remainder of dividing one polynomial in GF(2) (Galois field with two elements) by another. It is a little like treating the message as a very large binary number, and computing the remainder on dividing it by a fairly large prime number such as 2 16-4. Intuitively, one would expect this to give a reliable checksum. A polynomial in GF(2) is a polynomial in a single variable x whose coefficients are 0 or 1. Addition and subtraction are done modulo 2 that is, they are both the same as the exclusive OR operator. The CRC method treats the message as a polynomial in GF(2). For example, the message 11001001, where the order of transmission is from left to right(110 ) is treated as a representation of the polynomial x7 + x6 + x3 + 1. The ser and receiver agree on a certain fixed polynomial called the generator polynomial G(x). The CRC-CCITT generator polynomial is shown in Table 1. The polynomial can be translated into a binary value, For example, the CRC-CCITT polynomial translates to 10001000000100001b. All coefficients, like x 12 or x 5, are represented by a logical 1 in the binary value. III. CRC HARDWARE IMPLEMENTATION Figure 1. HARDWARE CRC-CCITT GENERATOR The CRC calculation is realized with a shift registers and XOR gates. Figure 1 shows a CRC generator for the CRC- CCITT polynomial. Each bit of the data is shifted into the CRC shift register (Flip-Flops) after being XOR ed with the CRC s most significant bit. IV. CRC SOFTWARE IMPLEMENTATION Following are steps for implementing a CRC in software. The steps for CRC computation are followed at transmitter side and that for CRC Checking are followed at receiver side. 4.1 Steps of CRC computation at transmitter[4] To compute an n-bit binary CRC, line the bits representing the input in a row, and position the (n+1)-bit pattern representing the CRC's divisor (called a "generator polynomial") underneath the left-hand of the row. Start with the message to be encoded: 10001110 = X 7 + x 3 + x 2 +x 1 This is first padded with zeroes corresponding to the bit length n of the CRC. Here is the first calculation for computing a 16-bit CRC: 10001110 0000000000000000 <--- input right 10001000000100001 <--- divisor (17 bits) = x16+x12+x5+1 -------------------------------------------- 000001100001000010000000 <--- result 4.1.1 Three Steps The divisor is XOR ed into the input Note: in other words, the input bit above each 1-bit in the divisor is toggled The divisor is then shifted one bit to the right, and the process is repeated until the divisor reaches the right-hand of the input row. Here is the entire calculation: 100011100000000000000000 <--- input right 000001100001000010000000 <--- result 0100101000000000100 <--- result ----------------- -------------------------- 0111000001000110 <---remainder (16 bits) 229

Since the leftmost divisor bit zeroed every input bit it touched, when this process s the only bits in the input row that can be nonzero are the n bits at the right-hand of the row. These n bits are the remainder of the division step, and will also be the value of the CRC function called as checksum. The validity of a received message can easily be verified by performing the above calculation again, this time with the check value added instead of zeroes. The remainder should equal zero if there are no detectable errors. computation result i.e checksum integer i; // loop counter poly = 17'b10001000000100001; always @ (data_in1, message) data_in1 = {message, 16'b0000000000000000}; // 4.2 Steps of CRC Checking at receiver to detect error[4] 100011100111000001000110 <--- input right 000001100110000011000110 <--- result 10001000000100001 <--- result ------------------------------------------- 0000000000000000 <---remainder (16 bits) Algorithm of Software Implementation Figure 2 shows a basic implementation of CRC-CCITT computation in software. The program initializes the register named poly to binary value of CRC-CCITT generator polynomial equivalent, apps 16 zero bits to the message and checks its MSB bit. If value of MSB is 0 then data is copied as it is into temporary register r1 otherwise the data is XOR ed with the generator polynomial to store the result in the register r1. Then data is left shifted by one bit and same operation is repeated. At last the result of CRC computation called as checksum is assigned to crc register. reg [7:0] message; reg [16:0] poly; // store generator polynomial reg[23:0] data_in1; reg[16:0] r1; // to store intermediate result app 16 zero bits to the message if (data_in1[23] == 0) r1 = data_in1[23:7]; r1 = data_in1[23:7] ^ poly[16:0]; for (i = 6; i >=0; i = i-1) r1 = {r1[15:0], data_in1[i]}; if (r1[16] == 0) r1 = r1; r1 = r1 ^ poly; Fig.2. Basic CRC-CCITT Computation algorithm Figure 3 shows a basic implementation of CRC-CCITT checking in software. The program is exactly same as that of Fig.2 except that the received message will be of 24 bits and 16 zero bits are replaced by checksum value present in the received message to the receiver. reg [15:0] crc; // output port to store crc 230

reg [23:0] codeword; // Received Message reg [16:0] poly; // store same generator polynomial reg [15:0] syndrome; crc checking result i.e syndrome poly = 17'b10001000000100001; reg[23:0] data_in1; reg[16:0] r1; integer i; always @ (data_in1, codeword) // output port to store data_in1 = codeword; // here we do not app 16 zero bits if (data_in1[23] == 0) r1 = data_in1 [23:7]; r1 = data_in1 [23:7] ^ poly [16:0]; for (i = 6; i >= 0; i = i-1) r1 = {r1 [15:0], data_in1 [i]}; if (r1 [16] == 0) r1 = r1; r1 = r1 ^ poly; Communication using CRC error detection algorithm Fig 4 shows the communication application using CRC as error detection algorithm. The PRNG Pseudo Random Number Generator Is used to generate 8 bit messages d(x). The Transmitter will perform CRC computation to encode the message by adding checksum value to it. This encoded message is called codeword c(x). The channel is unreliable transmission line which may corrupt the message due to noise, attenuation and interference. The possibly corrupted codeword at the receiver is decoded using CRC checking algorithm. Note that transmitter and receiver agrees on common generator polynomial G(x). The result of CRC checking is called Syndrome s(x) is used to detect error in the received message. Fig.4. Communication using CRC technique Detecting and Verifying errors. A cyclic code can be analyzed to find its capabilities by using polynomials. Message: d(x) Codeword: c(x) Generator: g(x) Syndrome: s(x) Error: e(x) In this analysis the intention is to find the criteria that must be imposed on the generator, G(x) to detect the type of error [7]. Here, received codeword = c(x) + e(x) The receiver divides the received codeword by g(x) to get the syndrome. This can be written as: Received codeword = c(x) + e(x) G(x) G(x) G(x) The first term does not have remainder. The second term does not have a remainder (syndrome = 0), in two cases :- Fig.3. Basic CRC Checking algorithm 231

1. The first case when e(x) is 0 if there is no error. 2. The second case when e(x) is divisible by G(x). Those errors that are divisible by g(x) are not caught. 3. In a cyclic code, those e(x) errors that are divisible by g(x) are not caught. V. CONCLUSION The CRC error correction is mostly used where large data packages are transmitted, for example, in local area networks such as Ethernet. We designed the serial circuit shown in figure.1 and reported the output of the circuit for a sample division. This is basic implementation of CRC-CCITT in software. This work can be exted to next version which employs table lookup. This is the usual way that CRC-32 is calculated. Although the programs above work one bit at a time, the table lookup method (as usually implemented) works one byte at a time. A table of 256 full-word constants is used. REFERENCES [1] Hamed Sheidaeian and Behrouz Zolfaghari,2012, International Journal of Computer Networks & Communications (IJCNC) Vol.4, No.1. PARALLEL COMPUTATION OF CRC USING SPECIAL GENERATOR POLYNOMIALS [2] Tanenbaum, Andrew S. Computer Networks, Second Edition. Prentice Hall, 1988. [3] Thomas Schmidt : Microchip Technology Inc., 2000. Microchip AN730, CRC Generating and Checking [4] Wikipedia, the free encyclopedia. http://en.wikipedia.org/wiki/cyclic_redundancy_check [5] Chapter 14. Cyclic Redundancy Check 7/28/09 [6] P. Hlavka, V. Rehak, A. Smrcka, P. Simecek, D. Safranek, and T. Vojnar,2011, supported by the CESNET activity Programmable hardware. Formal Verification of the CRC Algorithm Properties. [7] An approach for a Standard Polynomial for Cyclic Redundancy Check.International Journal of Computer Applications (0975 8887), December 2011. [8] Lattice semiconductorcorporation, April 2011 Reference Design RD1105. CYCLIC REDUNDANCY CHECKS IN USB 232