Module 2 Part 1
Module 2 Part 1
◻ To accomplish these goals, the data link layer takes the packets it gets from the
network layer and encapsulates them into frames for transmission.
◻ Each frame contains a frame header, a payload field for holding the packet, and a
frame trailer
• A Frame consists of following parts
Flag- It points to the starting and completion of the frame
Trailer- It includes the error correction and error detection bits
Payload field- It includes the message to be rendered
Frame header- It includes the origin and target addresses of the frame
Design Issues
1. Services Provided to the Network Layer
2. Framing
3. Error Control
4. Flow Control
Methods in Framing (To identify the starting and ending of the frame)
1. Character Count
2. Flag bytes with byte stuffing
3. Flag bits with bit stuffing
4. Physical layer coding violations.
a. Character Count
◻ Used a field in the header to specify no of characters
◻ When the data link layer at the destination sees the character count, it
knows how many characters follow and where the end of the frame is
◻ Can be garbled by transmission errors.
• Ex: if the character count of destination becomes 7, the destination
will go out of synchronization and will be unable to locate the start of
next frame.
b. Flag Bytes with Byte Stuffing
oEach frame start and end with special bytes called flag. If the receiver
ever loses its synchronization, it just search for flag byte to the find
the end of the current frame.
• A serious problem with this is that sometimes the flag bytes’s bit
pattern occurs in the data. To solve this problem, the sender’s data
link layer insert a special escape byte(ESC) just before each flag byte.
• The data link layer on the receiving end removes the escape byte
before the data are given to network layer. This technique is called
byte stuffing or character stuffing.
c. Bit Stuffing
• Each frame begins and ends with a special bit pattern 01111110 (in
fact a flag byte)
oWhenever the sender’s data link layer encounters five consecutive
1 s in the data, it automatically stuffs a 0 bit in the outgoing bit stream
oWhen the receiver sees five consecutive incoming 1 bits followed by a
0 bit, it automatically deletes the 0 bit. If the user data contains the
flag pattern 01111110 this flag is transmitted as 011111010 but
stored in the receiver’s memory as 01111110.
o In the figure a) Original data b)The data as they appear on the line c)
The data stored in receiver’s memory after destuffing
d. Physical layer Coding Violations
• Some reserved signals are used to indicate the start and end of the
frames
• As they are reserved signals, it is easy to find the start and end of the
frame.
3. Error Control
◻ Deliver frames with out error, in proper order
◻ Mechanisms include,
ACK/NAK :
◻ Feedback
◻ The usual way to ensure reliable delivery is to provide the sender with some
feedback about what is happening at the other end of the line.
◻ Typically, the protocol calls for the receiver to send back special control frames
bearing positive or negative acknowledgements about the incoming frames.
◻ If the sender receives a positive acknowledgement about a frame, it knows the
frame has arrived safely.
◻ On the other hand, a negative acknowledgement means that something has gone
wrong, and the frame must be transmitted again.
Time Out:
◻ Fixed time
◻ Multiple bits error − In the received frame, more than one bits are corrupted.
◻ Burst error − In the received frame, more than one consecutive bits are
corrupted.
◻ Error Control
◻ Error control can be done in two ways
◻ Error detection − Error detection involves checking whether any error
has occurred or not. The number of error bits and the type of error does
not matter.
◻ Error correction − Error correction involves ascertaining the exact
number of bits that has been corrupted and the location of the corrupted
bits.
Error Detection Techniques
◻ There are three main techniques for detecting errors in frames: Parity Check,
Checksum and Cyclic Redundancy Check (CRC).
◻ Parity Check
◻ The parity check is done by adding an extra bit, called parity bit to the data to
make a number of 1s either even in case of even parity or odd in case of odd
parity.
◻ While creating a frame, the sender counts the number of 1s in it and adds the parity
bit in the following way
◻ In case of even parity: If a number of 1s is even then parity bit value is 0. If the
number of 1s is odd then parity bit value is 1.
◻ In case of odd parity: If a number of 1s is odd then parity bit value is 0. If a
number of 1s is even then parity bit value is 1.
◻ On receiving a frame, the receiver counts the number of 1s in it. In case of even
parity check, if the count of 1s is even, the frame is accepted, otherwise, it is
rejected. A similar rule is adopted for odd parity check.
◻ The parity check is suitable for single bit error detection only.
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.
Two Dimensional Parity Check
3. Cyclic Redundancy Check (CRC)
◻ Cyclic Redundancy Check (CRC) involves binary division
of the data bits being sent by a predetermined divisor agreed
upon by the communicating system. The divisor is generated
using polynomials.
◻ Here, the sender performs binary division of the data
segment by the divisor. It then appends the remainder called
CRC bits to the end of the data segment. This makes the
resulting data unit exactly divisible by the divisor.
◻ The receiver divides the incoming data unit by the divisor. If
there is no remainder, the data unit is assumed to be correct
and is accepted. Otherwise, it is understood that the data is
corrupted and is therefore rejected.
Cyclic Redundancy Check
(CRC)
Cyclic Redundancy Check
The various steps followed in the CRC method are
44
➢it is possible to determine how many corresponding bits
differ.
➢In this case, 3 bits differ.
➢To determine how many bits differ, just exclusive OR the
two codewords and count the number of 1 bits in the
result.
Determining r2 bit
The r2 bit is calculated by performing a parity check on the bit positions whose binary
representation includes 1 in the second position.
We observe from the above figure that the bit positions that includes 1 in
the second position are 2, 3, 6, 7. Now, we perform the even-parity check
at these bit positions. The total number of 1 at these bit positions
corresponding to r2 is odd, therefore, the value of the r2 bit is 1.
Determining r4 bit
The r4 bit is calculated by performing a parity check on the bit positions
whose binary representation includes 1 in the third position.
We observe from the above figure that the bit positions that includes 1 in the
third position are 4, 5, 6, 7. Now, we perform the even-parity check at these bit
positions. The total number of 1 at these bit positions corresponding to r4
is even, therefore, the value of the r4 bit is 0.
Data transferred is given below:
.
Suppose the 4th bit is changed from 0 to 1 at the receiving end, then parity bits are recalculated.
R1 bit
The bit positions of the r1 bit are 1,3,5,7
We observe from the above figure that the binary representation of r1 is 1100. Now, we perform the even-parity
check, the total number of 1s appearing in the r1 bit is an even number. Therefore, the value of r1 is 0.
R2 bit
The bit positions of r2 bit are 2,3,6,7.
We observe from the above figure that the binary representation of r2 is 1001. Now, we perform the even-
parity check, the total number of 1s appearing in the r2 bit is an even number. Therefore, the value of r2 is 0.
R4 bit
The bit positions of r4 bit are 4,5,6,7.
• We observe from the above figure that the binary representation of
r4 is 1011. Now, we perform the even-parity check, the total number
of 1s appearing in the r4 bit is an odd number. Therefore, the value of
r4 is 1.
• The binary representation of redundant bits, i.e., r4r2r1 is 100, and its
corresponding decimal value is 4. Therefore, the error occurs in a
4th bit position. The bit value must be changed from 1 to 0 to correct
the error.
• Suppose the binary representation is 000 then it means no error.
Practise Question(Important)
• An 8-bit byte with binary value 10101111 is to be encoded
using an even-parity Hamming code. What is the binary
value after encoding?