You are on page 1of 137

Error Detection

Techniques in Data Link , Network and Transport Layers of


TCP/IP

McGraw-Hill Related Chapter ..10


©The McGraw-Hill Companies, Inc., 2000
Three Sections of Chapter 10

• First section
– It introduces Types of errors and concept of redundancy
– It distinguishes between error detection and correction.

• Second section discusses


– It discusses block coding
– It shows how error can be detected using block coding
– It also introduces the concept of Hamming distance.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Three Sections of Chapter 10

• Third section
– It discusses cyclic codes.
– It discusses a subset of cyclic code, CRC, that is very
common in the data-link layer. The section shows how
CRC can be easily implemented in hardware and
represented by polynomials.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Related CLO-3

• Differentiate error detection techniques in Datalink,


Network and Transport Layers and error correction
techniques in Datalink and Transport Layers of TCP/IP
Model.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Data link
TCP/IP layerStack
Protocol in the
andInternet
Data Linkmodel
Layer

• Let us recall …………..

• We know that
• The data link layer lies under the network layer in the Internet model.
• It provides services to the network layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


– Objective of Data Link Layer:

• Achieving reliable communication between two


adjacent machines’

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Data-link layer duties

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


What are the objectives of Data Link Layer…….????

• Design Issues:
1. Hop to hop delivery:
2. Packetizing (Framing) : data are sent in blocks called frames, the beginning
and end of each frame must be recognized by the receiver.
3. Addressing: on a multipoint line, such as a LAN, the identity of the two
stations involved in a transmission must be specified.
4. Error control: bit errors introduced by the transmission system should be
detected and/or corrected.
5. Flow control: the sending station must not send frames at a rate faster than
the receiving station can absorb them.
6. Medium Access Control: Transmit control information and data on the
same line
7. Some more………

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Here in this module we ll discuss Error Detection
& Correction in TCP/IP in general
and Data Link in particular ………….

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Error Detection and Correction

• At the data-link layer, if a frame is corrupted


between the two nodes, it needs to be corrected
before it continues its journey to other nodes.
• However, most link-layer protocols simply discard
the frame and let the upper-layer protocols handle
the retransmission of the frame. Some multimedia
applications, however, try to correct the corrupted
frame

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Error Control

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Error Control

• Types Of Errors
– Data are sent from one device to another in the form of
binary data(0s and 1s).
– Two types of errors may happen:
• Single-bit errors
• Burst errors

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Error Detection: Types of Error

• An error occurs when a bit is altered between transmission


and reception
• Single bit errors
– One bit is altered
– Adjacent bits are not affected
– Can occur in the presence of white noise (thermal noise)
• Burst errors
– A cluster of bits with Length B
– the first and the last and a number of intermediate bits in error
(not necessarily all the bits in the cluster suffer an error)
– More common and more difficult to deal with
– Can be caused by impulse noise
13
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
Note:

In a single-bit error, only 1 bit in the


data unit has changed.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Single-bit error

• Only 1 bit of a given data unit is changed from 1 to 0 or from 0 to 1.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Note:

A burst error means that two or more bits


in the data unit have changed.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Burst error of length five

• Burst error does not necessarily mean that the errors occur in
consecutive bits.
• The length of the burst is measured from the first corrupted bit
to the last corrupted bit.
•McGraw-Hill
Some bits in between may not have been corrupted.
©The McGraw-Hill Companies, Inc., 2000
Central concept in detecting or correcting errors is
‘redundancy’.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


To be able to detect or correct errors, we need to
send some extra bits with our data.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


10.1.2 Redundancy

• Redundant bits are added by the sender and


removed by the receiver. Their presence allows the
receiver to detect or correct corrupted bits.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Error detection

Note:

Error detection uses the concept of


redundancy, which means adding
extra bits for detecting errors at the
destination.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Redundancy

• The key to error detection is redundancy, a short group of bits


appended to or inserted to each unit of data.
• This technique is called redundancy because the extra bits are
redundant to the information.
• They are discarded as soon as the accuracy of the transmission has
been determined.
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
The correction of errors is more difficult than the detection.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


10.1.3 Detection versus Correction

• Error detection
– we are only looking to see if any error has occurred.
– Required answer is a simple yes or no.
– Not even interested in the number of corrupted bits.
– A single-bit error is the same for us as a burst error.

