Advertisement
xdxdxd123

Untitled

Dec 15th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.59 KB | None | 0 0
  1.  
  2. Parity Check
  3.  
  4. Date: 11/12/2000 at 11:55:33
  5. From: hf2186
  6. Subject: The Parity Check
  7.  
  8. What is a parity check, and how does it work?
  9.  
  10. Date: 11/14/2000 at 11:28:32
  11. From: Doctor TWE
  12. Subject: Re: The Parity Check
  13.  
  14. Hi - thanks for writing to Dr. Math.
  15.  
  16. Parity is a means of detecting errors in binary transmission streams.
  17. It is based on sending redundant data to verify the integrity of the
  18. received data. It is not foolproof.
  19.  
  20. To use a parity check, at the transmission end the data are divided
  21. into groups of bits (typically 7 or 8 bits per group). For each group
  22. a parity bit is generated and sent along with the data group. At the
  23. receiving end, another parity bit is generated based on the received
  24. data and compared with the parity bit sent by the transmitter. If the
  25. parity bits match, the data are considered (probably) valid, but if
  26. the parity bits do not match, an error has occurred during
  27. transmission.
  28.  
  29. There are two "types" of parity checks that can be used; even parity
  30. and odd parity. The transmitter and receiver must use the same method
  31. for the check to work properly.
  32.  
  33. With even parity, the total number of 1's in the data plus parity bit
  34. must be an even number. Thus, if there are already an even number of
  35. 1's in the data itself the parity bit generated is 0, but if there are
  36. an odd number of 1's in the data itself, the parity bit generated is 1
  37. to make the total even. For example (using 7 data bits, P is the
  38. parity bit generated):
  39.  
  40. EVEN PARITY
  41. Data #1's in data P Total # 1's (data and P)
  42. ------- ------------ - --------------------
  43. 0110110 4 (Even) 0 4 (Even)
  44. 0011111 5 (Odd) 1 6 (Even)
  45. 0000000 0 (Even) 0 0 (Even)
  46. 1010100 3 (Odd) 1 4 (Even)
  47. 1111111 7 (Odd) 1 8 (Even)
  48.  
  49. With odd parity, the total number of 1's in the data plus parity bit
  50. must be an odd number. Thus, if there are already an odd number of 1's
  51. in the data itself the parity bit generated is 0, but if there are an
  52. even number of 1's in the data itself, the parity bit generated is 1
  53. to make the total odd. For example (using 7 data bits, P is the parity
  54. bit generated):
  55.  
  56. ODD PARITY
  57. Data #1's in data P Total # 1's (data and P)
  58. ------- ------------ - --------------------
  59. 0110110 4 (Even) 1 5 (Odd)
  60. 0011111 5 (Odd) 0 5 (Odd)
  61. 0000000 0 (Even) 1 1 (Odd)
  62. 1010100 3 (Odd) 0 3 (Odd)
  63. 1111111 7 (Odd) 0 7 (Odd)
  64.  
  65. If a single bit is switched during transmission, a parity check will
  66. catch it, and we know the data are bad. We can't tell, however, which
  67. bit was switched. For example, suppose 0110110 is sent using odd
  68. parity, and the second bit from the left is switched:
  69.  
  70. Data sent: 0110110
  71. #1's in data: 4 (Even)
  72. Parity bit: 1
  73. Tl. # 1's: 5 (Odd)
  74.  
  75. Data received: 0010110 (Note the changed bit)
  76. #1's in data: 3 (Odd)
  77. Parity bit: 0
  78. Tl. # 1's: 3 (Odd)
  79.  
  80. Comparing the two parity bits, we can see that there was an error.
  81. However, we don't know which bit was switched. Any of the following
  82. data could have produced the received result with only a single bit
  83. change:
  84.  
  85. 1010110
  86. 0110110
  87. 0000110
  88. 0011110
  89. 0010010
  90. 0010100
  91. 0010111
  92.  
  93. We have no way of knowing which of the above were the original data.
  94.  
  95. As mentioned at the beginning, parity is not foolproof. For example,
  96. suppose 0110110 is sent using odd parity, and the second and fourth
  97. bits from the left are both switched:
  98.  
  99. Data sent: 0110110
  100. #1's in data: 4 (Even)
  101. Parity bit: 1
  102. Tl. # 1's: 5 (Odd)
  103.  
  104. Data received: 0011110 (Note the changed bits)
  105. #1's in data: 4 (Even)
  106. Parity bit: 1
  107. Tl. # 1's: 5 (Odd)
  108.  
  109. Here, the parity bit generated by the receiver matches the parity bit
  110. sent by the transmitter, so the data are assumed to be valid even
  111. though an error has occurred. In fact, any time two bits (or any even
  112. number of bits) are switched, the parity check is fooled.
  113.  
  114. There are other error detection (and even correction) schemes, many of
  115. which are more reliable than a simple parity check. Some examples are
  116. vertical parity, HVP (horizontal and vertical parity), checksums, and
  117. CRC (circular redundancy check.) Many of these, however, are built on
  118. the principles of parity.
  119.  
  120. I hope this helps. If you have any more questions, write back.
  121.  
  122. - Doctor TWE, The Math Forum
  123. http://mathforum.org/dr.math/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement