chapter 7 data coding. agenda coding code efficiency and conversion compression/compaction code...

25
Chapter 7 Data Coding

Upload: candace-clarke

Post on 27-Dec-2015

233 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Chapter 7

Data Coding

Page 2: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Agenda

• Coding

• Code efficiency and conversion

• Compression/compaction

• Code encryption/decryption

Page 3: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Coding

• Definition– A predetermined set of symbols having specific

meanings

• Types– Human code

• Morse code (dot and dash for telegraph)

– Machine code• Binary states• Binary digit (bit)

Page 4: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Machine Codes - I

• Characteristics– Two-state code– Same number of bits– Perfectly formed– Same transmission duration

• Character Assignment: unique sequence of bits

Page 5: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Machine Codes - II

• Types of characters– Alphanumeric– Format effector for terminal screen or paper – Control (device & transmission)

Page 6: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Parity checking

• Parity bit

• Even or odd

Page 7: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Escape mechanisms

• Escape or ESC Character

• Pro:– Increase codes

• Con:– Code and decode the data

Page 8: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Specific Codes

• Baudot code

• American Standard Code for Information Interchange (ASCII)

• Extended Binary Coded Decimal Interchange Code (EBCDIC)

• Unicode

• Binary Coded Decimal

• N-out-of-M code

Page 9: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Baudot Code

• 5 bits (32 code points)

• ESC mechanism– Figure shift (uppercase)– Letter shift (lowercase)

• Teletypewriters before 1965

• No error checking

Page 10: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

American Standard Code for Information Interchange (ASCII)

• By American National Standards Institute (ANSI)

• 7654321 (7-bit or 128 characters)

• Pros:– Easy sorting by computers – Used by microcomputers

Page 11: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Extended binary Coded Decimal Interchange Code (EBCDIC)

• 8-bit code or 256 characters

• IBM mainframe computers

• 01234567

Page 12: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Unicode

• 16-bit or 65,536 characters

• By Unicode Consortium for international languages

• Used by Windows NT

Page 13: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Other Codes

• Binary Coded Decimal– 6-bit code Hollerith code– No standard

• N-Out-Of-M Codes– M bits to transmit each character, n must be 1s– Error Detection– IBM’s 4-out-of-8

Page 14: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Control Characters

• Transmission control characters– SOH, STX, ETX, EOT, ACK, NAK, NUL

• Device control characters– BEL, DC1 (X-ON), DC3 (X-OFF)

• Format effect control characters– CR, LF, HT, VT

Page 15: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Code Efficiency

• Types of bits in a character– Information bits– Noninformation bits (parity bit)

• Definition: No. of information bits divided by the total no. of bits in a character

Page 16: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Code Conversion

• Harder from larger no. of bits code to smaller no. of bits code

• Use ESC mechanism

Page 17: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Data Compression/Compaction

• Types– Character compression/Huffman coding or adaptive

Huffman coding (bits assignment)

– Run length coding (repetitive characters)

– Character stripping (heading & trailing characters)

– Combination of the above three

• Consideration– throughput

– Storage and transmission cost

– Hardware cost & software cost

Page 18: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Code Encryption• Voice

– Scramble and descramble

• Data– Symmetric key

• Data encryption standard (DES) by National Institute of Standard and Technology (2 to 56)

• Triple DES (2 to 112)• Key security

– Asymmetric key or RSA encryption– Public key & private key

• Consideration– Hardware and/or software cost– Time delay– Security management cost

Page 19: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Example of Encryption - I

• Divide text into groups of 8 characters. Pad with blank at end as necessary

• Select an 8-characters key• Rearrange text by interchanging adjacent

characters• Translate each character into an ordinal number

with blank as 0, A as 1, B as 2…• Add the ordinal number of the key to the results• Divide the total by 27 and retain the remainder• Translate the remainder back into a character to

yield the cipher text

Page 20: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Example of Encryption - II

• Message: DATA COM

• Key: PROTOCOL

• A D A T C M O

• 01 04 01 20 03 00 13 15

• 01 04 01 20 03 00 13 15

• 16 18 15 20 15 03 15 12

• 17 22 16 40 18 03 28 27

• 17 22 16 13 18 03 01 00

• Q V P M R C A SPACE

Page 21: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Example of Decryption - I

• Divide cipher text into groups of eight characters. Pad with blanks at end as necessary

• Translate each cipher text alphabetic character and the encryption key into an ordinal number

• For each group, subtract the ordinal number of the key value from the ordinal number of the cipher text

• Add 27 to any negative number• Translate the number back to alphabetic

equivalents• Rearrange the text by interchanging adjacent

characters

Page 22: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Example of Decryption - II

• Q V P M R C A SPACE

• 17 22 16 13 18 03 01 00

• 17 22 16 13 18 03 01 00

• 16 18 15 20 15 03 15 12

• 01 04 01 -7 01 00 -14 -12

• plus 27 27 27 27

• 01 04 01 20 01 00 13 15

• A D A T C M O

• D A T A C O M

Page 23: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Points to Remember

• Coding

• Code efficiency and conversion

• Compression/compaction

• Code encryption/decryption

Page 24: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Discussion

• Design the efficient and secure coding system for an international company

Page 25: Chapter 7 Data Coding. Agenda Coding Code efficiency and conversion Compression/compaction Code encryption/decryption

Assignment

• Review chapters 1-7

• Read chapters 8-9