You are on page 1of 52

DATA COMMUNICATION AND COMPUTER NETWORKS

(EIE418)

Prof. E. Adetiba (Ph.D, R.Engr.(COREN))


Department of Electrical & Information Engineering,
College of Engineering, Covenant University, Ota,
Ogun State, Nigeria.
MODULE 3

Module 3: Channel Coding and Error Control


3.1 Transmission Error
• Signals travel through transmission media
(channels), which are not perfect and this
imperfection causes signal impairment(error). This
means that what is sent is not what is received.
• The three sources of transmission impairment
(error) are attenuation, distortion and noise.
• Attenuation means a loss of energy. When a signal
travels through a transmission medium (channel),
it loses some of its energy in overcoming the
resistance of the medium(Fig. 3.1). Some of the
electrical energy in the signal is converted to heat.
Fig. 3.1: Attenuation of Signal

• Distortion means change in the signal’s form or shape.


Distortion can occur in a composite signal made of
different frequencies. Signal components at the
receiver have phases different from what they had at
the sender. Thus, the shape of the composite signal is
not the same at the sender and receiver(see Fig. 3.2).
Transmission Medium

Transmitter Receiver

Fig. 3.2: Distortion of Signal

• Noise is another cause of transmission


impairment which include thermal
noise, induced noise, crosstalk and
impulse noise.
• Thermal noise: this is the random motion of
electrons in a wire, which creates an extra
signal not originally sent by the transmitter.
• Induced noise: this comes from sources such
as motors and appliances. These devices act
as a sending antenna and the transmission
medium acts as the receiving antenna.
• Crosstalk: this is the effect of one wire on the
other. One wire acts as a sending antenna
and the other as the receiving antenna.
• Impulse noise: is a spike (a signal with high energy in
a very short time) that comes from power lines or
lightning. Noise

Transmitted Received signal


signal

Transmission medium

Transmitted signal Noise Received signal

Fig. 3.3: Noise Leading to Signal Impairment (error)


3.1.1 Types of Error
i) Single-bit error: This implies that only 1 bit
of a given data unit (such as a byte,
character, or packet) is changed from 1 to
0 or from 0 to 1.

ii) Burst error: This is a type of error in


which 2 or more bits in the data unit have
changed from 1 to 0 or from 0 to 1.
Fig. 3.4: Single-bit Error

Fig. 3.5: Burst Error


• In data transmission, a burst error is
more likely to occur than a single-bit
error because the duration of the noise
signal is normally longer than the
duration of 1 bit.
• The number of bits affected depends on
the data rate and duration of noise.
• Error control involves the detection and
correction of error. The correction of
errors is more difficult than the
detection.
• In error detection, an Engineer is interested
in knowing if any error has occurred, not in
the number of corrupted bits. Error
detection gives a simple yes or no and a
single-bit error is the same for us as a burst
error.
• However in error correction, we need to
know the exact number of bits that are
corrupted and more importantly, their
location in the message. The number of
errors and the size of the message are
important factors.
3.2 Channel Coding
• Channel coding is the art of adding redundancy
to a message in order to make it more robust
against noise.
• It is used because noise and errors are
essentially unavoidable in systems such as
wireless communications and magnetic
storage.
• Coding allows one to trade-off rate for
reliability and usually provides large gains in
overall system efficiency.
Fig. 3.6: Block Diagram of Digital Communication
• Redundancy is achieved through various
coding schemes. The sender adds redundant
bits through a process that creates a
relationship between the redundant bits and
the actual data bits.
• The receiver checks the relationships
between the two sets of bits to detect
errors.
• The ratio of redundant bits to data bits and
the robustness of the process are important
factors in any coding scheme.
• Channel coding schemes are divided into two
broad categories, which are: i)Block coding
and ii) Convolution coding.

3.3 Block Coding


• In block coding, the message is divided into
blocks, each of k bits, called datawords.
• r redundant bits are added to each block to
make the length n = k + r.
• The resulting n-bit blocks are called
codewords.
Datawords