• Error correction
– we need to know the exact number and Location of Corrupted
bits in the message.
– Number of errors and the size of the message are important
factors.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


10.1.3 Detection versus Correction

• Receiver’s difficulty in finding Errors:


– If we need to correct a single error in an 8-bit data unit,
we need to consider eight possible error locations.
– If we need to correct two errors in a data unit of the
same size, we need to consider 28 possibilities.
– Receiver’s difficulty in finding 10 errors in a data unit of
1000 bits can be imagined .

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


10.1.4 Coding Schemes used in Error Detection

• The sender adds redundant bits through a process that creates a


relationship between the redundant bits and the actual data bits. The
receiver checks the relationships between the two sets of bits to
detect errors.

• Redundancy is achieved through various coding schemes.

• Important factors in any coding scheme.


– Ratio of redundant bits to data bits
– Robustness of the process

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


What are Four types of coding?

1. Data compression
– (or, source coding)

2.Error correction
– (or channel coding)
3. Cryptographic coding
– for secure communication
4. Line coding
– for use within a communications system for transmitting a digital
signal down a transmission line

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Difference between Source Coding and Channel coding ?

• Channel coding is adding redundancy to improve reliability, at a


cost in rate
• Error correction
• Source coding is removal of redundancy from information
bits to improve rate
• Compression
• This lecture is only about channel coding
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
We will remain focused on Error correction (or
channel coding)

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Classification of codes

1. Block codes
– Linear block codes: (n, k, dmin)
• Hamming codes
• Cyclic codes
– Reed-Solomon codes
– BCH codes
– Cyclic Redundancy Check (CRC) codes

– Nonlinear block codes


2. Convolutional codes: (n, k, m)
3. Compound codes
– Concatenated codes (outer code + inner code)
– Product codes
– Punctured convolutional codes
• Rate compatible punctured convolutional (RCPC) codes
– Turbo codes
– Low-density parity-check (LDPC) codes

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


• We concentrate on block coding only…………

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


• We concentrate on……………

Block coding

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


What is block code ?

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


• A block code is any member of the large and important
family of error-correcting codes that encode data in
blocks.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


What is block code ?

• A type of error-correcting or error-detecting code in which a


fixed number in the form of Dataword (conventionally k) of
digits are taken into the encoder at a time and then output in
the form of a codeword consisting of a greater number
(conventionally n) of digits.

• It is often specified as an (n, k) code, with block length k and


codeword length n.where in general n>k.

• This is known as an (n,k) block code

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Block Code - Example

• Dataword length k = 4
• Codeword length n = 7
• This is a (7,4) block code with code rate = 4/7

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Terminology in Block Coding

• Datawords: divided blocks of a message, each of k bits


• Code words: n-bit blocks composed of k-bit data word + r-bit
redundant extra

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Codebook

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


BLOCK CODING

• We have a set of datawords, each of size k, and a set of codewords,


each of size of n.

• With k bits, we can create a combination of datawords


• With n bits, we can create a combination of codewords.

• Since n > k, the number of possible codewords is larger than the


number of possible datawords.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


BLOCK CODING

• The block coding process is one-to-one; the same dataword is always


encoded as the same codeword.

• Hence we have codewords that are not used. We call these


codewords invalid or illegal.

• The trick in error detection is the existence of these invalid codes (will
be discussed later)

• If the receiver receives an invalid codeword, this indicates that the


data was corrupted during transmission.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


10.2.1 Error Detection

• How can errors be detected by using block coding?


– Receiver can detect a change in the original
codeword when .
1. Receiver has (or can find) a list of valid codewords.
2. Original codeword has changed to an invalid one.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


10.2.1 Error Detection

• Sender creates ‘codewords’ out of ‘datawords’ by using a


generator that applies the rules and procedures of
encoding (will be discussed later).

Process of
error
detection in
block coding
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
10.2.1 Error Detection

• Each codeword sent to the receiver may change during


transmission.

– If the received codeword is the same as one of the valid codewords,


the word is accepted; the corresponding dataword is extracted for
use.

– If the received codeword is not valid, it is discarded.


– Note:
• However, if the codeword is corrupted during transmission but the received
word still matches a valid codeword, the error remains undetected.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Example 10.1

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Example 10.1

• Let us assume that k = 2 and n = 3. Table shows the


list of datawords and codewords.

Datawords Codewords

