05 directnets errors

  • 171 views
Uploaded on

 

More in: Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
171
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
2
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • to transmit a message M(x) that is n bits long, P(x) is sent n -bit message plus k redundant bits make P(x) exactly divisible by C(x) If no errors during transmission receiver should be able to divide P(x) by C(x) exactly, leaving a remainder of zero if error received polynomial will no longer be exactly divisible by C(x) Implication: an error has occurred.
  • this algorithm scores well for using a small number of redundant bits—only 16 for a message of any length—but it does not score extremely well for strength of error detection. For example, a pair of single-bit errors, one of which increments a word, one of which decrements another word by the same amount, will go undetected. The reason for using an algorithm like this in spite of its relatively weak protection against errors (compared to a CRC, for example) is simple: This algorithm is much easier to implement in software. Experience in the ARPANET suggested that a checksum of this form was adequate. One reason it is adequate is that this checksum is the last line of defense in an end-to-end protocol; the majority of errors are picked up by stronger error detection algorithms, such as CRCs, at the link level.

Transcript

  • 1. Direct Link Networks: Error Detection Sections 2.4 1
  • 2. Outline• Error Detection – Cyclic Redundancy Check (2.4.3) – Internet Checksum Algorithm (2.4.2)• Reliable Transmission – Stop-and Wait (2.5.1) – Sliding Window Algorithm (2.5.2) – (will not cover implementation pp. (109-115) 2
  • 3. Error Detection• Errors are unavoidable – Electrical interference, thermal noise, etc.• Techniques for detecting errors – Cyclic Redundancy Check (CRC) – Checksum – Parity checking ( Section 2.4.1: will not cover in class) 3
  • 4. Cyclic Redundancy Check(CRC)• Generation of CRC and using it to detect errors makes use of Polynomial Arithmetic Modulo 2 4
  • 5. Polynomial Arithmetic• A polynomial is an expression of the form anxn + an-1xn-1 + ...... + a1x + a0x0 where the coefficients a0, a1, ...., an are drawn from some designated set S. S is called the coefficient set.• When an an ≠ 0, we have a polynomial of degree n.• Polynomial arithmetic deals with the addition, subtraction, multiplication, and division of polynomials. 5
  • 6. Polynomial Arithmetic Modulo 2:Overview• A special class of polynomial arithmetic• Coefficient set ={1, 0}• Operations on coefficients performed using modulo 2 arithmetic• Key properties (accept on faith) 1. Any polynomial B(x) can be divided by a divisor polynomial C(x) if B(x) is of higher degree than C(x) 2. Any polynomial B(x) can be divided once by a divisor polynomial C(x) if B(x) is of the same degree as C(x) 6
  • 7. Polynomial Arithmetic Modulo 2,Properties (cont.)3. The remainder obtained when B(x) is divided by C(x) is obtained by subtracting C(x) from B(x)4. To subtract C(x) from B(x) perform XOR on each pair of matching coefficients 7
  • 8. Polynomial Arithmetic Modulo 2,Example• B(x) = x3 + 1 can be divided by C(x) = x3 + x2 + 1 because they are both of degree 3 • remainder:  subtract C(x) from B(x) {XOR each pair of matching coefficients}  0 × x3 + 1 × x2 + 0 × x1 + 0 × x0 = x2• Phrased differently: 1001 can be divided by 1101 and leaves a remainder of 0100 8
  • 9. Cyclic Redundancy Check• Add k redundant bits to an n-bit message – want k << n – e.g. on an Ethernet a CRC-32 code is used • k = 32 and n = 12,000 (1500 bytes); ( .27% overhead )• Represent n-bit message as n-1 degree polynomial – e.g., 8-bit message, MSG=1001 1010 as M(x) = x7 + x4 + x3 + x1• Using polynomial arithmetic modulo 2, let k be the degree of some divisor polynomial – e.g., C(x) = x3 + x2 + 1; i.e. 1101 9
  • 10. CRC (cont)• Transmit polynomial P(x) that is evenly divisible by C(x) – Shift left message k bits, i.e., T(x) = M(x)xk {T(x) is called the zero extended message} – Divide T(x) by C(x) and find remainder – Subtract remainder from T(x) P(x) • P(x) is divisible exactly by C(x) • P(x) is M(x) followed by remainder• Think of the received polynomial as P(x) + E(x) – E(x) = 0 implies no errors – Divide (received polynomial, P(x) + E(x)) by C(x); remainder zero if: • E(x) was zero (no error), or • E(x) is exactly divisible by C(x) • Pick C(x) so that this is very unlikely for common types of errors 10 ??
  • 11. Figure 2.20 CRC calculation using polynomial long division • MSG= 1001 1010 ; M(x) = x7 + x4 + x3 + x1 • C(x) = x3 + x2 + 1; 1101 • k = the degree of the divisor , C(X) = 3 • T(x) = 1001 1010 000 11111001 Zero Extended Generator 1101 10011010000 Message 1101 1001 1101 1000 1101 1011 1101 1100 1101 1000 1101 101 Remainder • CRC = Remainder = 101 11 • Transmit P(x) = 1001 1010 101
  • 12. CRC – Example Decoding – NoErrors MSG = 1001 1010 C(x) = x3 + x2 + 1 = 1101 Generator P(x) = x10 + x7 + x6 + x4 + x2 + 1 = 10011010101 Received Message 1101 10011010101 Received 1101 message, no k + 1 bit check 1001 errors sequence c, 1101 equivalent to a 1000 degree-k 1101 Result: polynomial 1011 1101 CRC test is passed 1100 1101 1101 Remainder 1101 m mod c 0 12
  • 13. CRC – Example Decoding –with Errors MSG = 1001 1010 C(x) = x3 + x2 + 1 = 1101 Generator P(x) = x10 + x7 + x5 + x4 + x2 + 1 = 10010110101 Received Message 1101 10010110101 Received 1101 message k + 1 bit check 1000 Two bit errors sequence c, 1101 equivalent to a 1011 degree-k 1101 Result: polynomial 1101 1101 CRC test failed 0101 Remainder m mod c 13
  • 14. Selecting C(x)Sender and receiver agree on a divisor polynomial, C(x)• In practice, look C(x) up in a book• Choice of C(x) has a significant impact on what types of errors can be detected• A handful of divisor polynomials are very good choices for various environments• Exact choice: part of the protocol design• Ethernet standard uses a well-known polynomial of degree 32 14
  • 15. Common Polynomials for C(x)CRC C(x)CRC-8 x8 + x2 + x1 + 1CRC-10 x10 + x9 + x5 + x4 + x1 + 1CRC-12 x12 + x11 + x3 + x2 + x1 + 1CRC-16 x16 + x15 + x2 + 1CRC-CCITT x16 + x12 + x5 + 1CRC-32 x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x1 + 1 15
  • 16. Selecting C(x) (cont.)• The following types of errors can be detected by a C(x) with the stated properties: – All single-bit errors, as long as the xk and x0 terms have non-zero coefficients {proof p. 99). – All double-bit errors, as long as C(x) contains a factor with at least three terms – Any odd number of errors, as long as C(x) contains the factor (x + 1) – Any ‘burst’ error (i.e., sequence of consecutive error bits) for which the length of the burst is less than k bits. – Most burst errors of larger than k bits can also be detected 16
  • 17. Zero Extended Message x0 x 1 XOR gate x2 Figure 2.21 CRC algorithm implemented in hardware using a 3-bit shift register and XOR gates (This figure is for for the generator x3 + x2 + x0 )•# bits = k = 3•bits in register labeled 0 through k-1, left to right•XOR in front of bit n if there is a term xn in the generator polynomial•zero extended message shifted in from the left, beginning with mostsignificant bit•register will contain the CRC ( most significant bit on the right) 17
  • 18. Internet Checksum Algorithm (used in IP, UDP and TCP)• View message as a sequence of 16-bit integers (words)• Compute a sum of all the 16-bit words, with no carries, produce the sum• Transmit the data & the sum (checksum)• Receiver performs calculation on received data• Compares result with received checksum• If transmitted data (or transmitted checksum) is corrupted – result of receiver calculation will not match received checksum 18 • error
  • 19. Internet Checksum Example• Internet Checksum – Use 1’s complement addition on 16bit codewords – Example • Codewords: -5 -3 • 1’s complement binary: 1010 1100 • 1’s complement sum 1000• Comments – Small number of redundant bits – Easy to implement – Not very robust 19
  • 20. Internet Checksum Algorithm • produce the sum using 16-bit ones-complement arithmetic; take ones-complement of the result to get the checksum. u_short cksum(u_short *buf, int count) { register u_long sum = 0; while (count--)•routine assumes buf {already padded with 0s to sum += *buf++; if (sum & 0xFFFF0000)a 16-bit boundary { /* carry occurred, so wrap around */•count = the length of buf sum &= 0xFFFF; sum++;( in 16-bit units ) } } return ~(sum & 0xFFFF); } 20
  • 21. Error Correction• Some error codes can be used to detect and correct most errors – Overhead is too high• Some errors can not be corrected 21
  • 22. Error Detection vs. ErrorCorrection• Detection – Pro: Overhead (i.e. retransmission) only on messages with errors – Con: Cost in bandwidth and latency for retransmissions• Correction – Pro: Quick recovery – Con: Overhead on all messages• What should we use? – Correction if retransmission is too expensive – Correction if probability of errors is high 22