SlideShare a Scribd company logo
Error Detection and Correction 
1. Introduction 
2. Block Coding 
3. Linear Block Codes 
4. Cyclic Codes 
5. Checksum
Type of Errors 
• An electromagnetic signal is subject to interference from 
heat, magnetism, and other forms of electricity 
• Single-bit error: 0 ® 1 or 1 ® 0 
• Burst error: 2 or more bits have changed
Single-Bit Error 
• Only one bit of a given data unit is changed 
• The least likely type of error in serial transmission 
• Single-bit error can happen in parallel transmission
Burst Error 
• Two or more bits in the data unit have changed 
• Burst error does not necessarily mean that the errors occur in 
consecutive bits 
• Most likely to happen in a serial transmission 
• Number of bits affected depends on the data rate and duration of noise
Redundancy 
• Error detection uses the concept of redundancy, which 
means adding extra (redundant) bits for detecting errors at 
the destination
Error Control 
• Detection Versus Correction 
– Detection: error ? yes or no 
– Correction: Need to know the exact number of bits that 
are corrupted, and their location in the message 
• Forward Error Correction Versus Retransmission 
– Retransmission (resending) : Backward error correction 
• Coding for redundancy 
– Block coding: discussed in our textbook 
– Convolution coding
Modular Arithmetic 
• In modulo-N arithmetic, we use only the integers in the range 0 to N- 
1, inclusive. 
• Adding: 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 0 
• Subtracting: 0 – 0 = 0 0 – 1 = 1 1 – 0 = 1 1 – 1 = 0 
• XORing of two single bits or two words
Block Coding 
• Divide the message iinnttoo bblloocckkss,, eeaacchh ooff kk bbiittss,, ccaalllleedd ddaattaawwoorrddss.. 
• AAdddd rr rreedduunnddaanntt bbiittss ttoo eeaacchh bblloocckk ttoo mmaakkee tthhee lleennggtthh nn == kk ++ rr.. TThhee 
rreessuullttiinngg nn--bbiitt bblloocckkss aarree ccaalllleedd ccooddeewwoorrddss 
• EExxaammppllee:: 4B/5B block coding 
– k = 4 and n = 5. 
– 2k = 16 datawords and 2n = 32 codewords.
Error Detection in Block Coding 
• Example: 
Assume that k = 2 and n = 3 
(Table 10.1)
Error Detection: Example 
• Assume the sender encodes the dataword 01 as 011 and sends it 
to the receiver. Consider the following cases: 
1. The receiver receives 011 which is a valid codeword. The receiver 
extracts the dataword 01 from it. 
2. The codeword is corrupted during transmission, and 111 is 
received. This is not a valid codeword and is discarded. 
3. The codeword is corrupted during transmission, and 000 is 
received. This is a valid codeword. The receiver incorrectly 
extracts the dataword 00. Two corrupted bits have made the 
error undetectable. 
 An error-detecting code can detect only the types of errors for 