00 000

01 011

10 101

11 110

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Example 10.1

• Sender: Assume the sender encodes the dataword 01 as


011 and sends it to the receiver.
• Receiver: Three cases:
– Case I: The receiver receives 011. It is a valid codeword. The
receiver extracts the dataword 01 from it.
– Case 2:The codeword is corrupted during transmission, and 111 is
received (the leftmost bit is corrupted).This is not a valid
codeword and is discarded.
• Case 3:The codeword is corrupted during transmission, and 000 is
received (the right two bits are corrupted). This is a valid
codeword. The receiver incorrectly extracts the dataword 00. Two
corrupted bits have made the error undetectable.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


• Case 3:

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Some Important concepts
Central concept :Hamming Distance

Error control capability is


determined by the Hamming
McGraw-Hill ©Thedistance
McGraw-Hill Companies, Inc., 2000
Central concept :Hamming Distance

• Hamming distance between the received codeword and the


sent codeword is the number of bits that are corrupted
during transmission.

• The Hamming distance between two words (of the same


size) is the number of differences between the
corresponding bits.

• Hamming distance is between two words x and y as d(x, y).

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Central concept :Hamming Distance

• Example:
– If the codeword 00000 is sent and 01101 is received.
What will be the Hamming Distance ?
• Solution:
– 3 bits are in error and the Hamming distance between
the two is d(00000, 01101) = 3.
• The Hamming distance between:
• "karolin" and "kathrin" is 3.
• "karolin" and "kerstin" is 3.
• 1011101 and 1001001 is 2.
• 2173896 and 2233796 is 3.
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
Central concept :Hamming Distance

• The Hamming distance can easily be found if we apply the


XOR operation (⊕) on the two words and count the
number of 1s in the result.
• Note that the Hamming distance is a value greater than or
equal to zero.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Example 10.2

• Find the Hamming distance between two pairs of


words.
– 1. The Hamming distance d(000, 011) is 2 because (000
⊕ 011) is 011 (two 1s).

– 2. The Hamming distance d(10101, 11110) is 3 because


(10101 ⊕ 11110) is 01011 (three 1s).

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Note

The Hamming distance between two


words is the number of differences
between corresponding bits.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Our scope here is
Linear Block Codes

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Linear block codes

• Linear block codes


– are characterized by segmenting a message into separate blocks
of a fixed length, and encoding each block one at a time for
transmission.
– Linear block codes have the property of linearity, i.e. the sum of
any two codewords is also a code word, and they are applied to
the source bits in blocks, hence the name linear block codes.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Note

In a linear block code, the exclusive OR


(XOR) of any two valid codewords
creates another valid codeword.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Linear Block Codes

• Almost all block codes used today belong to a


subset of block codes called linear block
codes.
• Limitation of Nonlinear Block Codes
– Use of nonlinear block codes for error detection and
correction is not as widespread because their structure
makes theoretical analysis and implementation difficult.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


What are Linear Block Codes used for?

• Used in error correction and detection schemes.

• Allows more efficient encoding and decoding algorithms.

• The elements in the binary linear block codes are called codeword.

• Linear block codes are conceptually simple codes

• An extension of single-bit parity check codes for error detection.

• A single-bit parity check code is one of the most common forms of detecting
transmission errors.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Parity-Check Code

• Most familiar error-detecting code is the parity-check code.

• This code is a linear block code.

• In this code, a k-bit dataword is changed to an n-bit codeword where n =


k + 1. The extra bit, called the parity bit, is selected to make the total
number of 1s in the codeword even.

• Although some implementations specify an odd number of 1s

• we discuss the even case.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Table Simple parity-check code C(5, 4)

Code in Table is also a parity-


check code with k = 4 and n = 5.
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
Minimum Distance Decoding (one important concept)

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Minimum Distance Decoding

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Note

The minimum Hamming distance is the


smallest Hamming distance between
all possible pairs in a set of words.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Example 10.5

Find the minimum Hamming distance of the coding


scheme in Table 10.1.
Solution
We first find all Hamming distances.

The dmin in this case is 2.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Example 10.6

Find the minimum Hamming distance of the coding


scheme in Table 10.2.

Solution
We first find all the Hamming distances.

The dmin in this case is 3.

10.
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
Classification of codes

