Data Link Layer

Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

Data Link Layer

MAC; VLAN; Encapsulation into frames


It is responsible for the node-to-node delivery of data.
Its major role is to ensure error-free transmission of information.
OSI Layer 2 - Data Link Layer

• The data link layer or layer 2 is the second layer of the seven-layer OSI
model of computer networking.
• This layer is the protocol layer that transfers data between adjacent
network nodes in a wide area network (WAN) or between nodes on
the same local area network (LAN) segment.[1]
• The data link layer provides the functional and procedural means to
transfer data between network entities and might provide the means
to detect and possibly correct errors that may occur in the physical
layer.
Concerned
• The data link layer is concerned with local delivery of frames between devices on
the same LAN.
• Data-link frames, as these protocol data units are called, do not cross the
boundaries of a local network.
• Inter-network routing and global addressing are higher-layer functions, allowing
data-link protocols to focus on local delivery, addressing, and media arbitration.
• This way, the data link layer is analogous to a neighborhood traffic cop; it
endeavors to arbitrate between parties contending for access to a medium,
without concern for their ultimate destination.
• When devices attempt to use a medium simultaneously, frame collisions occur.
• Data-link protocols specify how devices detect and recover from such collisions,
and may provide mechanisms to reduce or prevent them.
Functions of the Data-link Layer

The data link layer receives the information in the form of packets from the Network layer, it divides packets into frames
and sends those frames bit-by-bit to the underlying physical layer.
Sub-layers of the Data Link Layer

• The data link layer is further divided into two sub-layers, which are as
follows:
• Logical Link Control (LLC)
• This sublayer of the data link layer deals with multiplexing, the flow of data
among applications and other services, and LLC is responsible for providing
error messages and acknowledgments as well.
• Media Access Control (MAC)
• MAC sublayer manages the device’s interaction, responsible for addressing
frames, and also controls physical media access.

DLL
• DLL is also responsible for encoding, decode and organizing the outgoing
and incoming data.
• This is considered the most complex layer of the OSI model as it hides all
the underlying complexities of the hardware from the other above layers.
Services

• Encapsulation
• Frame
synchronization
• Logical link control
(Error & Flow
control)
• Media access
control (MAC, LAN
switching, Physical
addressing, QaS,
VLAN, ...)
Detail
• Framing & Link access: Data Link Layer protocols encapsulate each network frame within a Link layer frame before the
transmission across the link. A frame consists of a data field in which network layer datagram is inserted and a number of data
fields. It specifies the structure of the frame as well as a channel access protocol by which frame is to be transmitted over the
link.
• Reliable delivery: Data Link Layer provides a reliable delivery service, i.e., transmits the network layer datagram without any
error. A reliable delivery service is accomplished with transmissions and acknowledgements. A data link layer mainly provides
the reliable delivery service over the links as they have higher error rates and they can be corrected locally, link at which an
error occurs rather than forcing to retransmit the data.
• Flow control: A receiving node can receive the frames at a faster rate than it can process the frame. Without flow control, the
receiver's buffer can overflow, and frames can get lost. To overcome this problem, the data link layer uses the flow control to
prevent the sending node on one side of the link from overwhelming the receiving node on another side of the link.
• Error detection: Errors can be introduced by signal attenuation and noise. Data Link Layer protocol provides a mechanism to
detect one or more errors. This is achieved by adding error detection bits in the frame and then receiving node can perform an
error check.
• Error correction: Error correction is similar to the Error detection, except that receiving node not only detect the errors but
also determine where the errors have occurred in the frame.
• Half-Duplex & Full-Duplex: In a Full-Duplex mode, both the nodes can transmit the data at the same time. In a Half-Duplex
mode, only one node can transmit the data at the same time
Addressing

• The data link layer encapsulates the source and destination’s MAC
address/ physical address in the header of each frame to ensure
node-to-node delivery.
• MAC address is the unique hardware address that is assigned to the
device while manufacturing.
Framing

• The packet received from the Network layer is known as a frame in the Data link layer.

• At the sender’s side, DLL receives packets from the Network layer and divides them into small
frames, then, sends each frame bit-by-bit to the physical layer.