which it is designed; other types of errors may remain 
undetected
Error Correction in Block Coding 
• Example: 
Assume that k = 2 and r = 3 
n = 5
Error Correction: Example 
• Assume the dataword is 01. The sender creates the codeword 
01011. The codeword is corrupted during transmission, and 
01001 is received. First, the receiver finds that the received 
codeword is not in the table. This means an error has occurred. 
The receiver, assuming that there is only 1 bit corrupted, uses the 
following strategy to guess the correct dataword 
1. Comparing the received codeword with the first codeword in the 
table (01001 versus 00000), the receiver decides that the first 
codeword is not the one that was sent because there are two 
different bits. (the same for third or fourth one in the table) 
2.. The original codeword must be the second one in the table 
because this is the only one that differs from the received 
codeword by 1 bit.
Hamming Distance 
• The Hamming distance between two words is the number of 
differences between corresponding bits. 
• Example: Hamming distance d(10101, 11110) is 3 
• The minimum Hamming distance is the smallest Hamming 
distance between all possible pairs in a set of words 
• Example for Table 10.1 
- dmin = 2
Hamming Distance 
• Three parameters to define the coding schemes 
– Codeword size n 
– Dataword size k 
– The minimum Hamming distance dmin 
• Coding scheme C(n, k) with a separate expression for dmin 
• Hamming distance and error 
– Hamming distance between the received codeword and the 
sent codeword is the number of bits that are corrupted 
• Minimum distance for error detection 
– To guarantee the detection of up to s errors in all cases, the 
minimum Hamming distance in a block code must be dmin 
= s + 1.
Minimum Hamming Distance: Example 
• The minimum Hamming distance in Table 10.1 is 2. This code 
guarantees detection of only a single error. 
For example, if the third codeword (101) is sent and one error 
occurs, the received codeword does not match any valid 
codeword. If two errors occur, however, the received codeword 
may match a valid codeword and the errors are not detected. 
• In Table 10.2, it has dmin = 3. This code can detect up to two errors. 
When any of the valid codewords is sent, two errors create a 
codeword which is not in the table of valid codewords. The 
receiver cannot be fooled. However, some combinations of three 
errors change a valid codeword to another valid codeword. The 
receiver accepts the received codeword and the errors are 
undetected.
To guarantee the detection of up to s errors 
in all cases, minimum Hamming distance in 
a block code must be dmin = s + 1. 
To guarantee correction of up to t errors in 
all cases, the minimum Hamming distance 
in a block code must be dmin = 2t + 1.
Linear Block Codes 
• Almost all block codes used today belong to a subset 
called linear block codes. 
• A linear block code is a code in which the exclusive OR 
(addition modulo-2) of two valid codewords creates 
another valid codeword 
• The minimum Hamming distance is the number of 1s in 
the nonzero valid codeword with the smallest number of 
1s
Linear Block Code: Parity-Check Code 
• A simple parity-check code is a single-bit error-detecting 
code in which n = k + 1 with dmin = 2. 
The extra bit called parity bit is selected to make the 
number of 1s in the codeword even.
K=4, n=5 
The addition of the 4 bits of the data word is the parity bit 
(modulo 2 ). If the no. of 1s are even, the result is 0; if the 
no. of 1s are odd the result is 1.
Encoder and Decoder for Parity-Check Code 
• The result of addition oovveerr aallll 55 bbiittss:: ssyynnddrroommee 
If the syndrome is 0, there is no error in the codeword, the data 
portion of the codeword (dataword) is accepted.
Assume the sender sends 1011, codeword is 10111, consider 
1. Syndrome 0, no error and dataword 1011 is created. 
2. One bit a1 changes, Syndrome 1, No dataword is created. 
3. One bit r0 changes, Syndrome 1, No dataword is created. 
4. An error with r0 and a3. Codeword is 00110, Syndrome is 0, 
wrong dataword 0011 is accepted. So parity check detector can 
not detect even no. of errors. 
5. Three bits a1, a2 and a3 are changed. Codeword is 01011. 
Syndrome is 1. Dataword not created. 
parity check guaranteed to detect one single error, can 
also find odd number of errors.
2 Dimensional Parity-Check Code
2 Dimensional Parity-Check Code
Linear Block Code: Hamming Code 
• All Hamming codes discussed in textbooks have dmin = 3. 
• Dataword (k bits), codeword (n bits), choose m >=3 
as the relationship between m and n in these codes is n = 2m − 1 
and k=n-m, r = m. 
If m=3, then n=7 and k=4, thus C(7,4) with dmin = 3
Encoder and Decoder for Hamming Code
Hamming Code 
• rr00 == aa22 ++ aa11 ++ aa00 mmoodduulloo--22 
• rr11 == aa33 ++ aa22 ++ aa11 mmoodduulloo--22 
• rr22 == aa11 ++ aa00 ++ aa33 mmoodduulloo--22 
• ss00 == bb22 ++ bb11 ++ bb00 ++ qq00 mmoodduulloo--22 
• ss11 == bb33 ++ bb22 ++ bb11 ++ qq11 mmoodduulloo--22 
• ss22 == bb11 ++ bb00 ++ bb33 ++ qq22 mmoodduulloo--22
Logical Decision by Decoder 
• Let us trace the path of three datawords from the sender to the 
destination: 
1 The dataword 0100 becomes the codeword 0100011. The codeword 
0100011 is received. The syndrome is 000, the final dataword is 
0100. 
2. The dataword 0111 becomes the codeword 0111001. The codeword 
0011001 received. The syndrome is 011. After flipping b2 (changing 
the 1 to 0), the final dataword is 0111. 
3. The dataword 1101 becomes the codeword 1101000. The codeword 
0001000 received (two errors). The syndrome is 101. After flipping 
b0, we get 0000, the wrong dataword. This shows that our code 
cannot correct two errors.
Burst Error Correction Using Hamming Code
Cyclic Code: CRC 
• Cyclic codes are special linear block codes with oonnee eexxttrraa pprrooppeerrttyy.. 
• IIff aa ccooddeewwoorrdd iiss ccyycclliiccaallllyy sshhiifftteedd ((rroottaatteedd)),, tthhee rreessuulltt iiss aannootthheerr 
ccooddeewwoorrdd 
• Cyclic Redundancy Check (CRC)
CRC Encoder and Decoder
Division in CRC Encoder
Division in CRC Decoder
Polynomials 
• Degree of a polynomial: the highest power in the polynomial 
Example: x6 + x + 1  the degree ‘6’
CRC Division Using Polynomials 
• The divisor in a cyclic code is normally called the generator 
polynomial or simply the generator.
Error Detection 
• Single-bit error 
If the generator has more than one term and the coefficient of x0 is 1, 
all single errors can be caught. 
• Two isolated single-bit error 
If a generator cannot divide xt + 1 (t between 0 and n – 1), then all 
isolated double errors can be detected
Summary and Standard Polynomials 
• A good polynomial generator needs to have the following 
characteristics: 
1. It should have at least two terms. 
2. The coefficient of the term x0 should be 1. 
3. It should not divide xt + 1, for t between 2 and n − 1. 
4. It should have the factor x + 1.
Checksum 
• Tendency is to replace the checksum with a CRC 
• Not as strong as CRC in error-checking capability 
• One’s complement arithmetic 
– We can represent unsigned numbers between 0 and 
2n – 1 using only n bits 
– If the number has more than n bits, the extra leftmost 
bits need to be added to the n rightmost bits 
(wrapping) 
– A negative number can be represented by inverting 
all bits. It is the same as subtracting the number from 
2n – 1
Checksum: Example 
• The sender initializes the checksum to 0 and adds all data items 
and the checksum. However, 36 cannot be expressed in 4 bits. The 
extra two bits are wrapped and added with the sum to create the 
wrapped sum value 6. The sum is then complemented, resulting in 
the checksum value 9 (15 − 6 = 9).
Internet Checksum 
Sender site: 
1. The message is divided into 16-bit words. 
2. The value of the checksum word is set to 0. 
3. All words including the checksum are added using one’s complement 
addition. 
4. The sum is complemented and becomes the checksum. 
5. The checksum is sent with the data. 
Receiver site: 
1. The message (including checksum) is divided into 16-bit words. 
2. All words are added using one’s complement addition. 
3. The sum is complemented and becomes the new checksum. 
4. If the value of checksum is 0, the message is accepted; otherwise, it is 
rejected.