1. Block codes
– Linear block codes: (n, k, dmin)
• Hamming codes
• Cyclic codes
– Reed-Solomon codes
– BCH codes
– Cyclic Redundancy Check (CRC) codes

– Nonlinear block codes


2. Convolutional codes: (n, k, m)
3. Compound codes
– Concatenated codes (outer code + inner code)
– Product codes
– Punctured convolutional codes
• Rate compatible punctured convolutional (RCPC) codes
– Turbo codes
– Low-density parity-check (LDPC) codes

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Hamming Codes

• Hamming code is a set of error-correction codes that can be used to


detect and correct bit errors that can occur when computer data is
moved or stored. Hamming code is named for R. W. Hamming of Bell
Labs.

• Like other error-correction code, Hamming code makes use of the


concept of parity and parity bits, which are bits that are added to
data so that the validity of the data can be checked when it is read or
after it has been received in a data transmission.

• Using more than one parity bit, an error-correction code can not only
identify a single bit error in the data unit, but also its location in the
data unit
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
• Perhaps the most familiar error-detecting code is
the parity-check code.
• This code is a linear block code.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Encoder and decoder for simple parity-check code

Figure shows a possible structure of an encoder (at the sender) and a


McGraw-Hill decoder (at the receiver).
©The McGraw-Hill Companies, Inc., 2000
Parity-Check Code

• Encoder:
– The encoder uses a generator that takes a copy of a 4-bit
Dataword (a0, a1, a2, and a3) and generates a parity bit r0.

– Dataword bits and the parity bit create the 5-bit codeword.

– Parity bit that is added makes the number of 1s in the codeword


even. This is normally done by adding the 4 bits of the dataword
(modulo-2); the result is the parity bit.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Parity-Check Code

• Note:
– In another words

• If the number of 1s is even, the result is 0


• If the number of 1s is odd, the result is 1.

Note:
McGraw-HillXOR is also called modulo-2 addition ©The McGraw-Hill Companies, Inc., 2000
Parity-Check Code

• Sender:
– The sender sends the codeword, which may be corrupted during
transmission.
• Receiver:
– The receiver receives a 5-bit word.
– The checker at the receiver does the same thing as the generator
in the sender with one exception.The addition is done over all 5
bits.
– The result, which is called the syndrome, is just 1 bit.

Note:
McGraw-HillXOR is also called modulo-2 addition ©The McGraw-Hill Companies, Inc., 2000
Parity-Check Code

• The syndrome is passed to the decision logic


analyzer.
• If the syndrome is 0,
– there is no detectable error in the received codeword;
the data portion of the received codeword is accepted as
the dataword;
• if the syndrome is 1,
– the data portion of the received codeword is discarded.
The dataword is not created.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Note

• Cyclic Redundancy Check (CRC) codes are a special


subset of linear block codes that are very popular in
digital communications. But will be discussed
later……………..

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Firstly Practical Examples
• Three types of redundancy checks are used in the data link layer:
• Vertical redundancy check (VRC) / Parity Check
• Longitudinal redundancy check (LRC)
• Cyclic Redundancy Check (CRC )

• Note:
• In TCP/IP , the checksum
technique is mostly used at the
network and transport layer
McGraw-Hill rather than©the data-link
The McGraw-Hill layer.
Companies, Inc., 2000
Detection methods

• Three types of redundancy checks are used in the data link layer:

• Vertical redundancy check (VRC) / Parity Check

• Longitudinal redundancy check (LRC)

• Cyclic Redundancy Check (CRC )

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


1. Vertical redundancy check (VRC) / Parity Check

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Note:

In vertical redundancy check (VRC), a


parity bit is added to every data unit so
that the total number of 1s becomes
even.
• But actually we have two implementations of VRC
– Odd
– Even

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Odd Parity Checking

• Add a parity bit


• Either a one or a zero is added
– Total number of ones adds an odd number
• Example
– Before parity 0110100
– After parity 01101000

Parity bit

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Even Parity Checking

• Even
– The total number of ones should add up to an
even number
• Example
– Before parity 0101010
– After parity 01010101

Parity bit
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
Error Detection Capability of VRC

• Errors can still escape detection


– When two bits change value in which case VRC
becomes ineffective
• Even parity example
– 11010111 Before transmission
– 10000111 After transmission
– Parity count remains the same
– But, the data has changed as shown by the
coloured digits

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


VERTICAL REDUNDANCY CHECK

