Unit-2 Data Link Layer
Unit-2 Data Link Layer
2
FRAMING
DLL translates the physical layer's raw bit
stream into discrete units (messages) called frames.
How can frame be transmitted so the receiver
can
detect frame boundaries ?
That is, how can the receiver recognize the start and end of a
frame?
Character Count
Flag byte with Byte Stuffing
Starting and ending flag with bite stuffing
Encoding Violations
FRAMING – CHARACTER COUNT
The first framing method uses a field in the header to
specify the number of characters in the frame. When
the data link layer at the destination sees the character
count, it knows how many characters follow and hence
where the end of the frame is.
1
The trouble with this algorithm is that the count can be garbled by a1
transmission error. 5
FRAMING – BYTE STUFFING
Use reserved characters to indicate the start and end of a frame. For
instance, use the two-character sequence DLE STX (Data-Link
Escape, Start of TeXt) to signal the beginning of a frame, and the
sequence DLE ETX (End of TeXt) to flag the frame's end.
The second framing method, Starting and ending character stuffing,
gets around the problem of resynchronization after an error by
having each frame start with the ASCII character sequence DLE STX
and end with the sequence DLE ETX.
Problem: What happens if the two-character sequence DLX
ETX happens to appear in the frame itself?
Solution: Use character stuffing; within the frame, replace every
occurrence of DLE with the two-character sequence DLE DLE. The
receiver reverses the processes, replacing every occurrence of DLE
DLE with a single DLE.
Example: If the frame contained ``A B DLE D E DLE'', the characters
transmitted over the channel would be ``DLE STX A B DLE DLE D E
DLE DLE DLE ETX''.
Disadvantage: character is the smallest unit that can be
1
operated on; not all architectures are byte oriented. 2
6
7
Byte stuffing and unstuffing
8
FRAMING – BIT STUFFING
This technique allows data frames to contain an arbitrary number of
bits and allows character codes with an arbitrary number of bits per
character. It works like this. Each frame begins and ends with a
special bit pattern, 01111110 (in fact, a flag byte).
Whenever the sender's data link layer encounters five consecutive
1s in the
data, it automatically stuffs a 0 bit into the outgoing bit stream.
This bit stuffing is analogous to byte stuffing, in which an escape
byte is stuffed into the outgoing character stream before a flag
byte in the data. When the receiver sees five consecutive incoming
1 bits, followed by a 0 bit, it automatically destuffs (i.e., deletes)
the 0 bit
9
Byte stuffing and unstuffing
10
ERROR CORRECTION AND DETECTION
It is physically impossible for any data recording or
transmission medium to be 100% perfect 100% of the
time over its entire expected useful life.
In data communication, line noise is a fact of life (e.g., signal
attenuation, natural phenomenon such as lightning, and the
telephone repairman).
As more bits are packed onto a square centimeter of
disk storage, as communications transmission speeds
increase, the likelihood of error increases-- sometimes
geometrically.
Thus, error detection and correction is critical to
accurate data transmission, storage and retrieval.
12
Error Detection & Error Correction
There are two types of attacks against errors:
Error Detecting Codes: Include enough redundancy
bits to detect
errors and use ACKs and retransmissions to recover from
the errors.
Error Correcting Codes: Include enough redundancy
to detect and correct errors. The use of error-correcting
codes is often referred to as forward error correction.
13
ERROR DETECTION
Error detection means to decide whether the received
data is correct or not without having a copy of the
original message.
14
Vertical Redundancy Check (VRC)
Append a single bit at the end of data block such that
the number of ones is even
Even Parity (odd parity is similar)
0110011 01100110
0110001 01100011
VRC is also known as Parity Check. Detects all odd-
number errors in a data block
15
EXAMPLE OF VRC
The problem with parity is that it can only detect odd
numbers of bit substitution errors, i.e. 1 bit, 3bit, 5,
bit, etc. errors. If there two, four, six, etc. bits which
are transmitted in error, using VRC will not be able to
detect the error.
2
6
16
Longitudinal Redundancy Check (LRC)
Longitudinal Redundancy Checks (LRC) seek to overcome the
weakness of simple, bit-oriented, one-directional parity checking.
LRC adds a new character (instead of a bit) called the Block Check
Character (BCC) to each block of data. Its determined like parity, but
counted longitudinally through the message (also vertically)
Its has better performance over VRC as it detects 98% of the burst
errors (>10 errors) but less capable of detecting single errors
If two bits in one data units are damaged and two bits in exactly the
same positions in another data unit are also damaged, the LRC
checker will not detect an error.
18
19
CYCLIC REDUNDANCY CHECK (CRC)
The cyclic redundancy check, or CRC, is a technique for
detecting errors in digital data, but not for making corrections
when errors are detected. It is used primarily in data
transmission
In the CRC method, a certain number of check bits, often
called a checksum, are appended to the message being
transmitted. The receiver can determine whether or not the
check bits agree with the data, to ascertain with a certain
degree of probability whether or not an error occurred in
transmission
The CRC is based on polynomial arithmetic, in particular, on
computing the remainder of dividing one polynomial in GF(2)
(Galois field with two elements) by another.
Can be easily implemented with small amount of hardware
Shift registers
XOR (for addition and subtraction) 3
1
20
CRC Calculation
21
CYCLIC REDUNDANCY CHECK
Let M(x) be the message polynomial
Let P(x) be the generator polynomial
P(x) is fixed for a given CRC scheme
P(x) is known both by sender and receiver
Create a block polynomial F(x) based on M(x)
and P(x) such that F(x) is divisible by P(x)
0
F (x)
P(x) Q(x) P(x)
22
CYCLIC REDUNDANCY CHECK
Sending
1. Multiply M(x) by xn
2. Divide xnM(x) by P(x)
3. Ignore the quotient and keep the
reminder C(x)
4. Form and send F(x) = xnM(x)+C(x)
Receiving
1. Receive F’(x)
2. Divide F’(x) by P(x)
3. Accept if remainder is 0, reject otherwise
23
Example of CRC
Consider a message 110010 represented by the polynomial
M(x) = x5 + x4 + x Consider a generating polynomial G(x) =
x3 + x2 + 1 (1101)
This is used to generate a 3 bit CRC = C(x) to be appended to
M(x).
Steps:
1. Multiply M(x) by x3 (highest power in G(x)). i.e. Add 3 zeros.
110010000
2. Divide the result by G(x). The remainder = C(x).
1101 long division into 110010000 (with subtraction mod 2)
= 100100 remainder 100
3. Transmit 110010000 + 100
To be precise, transmit: T(x) = x3M(x) + C(x)
= 110010100
4. Receiver end:
Receive T(x). Divide by G(x), should have remainder 0.
24
25
26
CHECKSUM
Checksum is the error detection scheme used in IP, TCP & UDP.
Here, 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
The checksum detects all errors involving an odd number of bits.
It also detects most errors involving even number of bits.
27
CHECKSUM
28
Checksum Example
29
30
31
32
ERROR CORRECTION
Once detected, the errors must be corrected
53
35
Example of Hamming Code
36
55
37
56
38
Let Receiver receives 10010100101
39
Burst Error Correction
41
Flow Control
• Flow control is a technique that allows two stations
working at different speeds to communicate with
each other.
• It is a set of measures taken to regulate the
amount of data that a sender sends so that a fast
sender does not overwhelm a slow receiver.
• In data link layer, flow control restricts the number
of frames the sender can send before it waits for an
acknowledgment from the receiver.
42
Error Control
• Error control in data link layer is the process of
detecting and correcting data frames that have
been corrupted or lost during transmission.
• In case of lost or corrupted frames, the receiver
does not receive the correct data-frame and sender
is ignorant about the loss.
• Data link layer follows a technique to detect transit
errors and take necessary actions, which is
retransmission of frames whenever error is detected
or frame is lost. The process is called Automatic
Repeat Request (ARQ). 43
Wired LANs
• Ethernet or local area network (LAN) is a computer
network that is designed for a limited geographic
area such as a building or a campus.
• Although a LAN can be used as an isolated
network to connect computers in an organization for
the sole purpose of sharing resources.
• The LAN market has several technologies such as
Ethernet, Token Ring, Token Bus, FDDI, and ATM
LAN. Some of these technologies survived for a
while, but Ethernet is by far the dominant
technology. 44
Wireless LANs
• Ethernet or local area network (LAN) is a computer
network that is designed for a limited geographic area
such as a building or a campus.
• A wireless LAN (WLAN) is a wireless computer
network that links two or more devices using wireless
communication to form a LAN within a limited area such
as a home, school, computer laboratory, campus, or
office building. This gives users the ability to move
around within the area and remain connected to the
network.
•Through a gateway, a WLAN can also provide a
connection to the wider Internet. 45
Bridge
• A bridge operates at data link layer. A bridge is a
repeater, with add on the functionality of filtering
content by reading the MAC addresses of source
and destination.
• It is also used for interconnecting two LANs
working on the same protocol. It has a single input
and single output port, thus making it a 2 port
device.
• Types of Bridges
• Transparent Bridges
• Source Routing Bridges 46
Switch
• A switch is a multiport bridge with a buffer and a
design that can boost its efficiency(a large number
of ports imply less traffic) and performance.
• A switch is a data link layer device. The switch can
perform error checking before forwarding data, that
makes it very efficient as it does not forward
packets that have errors and forward good packets
selectively to correct port only.
• In other words, switch divides collision domain of
hosts, but broadcast domain remains same.
47
References
• https://www.sciencedirect.com/topics/computer-sc
ience/data-link-layer
• https://www.sciencedirect.com/topics/engineering
/data-link-layer
• http://teachweb.milin.cc/datacommunicatie/tcp_o
si_model/data-link_layer.htm
• https://www.studytonight.com/computer-networks
/osi-model-datalink-layer
48