More Related Content

What's hot

DCN Error Detection & Correction
DCN Error Detection & CorrectionDCN Error Detection & Correction
DCN Error Detection & Correction
Rohan Bhatkar
 
Error Detection and correction concepts in Data communication and networks
Error Detection and correction concepts in Data communication and networksError Detection and correction concepts in Data communication and networks
Error Detection and correction concepts in Data communication and networks
Nt Arvind
 
Error detection correction (CRC)
Error detection correction  (CRC)Error detection correction  (CRC)
Error detection correction (CRC)
Karam Munir Butt
 
Check sum
Check sumCheck sum
Check sum
Pooja Jaiswal
 
Flow Control
Flow ControlFlow Control
Flow Control
selvakumar_b1985
 
Error detection and correction
Error detection and correctionError detection and correction
Error detection and correction
Siddique Ibrahim
 
Error control
Error controlError control
Error control
selvakumar_b1985
 
Topic:Terminal handling & polling
Topic:Terminal handling & pollingTopic:Terminal handling & polling
Topic:Terminal handling & polling
Dr Rajiv Srivastava
 
Encoding Techniques
Encoding TechniquesEncoding Techniques
Computer Networks Unit 1 Introduction and Physical Layer
Computer Networks Unit 1 Introduction and Physical Layer Computer Networks Unit 1 Introduction and Physical Layer
Computer Networks Unit 1 Introduction and Physical Layer
Dr. SELVAGANESAN S
 
Error detection and correction
Error detection and correctionError detection and correction
Error detection and correction
Maria Akther
 
Computer networks - Channelization
Computer networks - ChannelizationComputer networks - Channelization
Computer networks - Channelization
Elambaruthi Elambaruthi
 
