Error Detection and Correction

Slides:



Advertisements
Similar presentations
Hamming Code.
Advertisements

parity bit is 1: data should have an odd number of 1's
Chapter 6 Errors, Error Detection, and Error Control.
Chapter 10 Error Detection and Correction
Digital Fundamentals Floyd Chapter 2 Tenth Edition
CSCI 4550/8556 Computer Networks Comer, Chapter 7: Packets, Frames, And Error Detection.
1 Chapter Six - Errors, Error Detection, and Error Control Chapter Six.
PART III DATA LINK LAYER. Position of the Data-Link Layer.
Long distance communication Multiplexing  Allow multiple signals to travel through one medium  Types Frequency division multiplexing Synchronous time.
Practical Session 11 Codes. Hamming Distance General case: The distance between two code words is the amount of 1-bit changes required to reach from one.
Unit 1 Protocols Learning Objectives: Understand the need to detect and correct errors in data transmission.
Forward Error CORRECTION A little magic. Hamming in perspective Typically errors are corrected with retransmission. Hamming lets the receiver determine.
Error Detection and Correction
Hamming It Up with Hamming Codes CSE 461 Section Week 3.
Synchronous - Asynchronous Data Transmission. Asynchronous ► The sender and receiver are not Synchronised. ► The sender sends only one character at a.
Rutvi Shah1 ERROR CORRECTION & ERROR DETECTION Rutvi Shah2 Data can be corrupted during transmission. For reliable communication, errors must be detected.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
Digital Logic Lecture 4 Binary Codes The Hashemite University Computer Engineering Department.
1 Data Link Layer Lecture 20 Imran Ahmed University of Management & Technology.
PART III DATA LINK LAYER. Position of the Data-Link Layer.
British Computer Society
CIT 307 Online Data Communications Error Detection Module 11 Kevin Siminski, Instructor.
Error Control Code. Widely used in many areas, like communications, DVD, data storage… In communications, because of noise, you can never be sure that.
Part 2: Packet Transmission Packets, frames Local area networks (LANs) Wide area networks (LANs) Hardware addresses Bridges and switches Routing and protocols.
10.1 Chapter 10 Error Detection and Correction Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Data and Computer Communications by William Stallings Eighth Edition Digital Data Communications Techniques Digital Data Communications Techniques Click.
Practical Session 10 Error Detecting and Correcting Codes.
Unit 5 Lecture 2 Error Control Error Detection & Error Correction.
Error Control Code. Widely used in many areas, like communications, DVD, data storage… In communications, because of noise, you can never be sure that.
AS Computing Data Transmission and Networks. Transmission error Detecting errors in data transmission is very important for data integrity. There are.
Error Detection and Correction
Communication Systems 3.1) Characteristics of a Communication System.
Chapter 7 - Packets, Frames and Error Detection 1. Concepts of Packets 2. Motivation for Packet Switching 3. Framing 4. Frame Formats 5. Transmission Errors.
Verification & Validation. Batch processing In a batch processing system, documents such as sales orders are collected into batches of typically 50 documents.
Overview All data can be corrupted, for reliable communications we must be able to detect and correct errors implemented at the data link and transport.
Error Detection.
CS 111 – Sept. 13 Error detection Error correction Review/practice chapter 1 questions Commitment: –Please read sections 2.1 and 2.2.
10.1 Chapter 10 Error Detection and Correction Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Data Communications and Networking
10.1 Chapter 10 Error Detection and Correction Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Practical Session 10 Computer Architecture and Assembly Language.
ERROR DETECTION AND CORRECTION Chapter 8 Data Communications & Networking ERROR DETECTION AND CORRECTION Chapter 8 First Semester 2007/2008.
Data Transmission and Networks Transmission error checking & correcting.
Hamming Codes The Hamming Code is a Forward Error-correcting Code (FEC) that uses redundant bits to correct a single bit error For 4 bit codes, 3 redundant.
parity bit is 1: data should have an odd number of 1's
Computer Architecture and Assembly Language
Packetizing Error Detection
ERROR DETECTION AND CORRECTION
ERROR CORRECTING CODES
The Three Main Sources of Transmission Errors
Error Correcting Code.
Advanced Computer Networks
CIS 321 Data Communications & Networking
OCR AS Level F451: Data transmission
Even/odd parity (1) Computers can sometimes make errors when they transmit data. Even/odd parity: is basic method for detecting if an odd number of bits.
Error Detection Bit Error Rate(BER): It is the ratio of number Ne of errors appearing over a certain time interval t to the number Nt of 1 and 0 pulses.
Packetizing Error Detection
Packetizing Error Detection
Chapter 9 Error Detection and Correction
Fundamentals of Data Representation
Packetizing Error Detection
COMPUTER NETWORKS CS610 Lecture-5 Hammad Khalid Khan.
Chapter 9 Error Detection and Correction
Error Detection and Correction
Reliability and Channel Coding
Computer Architecture and Assembly Language
parity bit is 1: data should have an odd number of 1's
Types of Errors Data transmission suffers unpredictable changes because of interference The interference can change the shape of the signal Single-bit.
Error Detection and Correction
Error Detection Learning Objectives:
Presentation transcript:

