Outline, Lecture 6 Kevin Fall kfall@cs.berkeley.edu Jean Walrand wlr@eecs.berkeley.edu Error Control Overview : n ARQ vs. FEC n Link vs. End-to-End : n Objectives n How Codes Work Code Examples: n Parity n CRC - Fall & Walrand 166 Error Control Overview Errors occur due to noise or interference on a communication channel Two strategies to control errors: n Error detection + retransmission (ARQ) n Error correcting codes (Forward Error Correction) Most networks use ARQ Error Control Overview Where are Codes Used? Used on storage media (magnetic tape, CDs, etc) Common examples n Parity bits n Cyclic redundancy check (CRC) n Internet checksum (we will look briefly at block codes) - Fall & Walrand 167 - Fall & Walrand 168 Link vs. End-to-end ARQ FEC: Forward Error Correction ARQ: Automatic Repeat Request # data ED Network Seq # ACK ED data EC - Fall & Walrand 169 Network - Fall & Walrand 170
Comparison: ARQ FEC Longer delays More extra bits - Fall & Walrand 171 Tradeoff: Efficiency vs. Delay n FEC requires more extra bits than ARQ n FEC has smaller delays than ARQ Example n PER = 1%, RTT = 40ms, R = 1Mbps n FEC = % extra bits w FEC = about 90% efficient, delay = 20ms n ARQ = 2% extra bits (e.g.) w ARQ = about 99% efficient, delay = 20ms (99%) or 60ms (1%) - Fall & Walrand 172 Question: Should every link perform ARQ? n Link ARQ: n End-to-End ARQ: - Fall & Walrand 173 - Fall & Walrand 174 Two Extreme Cases. Case (1): Noisy Links Case (2): Reliable Links Link ARQ is faster than E-2-E ARQ when there are many errors - Fall & Walrand 175 Link ARQ is slower than E-2-E ARQ when there are few errors - Fall & Walrand 176
Objectives How Codes Work Objectives Codes to correct for errors in channel (versus source coding--compression) Benefits due to these phenomena n Redundancy n Noise averaging (over long time spans) Types of codes n block codes, tree codes - Fall & Walrand 177 - Fall & Walrand 178 y z How Codes Work: and Codewords x Code = subset of possible words: Codewords Example: n 3 bits => 8 words; codewords: subset 0 xyz = 1 1 1 1 :, 0, 0, 1 1, 1, 0, 1 Code:, 1, 1, 0 Send only codewords 0 - Fall & Walrand 0 179 How Codes Work: Code = all words No protection If we use all words: no error protection Sent Channel Error - Fall & Walrand 180 How Codes Work: Few Codewords Protection How Codes Work: Distance Few codewords: error protection Channel Error (2) (1) Sent Distance d = minimum Hamming distance between any two codewords Hamming distance = number of bits where two words differ. E.g., d(0, 1) = 2, d(1, 1) = 3. Codewords Error Detection: is not a codeword Error Correction: Find codeword closest to - Fall & Walrand 181 d = 1 d = 2 d = 3 - Fall & Walrand 182
How Codes Work: Protection Power Code with distance d n Error detection of up to d 1 bit errors n Error correction of up to d/2 bit errors Good Codes; Coding/Decoding Polynomial Codes Convolutional Codes Detected, not corrected d = 5 Detected and corrected - Fall & Walrand 183 - Fall & Walrand 184 Good Code; Coding/Decoding Good Code: n Large Distance; Easy to Encode and Decode n Efficient: Few extra bits Coding/Decoding: Sourceword CODING Codeword CHANNEL Word Decoded Word DECODING - Fall & Walrand 185 Coding/Decoding: Example Parity Bit Code separates the transmitted words 1 DECODING CODING 0 1 1 Sourcewords 0 0 - Fall & Walrand 186 1 others error Coding/Decoding: Example Parity Bit CODING Sourcewords 1 1 0 Sent Codewords Rate of code: 2/3 (2 source bits for 3 transmitted bits) CHANNEL 1 1 0 other DECODING error Decoded - Fall & Walrand 187 Coding/Decoding: Example Replication 0 1 CODING 1 Sourcewords Sent Codewords Rate of code: 1/3 (1 source bits for 3 transmitted bits) CHANNEL 1 0 0 1 1 1 0 DECODING 1 Closest codeword - Fall & Walrand 188 0 1 Decoded
CRC: Cyclic Redundancy Code M = [ 0] C = [..01] Extra bits = CRC bits CRC bits (r bits) calculated from M so that C = A*G where Message (sourceword) Codeword G = given r+1 bit word (e.g., 11) = generator of code (standardized) * = operations modulo 2 without carry - Fall & Walrand 189 CRC: Cyclic Redundancy Code: Calculation 7 6 5 4 3 2 1 0 M = = x 7 + x 4 + x 3 + x 1 2 1 0 R = 1 7 6 5 4 3 2 1 0 [MR] = 1 = M*x 3 + R G = = x 3 + x 2 + 1 M*x 3 = = x + x 7 + x 6 + x 4 Find A and R (3 bits) so that M*x 3 = A*G + R Then [MR] = M*x 3 + R = A*G + R + R = A*G - Fall & Walrand 190 CRC: Cyclic Redundancy Code: Calculation M = G = Find A and R (3 bits) so that M*x 3 = A*G + R Long division of M*x 3 by G [Operations mod2, no carry] 1 1 1 - Fall & Walrand 191 G M*x 3 CRC: Cyclic Redundancy Code: G(x) G(x) is standardized to be small but typically produce remainders. Detects: n all single bit errors n all double-bit errors if G(x) has a factor with at least 3 terms n any odd number of errors, if (x+1) divides G(x) n any burst error of length < len of FCS n most large burst errors - Fall & Walrand 192 CRC: Cyclic Redundancy Code: Standard G CRC-8: CRC-: 01 CRC-12: 1 (text is wrong) CRC-16: 1 CRC-CCITT: 1 CRC-32: 1 Internet Used in IP, ICMP, TCP, UDP, Alg: 1 s complement of the 1 s complement sum of data interpreted 16 bits at a time. In 1 s comp., two zeros! 1 s complement addition is end-roundcarry addition. Why? n 2 s complement carry is a zero-crossing; account for -0 by adding one - Fall & Walrand 193 - Fall & Walrand 194
Internet Examples Message: e3 4f 23 96 44 27 99 f3 2 s comp sum is: 1e4ff 1 s comp sum is: e4ff + 1 = e5 So, Internet cksum is 1aff Note that message + cksum = ffff Thus, cksum(msg+cksum) = 0 Internet: Incremental Updates Possible to determine new cksum without touching all data only need sum of areas being changed (from and to) Why useful? [for small changes] n Network Address Translation (NAT) n IP forwarding (TTL decrement) - Fall & Walrand 195 - Fall & Walrand 196