An Error occurs when the information received by
the receiver does not match with the sender’s
    information.
   During transmission, digital signals suffer from
    noise that can introduce errors in the binary bits
    travelling from sender to receiver.
   That means a 0 bit may change to 1 or a 1 bit may
    change to 0.
   The various types of errors are:
                https://www.faceprep.in/computer-networks/computer-networks-error-detection/
a) Single bit error
b) Multiple bit error
c) Burst error
                        https://www.faceprep.in/computer-networks/computer-networks-error-detection/
https://www.youtube.com/watch?v=EMrY-8m8D1E
Error detection techniques                  Error Correction
                                            techniques
1. Simple Parity check                      Hamming Code
2. Two-dimensional Parity
   check
                                             ARQ (retransmission of loss
3. Checksum                                  packets)
4. Cyclic redundancy
   check
             https://www.faceprep.in/computer-networks/computer-networks-error-detection/
   Error detecting codes are either implemented at the data link layer or
    transport layer of OSI model.
   Whenever a message is transmitted, it may get scrambled by noise or
    data may get corrupted.
   To avoid this, we use error-detecting codes which are additional data
    added to a given digital message to help us detect if an error has
    occurred during transmission of the message.
Basic approach used for error detection is the use of redundancy bits,
where additional bits are added to facilitate detection of errors.
   Some popular techniques for error detection are:
   1.   Simple Parity check
   2.   Two-dimensional Parity check
   3.   Checksum
   4.   Cyclic redundancy check
                     https://www.faceprep.in/computer-networks/computer-networks-error-detection/
1. Simple Parity check: Blocks of data from the source are subjected to a
check bit or parity bit generator form, where a parity of :
     1 is added to the block if it contains an odd number of 1’s, and
     0 is added if it contains an even number of 1’s
This scheme makes the total number of 1’s even, that is why it is called
even parity checking.
                       https://www.geeksforgeeks.org/error-detection-in-computer-networks/
2. Two-dimensional Parity check
Parity check bits are calculated for each row, which is equivalent
to a simple parity check bit. Parity check bits are also calculated
for all columns, then both are sent along with the data. At the
receiving end these are compared with the parity bits calculated
on the received data..
                      https://www.geeksforgeeks.org/error-detection-in-computer-networks/
2. Checksum
 In checksum error detection scheme, the data is
  divided into k segments each of m bits.
 In the sender’s end the segments are added using
  1’s complement arithmetic to get the sum. The sum
  is complemented to get the checksum.
 The checksum segment is sent along with the data
  segments.
 At the receiver’s end, all received segments are
  added using 1’s complement arithmetic to get the
  sum. The sum is complemented.
 If the result is zero, the received data is accepted;
  otherwise discarded.
                  https://www.geeksforgeeks.org/error-detection-in-computer-networks/
Sender Side
Receiver Side
     https://www.youtube.com/watch?v=AtVWnyDDaDI
3. Checksum
              https://www.geeksforgeeks.org/error-detection-in-computer-networks/
0   +   0   =   0
0   +   1   =   1
1   +   0   =   1
1   +   1   =   10 (which is 0 carry 1)
4. Cyclic redundancy check (CRC)
• Unlike checksum scheme, which is based on
  addition, CRC is based on binary division.
• In CRC, a sequence of redundant bits, called cyclic
  redundancy check bits, are appended to the end of
  data unit so that the resulting data unit becomes
  exactly divisible by a second, predetermined binary
  number.
• At the destination, the incoming data unit is divided
  by the same number. If at this step there is no
  remainder, the data unit is assumed to be correct
  and is therefore accepted.
• A remainder indicates that the data unit has been
  damaged in transit and therefore must be rejected.
                https://www.geeksforgeeks.org/error-detection-in-computer-networks/
https://www.youtube.com/watch?v=A9g6rTMblz4
4. Cyclic redundancy check (CRC)
                 https://www.geeksforgeeks.org/error-detection-in-computer-networks/