Computer Networks - Error Detection & Error Correction
Computer Networks - Error Detection & Error CorrectionComputer Networks - Error Detection & Error Correction
Computer Networks - Error Detection & Error Correction
Saikrishna Tanguturu
 
Chapter 10
Chapter 10Chapter 10
Chapter 10
Faisal Mehmood
 
Error correction and detection th
Error correction and detection thError correction and detection th
Error correction and detection th
ShardaSalunkhe1
 
Guided Transmission Media
Guided Transmission MediaGuided Transmission Media
Guided Transmission Media
asrabatool
 
Linear Block Codes
Linear Block CodesLinear Block Codes
Linear Block Codes
NilaNila16
 
Error Detection And Correction
Error Detection And CorrectionError Detection And Correction
Error Detection And Correction
Renu Kewalramani
 
Routing algorithm
Routing algorithmRouting algorithm
Routing algorithm
Bushra M
 
Channel coding
Channel coding  Channel coding

What's hot (20)

DCN Error Detection & Correction
DCN Error Detection & CorrectionDCN Error Detection & Correction
DCN Error Detection & Correction
 
Error Detection and correction concepts in Data communication and networks
Error Detection and correction concepts in Data communication and networksError Detection and correction concepts in Data communication and networks
Error Detection and correction concepts in Data communication and networks
 
Error detection correction (CRC)
Error detection correction  (CRC)Error detection correction  (CRC)
Error detection correction (CRC)
 
Check sum
Check sumCheck sum
Check sum
 
Flow Control
Flow ControlFlow Control
Flow Control
 
Error detection and correction
Error detection and correctionError detection and correction
Error detection and correction
 
Error control
Error controlError control
Error control
 
Topic:Terminal handling & polling
Topic:Terminal handling & pollingTopic:Terminal handling & polling
Topic:Terminal handling & polling
 
Encoding Techniques
Encoding TechniquesEncoding Techniques
Encoding Techniques
 
Computer Networks Unit 1 Introduction and Physical Layer
Computer Networks Unit 1 Introduction and Physical Layer Computer Networks Unit 1 Introduction and Physical Layer
Computer Networks Unit 1 Introduction and Physical Layer
 
Error detection and correction
Error detection and correctionError detection and correction
Error detection and correction
 
Computer networks - Channelization
Computer networks - ChannelizationComputer networks - Channelization
Computer networks - Channelization
 
Computer Networks - Error Detection & Error Correction
Computer Networks - Error Detection & Error CorrectionComputer Networks - Error Detection & Error Correction
Computer Networks - Error Detection & Error Correction
 
Chapter 10
Chapter 10Chapter 10
Chapter 10
 
Error correction and detection th
Error correction and detection thError correction and detection th
Error correction and detection th
 
Guided Transmission Media
Guided Transmission MediaGuided Transmission Media
Guided Transmission Media
 
Linear Block Codes
Linear Block CodesLinear Block Codes
Linear Block Codes
 
Error Detection And Correction
Error Detection And CorrectionError Detection And Correction
Error Detection And Correction
 
Routing algorithm
Routing algorithmRouting algorithm
Routing algorithm
 
Channel coding
Channel coding  Channel coding
Channel coding
 

Similar to New error-detection (2)

3F4ecc.ppt
3F4ecc.ppt3F4ecc.ppt
3F4ecc.ppt
Annymus
 
Error detection and correction
Error detection and correctionError detection and correction
Error detection and correction
Abdul Razaq
 
linear codes and cyclic codes
linear codes and cyclic codeslinear codes and cyclic codes
linear codes and cyclic codes
saigopinadh bodigiri
 
Lecture8_Error Detection and Correction 232.pptx
Lecture8_Error Detection and Correction 232.pptxLecture8_Error Detection and Correction 232.pptx
Lecture8_Error Detection and Correction 232.pptx
MahabubAlam97
 
Unit-4.pptx
Unit-4.pptxUnit-4.pptx
Digital Communication: Channel Coding
Digital Communication: Channel CodingDigital Communication: Channel Coding
Digital Communication: Channel Coding
Dr. Sanjay M. Gulhane
 
Introduction to the Data Link Layer
Introduction to the Data Link LayerIntroduction to the Data Link Layer
Introduction to the Data Link Layer
Meenakshi Paul
 
