1 / 59

A few more things about binary numbers

Learn about errors in binary numbers, including flipped bits, error detection and correction, error-checking protocols, bit error rate, parity, checksum, and catching errors.

henryflores
Download Presentation

A few more things about binary numbers

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. A few more things about binary numbers

  2. Errors • Recall that using a binary representation maximizes our tolerance of fluctuations without loss of the information represented. • Still errors occur. They have fall into two categories: • Errors that cannot be interpreted as a 1 or 0 • Flipped bits: interpreting a 1 where a 0 should be and vice versa.

  3. Error Detection and Correction • One may worry about errors wherever data is held temporarily, stored semi-permanently or transmitted. • The discovery that a bit or bits were flipped is known as error detection. • The restoration of the correct data is known as error correction.

  4. Error-checking protocols • Data being transmitted by a modem is chunked into "blocks" of a certain byte size and sent to the destination modem. • The destination modem checks each block for errors and returns • ACK if no errors are found • NAK if errors are found, which leads to a retransmission. • The kind of checking (checksum or cyclic redundancy checking) varies from protocol to protocol.

  5. BER • The bit error rate (BER) is the ratio of bits having errors (opposite of the value they are supposed to have 01 or 10) to the total number of bits sent • It is often expressed as ten to a negative power. • For example, a BER of 10-6, means that on average, for every million bits sent, one error occurs.

  6. BER (Cont.) • The BER indicates how often a packet has to be resent. • Sometimes increasing the data transmission rate also increases the BER, making it actually beneficial to reduce the transmission rate so that fewer packets need to be resent. • A BERT (bit error rate test or tester) is a procedure or device that measures the BER.

  7. Error Detection (Cont.) • Error detection schemes involve transmitting additional information which the receiver can use to validate the data. • Error detection can inform the receiver of the presence of an error but cannot fix the error, the packet must be resent. • Error correction schemes (which are distinct) attempt to pinpoint the flipped bit.

  8. Parity • Parity is a simple error detection scheme. • One chooses ahead of time on the type of parity to be used (even or odd). Let us assume even. • Then one takes a string of binary data and calculates whether the number of 1’s in the string is even or odd.

  9. Parity (Cont.) • The transmitter includes an extra bit • 0 if the number of data-bit 1’s is even • 1 if the number of data-bits 1’s is odd • The string consisting of the data plus parity bit is now guaranteed to have an even number of 1’s. • When the data is going to be used or received in the case of transmission, one checks that the data plus parity bit have even parity (an even number of 1’s). • If the data now has odd parity, some error must have occurred. • But we do not know which bit was flipped (detection not correction).

  10. Even Parity (Cont.) D – data P – parity

  11. Parity (Cont.) • (You may read that the number of 1’s is counted, this is not true and is unnecessarily complicated.) • A multi-input XOR (excluded OR) gate will determine the parity bit, this circuitry is much simpler than what is required for counting the number of 1’s.

  12. 2-input XOR Truth Table

  13. 3-input XOR Truth Table

  14. Parity (Cont.) • Parity can be used when data is moved around within computers as well as when data is sent from computer to computer. • Modems use parity. Users may also select no parity, meaning that the modems will not include the parity bit. Sending fewer bits speeds up transmission.

  15. Parity Setting for Modem

  16. Choose the Modems Tab and then the Properties button

  17. Choose the Advanced Tab and click the Change Default Preferences button

  18. Choose the Advanced Tab

  19. Modem Parity Choices

  20. Checksum • A checksum is another error-detection scheme often used in transmission. • The transmission string of data bits is broken up into units, for instance consisting of 16 bits each. • These 16-bit numbers are then added. • The sum is sent along as part of the frame’s trailer field. • The receiver repeats the calculation. If the sums match, it's assumed that no transmission error occurred.

  21. Checksum (Cont.) • Actually instead of including the sum in the trailer, one can transmit instead its negative. • The receiver then repeats the sum over the data and includes in that summation the negative of the sum sent in the trailer. • The result should be zero. It is easier to test for a result of all zeros (an multi-input OR gate).

  22. Catching errors • Since the 16-bit string might end up in any of 216 (65536) possible states, you might assume that the checksum would catch errors 65535/65536  99.9985% of the time. • But this would assume that all possible errors are equally likely, which is not true.

  23. IP Datagram Protocol

  24. TCP Segment Protocol

  25. Burst errors • For multi-bit errors, it is more likely that a group of consecutive bits are affected as opposed to randomly selected bits, such an error is known as a burst error. • It is also common for periodic errors to occur (e.g. the first two bits in every byte).

  26. CRC • Cyclic Redundancy Check is better at catching burst errors than checksums. • The idea is the same, perform some mathematical operation on the data, send the result, have the receiver do the same calculation and check that the same answer is obtained.

  27. CRC (Cont.) • CRC is somewhat like division • If one thinks of the data as a large number, one can divide it by another number N giving a whole number answer and a remainder • The remainder could be any number between 0 and N-1. • The problem here is that division is a fairly difficult computation (more circuitry and a slow process).

  28. CRC (Cont.) • CRC uses a variation on division that while mathematically abstract is very simple to build a circuit for. • The circuitry needs only a shift register and some (2-input) XOR gates.

  29. Shift Register • A register is a small piece of memory that holds values. • In addition to holding values, a shift register performs a simple operation on the values; it moves them to the left to to the right.

  30. Shift Register time Output Shift register Input

  31. How shift registers are used? • Multiplication • Adding floats • Converting Parallel Data (the form inside the computer) to Serial (the form sent over transmission lines) • Cyclic Redundancy check (CRC)

  32. CRC (Cont.) • Again the 16-bit string might end up in any of 216 (65536) possible states, so you might expect that CRC would catch errors 65535/65536  99.9985% of the time same as a 16-bit checksum. • But CRC is better at detecting burst errors which are more likely than purely random errors. • The positions of the XORs are important in determining what kinds of burst errors are detected.

  33. CRC: Transmission Only • The data must be serializedfor a Cyclic Redundancy Check. • This is fine for transmission error checking since the data was serialized for transmission. • However, serializing the data would waste a lot of time if the data were in a parallel form (as it is inside the computer).

  34. CRC = Shift register + XORs Basically one has a shift register with a few excluded OR gates inserted in strategic positions.

  35. Ethernet Frame Protocol Ethernet uses CRC because at that low level the data is serialized. The higher levels in the stack (e.g. IP and TCP) used checksums.

  36. XOR Truth Table Reminder in CRC Context

  37.  0 0 0 0 11000001010   0 0 0 1 1000001010   1 0 0 1 000001010   1 0 1 0 00001010

  38.  0001010 0 1 1 0   0 0 0 1 001010   1 0 0 0 01010   0 0 1 0 1010

  39.  0 1 0 1 010   1 1 0 1 10   1 1 1 0 0   0 0 1 1

  40. Hamming Code • Hamming code extends the idea of parity. It can be used as either as • An extended error detection scheme • Parity will discover if an odd number of bits have been flipped. Hamming code can be used to detect two-bit errors. • Or an error correction scheme • If a single bit error is assumed, Hamming code can locate the offending bit.

  41. Hamming code (Cont.) • Hamming code breaks the bit string into a few overlapping groups. • By overlapping here we mean that a given bit can belong to more than one group. But each bit should belong to a unique set of groups. That’s how the bit is located. • One generates a parity bit for each group. • On checking for errors, one identifies which groups violate parity. From these one can locate the bit in error.

  42. Hamming code (Cont.) • The set of data and parity bits are numbered such that the parity bits correspond to numbers which are powers of 2: 1, 2, 4, 8 etc. • Recall in binary the powers of 2 consist of one 1 and the rest 0’s. • 1: 0001 • 2: 0010 • 4: 0100 • 8: 1000

  43. Hamming code (Cont.) • The groups: • Any bit whose count in binary has a 1 in the 1’s position belongs to the first group. • Any bit whose count in binary has a 1 in the 2’s position belongs to the second group. • Any bit whose count in binary has a 1 in the 4’s position belongs to the third group. • Etc.

  44. Groups for Hamming code Parity bits Data bits

  45. Groups for Hamming code

  46. Locating the offending bit • Let us assume that in a case having four data bits and three parity bits that parity errors were found in check groups 1 and 3. • We look for the bit that belongs to groups 1 and 3 and does not belong to group 2. • If it belongs to group 1, it has a 1 in the 1’s position. • If it does not belong to group 2, it has a 0 in the 2’s position. • If it belongs to group 3, it has a 1 in the 4’s position. • It must be 5.

  47. Locating the offending bit 101  5

  48. Note that each row represents a different set of data.

  49. Now reverse the situation! Neither row violates even parity for the first group.

More Related