html5-img
1 / 36

COM342 Networks and Data Communications

COM342 Networks and Data Communications. Lecture 4: Data Compression, Error Detection and Error Correction. Ian McCrum Room 5B18 Tel: 90 366364 voice mail on 6 th ring Email: IJ.McCrum@Ulster.ac.uk Web site: http://www.eej.ulst.ac.uk. The Encoding and compression of data. Introduction

mahina
Télécharger la présentation

COM342 Networks and Data Communications

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COM342Networks and Data Communications Lecture 4: Data Compression, Error Detection and Error Correction Ian McCrum Room 5B18 Tel: 90 366364 voice mail on 6th ring Email: IJ.McCrum@Ulster.ac.uk Web site: http://www.eej.ulst.ac.uk www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  2. The Encoding and compression of data • Introduction • Information Content of a message stream • simple coding methods • Huffman coding • compression techniques www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  3. REDUNDANCY • Consider that you were in receipt of the following telegram: • RONMIE (ROCKTT) O’SULLIVON 146 CREAK • It is possible due to the inherent redundancy of natural language to perform a reconstruction leading to the message on the next slide. www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  4. REDUNDANCY • Consider that you were in receipt of the following telegram: • RONMIE (ROCKTT) O’SULLIVON 146 CREAK • It is possible due to the inherent redundancy of natural language to perform a reconstruction leading to the message below. • RONNIE (ROCKET) O’SULLIVAN 146 BREAK • but what about the numbers in the message? www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  5. Redundancy • Redundancy arises due to the correlation of letters occurring in natural language, consider the word: • YACH ( if T is sent it will carry no information) • Is it possible for a coding schema to produce an Ideal code? www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  6. Reduction of Redundancy • observe the • Statistical occurrence of symbols • Repetition of symbols • employ • Fano coding, Huffman coding (the most common symbols are given shorter codes) • data compression (e,g code repetition as a special case) www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  7. Packed decimal / half byte compression • When frames just contain numeric characters • use binary coded decimal instead of 7 bit ASCII or 8 bit EBCDIC as only the four least significant bits change with number. • In ASCII “:” and “;” in same column are used as decimal pt and space respectively www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  8. Packed Decimal STX Cntrl XX ‘2’’6’ ‘:’’3’ ‘2’’;’ ‘4’’5’ ETX BCC Closing flag & Block CC 1st number 26.32 Number of digits following Control character half byte compression Opening Flag www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  9. Relative encoding • Whenever only small differences occur between successive values • send only that difference • very effective in data logging • consider level of a river Relative encoding sign, number and delimiter STX ‘+’ ‘1’ ‘¬’ ‘+ ‘ ‘4’ ‘¬’ ETX BCC Relative encoding using signed 8 bit integers STX +3 -95 +11 +124 -100 ETX BCC www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  10. Character suppression • in a stream of digits there are often sequences of the same characters, most frequently spaces. • if a continuous string of three or more chars in a sequence it is replaced by Cntrl,char,number • thus CntrlF25 means 25Fs in a sequence. • type of run-length encoding www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  11. Character suppression STX Cntrl sp 45 ‘A’ ‘B’ ETX BCC Single letters Closing flag & Block CC number of chars Char being suppressed Control character Opening Flag www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  12. Run length encoding • Run-length compression where the codeword actually contains the number of repetitions. • A three byte minimum repetition is chosen such that all occurrences of repetitions greater or equal to 3 will be encoded thus. • <char><char><char><n> • this four byte codeword can represent repetitions up to 259 • <char> <char> • <char><char> <char><char> • <char><char><char> <char><char><char><0> • <char><char><char><char> <char><char><char><1> • <char><char><char><char><char> <char><char><char><2> www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  13. Huffman coding • Instead of representing symbols with a fixed no of bits, fewer bits are used for frequently occurring symbols and vice versa • Method: Determine the relative frequency of symbols. Create an unbalanced tree with unequal branches. www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  14. Example of Huffman • Consider that a group of characters A to H is to be transmitted. This comprises • 9As, 9Bs, 5Cs, 5Ds, 2Es, 2Fs, 2Gs, 2Hs • Sequence of operations. • a) Order the symbols in terms of probability • b) Combine the two least frequently occurring symbols • c) assigning 1(upper) and 0(lower) to each. • d) This is now considered to be one entity. www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  15. Huffman continued • Perform the same steps until only two symbols are left. • Determine the codeword by reading from left to right. The first bit being read is the least significant one. www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  16. www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  17. Comparison • If there were N symbols then N codewords would be sent. In the case of fixed length binary codes this would be represented by 3N bits. • How does this compare with those required by this example of Huffman encoding? www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  18. www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  19. Therefore there has been a saving of 0.28N bits in comparison with fixed length binary each of 3 bits. Redundancy it can shown that the ideal code for this sequence of symbols would take 2.53N bits ie. this is the actual information content of the stream of codewords. Thus for fixed length binary codes the Information content Redundancy = 1 - ------------------------- Number of bits sent or = 1 - 2.53N/3.0N = 16% for Huffman = 1 - 2.53N/2.72N = 7% www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  20. MNP Class 5 Compression • is a combination of Huffman and run-length encoding. • The symbol stream is run-length encoded with a minimum repetition of 3 bytes and then Huffman encoded using a statistically generated table. • During transmission the statistics for the occurrence of each symbol are updated and the allocation of codewords are dynamically changed. • MNP Class 5 compression achieves 2:1 compression on a regular basis. Its major drawback is that cannot turn itself off when it offers no gain, so that an incompressible file actually expands by >10%. www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  21. Error detection and protection • Introduction • Error Detection • recognise that one has happened • Error Correction • repair damaged data • parity and CRC. • BCC and Hamming, www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  22. Data errors • Errors can arise due to attenuation of signal strength and due to other reasons. • well shaped signals can become distorted and thus misinterpreted. • Random errors (each occurs with certain probability) • noise in electronics • distance traveled • Burst errors (groups of bits in error occur) • source interference • faults in equipment www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  23. Error detection • A sequence of bits (I0 … In) is subjected to some processing (P) giving rise to a check sequence (C0…Ck) • Both are transmitted toward a receiver and incur a possibility of corruption. • Upon reception the bit stream is separated into received data (I0r … Inr) and received check sequence (C0r…Ckr). • The received data (I0r … Inr) is assumed to be correct and the same processing (P) is performed on it giving the reconstructed sequence (C0rr...Ckrr). • If received check sequence (C0r…Ckr) and the reconstructed sequence (C0rr...Ckrr) are equal then no detectable error has occurred. www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  24. Parity for ASCII codes • Consider a seven-bit ASCII code to comprise the following bits which can be labeled I6, I5, I4, I3, I2, I1, I0 • A Parity bit P0 is placed beside the most significant bit I6 so that the codeword P0, I6, I5, I4, I3, I2, I1, I0 is formed. • The Parity bit is determined as before so that for Odd parity there are an odd number of 1s in the codeword. • and for Even parity there are an even number of 1s in the codeword. www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  25. Block Sum Check Character P0 I6 I5 I4 I3 I2 I1 I0 1 0 1 1 1 0 1 0 0 1 1 1 1 0 0 1 1 1 0 1 1 1 0 0 0 0 1 0 0 1 1 0 1 1 1 0 1 0 0 1 1 1 1 1 0 1 1 1 0 1 0 1 1 0 0 0 Codeword 1 Codeword 2 Codeword 3 Codeword 4 Codeword 5 Codeword 6 Block Check Char. Hey! See me!! www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  26. Block Sum Check Character • Consider what this method can do: • in terms of detecting errors. • in terms of correcting errors. • Can you see where it might be used in practice? • Where will it cease to work adequately? www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  27. Cyclic Redundancy Check (CRC) • The CRC is so called because the codes fall into a class of cyclic codes each forming new legal code which shifted, when added to a sequence of bits they increase the redundancy of the codeword. • The data sequence is divided by a standard polynomial and the remainder is the check bits or CRC. • Polynomial is of the form • 1.X4 + 0.X3 + 1.X2 + 0.X1 + 1 • more usually written X4 + X2 + 1 • and in binary take the form 10101 www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  28. The arithmetic is different! But easier • In decimal 0..9 and 0..9 means 100 different additions and 21 different answers (0..20) • In binary using a half adder or exclusive OR there are (0 1) and (0 1) meaning 4 different additions and only 2 answers. • Thus 0  0 = 0, 0  1 = 1, 1  0 = 1 and 1  1 = 0 •  being the symbol for exclusive OR. • think of a half adder being an adder without a carry. www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  29. To perform CRC determination • Get data to be protected, ok 11011 • Choose polynomial ok X4 + X2 + 1 • append to data the number of bits indicated by the maximum order of the polynomial (4) giving 110110000 • divide this number by the polynomial thus • 110110000 / 10101 • Take the remainder and send after the original data. • Upon reception check received CRC with reconstructed CRC to determine error conditions. www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  30. Use the polynomial x4 + x2 + 1 to generate CRC 11101 10101 110110000 10101 11100 10101 10010 10101 11100 10101 1001 Thus the remainder is 1001and codeword 110111001 www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  31. Does 111010010 contain an error, generated by using the same polynomial as before. 11000 10101 111010000 10101 10000 10101 10100 10101 010 Thus the remainder is 0010 and codeword 111010010 www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  32. Or divide rx data and crc by generating polynomial and remainder should be zero 11010 10101 111010010 10101 10000 10101 10101 10101 000 Thus the remainder is 000 and codeword 11101 was rx ok! www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  33. Hamming Codes 11 10 9 8 7 6 5 4 3 2 1position in codeword I6 I5 I4 C3 I3 I2 I1C2 I0C1C0information and checks Given an ASCII code 1001010 what is the Hamming Code? 11 10 9 8 7 6 5 4 3 2 1 I6 I5 I4C3 I3 I2 I1C2 I0 C1C0 1 0 0 x 1 0 1 x 0xx www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  34. How to determine the values of C3C2C1&C0 C3C2 C1C0 11 1 0 1 1 7 0 1 1 1 5 0 1 0 1 1 0 0 1 I6 I5 I4C3 I3 I2 I1C2 I0 C1C0 1 0 0 1 1 0 1 0 001 www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  35. How does this detect an error? I6 I5 I4C3 I3 I2 I1C2 I0 C1C0 1 0 0 1 1 1 1 0 001 Bit in error C3C2 C1C0 11 1 0 1 1 8 1 0 0 0 7 0 1 1 1 6 0 1 1 0 5 0 1 0 1 1 0 0 0 1 0 1 1 0 Therefore 6th bit was received in error www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

  36. Summary • Hamming codes have their redundant bits in the positions which are powers of 2 ie 1,2,4,8 etc • They can detect and correct single errors. • They can indicate multiple error conditions but cannot correct. • Used for random errors. • Can you think of how they might be applied to a circumstance a burst error could occur? Assume that the burst is shorter that 8 bits and there are 256 bytes to be transmitted. www.eej.ulster.ac.uk/~ian/modules/COM342/COM342_L4.ppt

More Related