Error control 20
Error control 20Error control 20
Error control 20
zulhelman hanafi
 
4_Datalink__Error_Detection_and Correction.pdf
4_Datalink__Error_Detection_and Correction.pdf4_Datalink__Error_Detection_and Correction.pdf
4_Datalink__Error_Detection_and Correction.pdf
kenilpatel65
 
Computer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfComputer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdf
abdnazar2003
 
ch10.pdf
ch10.pdfch10.pdf
ch10.pdf
MarckyCaones
 
Channel Coding (Error Control Coding)
Channel Coding (Error Control Coding)Channel Coding (Error Control Coding)
Channel Coding (Error Control Coding)
Ola Mashaqi @ an-najah national university
 
Ch10
Ch10Ch10
10 Error Detection_and_Correction
10 Error Detection_and_Correction10 Error Detection_and_Correction
10 Error Detection_and_Correction
Ahmar Hashmi
 
Ch10
Ch10Ch10
Ch10
Lia Nakid
 
Data links
Data links Data links
Data links
EshaAfzal5
 
13-DataLink_02.ppt
13-DataLink_02.ppt13-DataLink_02.ppt
13-DataLink_02.ppt
WinterSnow16
 

Similar to New error-detection (2) (20)

3F4ecc.ppt
3F4ecc.ppt3F4ecc.ppt
3F4ecc.ppt
 
Error detection and correction
Error detection and correctionError detection and correction
Error detection and correction
 
linear codes and cyclic codes
linear codes and cyclic codeslinear codes and cyclic codes
linear codes and cyclic codes
 
Lecture8_Error Detection and Correction 232.pptx
Lecture8_Error Detection and Correction 232.pptxLecture8_Error Detection and Correction 232.pptx
Lecture8_Error Detection and Correction 232.pptx
 
Unit-4.pptx
Unit-4.pptxUnit-4.pptx
Unit-4.pptx
 
Digital Communication: Channel Coding
Digital Communication: Channel CodingDigital Communication: Channel Coding
Digital Communication: Channel Coding
 
Introduction to the Data Link Layer
Introduction to the Data Link LayerIntroduction to the Data Link Layer
Introduction to the Data Link Layer
 
Error control 20
Error control 20Error control 20
Error control 20
 
4_Datalink__Error_Detection_and Correction.pdf
4_Datalink__Error_Detection_and Correction.pdf4_Datalink__Error_Detection_and Correction.pdf
4_Datalink__Error_Detection_and Correction.pdf
 
Ch3 datalink
Ch3 datalinkCh3 datalink
Ch3 datalink
 
Computer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfComputer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdf
 
ch10.pdf
ch10.pdfch10.pdf
ch10.pdf
 
Channel Coding (Error Control Coding)
Channel Coding (Error Control Coding)Channel Coding (Error Control Coding)
Channel Coding (Error Control Coding)
 
Ch10
Ch10Ch10
Ch10
 
10 Error Detection_and_Correction
10 Error Detection_and_Correction10 Error Detection_and_Correction
10 Error Detection_and_Correction
 
Ch10
Ch10Ch10
Ch10
 
Ch10
Ch10Ch10
Ch10
 
Data links
Data links Data links
Data links
 
13-DataLink_02.ppt
13-DataLink_02.ppt13-DataLink_02.ppt
13-DataLink_02.ppt
 
error control coding
error control coding error control coding
error control coding
 

More from Nitesh Singh

Risk taking and emotions
Risk taking and emotionsRisk taking and emotions
Risk taking and emotionsNitesh Singh
 
Project report RAILWAY TICKET RESERVATION SYSTEM SAD
Project report RAILWAY TICKET RESERVATION SYSTEM SADProject report RAILWAY TICKET RESERVATION SYSTEM SAD
Project report RAILWAY TICKET RESERVATION SYSTEM SAD
Nitesh Singh
 
The real comedy behind comedy
The real comedy behind comedyThe real comedy behind comedy
The real comedy behind comedy
Nitesh Singh
 
Project report Rs Dry celaners
Project report Rs Dry celaners Project report Rs Dry celaners
Project report Rs Dry celaners Nitesh Singh
 
Routing protocols-network-layer
Routing protocols-network-layerRouting protocols-network-layer
Routing protocols-network-layerNitesh Singh
 
