Coding Line Coding Covered
Coding Line Coding Covered
symbols)
How many bits are required to encode the
message DEAACAAAAABA?
there are twelve symbols, each requires 3 bits
12*3 = 36 bits are required
Drawbacks of fixed-length codes
Wasted space
Unicode uses twice as much space as ASCII
• inefficient for plain-text messages containing only ASCII characters
Same number of bits used to represent all characters
‘a’ and ‘e’ occur more frequently than ‘q’ and ‘z’
Symbol Code
P 000
01001101100010
Q 11
R 01 RSTQPT
S 001
T 10
000 is not a prefix of 11, 01, 001, or 10
11 is not a prefix of 000, 01, 001, or 10 …
Code without prefix property
The following code does not have prefix property
Symbol Code
P 0
Q 1
R 01
S 10
T 11
DEAACAAAAABA
Symbol Code
A 0
B 10
C 110
D 1110
E 11110
1110111100011000000100 22 bits
Another possible code
DEAACAAAAABA
Symbol Code
A 0
B 100
C 101
D 1101
E 1111
1101111100101000001000 22 bits
Better code
DEAACAAAAABA
Symbol Code
A 0
B 100
C 101
D 110
E 111
11011100101000001000 20 bits
What code to use?
Question: Is there a variable-length code that makes the most efficient
use of space?
Answer: Yes!
Huffman coding tree
Binary tree
each leaf contains symbol (character)
label edge from node to left child with 0
label edge from node to right child with 1
Code for any symbol obtained by following path from David Albert
root to the leaf containing symbol Huffman (August
9, 1925 –
Code has prefix property October 7, 1999)
leaf node cannot appear on path to another leaf was an American
pioneer in
note: fixed-length codes are represented by a computer
complete Huffman tree and clearly have the prefix science, known
for his Huffman
property coding. He was
also one of the
pioneers in the
field of
mathematical
Building a Huffman tree
Find frequencies of each symbol occurring in message
Begin with a forest of single node trees
each contain symbol and its frequency
Do recursively
select two trees with smallest frequency at the root
produce a new binary tree with the selected trees as children and
store the sum of their frequencies in the root
Recursion ends when there is one tree
this is the Huffman coding tree
https://www.youtube.com/watch?v=LfWa6_xMy6Y&list=PLOuGMjEXHeeAv5Ejeo4xz3BHM2-0cN8nN&index=6
Many different line coding techniques, ranging in complexity from very basic
unipolar schemes in which the presence or absence of a voltage is used to
represent a binary one or a binary zero, to highly sophisticated multilevel schemes
in which different signal amplitudes are used, each representing a unique grouping
of binary digits.
There are 3 types of Line Coding
• Power efficiency - the transmitted signal power should be as low as possible for the required data
rate and probability of error in order to make the most efficient use of power and minimise the
amount of electromagnetic noise on the transmission line.
• Target spectral density - the power spectral density (PSD) is the distribution of power over the
frequencies that make up the signal. The PSD of the transmitted signal should be compatible with
the communication channel's frequency response. If the signal bandwidth (i.e. the frequency
interval that contains most of the signal's power) is greater than that of the channel, the higher
frequencies will be cut off, causing the signal to spread out in the time domain.
• Avoidance of baseline wandering - the average signal-power at the receiver is used as a baseline
reference against which the value of incoming data elements is determined. The baseline may
drift up or down over time if long strings of ones or zeros are transmitted, making it difficult for
the receiver to decode the incoming signal correctly. Most line coding schemes are designed to
prevent this from happening.
UNIPOLAR: NON-RETURN TO ZERO NRZ
• Advantages
• It is simple.
• A lesser bandwidth is required.
• Disadvantages
• No error correction done.
• No clock is present.
• Loss of synchronization is likely to occur (especially for
long strings of 1s and 0s).
UNIPOLAR: RETURN TO ZERO (RZ)
• Advantages
• It is simple.
• The spectral line present at the symbol rate can be used as
a clock.
• Disadvantages
• No error correction done.
• Occupies twice the bandwidth as unipolar NRZ.
• Larger bandwidth
POLAR SIGNALING
• In polar schemes, the voltages are on the
both sides of the axis.
• There are two methods of Polar Signaling.
They are
• Polar NRZ
• Polar RZ
POLAR: NRZ
• High in data is represented by a positive pulse,
while a Low in data is represented by a negative
pulse.
• NRZ-L and NRZ-I – These are somewhat similar to
unipolar NRZ scheme but here we use two levels
of amplitude (voltages).
• NRZ-L(NRZ-Level): the level of the voltage
determines the value of the bit, typically binary 1
maps to logic-level high, and binary 0 maps to
logic-level low.
• NRZ-I(NRZ-Invert): The idea is that whenever
we encounter logical 1 then the signal will be
inverted, but when it encounters logical 0 then it
remains on the same side. This is the NRZ-Invert..
ADVANTAGES AND DISADVANTAGES OF POLAR
NRZ
• Advantages
• It is simple.
• Disadvantages
• No error correction.
• No clock present.
• The Baseline wandering.
POLAR: RZ
• A High in data, though represented by
a Mark pulse, its duration T0 is less than the
symbol bit duration. Half of the bit duration
remains high but it immediately returns to
zero and shows the absence of pulse during
the remaining half of the bit duration.
• However, for a Low input, a negative pulse
represents the data, and the zero level
remains same for the other half of the bit
duration.
• Uses three values: positive, negative and
zero. In this scheme signal goes to 0 in the
middle of each bit.
ADVANTAGES AND DISADVANTAGES OF POLAR
RZ
• Advantages
• Return to zero proved out to be a nice alternative or say a solution to
NRZ drawbacks.
• Disadvantages
• No error correction.
• No clock present.
• Complex encoding as it uses three levels of voltages
• Occupies twice the bandwidth of Polar NRZ
• Signal drop is caused at the places where the signal is non-zero at 0 Hz
BIPOLAR CODING
• Bipolar consists of three voltage levels
namely +, - and 0. Such a signal is called
as duo-binary signal.
• An example of this type is Alternate Mark
Inversion (AMI). For a 1, the voltage level
gets a transition from + to – or from – to
+, having alternate 1s to be of equal
polarity. A 0 will have a zero voltage level.
• Two types.
• Bipolar NRZ
• Bipolar RZ
BIPOLAR CODING
• Two types.
• Bipolar NRZ
• Bipolar RZ
• A checksum is created based on the data values in the data blocks using some
algorithm and appended to the data. When the receiver gets this data, a new
checksum is calculated and compared with the existing checksum. A non-match
indicates an error.
• For error detection by checksums, data is divided into fixed sized frames or segments.
• Sender’s End − The sender adds the segments using 1’s complement arithmetic to get
the sum. It then complements the sum to get the checksum and sends it along with
the data frames.
• Receiver’s End − The receiver adds the incoming segments along with the checksum
using 1’s complement arithmetic to get the sum and then complements it.
• If the result is zero, the received frames are accepted; otherwise they are discarded.
CHECKSUM EXAMPLE
• Suppose that the sender wants to send 4 frames each of 8
bits, where the frames are 11001100, 10101010, 11110000
and 11000011.
• The sender adds the bits using 1s complement arithmetic.
While adding two numbers using 1s complement arithmetic,
if there is a carry over, it is added to the sum.
• After adding all the 4 frames, the sender complements the
sum to get the checksum, 11010011, and sends it along with
the data frames.
• The receiver performs 1s complement arithmetic sum of all
the frames including the checksum. The result is
complemented and found to be 0. Hence, the receiver
assumes that no error has occurred.
CONSTRAINTS IN ERROR DETECTION