Error Detection and Correction Parity and Hamming Code

Data Transmission and Interference 00101011 00101111 00101011

Causes of Electrical Interference

The Effect of Errors Hi Dave you’re the best. Hi Dove you’re the belt. LDA #0 .loop INC CMP #10 BNE loop LDA #0 .loop DEC CMP #10 BNE loop USB Error rate 1 in 10,000,000,000 bits (this one might not quite be true!)

Parity Bits – The Solution ASCII code characters only uses 7 of the 8 bits in a byte so the most signifcant bit (MSB) can be often used as a parity bit. Two systems: Odd parity – each byte should contain an odd number of ones. Even parity – each byte should contain an even number of ones. Example – sending an “S” character using even parity: ASCII code of “S” Receiver counts odd number of 1s, error detected! 1 1 Sender sets parity bit to 0 Interference changes bit

Parity Bit Exercise All these exercises assume an even parity system is in use. (1) Work out the parity bits for these two examples: 1 1 1 1 1 1 1 1 (2) Which of these bytes have been received correctly? 1 1 1 1 1 X 1 1 1 1  Q

Parity Bits – NOT The Solution Receiver counts odd number of 1s, error detected! BUT which bit is wrong, and how can it be fixed? 1 1 Sender sets parity bit to 0 Interference changes bit Receiver counts even number of 1s, error NOT detected! 1 1 1 1 1 Most errors are burst errors so pretty useless. Interference changes 2 bits Sender sets parity bit to 0 No mechanism to detect errors with even number of bits or to correct any errors 

Hamming Codes – The Solution Hamming codes make use of multiple parity bits to enable single bit error correction and two-bit error detection. HAMMING CODE = DATA BITS + PARITY BITS Within a Hamming code: Bits at positions that are powers of 2 are used as parity bits. Bits at other positions are used to store data bits. To transmit an 8-bit byte using Hamming code, 12 bits are required: Bits at positions 1, 2, 4, 8 are used as parity bits. Bits at other positions are used to store the data to send. This sounds more complex than just putting all of the parity bits at the end of the data bits, but it has a reason which we will see later. Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 The bits are usually labelled with letters and numbers to indicate their type (D for Data, P for Parity) and position within the bits of this type. e.g. “D5”

Hamming Codes – Bit Positions Each parity bit is calculated based upon the values at certain positions within the Hamming code. The rule to determine which bits to include in the calculation of parity bit number x at bit position n is: Px: Skip n-1 bits from left, where n is the bit position of Px then include n bits in the check then miss out the next n bits and so on. For a 12-bit Hamming code the data bits checked by each parity bit are: KEY POINT: Each data bit is checked by a unique combination of parity bits. e.g. data bit D7 is checked by parity bits P1, P2 and P4 and not P3. Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 Included in P1:   Included in P2: Included in P3: Included in P4:

Hamming Code - Transmission Transmitting the byte 00100011: The data bits are copied into positions D8 down to D1. Each parity bit (P1 to P4) is calculated in turn, using even parity. The parity bits and data bits combine to make the Hamming code, so the Hamming code for 00100011 is 001010011100. Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Original Data   2. Calculate P1 3. Calculate P2 4. Calculate P3 5. Calculate P4 Hamming Code Is