Ta 104-topology (1)
Ta 104-topology (1)Ta 104-topology (1)
Ta 104-topology (1)Nitesh Singh
 

More from Nitesh Singh (20)

Risk taking and emotions
Risk taking and emotionsRisk taking and emotions
Risk taking and emotions
 
Project report RAILWAY TICKET RESERVATION SYSTEM SAD
Project report RAILWAY TICKET RESERVATION SYSTEM SADProject report RAILWAY TICKET RESERVATION SYSTEM SAD
Project report RAILWAY TICKET RESERVATION SYSTEM SAD
 
The real comedy behind comedy
The real comedy behind comedyThe real comedy behind comedy
The real comedy behind comedy
 
Project report Rs Dry celaners
Project report Rs Dry celaners Project report Rs Dry celaners
Project report Rs Dry celaners
 
BIG DATA ANALYSIS
BIG DATA ANALYSISBIG DATA ANALYSIS
BIG DATA ANALYSIS
 
Udp vs-tcp
Udp vs-tcpUdp vs-tcp
Udp vs-tcp
 
Routing protocols-network-layer
Routing protocols-network-layerRouting protocols-network-layer
Routing protocols-network-layer
 
Routers vs-switch
Routers vs-switchRouters vs-switch
Routers vs-switch
 
New udp
New udpNew udp
New udp
 
I pv4 format
I pv4 formatI pv4 format
I pv4 format
 
I pv4 addressing
I pv4 addressingI pv4 addressing
I pv4 addressing
 
Hub vs-switch
Hub vs-switchHub vs-switch
Hub vs-switch
 
Ftp
FtpFtp
Ftp
 
Email ftp
Email ftpEmail ftp
Email ftp
 
Www and http
Www and httpWww and http
Www and http
 
Transmission main
Transmission mainTransmission main
Transmission main
 
Ta 104-topology
Ta 104-topologyTa 104-topology
Ta 104-topology
 
Ta 104-topology (1)
Ta 104-topology (1)Ta 104-topology (1)
Ta 104-topology (1)
 
Ta 104-tcp
Ta 104-tcpTa 104-tcp
Ta 104-tcp
 
Ta 104-media-3
Ta 104-media-3Ta 104-media-3
Ta 104-media-3
 

