Binary Codes

advertisement
Chapter 17 Information Science
Binary Codes
Encoding with Parity-Check Sums
Data Compression
Cryptography
Web Searches & Logic
Spring 2015
Mathematics in
Management Science
Can You Raed Tihs?
“I cnduo’t bvleiee taht I culod aulaclty uesdtannrd
waht I was rdnaieg. Unisg the icndeblire pweor of the
hmuan mnid, aocdcrnig to rseecrah at Cmabrigde
Uinervtisy, it dseno’t mttaer in waht oderr the lterets
in a wrod are, the olny irpoamtnt tihng is taht the frsit
and lsat ltteer be in the rhgit pclae. The rset can be a
taotl mses and you can sitll raed it whoutit a pboerlm.
Tihs is bucseae the huamn mnid deos not raed ervey
ltteer by istlef, but the wrod as a wlohe. Aaznmig,
huh? Yaeh and I awlyas tghhuot slelinpg was
ipmorantt! See if yuor fdreins can raed tihs too.”
Binary Codes
Bits, Bytes, & Strings
Parity, ASCII Code
Error Detection &
Correction
Spring 2015
Mathematics in
Management Science
Error Detection & Correction
Data can be corrupted during its
transmission due to human error,
distortion, noise, etc.
Some applications require that errors
be detected and corrected.
Exs: CDs, DVDs, TV signal, phone
signal, wifi signal, etc.
Bits, Bytes, & Binary Strings
A binary number is a number written in
base 2, so its digits are all either 0 or 1.
A single binary digit (a 0 or a 1) is a bit.
A byte is a group of binary digits or bits
(usually eight) operated on as a unit;
bytes are considered as a unit of
memory size.
A binary string (or word) is a list of bits.
Bits & Binary Strings
When a binary string is transmitted,
one or more of its bits may be
incorrectly received.
If a single bit is known to be incorrect,
then the receiver knows what the
correct bit should be, right?
Single bit errors can always be
corrected. In a single-bit error, only 1
bit in the data has changed.
Single Bit Error
To detect or correct errors, we need to send
extra (redundant) bits with the data.
Binary Codes
A system for coding data made up of
two states (or symbols); “0” or “1”.
Postnet code, UPC code, Morse code,
Braille, etc.
DVDs, Blu Ray, faxes, high defn TVs,
cell phones, all use binary codes with
data represented as strings of 0’s and
1’s instead of usual digits 0 through 9
and letters A through Z.
ASCII
Code
American
Standard
Code for
Information
Interchange
Error Detection
Bits can be flipped in transmission.
Sender may transmit 1101001, and
receiver gets the string 0101011.
Adding redundancy allows detection,
and possibly correction, of some errors
of this type.
Simple approach: Repeat each bit
Error Detection
Simple approach: Repeat bits.
Repeat each bit twice. For x, transmit xx. If
receiver gets two different bits, it requests
retransmission. This allows one error to be
detected, but it is not error-correcting, since
retransmission is necessary.
Repeat each bit three times. For each bit x,
transmit xxx. Now the receiver can correct a
single error. (How?)
Parity
A bit string has odd parity if the number
of 1s in the string is odd. A bit string
has even parity if the number of 1s in
the string is even.
01100, 000, 11001001 – even parity.
1000011, 1, 00010 – odd parity.
Parity Check Code
Append parity bit b chosen so that new
word has even parity.
If w = 10110, we send
wb = 101101
which has even parity.
Parity Check Code
If there are an even number of bit flip errors
in transmission, the receiver gets a bit string
with even parity, and the error(s) go
undetected.
If there are an odd number of bit flip errors
in transmission, the receiver gets a bit string
with odd parity, indicating an error occurred.
The receiver requests retransmission.
Error Correcting Code
A method of encoding data with
sufficient redundancy to allow the
recovery of data in the face of (a limited
number of) errors.
Messages are encoded by appending
extra digits, determined by parity (even
or odd sums) of certain portions of the
messages.
Example
To encode 4 bits, we use 7 bits with
parity-check sums.
Want to send a1a2a3a4. Will append
parity check-sum digits c1c2c3 .
The check-sum digits c1c2c3 are
determined as follows.
Write digits a1a2a3a4 inside circles as
pictured.
a1
c1
c2
a3
a2
a4
c3
Example
Sending a1a2a3a4. Write a1a2a3a4
inside circles as pictured.
The parity check-sum digits c1c2c3 are
chosen so that inside each circle the
sum has even parity; so, want an even
number of ones inside each circle 
To send 0110
Append ???
0
?
?
1
1
0
?
To send 0110
Append 010
Transmit
0110010
0
0
1
1
1
0
0
To send 1010
Append 001
Transmit
1010001
1
0
0
1
0
0
1
Error Correction
Suppose code received is 0111010.
Transmission error? How to correct?
The black circle is ok—it has even parity sum.
But, the two blue circles have incorrect parity.
We assume at worst one bit error.
The error lies inside
both the blue circles.
But outside the black
circle.
So, the digit a4=1 is
incorrect—it should
be a 0.
0
0
1
1
1
1
0
Error Correction
Code word received was 0111010.
Should have been
0110010.
Code word received is 1101110.
Two blue circles have incorrect parity.
We assume at worst one bit error.
The error lies inside
both blue circles and
outside black circle.
Digit a1 should be 0.
Correct code is 0101110.
1
1
1
0
1
1
0
Reliable Data Transmission
How to decode?
a1
c1
c2
a3
a2
a4
c3
a1
c1
c2
a3
a2
a4
c3
a1
c1
c2
a3
a2
a4
c3
Download