• It also attaches some special bits (for error control and addressing) at the header and end of the
frame.

• At the receiver’s end, DLL takes bits from the Physical layer organizes them into the frame, and
sends them to the Network layer.

• Framing is an important aspect of data link layer protocol design because it allows the transmission
of data to be organized and controlled, ensuring that the data is delivered accurately and
efficiently.
Frames
• Frames are the units of digital transmission, particularly in computer networks
and telecommunications. Frames are comparable to the packets of energy called
photons in the case of light energy. Frame is continuously used in Time Division
Multiplexing process.
• Framing is a point-to-point connection between two computers or devices
consisting of a wire in which data is transmitted as a stream of bits.
• However, these bits must be framed into discernible blocks of information.
• Framing is a function of the data link layer.
• It provides a way for a sender to transmit a set of bits that are meaningful to the
receiver.
• Ethernet, token ring, frame relay, and other data link layer technologies have their
own frame structures.
• Frames have headers that contain information such as error-checking codes.
The advantage of using frames is that data is broken up into recoverable chunks that can easily be checked for corrupt

The process of dividing the data into frames and reassembling it is transparent to the user and is handled by the data link layer.
Problems in Framing
• Detecting start of the frame: When a frame is transmitted, every station must be able to
detect it. Station detects frames by looking out for a special sequence of bits that marks
the beginning of the frame i.e. SFD (Starting Frame Delimiter).
• How does the station detect a frame: Every station listens to link for SFD pattern through
a sequential circuit. If SFD is detected, sequential circuit alerts station. Station checks
destination address to accept or reject frame.
• Detecting end of frame: When to stop reading the frame.
• Handling errors: Framing errors may occur due to noise or other transmission errors,
which can cause a station to misinterpret the frame. Therefore, error detection and
correction mechanisms, such as cyclic redundancy check (CRC), are used to ensure the
integrity of the frame.
• Framing overhead: Every frame has a header and a trailer that contains control
information such as source and destination address, error detection code, and other
protocol-related information. This overhead reduces the available bandwidth for data
transmission, especially for small-sized frames.
Problems in Framing
• Framing incompatibility: Different networking devices and protocols may
use different framing methods, which can lead to framing incompatibility
issues. For example, if a device using one framing method sends data to a
device using a different framing method, the receiving device may not be
able to correctly interpret the frame.
• Framing synchronization: Stations must be synchronized with each other
to avoid collisions and ensure reliable communication. Synchronization
requires that all stations agree on the frame boundaries and timing, which
can be challenging in complex networks with many devices and varying
traffic loads.
• Framing efficiency: Framing should be designed to minimize the amount of
data overhead while maximizing the available bandwidth for data
transmission. Inefficient framing methods can lead to lower network
performance and higher latency.
Types of framing

• 1. Fixed-size: The frame is of fixed size and there is no need to provide


boundaries to the frame, the length of the frame itself acts as a delimiter.
• Drawback: It suffers from internal fragmentation if the data size is less than
the frame size
• Solution: Padding
• 2. Variable size: In this, there is a need to define the end of the frame as
well as the beginning of the next frame to distinguish. This can be done in
two ways:
• Length field – We can introduce a length field in the frame to indicate the
length of the frame. Used in Ethernet(802.3). The problem with this is that
sometimes the length field might get corrupted.
• End Delimiter (ED) – We can introduce an ED(pattern) to indicate the
end of the frame. Used in Token Ring. The problem with this is that
ED can occur in the data. This can be solved by:
• 1. Character/Byte Stuffing: Used when frames consist of characters.
If data contains ED then, a byte is stuffed into data to differentiate it
from ED.
• Let ED = “$” –> if data contains ‘$’ anywhere, it can be escaped using
‘\O’ character.
–> if data contains ‘\O$’ then, use ‘\O\O\O$'($ is escaped using \O
and \O is escaped using \O).
Disadvantage – It is very costly and obsolete method.
• 2. Bit Stuffing: Let ED = 01111 and if data = 01111
–> Sender stuffs a bit to break the pattern i.e. here appends a 0 in data =
011101.
–> Receiver receives the frame.
–> If data contains 011101, receiver removes the 0 and reads the data.
Example
• If Data –> 011100011110 and ED –> 0111 then, find data after bit
stuffing.
• --> 011010001101100
Access Control