Find the CRC of Data Block 100100 with the divisor 1101 ?
               Sender                            Receiver
                              https://www.youtube.com/watch?v=A9g6rTMblz4
   Message Bits = M
                               Total Bits = M + R
   Redundant Bits = R
             M                                M
                                                    Y
                                                        Correct
                                                        (Y/N)?
          Encode /    R Bits
                                          Extractor /
          Generator                        Checker
                                                             N
               M+R
                                                        Discard
   Hamming codes are linear block codes
   It is an error correcting codes
   Parity bits are used here
   They are inserted in between the data bits
   The most commonly used is 7-bit hamming
    code
   Structure (7-bit Hamming code)
              7       6      5        4         3        2      1
              D4     D3      D2       P3       D1       P2      P1
                                      22                 21      20
      D – Data Bit
                     P – Parity Bit            2m = 0,1,2,3,….
                                          https://www.youtube.com/watch?v=QSiuqhb7sw8
https://www.youtube.com/watch?v=m2dFjkZVlVw
            7      6     5      4        3        2      1
           D4      D3    D2    P3       D1      P2       P1
          111      110   101   100      011      010     001
P1 - > (1,3,5,7)         These bits are adjusted to 0 or
                         1 depending upon the
P2 - > (2,3,6,7)         condition
P3 - > (4,5,6,7)
                               https://www.youtube.com/watch?v=QSiuqhb7sw8
   Problem: A bit word 1011 is to be
    transmitted. Construct even parity 7-bit
    hamming code.
           7   6        5      4            3        2   1
       D4      D3      D2     P3    D1             P2    P1
       1       0       1                1
    P1 - > (1,3,5,7)        P1, 1,1,1           P1 = 1
    P2 - > (2,3,6,7)        P2, 1,0,1           P2 = 0
    P3 - > (4,5,6,7)        P3, 1,0,1           P3 = 0
                            Hamming Code             1010101
                                        https://www.youtube.com/watch?v=JeFT_XA-ryY
   Problem: A bit word 1010 is to be
    transmitted. Construct even parity 7-bit
    hamming code.
           7   6        5      4            3        2   1
       D4      D3      D2     P3    D1             P2    P1
       1       0       1                0
    P1 - > (1,3,5,7)        P1, 0,1,1           P1 = 0
    P2 - > (2,3,6,7)        P2, 0,0,1           P2 = 1
    P3 - > (4,5,6,7)        P3, 1,0,1           P3 = 0
                            Hamming Code             1010010
                                        https://www.youtube.com/watch?v=JeFT_XA-ryY
   Problem: Code received =1011011. Assume even
    parity. State whether received code is correct or
    wrong. If wrong, locate the bit in error.
           7   6        5         4       3         2     1
       D4      D3      D2     P3      D1       P2       P1
       1       0       1      1       0         1       1
    P1 - > (1,3,5,7)        (1,0,1,1) – Odd (Error)           Error Word P3, P2, P1
    P2 - > (2,3,6,7)        (1,0,0,1) - Even                  Error Word       1, 0, 1
    P3 - > (4,5,6,7)        (1,1,0,1) – Odd (Error)           Error Word      (5)
                                                              Error is in 5th bit
                             Correct Code           1001011
                                              https://www.youtube.com/watch?v=JeFT_XA-ryY
   Problem: A bit word 1101 is to be
    transmitted. Construct even parity 7-bit
    hamming code.
           7   6        5      4            3        2   1
       D4      D3      D2     P3    D1             P2    P1
       1       1       0                1
                                                                              4th
                                                                        1100110
    P1 - > (1,3,5,7)        P1, 1,0,1           P1 = 0
                                                                                    Error
    P2 - > (2,3,6,7)        P2, 1,1,1           P2 = 1
                                                                        1101110
    P3 - > (4,5,6,7)        P3, 0,1,1           P3 = 0
                            Hamming Code             1100110
                                        https://www.youtube.com/watch?v=JeFT_XA-ryY
   Problem: Code received =1101110. Assume even
    parity. State whether received code is correct or
    wrong. If wrong, locate the bit in error.
           7   6        5         4       3         2     1
       D4      D3      D2     P3      D1       P2       P1
       1       1       0      1       1         1       0
    P1 - > (1,3,5,7)        (0,1,0,1) – Even                  Error Word P3, P2, P1
    P2 - > (2,3,6,7)        (1,1,1,1) - Even                  Error Word       1, 0, 0
    P3 - > (4,5,6,7)        (1,1,0,1) – Odd (Error)           Error Word      (4)
                                                              Error is in 4th bit
                             Correct Code           1100110
                                              https://www.youtube.com/watch?v=JeFT_XA-ryY