• VRC can detect all single – bit errors


• How can we say ………..
– It can detect burst errors if the total number of errors in
each data unit is odd ????
– VRC can not detect errors where the total number of
bits changed is even ????

83
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
Even parity VRC concept

• The most common and least expensive mechanism for error


detection. Often called a parity check.
• In this technique, a redundant bit, called a parity bit, is appended to
every data unit so that the total number of 1s in the unit(including the
parity bit)becomes even.
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
VERTICAL REDUNDANCY CHECK

• VRC is considered an unreliable error-detection


method.
• A vertical redundancy check is also called a
transverse redundancy check when used in
combination with other error-controlling codes such
as a longitudinal redundancy check.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


2. LONGITUDINAL REDUNDANCY CHECK(LRC)

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


2. LONGITUDINAL REDUNDANCY CHECK(LRC)

• LRC verifies the accuracy of stored and transmitted data


using parity bits.

• It is a redundancy check applied to a parallel group of


bit streams.

• The data to be transmitted is divided into transmission


blocks into which additional check data is inserted.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


LONGITUDINAL REDUNDANCY CHECK(LRC)

• In this method , a block of bits is organized in table(rows and columns)

• Calculate the parity bit for each column and the set of this parity bit is
also sending with original data.

• From the block of parity we can check the redundancy.

Rutvi Shah 88
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
LRC

• In Longitudinal redundancy check (LRC),a block of bits is organized in a


table(rows and columns).
• Then calculate the parity bit for each column and create a new row of 8 bits,
which are the parity bits for the whole block.
• First parity bit in the fifth row is calculated based on all first bits , and so on.
• Then attach the 8 parity bits to the original data and send them to the receiver.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Longitudinal Redundancy Checking (LRC)

• LRC was developed to overcome the problem with parity’s


low probability of detection.

• LRC adds one additional character, called the block check


character (BCC) to the end of the entire message or packet of
data.

• The value of the BCC is calculated much like the Parity bit,
but for the entire message. Results in a 98% reliability rate.

90
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
Note:

In longitudinal redundancy check


(LRC), a block of bits is divided into
rows and a redundant row of bits is
added to the whole block.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


LRC Generation

• LRC field is one byte, containing an eight-bit binary value.

• The LRC value is calculated by the transmitting device, which appends


the LRC to the message.

• The receiving device recalculates an LRC during receipt of the


message, and compares the calculated value to the actual value it
received in the LRC field. If the two values are not equal, an error
results.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Difference between VRC and LRC

• Serial communications often use vertical redundancy checking (VRC)


when it adds a parity bit to the transmitted character.

• Longitudinal (or horizontal) redundancy checking adds a parity bit for


all bits in the message at the same bit position.

• Vertical coding operates on a single character and is known as


character error coding.

• Horizontal checks operate on groups of characters and are described


as message coding. LRC always uses even parity.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


3. Cyclic redundancy check (CRC).

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


3.CRC

• Most powerful of the redundancy checking techniques is the cyclic


redundancy check (CRC).

• Unlike VRC and LRC, which are based on addition, CRC is based on
binary division.

• Instead of adding bits together to achieve a desired parity ,a sequence


of redundant bits, called the CRC or the CRC remainder, is
appended to the end of a data unit so that the resulting data unit
becomes exactly divisible by a second, predetermined binary number.

• A remainder indicates that the data unit has been damaged in transit
and therefore must be rejected.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


How is CRC related to networking?

• Transmitter:
– The transmitter has the message M.
– The transmitter and receiver agrees on a common polynomial (P) and data
block size (k) that will be used.
– It calculates F, appends F to M, and puts the whole thing (k+n bits) on the
wire.
• Receiver:
– On receiving the k+n bits, receiver divides them with P.
– If the polynomial based on the received k+n bits is fully divisible by P, then the
receiver is satisfied that there was no error in transmission.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Example _ How is CRC related to networking?

• In this example, we shall encode 6 bits of message with a 3-bit CRC


(We pad with zeroes corresponding to the bit length n of the CRC) ,
with a polynomial having 4 coefficients.
• Let our message be M = 10001000 and the polynomial is P = 1101.
• The steps are:
– Append 'n' 0's to M to get the dividend D = 10001000000
– Divisor is P = 1101……………..(n+1)
– Perform CRC division [D / P] keeping in mind the XOR subtraction

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Revision _ Binary addition and Subtraction

