DATA
COMMUNICATION
AND NETWOKS
UNIT 2 - DATA LINK LAYER
Part 1
Likhitha M M
Assistant Professor
DoS in Computer Science
Mahajana PG Wing, Mysore
Contents
Introduction
Data-Link Control- Framing
Error Control
DATA COMMUNICATION
AND NETWOKS
UNIT 2 - DATA LINK LAYER
Part 1
Likhitha M M
Assistant Professor
DoS in Computer Science
Mahajana PG Wing, Mysore
DATA LINK CONTROL
DLC SERVICES
• The data link control (DLC) deals with procedures for
communication between two adjacent nodes
• i.e. node-to-node communication.
• Data link control functions include
1) Framing and 2) Flow control and 3) Error control.
Framing
• A frame is a group of bits.
• Framing means organizing the bits into a frame that are carried
by the physical layer.
• The data-link-layer needs to form frames, so that each frame is
distinguishable from another.
• Framing separates a message from other messages by adding
sender-address & destination-address.
• The destination-address defines where the packet is to go.
• The sender-address helps the recipient acknowledge the receipt.
Q: Why the whole message is not packed in one frame?
Ans: Large frame makes flow and error-control very inefficient.
Even a single-bit error requires the re-transmission of the whole
message.
When a message is divided into smaller frames, a single-bit error
affects only that small frame.
(Our postal system practices a type of framing. The simple act of
inserting a letter into an envelope separates one piece of
information from another; the envelope serves as the delimiter. In
addition, each envelope defines the sender and receiver addresses
since the postal system is a many-to-many carrier facility).
Frame Size
Two types of frames:
1) Fixed Size Framing
2) Variable Size Framing
1) Fixed Size Framing
• There is no need for defining boundaries of frames; the size itself
can be used as a delimiter.
• For example: ATM WAN uses frames of fixed size called cells.
(asynchronous transfer mode)
2) Variable Size Framing
• We need to define the end of the frame and the beginning
of the next frame.
• Two approaches are used:
1. Character-oriented approach
2. Bit-oriented approach.
Variable Size
Framing
Character Oriented Framing
Data to be carried are 8-bit characters from a coding system
such as ASCII (Figure 11.1).
The header and the trailer are also multiples of 8 bits.
1) Header carries the source and destination-addresses and
other control information.
2) Trailer carries error-detection or error-correction
redundant bits.
• To separate one frame from the next frame, an 8- bit (I-byte)
flag is added at the beginning and the end of a frame.
• The flag is composed of protocol-dependent special
characters.
• The flag signals the start or end of a frame.
•Problem:
• Character-oriented framing is suitable when only text is
exchanged by the data-link-layers.
• However, if we send other type of information (say
audio/video), then any pattern used for the flag can also
be part of the information.
• If the flag-pattern appears in the data-section, the receiver
might think that it has reached the end of the frame.
Solution: A byte-stuffing is used.
• (Byte stuffing / character stuffing)
• In byte stuffing, a special byte is added to the data-section
of the frame when there is a character with the same
pattern as the flag.
• The data-section is stuffed with an extra byte. This byte is
called the escape character (ESC), which has a predefined
bit pattern.
• When a receiver encounters the ESC character, the receiver
→ removes ESC character from the data-section and
→ treats the next character as data, not a delimiting flag.
Problem:
• What happens if the text contains one or more escape
characters followed by a flag?
• The receiver removes the escape character, but keeps the
flag, which is incorrectly interpreted as the end of the
frame.
Solution:
• Escape characters part of the text must also be marked by
another escape character (Fig 11.2).
In short, byte stuffing is the process of adding one extra byte
whenever there is a flag or escape character in the text.
Variable Size
Framing
Bit Oriented Framing
• The data-section of a frame is a sequence of bits to be
interpreted by the upper layer as text, audio, video, and so on.
• However, in addition to headers and trailers, we need a
delimiter to separate one frame from the other.
• Most protocols use a special 8-bit pattern flag 01111110 as the
delimiter to define the beginning and the end of the frame
(Figure 11.3).
Problem:
• If the flag-pattern appears in the data-section, the receiver
might think that it has reached the end of the frame.
Solution: A bit-stuffing is used.
• In bit stuffing, if a 0 and five consecutive 1 bits are
encountered, an extra 0 is added. This extra stuffed bit is
eventually removed from the data by the receiver. (Figure
11.4).
• This guarantees that the flag field sequence does not
inadvertently appear in the frame.
In short, bit stuffing is the process of adding one extra 0
whenever five consecutive 1s follow a 0 in the data, so that the
receiver does not mistake the pattern 0111110 for a flag.
Flow Control and Error Control
One of the responsibilities of the DLC sublayer is flow and error
control at the data-link layer.
Flow Control
• Whenever an entity produces items and another entity consumes
them, there should be a balance between production and
consumption rates.
• If the items are produced faster than they can be consumed, the
consumer can be overwhelmed and may need to discard some
items.
• We need to prevent losing the data items at the consumer site.
• At the sending node, the data-link layer tries to push frames
toward the data-link layer at the receiving node (Figure
11.5).
• If the receiving node cannot process and deliver the packet to
its network at the same rate that the frames arrive, it
becomes overwhelmed with frames.
• Here, flow control can be feedback from the receiving node
to the sending node to stop or slow down pushing frames
•Buffers
• Flow control can be implemented by using buffer.
• A buffer is a set of memory locations that can hold packets at the sender and receiver.
• Normally, two buffers can be used.
1) First buffer at the sender.
2) Second buffer at the receiver.
• The flow control communication can occur by sending signals from the consumer to the producer.
• When the buffer of the receiver is full, it informs the sender to stop pushing frames.
•3.6.2.2 Error Control
• Error-control includes both error-detection and error-correction.
• Error-control allows the receiver to inform the sender of any frames lost/damaged in transmission.
• A CRC is
• → added to the frame header by the sender and
• → checked by the receiver.
• At the data-link layer, error control is normally implemented using one of the following two methods.
1) First method: If the frame is corrupted, it is discarded;
• If the frame is not corrupted, the packet is delivered to the network layer.
• This method is used mostly in wired LANs such as Ethernet.
2) Second method: If the frame is corrupted, it is discarded;
• If the frame is not corrupted, an acknowledgment is sent to the sender.
• Acknowledgment is used for the purpose of both flow and error control.
•Combination of Flow and Error Control
•Flow and error control can be combined.
•The acknowledgment that is sent for flow control can
also be used for error control to tell the sender the
packet has arrived uncorrupted.
•The lack of acknowledgment means that there is a
problem in the sent frame.
•A frame that carries an acknowledgment is normally
called an ACK to distinguish it from the data frame.