k bits
Fig. 3.7: Block Coding
• With k bits, we can create a combination
of 2k datawords while n bits can produce a
combination of 2n codewords.
• Since n > k, the number of possible
codewords is larger than the number of
possible datawords.
• The block coding process is one-to-one,
which implies that we have 2n − 2k
codewords that are not used, known as
invalid or illegal codewords.
• The trick in error detection is the
existence of these invalid codes.

• Since the receiver has (or can find) a list


of valid codewords, if it receives an
invalid codeword, it means the data was
corrupted during transmission.

• The role of block coding in error


detection is illustrated with Fig. 3.7.
Fig. 3.8: Error Detection using Block Coding

• As shown in Fig. 3.8, the sender creates


codewords out of datawords by using a
generator that applies the appropriate rules
of encoding.
• If the received codeword is the same as one
of the valid codewords, the word is accepted
and the corresponding dataword is extracted
for use.
• If the received codeword is not valid, it is
discarded.
• However, if the codeword is corrupted
during transmission but the received word
still matches a valid codeword, the error
remains undetected.
Example 3.1
Given that k = 2 and n = 3. Table 3.1 shows the list of
possible datawords and codewords.

Table 3.1: Error Detection Code for (k=2 and n=3)


Dataword Codeword
00 000
01 011
10 101
11 110
• Lets assume that in Example 3.1, the sender
encodes the dataword 01 as 011 and sends it
to the receiver.
• The following are the possible scenarios(based
on Table 3.1): 
i) If the receiver receives 011, this is a valid
codeword - the receiver will extract the
dataword 01 from it.
ii) If the codeword is corrupted during
transmission, and 111 is received, this is not a
valid codeword and therefore it will be
discarded.
iii) If the codeword is corrupted during
transmission, and 000 is received. Although this is
a valid codeword, the receiver will incorrectly
extract the dataword 00 and two corrupted bits
have made the error undetectable.
• Therefore, it should be noted that an
error-detecting coding scheme can detect only the
types of errors for which it was designed; other
types of errors may remain undetected.
3.3.1 Linear Block Codes
• Almost all block codes used today belong to a
subset of block codes called linear block codes.

• A linear block code is a code in which the


exclusive OR (addition modulo-2) of two valid
codewords creates another valid codeword.

• One of the central concepts in channel coding that


is applied in linear block coding is the idea of
Hamming distance.
• The Hamming distance d(x,y) between two
words x and y is the number of differences
between corresponding bits.
• Hamming distance can easily be found if we
apply the XOR operation (⊕) on the two words
and count the number of 1s in the result.  
• Thus:
The Hamming distance d(000, 011) = 2
because (000 ⊕ 011) is 011 (there are two 1s in the
result).
The Hamming distance d(10101, 11110) = 3
because (10101 ⊕ 11110) is 01011 (there are three 1s).
• Hamming distance is important because it
indicates the number of bits that are
corrupted during transmission i.e. if the
Hamming distance between the sent and the
received codeword is not zero, the codeword
has been corrupted during transmission.
• For a linear block code, the minimum
Hamming distance is the number of 1s in the
nonzero valid codeword with the smallest
number of 1s.
• For instance, in Table 3.1, the numbers of 1s in the
nonzero codewords are 2, 2, and 2. So the minimum
Hamming distance is dmin = 2.

• To guarantee the detection of up to s errors, the


minimum Hamming distance in a block code must be:
dmin = s + 1 (3.1)
• For example, if a coding scheme has a minimum
Hamming distance dmin = 4, the scheme guarantees
the detection of up to 3 errors, i.e.
4=s+1
s=3
3.3.1.1 Parity-Check Code
• Parity-Check Code is a linear block code and
perhaps the most familiar error-detection code.

• In this code, a k-bit dataword is changed to an


n-bit codeword where n = k + 1.

• The extra bit, called the parity bit, is selected to