• Example:
• Find 1101011001 - 0010111010 (note the leading zeros)

• Complement the second row and add:


• 1101011001
+ 1101000101
-----------------------------------------
(1) 1010011110

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


CRC encoder and decoder

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Division in CRC encoder

Sender

we simply apply the bit-


wise exclusive-OR
operation repeatedly

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Division in the CRC decoder for two cases

Receiver
(Two possibilities)

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Now theoretical Background regarding CRC

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


10.3 CYCLIC CODES

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


10.3 CYCLIC CODES

• Cyclic codes are special linear block codes with one


extra property.
– In a cyclic code, if a codeword is cyclically shifted
(rotated), the result is another codeword.
– For example,if 1011000 is a codeword and we cyclically
left-shift, then 0110001 is also a codeword.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


10.3.1 Cyclic Redundancy Check

• We can create cyclic codes to correct errors.

• We simply discuss a subset of cyclic codes called the


cyclic redundancy check (CRC), which is used in
networks such as LANs and WANs.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Table _ A CRC code with C(7, 4)
CRC encoder and decoder
CRC encoder and decoder

 Encoder:
 In the encoder, the dataword has k bits (4 here); the codeword has n bits (7
here).
 The size of the dataword is augmented by adding n − k (3 here) 0s to the right-
hand side of the word.
 The n-bit result is fed into the generator.
 The generator uses a divisor of size n − k + 1 (4 here), predefined and agreed
upon.
 The generator divides the augmented dataword by the divisor (modulo-2
division).
 The quotient of the division is discarded;
 The remainder (r2r1r0) is appended to the dataword to create the codeword.
CRC encoder and decoder

 Decoder:
 The decoder receives the codeword (possibly corrupted in
transition).
 A copy of all n bits is fed to the checker, which is a replica of the
generator.
 The remainder produced by the checker is a syndrome of n − k (3
here) bits, which is fed to the decision logic analyzer.
 The analyzer has a simple function.
 If the syndrome bits are all 0s, the 4 leftmost bits of the codeword are
accepted as the dataword (interpreted as no error);
 otherwise, the 4 bits are discarded (error).
Polynomial Codes

• Treat bit strings as representations of polynomials with coefficients 1’s and 0’s.

• K-bit frame is coefficient list of polynomial with k terms (and degree k-1), from
xk-1to x0.
– Highest-order bit is coefficient of xk-1, etc.
– Example: 110001 represents x5 + x4 +x0.

• The power of each term shows the position of the bit; the coefficient shows the
value of the bit.

• Generator polynomial G(x).


– Agreed upon by sender and receiver.

CMPE 150- Introduction to Computer Networks


110
Polynomials

• Figure shows a binary pattern and its polynomial representation.


• Figure (a) shows how to translate a binary pattern into a polynomial
• Figure (b) shows how the polynomial can be shortened by removing all terms with
zero coefficients and replacing x1 by x and x0 by 1.

Figure (b) shows one immediate benefit


A 7-bit pattern can be replaced by three terms
.
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
A polynomial

112
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
A polynomial representing a divisor

113
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
Standard polynomials

The order of a polynomial is the power of the highest non-zero


coefficient

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Note

An error-detecting code can detect


only the types of errors for which it is
designed; other types of errors may
remain undetected.
• Note:
• In TCP/IP , the checksum
technique is mostly used at the
network and transport layer
rather than the data-link layer.
Checksum
• It can be applied to a message of any length.

• The idea is to simply send additional data ( for example the sum) along with the
data. At the destination, the sum is calculated and compared to the one sent.