• When multiple devices share the same communication channel there


is a high probability of collision, so it’s the responsibility of DLL to
check which device has control over the channel
and CSMA/CD and CSMA/CA can be used to avoid collisions and loss
of frames in the channel.
Collision Detection in CSMA/CD
• CSMA/CD (Carrier Sense Multiple Access/ Collision Detection) is a media access control
method that was widely used in Early Ethernet technology/LANs when there used to be
shared Bus Topology and each node ( Computers) were connected By Coaxial Cables.
• Now a Days Ethernet is Full Duplex and Topology is either Star (connected via Switch or
Router) or Point to Point ( Direct Connection). Hence CSMA/CD is not used but they are
still supported though.
• Consider a scenario where there are ‘n’ stations on a link and all are waiting to transfer
data through that channel.
• In this case, all ‘n’ stations would want to access the link/channel to transfer their own
data. The problem arises when more than one station transmits the data at the moment.
In this case, there will be collisions in the data from different stations.
• CSMA/CD is one such technique where different stations that follow this protocol agree
on some terms and collision detection measures for effective transmission.
• This protocol decides which station will transmit when so that data reaches the
destination without corruption.
How CSMA/CD works?

• Step 1: Check if the sender is ready for transmitting data packets.


• Step 2: Check if the transmission link is idle.
Sender has to keep on checking if the transmission link/medium is idle. For this, it
continuously senses transmissions from other nodes. Sender sends dummy data on the
link. If it does not receive any collision signal, this means the link is idle at the moment. If
it senses that the carrier is free and there are no collisions, it sends the data. Otherwise, it
refrains from sending data.
• Step 3: Transmit the data & check for collisions.
Sender transmits its data on the link. CSMA/CD does not use an ‘acknowledgment’
system. It checks for successful and unsuccessful transmissions through collision signals.
During transmission, if a collision signal is received by the node, transmission is stopped.
The station then transmits a jam signal onto the link and waits for random time intervals
before it resends the frame. After some random time, it again attempts to transfer the
data and repeats the above process.
• Step 4: If no collision was detected in propagation, the sender completes its frame
transmission and resets the counters.
How does a station know if its data collide?
• Consider the above situation. Two stations, A & B.
Propagation Time: Tp = 1 hr ( Signal takes 1 hr to go from A to B)

• At time t=0, A transmits its data.


• t= 30 mins : Collision occurs.
• After the collision occurs, a collision signal is generated and sent to
both A & B to inform the stations about the collision. Since the
collision happened midway, the collision signal also takes 30 minutes
to reach A & B.
• Therefore, t=1 hr: A & B receive collision signals.
Error Control

• Data can get corrupted due to various reasons like noise, attenuation,
etc. So, it is the responsibility of the data link layer, to detect the
error in the transmitted data and correct it using error
detection and correction techniques respectively. DLL adds error
detection bits into the frame’s header, so that receiver can check
received data is correct or not. It adds reliability to phyiscal layer by
adding mechansims to detect and retransmit damaged or lost frames.
ARP Address Resolution Protocol
ARCnet
ATM
CDP Cisco Discovery Protocol
CAN Controller Area Network
Econet
Ethernet
EAPS Ethernet Automatic Protection Switching
FDDI Fiber Distributed Data Interface
Frame Relay
HDLC High-Level Data Link Control
IEEE 802.2 provides LLC functions to IEEE 802 MAC layers
IEEE 802.11 wireless LAN
I²C
LattisNet
LAPD Link Access Procedures, D channel
LLDP Link Layer Discovery Protocol
LocalTalk
MIL-STD-1553
MPLS Multiprotocol Label Switching
NDP Nortel Discovery Protocol
SDN OpenFlow
PPP Point-to-Point Protocol
Profibus
SpaceWire
SLIP Serial Line Internet Protocol (obsolete)
SMLT Split multi-link trunking
IEEE 802.1aq Shortest Path Bridging
Spanning Tree Protocol
StarLan
Token ring
UDLD Unidirectional Link Detection
UNI/O

You might also like