Lesson Plan 3
Lesson Plan 3
curriculum
F3
CS
MR CHIRINDA
FOCUS: UNDERSTANDING ERROR CHECKING METHODS
Success criteria
Keywords: Parity,checksum
VIDEO
The need to check for errors
• Parity checking is one method used to check whether data has been
changed or corrupted following data transmission. This method is
based on the number of 1-bits in a byte of data.
• The parity can be either called EVEN (that is, an even number of 1-bits
in the byte) or ODD (that is, an odd number of 1-bits in the byte). One
of the bits in the byte (usually the most significant bit or left-most bit)
is reserved for a parity bit. The parity bit is set according to whether
the parity being used is even or odd. For example, consider the byte:
• In this example, if the byte is using even parity, then the parity bit
needs to be set to 0, since there is already an even number of 1-bits
in the byte (four 1-bits). We thus get
• In this example, if the byte is using odd parity, then the parity bit
needs to be set to 1, since we need to have an odd number of 1-bits
in the byte. We thus get
• Before data is transferred, an agreement is made between sender and
receiver regarding which type of parity is being used. Parity checks are
therefore being used as a type of transmission protocol
Activity
• If a byte has been transmitted from ‘A’ to ‘B’, and if even parity is
used, an error would be flagged if the byte now had an odd number
of 1-bits at the receiver’s end. For example (assuming even parity is
being used)
• In this case, the byte received has three 1-bits, which means it now
has odd parity; while the sender’s byte was using even parity (four 1-
bits). This means an error has occurred during the transmission of the
byte. The error is detected by the recipient’s computer re-calculating
the parity of the byte sent. If even parity had been agreed between
sender and receiver, then a change in parity in the received byte
indicates that a transmission error has occurred.
• If two of the bits change value following data transmission, it may be
impossible to locate the error using parity checking.
• Let us imagine we are transmitting the following byte, using even
parity
• Suppose more than one bit has been modified during data
transmission. This means the byte could have reached the destination
as any of the following
• In all these cases, the byte has clearly been corrupted, but the bytes
have retained even parity. Therefore, no error would be flagged in
spite of the obvious errors in transmission. Clearly it will be necessary
to have other ways to complement parity when it comes to error
checking to ensure errors are never missed. One such method is
called checksum .
• You should have concluded that any of the bits in question 2 (Activity
2.5) could have been changed where there was a transmission error.
Therefore, even though an error has been flagged, it is impossible to
know exactly which bit is in error.
• One of the ways round this problem is to use parity blocks. In this
method, a block of data is sent and the number of 1-bits are totalled
horizontally and vertically (in other words, a parity check is done in
both horizontal and vertical directions). As the following example
shows, this method not only identifies that an error has occurred but
also indicates where the error is
Example 1