make the total number of 1s in the codeword
even(for even parity implementation) or odd
(for odd parity implementation).
• The codeword in Table 3.1 where (k=2
and n=3) is a parity-check code.
• In Example 3.1, dmin = 2 and this implies
that the code is a single-bit error-
detecting code.
Example 3.2
If k = 4 and n = 5 for an even parity-check
code. Create the list of possible
datawords and codewords for this code
in a tabular form.
Table 3.2: Solution to Example 3.2
(A Simple Even Parity-Check Code)
Dataword Codeword Dataword Codeword
0000 00000 1000 10001
0001 00011 1001 10010
0010 00101 1010 10100
0011 00110 1011 10111
0100 01001 1100 11000
0101 01010 1101 11011
0110 01100 1110 11101
0111 01111 1111 11110
• The structure of an encoder (at the sender) and a
decoder (at the receiver) for the datawords and
codewords in Table 3.2 is shown in Fig. 3.9

Fig.3.9: Encoder and Decoder Structure for Table 3.2


• As shown in Fig 3.9, the encoder uses a
Generator that takes a copy of a 4-bit dataword
(a0, a1, a2, and a3) and generates a parity bit r0.
• This is done by adding the 4 bits of the
dataword (modulo-2) to obtain the parity bit i.e.
r0 = a3 + a2 + a1 +a0 (modulo-2) (3.2)
• If the number of 1s is even, the result is 0; if the
number of 1s is odd, the result is 1.
• In both cases, the total number of 1s in the
codeword is even.
• The sender sends the codeword, which may be
corrupted during transmission and the receiver
receives a 5-bit word.
• The Checker at the receiver adds all the received 5
bits(similar to what the Generator did at the sender for
the datawords) to produce the Syndrome, which is just
1-bit.
s0 = b3 + b2 + b1 + b0 + q0 (modulo-2) (3.3)

• The Syndrome is passed to the Decision Logic for


analysis.
• If the Syndrome is 0, there is no detectable error in
the received codeword, thus the data portion of the
received codeword is accepted as the dataword.
• If the syndrome is 1, it means there is error in
the transmission. Thus, the data portion of the
received codeword is discarded and the
dataword will not be created.

Exercise 3.2
If k = 5 and n=6 for an even parity-check code:
i)generate the possible datawords and codewords
in a tabular form.
ii) find dmin and the number of errors s that can be
detected by the code.
3.3.1.2 Cyclic Redundancy Check (CRC)
• CRC is a special type of linear block codes
which is used in data networks such as
LANs and WANs for error detection.
• At the encoder:
The dataword has k bits while the codeword has n bits
The size of the dataword is augmented by adding
(n − k) 0s to the right-hand side of the dataword.
The outcome which is n-bit in size is fed into the
generator.
The generator uses a divisor of (n − k + 1) bits, which is
predefined and agreed upon.
The generator divides the augmented
dataword by the divisor (modulo-2 division).
The quotient of the division is discarded while
the remainder (r2 r1 r0) is the CRC bits, which is
appended to the dataword to create the
codeword.
Thus:
Codeword = Dataword + CRC bits
• At the decoder:
The decoder receives the codeword (which is possibly
corrupted in transition).
A copy of all n bits is fed to the checker(a replica of the
generator).
The remainder produced by the checker is a syndrome
of (n − k) bits, which is fed to the decision logic
analyzer.
The analyzer examines the syndrome bits. If they are all
0s, this is interpreted as no error and the 4 left-most
bits of the codeword are accepted as the dataword,
other-wise, there is an error and the 4 bits are
discarded.
Example 3.3
If a CRC code is C(7, 4), generate the corresponding
codeword for dataword 1001.
Solution
k=4
n=7
augmentation bits = (n-k) 0s = 3 0s = 000
augmented dataword = 1001000
divisor bits = (n-k+1)bits = 4bits,
Given a divisor of value 1011 (represented in
polynomial as x3 + x +1), the design of the encoder
and decoder for C(7,4) is shown in Fig. 3.10.
Fig. 3.10: A CRC Design for C(7,4)
• As shown in Fig. 3.10, the CRC bits (which is the
remainder) is computed by the generator (using
modulo-2 division) to obtain 110:
• Therefore, the codeword = 1001110
• The decoder does the same division process as the
encoder to generate a remainder, which is the
syndrome.
• For the case when the codeword is uncorrupted,
the syndrome is 000:

