Title: Error Detection
1Error Detection Correction
2Why Errors Occur
- Errors in transmitted data can occur for a
variety of reasons. - Some errors are due to equipment failure.
- Some errors are due dispersion in optical fibers
(i.e. light pulses spread out). - Some errors are due to attenuation (loss of
signal power over a line). - Most errors are due to thermal noise that occurs
naturally on the line.
3Equipment Failure
- Equipment can fail at any time.
- Equipment can fail because of a power cut,
because of physical damage or the equipment can
be shut off for maintenance. - The equipment may simply wear out.
- In solid state electronics, equipment is
extremely unlikely to wear out but it can be
effected by radiation and thermal noise.
4Dealing with Equipment Failure
- More more pieces of equipment that your signal
needs to pass through, the more likely it is that
youll have a failure. - Fewer intermediate devices or more reliable
devices will reduce the probability of failure. - Redundant devices can also reduce the probability
of failure by taking over from other devices when
they fail.
Transmitter
Receiver
Modem
Switch
Switch
Modem
5Dispersion
- Dispersion mainly occurs in optical fibers.
- A light pulse is made of billions of photons.
Each photon follows a slightly different path as
it bounces along the optical fiber. - A crisp light pulse will eventually spread out
and overlap with other pulses.
6Dealing with Dispersion
- Thinner optical fibers reduces the length of the
path that photons have to travel. - Making the pulses in a special shape has been
discovered to cancel out the effects of
dispersion. - Called solitons,these pulses canbe sent
forthousands ofkilometers.
7Attenuation
- Attenuation is the reduction in the power of a
signal as it is transmitted. - Attenuation is measured in decibels (dB) and is
given by the formula - For example, f we receive only half the original
signal power then the attenuation will be 10
log10(2) 3 dB.
8Problem with Attenuation
- Attenuation is a problem because the signal
eventually loses so much power that it becomes
difficult to distinguish it from the thermal
noise in the background. - The ratio of the power of received signal power
to noise power is called the signal-to-noise
ratio. This is usually converted to decibels
using the formula
9Signal-to-Noise Ratio
- Suppose the signal-to-noise ratio is 1001, in
decibels this is 10 log10(100/1)20dB. - The signal-to-noise ratio of a channel determines
the maximum number of bits that can be sent over
it every second (Shannons equation) - Where H is the bandwidth of the channel.
10Using Shannons Equation
- Suppose we are transmitting data down an analogue
telephone connection. - We know that the bandwidth of a telephone line is
3400 - 300 Hz 3100 Hz. - If the signal to noise ratio is 20dB then
S/N100/1. - Using Shannons equation we find that the maximum
bit rate is 3100.log2(1100/1) 20640 bits/sec.
11Where Shannon can be Used
- Shannons equation is very important in data
communications because it tells us that maximum
bit rate of any type of channel. - It does not matter how what kind of modulation,
how many signal levels or what baud rate we use,
Shannons equation tells us that upper limit of
the bit rate. - Even if we transmit at less than this rate, bits
can still be damaged by noise.
12Dealing With Errors
- We need to build systems that are resilient to
errors in data. - There is no way to guarantee that all bits will
be sent uncorrupted. - One way to cope with this is to detect errors and
request that corrupted data should be
retransmitted. - Detecting errors cannot be guaranteed either. We
can at least make it extremely unlikely that
errors will go undetected.
13Errors in Data
- Data is sent in the form of binary numbers.
- The binary numbers consist bites - which are
either 0 or 1. - There are four possible ways that noise can
effect a bit - If a bit is 0, the noise can effect it so it
stays 0 - If a bit is 0, the noise can change it to 1
- If a bit is 1, the noise can effect it so it
stays 1 - if a bit is 1, the noise can change it to 0
14Pure Noise
- If the noise is overwhelming then (with some
surprise perhaps) we will still receive half the
bits correctly. - The problem is that there is no way of telling
which bits are correct and which bits are not. - The data is no better than if we generated the
bits randomly.
15Detecting Errors
- Usually, noise levels are fairly low and most of
the bits are received correctly by the receiver. - The question is, how can the receiver know when
an error has occurred? - Because errors occur randomly, there is no way of
knowing with complete certainty if the data is
correct. - The best we can do is detect most errors.
16Detecting Errors
- We could try sending the data twice and comparing
the two transmissions to see where the errors
are. - This is inefficient, particularly if all we want
to know is if there is an error in a particular
block of data (yes or no?). - Even when we detect an error, the next question
is what to do about it?
17Parity Checking
- One of the most common ways of checking to see if
an error is to count the bits in a character to
see if there is an even or odd number. - Before transmission, an extra bit is appended to
the character to force the number of bits to be
even (or odd). - If the received character does not have an ever
(or odd) number of bits then an error must have
occurred.
18Parity
- Both the sender and receiver must know which form
of parity to use. - A character such as 0110001 would be transmitted
as - Parity checking will detect a single error in a
character but not double errors.
Odd Parity 01100010 (There are an odd
number of 1s)
Even Parity 01100011 (There are an even
number of 1s)
19Hamming Distance
- The Hamming distance between two bit patterns is
the number of dissimilar bits. - For example, the Hamming distance between
01000001 (A) and 01000011 (C) is 1 because
there is only one dissimilar bit. - One error in the wrong place can turn an A into
a C.
20Hamming Distance
- The Hamming distance between 01000001 (A) and
01000010 (B) is 2 because there are two
dissimilar bits. - It would take two errors in the wrong place to
turn an A into a B. - Adding a parity bit ensures that there is at
least a Hamming distance of 2 between any two
code words.
21Block Parity Check
- The idea of parity checking can be extended into
two dimensions. In addition to a parity bit
being appended to each character, a parity byte
can be sent (containing the parity of the
columns).
Parity Bit
Byte 1 0 1 1 0 1 1 0 1 2 1 0 1 0 1 1 1
0 3 0 1 1 1 0 1 0 1 4 1 1 1 0 0
0 1 1 5 0 0 0 1 0 1 1 0 Parity byte 1 0
1 1 1 1 0 0
22Block Parity
- Should one of the bits in the block of data
become corrupted, the parity for one column and
one row will be wrong. - We can use this to reveal where the error is and
even occasionally correct it.
Byte 1 0 1 1 0 1 1 0 1 2 1 1 1 0 1 1 1
0 3 0 1 1 1 0 1 0 1 4 1 1 1 0 0
0 1 1 5 0 0 0 1 0 1 1 0 Parity byte 1 0
1 1 1 1 0 0
23Checksum
- Another simple way of checking if there has been
an error in a block of data is to find a
checksum. - Imagine we send the data 121, 17, 29 and 47.
Adding these numbers up, we get 214. - We actually send 121,17,29,47 and 214.
- The receiver can total up the first numbers and
compare it to the last one. - A difference means an error has occurred.
24Checksums
- Typically pairs of bytes are joined to make 16
bit numbers. It is these 16 bit numbers that are
totaled to make the checksum. - If the checksum becomes larger than 65535 (the
largest possible 16 bit number) then the carried
bits are discarded. - Checksums are common but not particularly good at
catching errors. Later errors can easily hide
earlier ones.
25Cyclic Redundancy Code (CRC)
- A far more effective way of detecting errors in a
block of data is to use a Cyclic Redundancy Code. - The block of data is regarded as one very large
binary number. - We divide this number by a prime polynomial using
modulo 2 division. - The remainder from this division is the Cyclic
Redundancy Code.
26Cyclic Redundancy Code
- The first step is to find a polynomial of order m
where m is the number of bits in our code. This
is called the generator polynomial G(x).
27Cyclic Redundancy Code
- Imagine that our block of data forms the number
00110001. From this we would form the
polynomial - Next we multiply this polynomial by xm
- Now we must divide f(x) by G(x) using modulo 2
division.
28Finding a Cyclic Redundancy Code
29Modulo 2 division
- Note that at each stage, the coefficient of each
xk is either 0 or 1. - One number is NOT subtracted from another but the
coefficients are XORed instead. - We ignore the quotient because it is the
remainder we are interested in (x 7 x 6 x 4
x 2 x 1). We then use the coefficients to
make a binary number 11010111.
30Efficiency of CRCs
- If you examine the modulo 2 division closely, you
will see it comes down to a series of shifts and
XORs of binary numbers. - This can be implemented very efficiently in
hardware. - Typically the CRC is appended to the end of the
block of bits so that when the check is performed
by the receiver, the division will have remainder
0 if there are no errors.
31Standard CRCs
- The CCITT standard for CRC is a 16-bit CRC which
uses the polynomialx 16 x 12 x 5 1 for the
generator polynomial G(x). - This polynomial is used by most protocols with
cyclic redundancy checking. It will detect all
burst errors of 16-bits or less and will detect
99.998 of all 18-bit and longer burst errors.
It will also detect all errors with an odd number
of bit alterations.
32Another Example
33Hamming Codes
- We have already seen how we can correct an error
using Block Parity Checking. - A more sophisticated method of correcting errors
is to use Hamming Codes. - Hamming codes ensure that any two code words are
at least a Hamming distance of d apart. - This means that d errors are required to turn one
Hamming Code into another.
34Detecting Errors in Hamming Codes
- If it takes d errors to turn one Hamming Code
into another, then this means that we can detect
up to d-1 errors. - Further more, it means that we can correct up to
? (d-1)/2 ? errors by changing the distorted code
to the nearest legal code. - Adding a single parity bit only makes the
distance between code words 2 at most (not enough
to correct errors since ?(2-1)/2?0 ).
35Creating Hamming Codes
- The extra parity bits are just added to the
number to make the Hamming Code. - Each legal code is at a distance of 2 from any
other legal code word so we can correct a single
error using these codes. - If we are clever, we can arrange the parity bits
to actually tell us the location of any errors.
36Positioning Parity Bits
- Call the left most bit, bit1 and the next bit
bit2 etc.. - Bit1 will be the parity bit for all the odd bits
in the code word bits 1,3,5 and 7 - Bit2 will be the parity bit for bits 2,3,6
and 7 - Bit4 will be the parity bit for bits4,5,6 and
7 - The data will be in bits3,5,6 and 7
37Detecting Errors in Hamming Codes
- Each parity bit is checked to see if it has the
correct parity for its group. - The sum of those parity bits with incorrect
parities identifies the position of the erroneous
bit. - For example, the number 1100 would be encoded as
0111100. - If bit5 is corrupted, then the parity bits 1
and 4 will become wrong. (145).
38Encoding 7-bit ASCII characters
- We can encode a 7-bit ASCII character using an
11-bit Hamming Code as follows - bit 1 is the parity for bits 1,3,5,7,9,11
- bit 2 is the parity for bits 2,3,6,7,10,11
- bit 4 is the parity bit bits 4,5,6,7
- bit 8 is the parity bit bit 8,9,10,11
- the data is in bits 3,5,6,7,9,10,11
- Sending characters in this way allows single
errors to be corrected.
39Dealing with Burst Errors
- Errors often occur in short bursts. Hamming
codes can only deal with single errors but there
is a trick to allow them to deal with burst
errors. - A sequence of k consecutive code words can be
arrange as a matrix (one code word to each row). - Rather than transmitting the data a row at a
time, the data can be transmitted a column at a
time.
40Dealing with Burst Errors
- When received, the matrix is reconstructed. Any
burst errors are likely to effect only one column
(effecting only one bit per row).
41Length of Burst Errors
- Sending Hamming codes in this way means that if
there are k rows then a burst error of up to k
bits in length can be corrected. - For example, say we had 8 rows. A burst error
that changes 8 bits in succession will only
effect one bit in each of the 8 rows. - Since each row is a Hamming code capable of
correcting a single bit, all 8 bits will be
corrected.
42Slipping
- Another source of errors occurs because of
slipping. - Slipping is when the receiver missing the
beginning or the end of a block of data. - The result is that the receiver is confused about
where the beginnings and the ends of the blocks
of data occur and it may take some time to get
back on track.
43Character Frames
DLE
STX
Data (N characters)
ETX
DLE
DLEData Link Escape STXStart of TeXt ETXEnd of
TeXt
- Recall that when frames are transmitted, there
are special characters at the beginning of each
frame. - If a frame slips, the receiver can get back on
track very quickly by looking for the bit pattern
of DLE STX. - The receiver will know when a frame is finished
when it comes across DLE ETX bit pattern.
44Character Stuffing
- The only problem with this approach is what to do
when we want to transmit a DLE character within
the data. - The solution is simple, whenever a DLE appears in
the data, it must always be escaped with another
DLE. - Whenever the receiver sees DLE DLE, it reduces to
one DLE.
45Bit Stuffing
- A problem with character stuffing is that it is
closely tied in with 8-bit characters. - Many protocols are designed to work independent
of character size. - Instead of starting and ending the data with DLE
STX and DLE ETX, each frame starts and ends with
the bit pattern 01111110. - But what do we do if the pattern 01111110 occurs
in our data?
46.Bit Stuffing
- Whenever more than five 1s are transmitted in a
row, it is followed by a 0. - This means that the pattern 01111110 will be
transmitted as 011111010 - The receiver, when it comes across five 1s and a
0 simply changes it back to five 1s.
47Practical Work
When frames comprising just numeric characters
are being transmitted significant savings can be
obtained via the technique of Half Byte
compression. How is data compression achieved
with this particular technique? The
technique exploits the redundancy found among the
symbolic representation of numeric data under
ASCII or EBCDIC. For numeric data in ASCII the
three high-order bits are all 011 (The four
high-order bits for these data elements under
EBCDIC are always 1111). In acknowledging the
redundancy in the high-order bits Half-Byte
compression strives to send two digits per byte,
each occupying only four bits. EG. Adopting
EBCDIC representation 1. Digit values to be
transmitted 2 1
9
8 2. Uncompressed bit values 11110010 111
10001 11111001 11111000 3. Compressed
data Control byte 0010 0001 1001
1000 (to signify Compression )