• Note:
– Several Internet protocols (e.g. IP, TCP, UDP) use check bits to
detect errors in the header
– A checksum is calculated for header contents and included in a
special field.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Checksum
• At the source
– the message is first divided into m-bit units.
– The generator then creates an extra m-bit unit called the
checksum, which is sent with the message.
• At the Destination
– Checker creates a new checksum from the combination of the
message and sent checksum.
– If the new checksum is all 0s, the message is accepted; otherwise,
the message is discarded (Figure
• Note
– in the real implementation, the checksum unit is not necessarily added at the
end of the message; it can be inserted in the middle of the message

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Checksum

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Example 10.11

• Suppose the message is a list of five 4-bit numbers that we want to


send to a destination.

• In addition to sending these numbers, we send the sum of the


numbers.

• Example:
– If the set of numbers is (7, 11, 12, 0, 6), we send (7, 11, 12, 0, 6, 36), where 36
is the sum of the original numbers.
– The receiver adds the five numbers and compares the result with the sum.
– If the two are the same, the receiver assumes no error, accepts the five
numbers, and discards the sum. Otherwise, there is an error somewhere and
the message is not accepted.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Checksum

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Another Implementation of Checksum

• We can make the job of the receiver easier if we


send the negative (complement) of the sum, called
the checksum.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Limitations of Techniques so far

• Error detection and retransmission Techniques have been


discussed.
• But retransmission of corrupted and lost packets is not
useful for real-time multimedia transmission because it
creates an unacceptable delay in reproducing: we need to
wait until the lost or corrupted packet is resent.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Picture abhi baaqi ha ……………

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


A Technique for Error detection and Error
Correction
‘Forward Error Correction (FEC) Techniques”.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Forward Error Correction (FEC) techniques.

• Error detection and retransmission have been discussed so far.

• However, the retransmission of corrupted and lost packets is not


useful for real-time multimedia transmission because it creates an
unacceptable delay in reproducing.

• For such applications, we need to correct the error or reproduce the


packet immediately.

• Several schemes have been designed and used in this case that is
collectively referred to as forward error correction (FEC) techniques.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Forward Error Correction

• FEC means the receiving device can correct incoming messages


itself instead of having them resent.

• To do this, extra corrective information needs to be sent along


with the data that allows the data to be checked and corrected by the
receiver.

• The amount of extra information needed is usually quite a lot (50-


100% of the data).

• This technique is useful for one way transmissions or when


transmission times are very long (as with communications to
spacecraft).
127
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
Forward Error Correction (Figure 4-7)

• One FEC technique, called a Hamming Code


– Extra parity values are calculated so that each data bit figures into two parity bit
calculations.

– That means that if any one bit, either parity or data, gets changed in
transmission, the change in the received data can be detected and corrected .

– This technique only works for one bit errors.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


How it works
• FEC is accomplished by adding redundancy to the
transmitted information using a predetermined
algorithm.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


How it works
• The original information may or may not appear in the encoded output;
codes that include the unmodified input in the output are systematic,
while those that do not are nonsystematic.

• An extremely simple example would be an analog to digital converter that


samples three bits of signal strength data for every bit of transmitted data.
– If the three samples are mostly zero, the transmitted bit was probably a zero
– If three samples are mostly one, the transmitted bit was probably a one.

• The simplest example of error correction is for the receiver to assume the
correct output is given by the most frequently occurring value in each
group of three.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


How it works
• This allows an error in any one of the three samples to be
corrected by "democratic voting".

• Highly inefficient FEC, and in practice would not work very


well, but it does illustrate the principle.

• In practice, FEC codes typically examine the last several dozen,


or even the last several hundred, previously received bits to
determine how to decode the current small handful of bits
(typically in groups of 2 to 8 bits).

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


How it works

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Thanks

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Another Implementation of Checksum

• At the sender
– The unit is divided into k sections, each of n bits.
– All sections are added together using one’s complement to get the sum.
– The sum is complemented and becomes the checksum.
– The checksum is sent with the data

• At the receiver
– The unit is divided into k sections, each of n bits.
– All sections are added together using one’s complement to get the sum.
– The sum is complemented.
– If the result is zero, the data are accepted: otherwise, they are rejected.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Another Implementation of Checksum

• In this case, we
send (7, 11, 12,
0, 6, −36). The
receiver can add
all the numbers
received
(including the
checksum). If the
result is 0, it
assumes no
error; otherwise,
there is an error.
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
• Construct the base 2 representation of the
positive number, by taking all the remainders
starting from the bottom of the list
constructed above:
• 36(10) = 10 0100(2)

10.136
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
• . Divide the number repeatedly by 2, keeping track of each
remainder, until we get a quotient that is equal to zero:
– division = quotient + remainder;
– 36 ÷ 2 = 18 + 0;
– 18 ÷ 2 = 9 + 0;
– 9 ÷ 2 = 4 + 1;
– 4 ÷ 2 = 2 + 0;
– 2 ÷ 2 = 1 + 0;
– 1÷2=0+1

10.137
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

You might also like