• Therefore, the dataword 1001 will be accepted.


• For the case where the codeword is corrupted.
Assuming the received codeword is 1000110, the
syndrome will be 011.

• The dataword in this case will be discarded.


• The other datawords and corresponding
codewords for the CRC with C(7,4) are shown in
Table 3.3.
Table 3.3: Datawords and Corresponding Codewords for k=4 and n=7
• Some standard polynomials(and the
corresponding bit patterns) used as divisors by
popular protocols for CRC generation are shown in
Table 3.4.
Table 3.4: Standard Polynomials used as divisors for CRC generation
• CRC is a very effective error detection method,
when the divisor is properly selected. The
performance of this scheme are as follows:
 Detection of all burst errors that affect an odd number of
bits.
 Detection of all burst errors of length less than or equal
to the degree of the polynomial.
 Detection of burst errors of length greater than the
degree of the polynomial with a very high probability.

Class Exercises
1) If k = 3 and n = 4, generate all the possible datawords and corresponding codewords,
using odd parity. What is the number of error bits that can be detected by this scheme.
2) X = 00111 and Y = 11100, compute d(X,Y)
3) What is the polynomial for CRC-8? State the value of the divisor
3.3.1.3 Checksum
• Checksum is a block code error-detection technique
that can be applied to a message of any length.
• In the Internet, It is mostly used at the network and
transport layers rather than the data-link layer.
• At the encoder:
The message is divided into K chunks of n bit each.
The generator adds all K chunks using 1s complement
addition.
The generator takes the compliment of the result to
generate the checksum.
The result, which is the message padded with the
checksum will be sent.
• Note: In 1’s compliment addition, if the result has a
carry bit, add carry with LSB (Least Significant Bit)
of the result.
• At the decoder:
 After receiving the message from the sender, the
receiver will divide the data into n bit chunks. Note that
with the appended checksum, there will be K + 1
chunks.
 The checker adds all the chunks using 1’s compliment
addition.
 The checker then takes the compliment of the result.
 The analyzer(decision block) examines if all the bits in
result is 0, then, accept the data, otherwise, the data
will be discarded due to error.
• Fig. 3.11 illustrates these steps both at the sender and
receiver.

Fig. 3.11: Checksum Error Detection Scheme


Example 3.4
Suppose a message is represented as 01110011, calculate
the checksum both at the sender and receiver assuming
each data chunk is 4 bits.
Solution
 n = 4, so the data is divided into 4 bit chunks.
 K = 2 chunks, Since the total number of digits in the data is
8(0111 and 0011 ).
 Adding both chunks at the sender, we have:
0111
0011
———
1010
———
 result = 1010, with no carry bit.
 checksum(which is 1’s compliment of the result) = 0101.
 message = 011100110101

• At the receiver:
 received message = 011100110101
 since n = 4, there are 3 chunks.
 The chunks are 0111 0011 0101
 Adding all chunks using 1’s complement, we have:
0 1 1 1
0 0 1 1
0101
————–
1 1 1 1
————–
the compliment of 1111 = 0000, therefore, there is no error.

• Although, Checksum scheme is not as strong as CRC, it uses


a small number of bits (e.g. 16) to detect errors in a
message of big size (sometimes thousands of bits).

• However, it cannot detect errors in the following scenarios:


 If the value of one word is incremented and the value of
another word is decremented by the same amount, the two
errors cannot be detected because the sum and checksum
remain the same.
 Also, if the values of several words are incremented but the
sum and the checksum do not change, the errors are not
detected.
Module 3 Assignments
1) Using MATLAB, implement the even parity-check
code generator that can compute the dataword
for any given k bits and the corresponding
codewords.
2) Use the CRC System Object in MATLAB to
implement Example 3.3.

Submission Date: 01/02/2021.


Submission Rule: Code submissions with sample
outputs should be done on Moodle.

You might also like