Exercise: Transmission Transmitting the byte 11010011: Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Original Data   2. Calculate P1 3. Calculate P2 4. Calculate P3 5. Calculate P4 Hamming Code Is Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Original Data   2. Calculate P1 3. Calculate P2 4. Calculate P3 5. Calculate P4 Hamming Code Is Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Original Data   2. Calculate P1 3. Calculate P2 4. Calculate P3 5. Calculate P4 Hamming Code Is Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Original Data   2. Calculate P1 3. Calculate P2 4. Calculate P3 5. Calculate P4 Hamming Code Is Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Original Data   2. Calculate P1 3. Calculate P2 4. Calculate P3 5. Calculate P4 Hamming Code Is Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Original Data   2. Calculate P1 3. Calculate P2 4. Calculate P3 5. Calculate P4 Hamming Code Is Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Original Data   2. Calculate P1 3. Calculate P2 4. Calculate P3 5. Calculate P4 Hamming Code Is Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Original Data   2. Calculate P1 3. Calculate P2 4. Calculate P3 5. Calculate P4 Hamming Code Is Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Original Data   2. Calculate P1 3. Calculate P2 4. Calculate P3 5. Calculate P4 Hamming Code Is Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Original Data   2. Calculate P1 3. Calculate P2 4. Calculate P3 5. Calculate P4 Hamming Code Is Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Original Data   2. Calculate P1 3. Calculate P2 4. Calculate P3 5. Calculate P4 Hamming Code Is Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity   1. Original Data 2. Calculate P1 3. Calculate P2 4. Calculate P3 5. Calculate P4 Hamming Code Is Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Original Data   2. Calculate P1 3. Calculate P2 4. Calculate P3 5. Calculate P4 Hamming Code Is Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Original Data   2. Calculate P1 3. Calculate P2 4. Calculate P3 5. Calculate P4 Hamming Code Is Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Original Data   2. Calculate P1 3. Calculate P2 4. Calculate P3 5. Calculate P4 Hamming Code Is Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Original Data   2. Calculate P1 3. Calculate P2 4. Calculate P3 5. Calculate P4 Hamming Code Is The Hamming code for 11010011 is 110110010100 Q

Hamming Code – No Error The Hamming code 001010011100 is received. The parity bits are all recalculated from the data bits (recalculated parity bits shown in blue text): Each of the four recalculated parity bits (blue) match the received parity bits (red) so the Hamming code is valid. The received data value, read off from the data bits is 00100011. Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Received Data 2. Recalculate P1   3. Recalculate P2 4. Recalculate P3 5. Recalculate P4 6. Do parity bits match? ü

Hamming Code – 1 Bit Error The Hamming code 001010011100 is transmitted but the code 001010001100 is received because interference has corrupted the bit at position 5, changing it from a 1 to a 0. The parity bits are all recalculated from the data bits (recalculated parity bits shown in blue text): Recalculated parity bits P3 and P1 at bit positions 4 and 1 do not match the received parity bits. An error has been successfully detected! Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Received Data 2. Recalculate P1   3. Recalculate P2 4. Recalculate P3 5. Recalculate P4 6. Do parity bits match? ü x

Hamming Code – Correction Now the magic bit! The two parity bits with errors are P1 and P3. The only bit that is checked by both these parity bits and only these two parity bits is D2, so this is where the error is. This can be worked out more easily using the bit positions (this is why the parity bits weren’t all put at the end). The parity bits with errors are at bit positions 1 and 4. Add these two numbers together to give the answer 5, which is the bit position where the error is. Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Received Data 2. Recalculate P1   3. Recalculate P2 4. Recalculate P3 5. Recalculate P4 6. Do parity bits match? ü x

Hamming Code – Correction Now we know the error is at bit position 5 which has been received as a 0. As the binary system is used, there are only two possible bit values (0 and 1) so if 0 is incorrect, 1 must be correct. Therefore the error can be corrected by simply NOTing the bit value at the error position: The data value received, after correction, is 00100011which is the value that was sent, despite the interference having occurred. Error corrected! Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Received Data 2. Recalculate P1   3. Recalculate P2 4. Recalculate P3 5. Recalculate P4 6. Do parity bits match? ü x 7. Calculate position of error Parity bits at bit positions 1 and 4 do not match so error position is 1+4=5 8. Flip error bit 9. Corrected code is