New error-detection (2)

  • 1. Error Detection and Correction 1. Introduction 2. Block Coding 3. Linear Block Codes 4. Cyclic Codes 5. Checksum
  • 2. Type of Errors • An electromagnetic signal is subject to interference from heat, magnetism, and other forms of electricity • Single-bit error: 0 ® 1 or 1 ® 0 • Burst error: 2 or more bits have changed
  • 3. Single-Bit Error • Only one bit of a given data unit is changed • The least likely type of error in serial transmission • Single-bit error can happen in parallel transmission
  • 4. Burst Error • Two or more bits in the data unit have changed • Burst error does not necessarily mean that the errors occur in consecutive bits • Most likely to happen in a serial transmission • Number of bits affected depends on the data rate and duration of noise
  • 5. Redundancy • Error detection uses the concept of redundancy, which means adding extra (redundant) bits for detecting errors at the destination
  • 6. Error Control • Detection Versus Correction – Detection: error ? yes or no – Correction: Need to know the exact number of bits that are corrupted, and their location in the message • Forward Error Correction Versus Retransmission – Retransmission (resending) : Backward error correction • Coding for redundancy – Block coding: discussed in our textbook – Convolution coding
  • 7. Modular Arithmetic • In modulo-N arithmetic, we use only the integers in the range 0 to N- 1, inclusive. • Adding: 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 0 • Subtracting: 0 – 0 = 0 0 – 1 = 1 1 – 0 = 1 1 – 1 = 0 • XORing of two single bits or two words
  • 8. Block Coding • Divide the message iinnttoo bblloocckkss,, eeaacchh ooff kk bbiittss,, ccaalllleedd ddaattaawwoorrddss.. • AAdddd rr rreedduunnddaanntt bbiittss ttoo eeaacchh bblloocckk ttoo mmaakkee tthhee lleennggtthh nn == kk ++ rr.. TThhee rreessuullttiinngg nn--bbiitt bblloocckkss aarree ccaalllleedd ccooddeewwoorrddss • EExxaammppllee:: 4B/5B block coding – k = 4 and n = 5. – 2k = 16 datawords and 2n = 32 codewords.
  • 9. Error Detection in Block Coding • Example: Assume that k = 2 and n = 3 (Table 10.1)
  • 10. Error Detection: Example • Assume the sender encodes the dataword 01 as 011 and sends it to the receiver. Consider the following cases: 1. The receiver receives 011 which is a valid codeword. The receiver extracts the dataword 01 from it. 2. The codeword is corrupted during transmission, and 111 is received. This is not a valid codeword and is discarded. 3. The codeword is corrupted during transmission, and 000 is received. This is a valid codeword. The receiver incorrectly extracts the dataword 00. Two corrupted bits have made the error undetectable.  An error-detecting code can detect only the types of errors for which it is designed; other types of errors may remain undetected
  • 11. Error Correction in Block Coding • Example: Assume that k = 2 and r = 3 n = 5
  • 12. Error Correction: Example • Assume the dataword is 01. The sender creates the codeword 01011. The codeword is corrupted during transmission, and 01001 is received. First, the receiver finds that the received codeword is not in the table. This means an error has occurred. The receiver, assuming that there is only 1 bit corrupted, uses the following strategy to guess the correct dataword 1. Comparing the received codeword with the first codeword in the table (01001 versus 00000), the receiver decides that the first codeword is not the one that was sent because there are two different bits. (the same for third or fourth one in the table) 2.. The original codeword must be the second one in the table because this is the only one that differs from the received codeword by 1 bit.
  • 13. Hamming Distance • The Hamming distance between two words is the number of differences between corresponding bits. • Example: Hamming distance d(10101, 11110) is 3 • The minimum Hamming distance is the smallest Hamming distance between all possible pairs in a set of words • Example for Table 10.1 - dmin = 2
  • 14. Hamming Distance • Three parameters to define the coding schemes – Codeword size n – Dataword size k – The minimum Hamming distance dmin • Coding scheme C(n, k) with a separate expression for dmin • Hamming distance and error – Hamming distance between the received codeword and the sent codeword is the number of bits that are corrupted • Minimum distance for error detection – To guarantee the detection of up to s errors in all cases, the minimum Hamming distance in a block code must be dmin = s + 1.
  • 15. Minimum Hamming Distance: Example • The minimum Hamming distance in Table 10.1 is 2. This code guarantees detection of only a single error. For example, if the third codeword (101) is sent and one error occurs, the received codeword does not match any valid codeword. If two errors occur, however, the received codeword may match a valid codeword and the errors are not detected. • In Table 10.2, it has dmin = 3. This code can detect up to two errors. When any of the valid codewords is sent, two errors create a codeword which is not in the table of valid codewords. The receiver cannot be fooled. However, some combinations of three errors change a valid codeword to another valid codeword. The receiver accepts the received codeword and the errors are undetected.
  • 16. To guarantee the detection of up to s errors in all cases, minimum Hamming distance in a block code must be dmin = s + 1. To guarantee correction of up to t errors in all cases, the minimum Hamming distance in a block code must be dmin = 2t + 1.
  • 17. Linear Block Codes • Almost all block codes used today belong to a subset called linear block codes. • A linear block code is a code in which the exclusive OR (addition modulo-2) of two valid codewords creates another valid codeword • The minimum Hamming distance is the number of 1s in the nonzero valid codeword with the smallest number of 1s
  • 18. Linear Block Code: Parity-Check Code • A simple parity-check code is a single-bit error-detecting code in which n = k + 1 with dmin = 2. The extra bit called parity bit is selected to make the number of 1s in the codeword even.
  • 19. K=4, n=5 The addition of the 4 bits of the data word is the parity bit (modulo 2 ). If the no. of 1s are even, the result is 0; if the no. of 1s are odd the result is 1.
  • 20. Encoder and Decoder for Parity-Check Code • The result of addition oovveerr aallll 55 bbiittss:: ssyynnddrroommee If the syndrome is 0, there is no error in the codeword, the data portion of the codeword (dataword) is accepted.
  • 21. Assume the sender sends 1011, codeword is 10111, consider 1. Syndrome 0, no error and dataword 1011 is created. 2. One bit a1 changes, Syndrome 1, No dataword is created. 3. One bit r0 changes, Syndrome 1, No dataword is created. 4. An error with r0 and a3. Codeword is 00110, Syndrome is 0, wrong dataword 0011 is accepted. So parity check detector can not detect even no. of errors. 5. Three bits a1, a2 and a3 are changed. Codeword is 01011. Syndrome is 1. Dataword not created. parity check guaranteed to detect one single error, can also find odd number of errors.
  • 24. Linear Block Code: Hamming Code • All Hamming codes discussed in textbooks have dmin = 3. • Dataword (k bits), codeword (n bits), choose m >=3 as the relationship between m and n in these codes is n = 2m − 1 and k=n-m, r = m. If m=3, then n=7 and k=4, thus C(7,4) with dmin = 3
  • 25. Encoder and Decoder for Hamming Code
  • 26. Hamming Code • rr00 == aa22 ++ aa11 ++ aa00 mmoodduulloo--22 • rr11 == aa33 ++ aa22 ++ aa11 mmoodduulloo--22 • rr22 == aa11 ++ aa00 ++ aa33 mmoodduulloo--22 • ss00 == bb22 ++ bb11 ++ bb00 ++ qq00 mmoodduulloo--22 • ss11 == bb33 ++ bb22 ++ bb11 ++ qq11 mmoodduulloo--22 • ss22 == bb11 ++ bb00 ++ bb33 ++ qq22 mmoodduulloo--22
  • 27. Logical Decision by Decoder • Let us trace the path of three datawords from the sender to the destination: 1 The dataword 0100 becomes the codeword 0100011. The codeword 0100011 is received. The syndrome is 000, the final dataword is 0100. 2. The dataword 0111 becomes the codeword 0111001. The codeword 0011001 received. The syndrome is 011. After flipping b2 (changing the 1 to 0), the final dataword is 0111. 3. The dataword 1101 becomes the codeword 1101000. The codeword 0001000 received (two errors). The syndrome is 101. After flipping b0, we get 0000, the wrong dataword. This shows that our code cannot correct two errors.
  • 28. Burst Error Correction Using Hamming Code
  • 29. Cyclic Code: CRC • Cyclic codes are special linear block codes with oonnee eexxttrraa pprrooppeerrttyy.. • IIff aa ccooddeewwoorrdd iiss ccyycclliiccaallllyy sshhiifftteedd ((rroottaatteedd)),, tthhee rreessuulltt iiss aannootthheerr ccooddeewwoorrdd • Cyclic Redundancy Check (CRC)
  • 30. CRC Encoder and Decoder
  • 31. Division in CRC Encoder
  • 32. Division in CRC Decoder
  • 33. Polynomials • Degree of a polynomial: the highest power in the polynomial Example: x6 + x + 1  the degree ‘6’
  • 34. CRC Division Using Polynomials • The divisor in a cyclic code is normally called the generator polynomial or simply the generator.
  • 35. Error Detection • Single-bit error If the generator has more than one term and the coefficient of x0 is 1, all single errors can be caught. • Two isolated single-bit error If a generator cannot divide xt + 1 (t between 0 and n – 1), then all isolated double errors can be detected
  • 36. Summary and Standard Polynomials • A good polynomial generator needs to have the following characteristics: 1. It should have at least two terms. 2. The coefficient of the term x0 should be 1. 3. It should not divide xt + 1, for t between 2 and n − 1. 4. It should have the factor x + 1.
  • 37. Checksum • Tendency is to replace the checksum with a CRC • Not as strong as CRC in error-checking capability • One’s complement arithmetic – We can represent unsigned numbers between 0 and 2n – 1 using only n bits – If the number has more than n bits, the extra leftmost bits need to be added to the n rightmost bits (wrapping) – A negative number can be represented by inverting all bits. It is the same as subtracting the number from 2n – 1
  • 38. Checksum: Example • The sender initializes the checksum to 0 and adds all data items and the checksum. However, 36 cannot be expressed in 4 bits. The extra two bits are wrapped and added with the sum to create the wrapped sum value 6. The sum is then complemented, resulting in the checksum value 9 (15 − 6 = 9).
  • 39. Internet Checksum Sender site: 1. The message is divided into 16-bit words. 2. The value of the checksum word is set to 0. 3. All words including the checksum are added using one’s complement addition. 4. The sum is complemented and becomes the checksum. 5. The checksum is sent with the data. Receiver site: 1. The message (including checksum) is divided into 16-bit words. 2. All words are added using one’s complement addition. 3. The sum is complemented and becomes the new checksum. 4. If the value of checksum is 0, the message is accepted; otherwise, it is rejected.