Exercise: Received Correctly? The Hamming code 101100100111 is received, that appears to contain the data value 10110101. What data value was transmitted? Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Received Data 2. Recalculate P1   3. Recalculate P2 4. Recalculate P3 5. Recalculate P4 6. Do parity bits match? ü x Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Received Data 2. Recalculate P1   3. Recalculate P2 4. Recalculate P3 5. Recalculate P4 6. Do parity bits match? x ü Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Received Data 2. Recalculate P1   3. Recalculate P2 4. Recalculate P3 5. Recalculate P4 6. Do parity bits match? x ü 7. Calculate position of error Parity bits at bit positions 1 and 8 do not match so error position is 1+8=9 8. Flip error bit 9. Corrected code is Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Received Data 2. Recalculate P1   3. Recalculate P2 4. Recalculate P3 5. Recalculate P4 6. Do parity bits match? x ü 7. Calculate position of error Parity bits at bit positions 1 and 8 do not match so error position is 1+8=9 8. Flip error bit 9. Corrected code is Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Received Data 2. Recalculate P1   3. Recalculate P2 4. Recalculate P3 5. Recalculate P4 6. Do parity bits match? ü x Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Received Data 2. Recalculate P1   3. Recalculate P2 4. Recalculate P3 5. Recalculate P4 6. Do parity bits match? x ü 7. Calculate position of error Parity bits at bit positions 1 and 8 do not match so error position is 1+8=9 8. Flip error bit 9. Corrected code is Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Received Data 2. Recalculate P1   3. Recalculate P2 4. Recalculate P3 5. Recalculate P4 6. Do parity bits match? ü x Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Received Data 2. Recalculate P1   3. Recalculate P2 4. Recalculate P3 5. Recalculate P4 6. Do parity bits match? Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Received Data 2. Recalculate P1   3. Recalculate P2 4. Recalculate P3 5. Recalculate P4 6. Do parity bits match? ü x Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Received Data 2. Recalculate P1   3. Recalculate P2 4. Recalculate P3 5. Recalculate P4 6. Do parity bits match? Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Received Data 2. Recalculate P1   3. Recalculate P2 4. Recalculate P3 5. Recalculate P4 6. Do parity bits match? x Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Received Data 2. Recalculate P1   3. Recalculate P2 4. Recalculate P3 5. Recalculate P4 6. Do parity bits match? x Q The data value that was transmitted is 10100101. The transmission was corrupted but the original data value was recovered by error correction.

Hamming Code – 2 Bit Error You won’t need to be able to do this for the exam but Hamming codes can also detect 2-bit errors, but cannot correct them: Hamming Code 001010011100 is transmitted but received as 011010001100 : Bit Position 12 11 10 9 8 7 6 5 4 3 2 1 Data/Parity D8 D7 D6 D5 P4 D4 D3 D2 P3 D1 P2 P1 1. Received Data 2. Recalculate P1   3. Recalculate P2 4. Recalculate P3 5. Recalculate P4 6. Do parity bits match? x ü 7. Calculate position of error Parity bits at positions 2,4 and 8 do not match so error at bit position 14 The calculated bit position of the error is 14, but there are only 12 bits. The error has been detected but cannot be corrected.

Comparing Parity and Hamming A simple parity system with one parity bit can detect single bit errors but cannot correct them. The advantages of Hamming codes over a simple parity system are that they can correct a single bit error and can also detect 2-bit errors. The major disadvantage of Hamming codes is that some of the bandwidth of the transmission medium is used to send the parity bits. In our example, to send an 8-bit byte, 12 bits were required. So, one third of the bandwidth was used sending error correction data. For a communication channel with a bit rate of 600Mbit/second, this would effectively be slowed to 400Mbit/second.

For The Exam You need to: be able to calculate parity bits using odd and even parity. know the role of the sending and receiving devices when a parity system is used. be able to calculate Hamming codes. be able to detect and correct an error using a Hamming code. know the advantages and disadvantages of Hamming codes when compared to a simple parity bit system. You don’t need to: know the causes of interference. know how to detect 2-bit errors.

A Bit More... Hamming codes and parity bits are typically used on small amounts of data e.g. single bytes. More advanced techniques such as cyclic redundancy checks and checksums are used on bigger blocks of data such as packets transmitted on networks and sectors saved on disks. These involve calculating a hash value from all of the data in the block – you can find out lots more about these online.