Table of Contents
Role of the Data Link Layer
The Data Link layer is Layer 2 of the OSI model. Its main purpose is to move data between directly connected devices over a specific physical medium. While the Physical layer is concerned with signals and cables or radio waves, the Data Link layer is concerned with how those signals are grouped, addressed, and checked so that one device on the same link can reliably talk to another.
On a typical Ethernet network, the Data Link layer defines how bits are grouped into frames, how devices on the same local network are identified by hardware addresses, and how errors on the link are detected. It connects higher layers, which work with packets, to the actual transmission medium, which only sees bits.
Frames and Link-Level Communication
At the Data Link layer, the unit of data is called a frame. Higher layers, such as the Network layer, hand down packets. The Data Link layer adds its own information before and after those packets, creating a frame that can be transmitted over the local link.
A simple view of an Ethernet frame structure is:
| Field | Purpose |
|---|---|
| Destination MAC | Hardware address of the receiver on link |
| Source MAC | Hardware address of the sender |
| Type / Length | Identifies what is inside (for example IPv4) |
| Payload | The actual data, often a Network layer packet |
| FCS (CRC) | Error check value for the frame |
The exact details of the Ethernet frame are studied in the Ethernet and Switching section, but it is important here to understand that the Data Link layer wraps higher layer data inside a frame with local addressing and error detection information.
Data Link communication is always local. A frame is only delivered across one single link, such as between a host and a switch, or between two switches that share a cable. Getting traffic across multiple networks is the job of the Network layer. The Data Link layer only concerns itself with the hop from one node to the next node on that path.
Local Addressing and MAC Addresses
At Layer 2, devices on the same link or local network use hardware addresses. In Ethernet, these are called MAC (Media Access Control) addresses. A MAC address is typically written as six pairs of hexadecimal digits, such as 00:1A:2B:3C:4D:5E.
The Data Link layer uses these addresses to decide which device on the same network segment should receive a frame. When a host sends a frame, it fills in the destination MAC address with the address of the next device on the local link that should receive the frame. That device may be the final recipient or an intermediate device such as a router.
Broadcast and multicast are also defined at this layer. A special broadcast MAC address indicates that all devices on the local network segment should receive the frame. Multicast MAC addresses indicate a group of devices with a shared interest in specific traffic. These concepts are tied to how switches operate and will be revisited in the Ethernet and Switching part of the course.
Logical Sub-Layers: LLC and MAC
The Data Link layer is often divided into two logical parts: Logical Link Control (LLC) and Media Access Control (MAC). These are not separate OSI layers, but sub-layers within Layer 2.
The LLC sub-layer focuses on identifying which Network layer protocol is carried in the frame, and on providing an interface between the Network layer and the Data Link layer. It also defines some optional flow control and error control mechanisms above the basic frame structure.
The MAC sub-layer focuses on how frames are actually sent and received over the shared physical medium. It defines addressing at Layer 2 and how devices access the medium without talking over each other. In Ethernet, the MAC sub-layer is responsible for using MAC addresses, interpreting frame headers and trailers, and following the rules for when a device is allowed to transmit.
In practice, you can think of the LLC part as dealing with what is inside the frame and how it relates to higher layers, while the MAC part deals with how the frame is placed onto the wire or radio link.
Media Access Control on Shared Links
On a shared medium, more than one device may want to send data at the same time. The Data Link layer must include rules about when a device can transmit. This is known as media access control.
Different link technologies use different access methods. Historically, Ethernet used a method where devices listened before talking, to try to avoid sending at the same time. Modern switched Ethernet provides each device with its own dedicated link, so collisions are effectively removed, but the concept that the Data Link layer controls access to the medium remains.
Wireless networks use their own media access rules, since devices must share radio space that is inherently shared among many users. While the specific mechanisms are studied later, all of them are Data Link functions, because they govern who can talk, when they can talk, and how to reduce interference between senders.
Error Detection on the Link
The physical medium can introduce errors, such as flipped bits due to noise. The Data Link layer adds error detection information so that the receiving device can check whether the frame arrived intact.
In Ethernet, this is done using a Frame Check Sequence (FCS) based on a Cyclic Redundancy Check (CRC). The sender computes a CRC value from the contents of the frame and places this value in the FCS field. The receiver performs the same calculation on the received bits and compares the result to the FCS in the frame.
If the values match, the receiver assumes the frame is intact. If they do not match, the frame is considered corrupted and is discarded. The Data Link layer in basic Ethernet does not try to fix the error, it only detects it.
The CRC operation itself is based on binary arithmetic, but you do not need the internal mathematics at this stage. What matters is that CRC provides a strong way to detect many types of errors on the physical link.
Important: At the Data Link layer, frames with an incorrect Frame Check Sequence (FCS) must be treated as invalid and discarded to prevent corrupted data from being passed up to higher layers.
Some Data Link technologies can also perform simple retransmissions at this layer, especially in wireless environments, but in many common wired networks, reliability is mainly handled at higher layers such as the Transport layer.
Point-to-Point vs Shared Links
The Data Link layer must handle slightly different tasks depending on whether the link connects only two devices or is shared.
On a point to point link, such as a direct connection between two routers with a serial link or a dedicated fiber, there are exactly two endpoints. In this case, the Data Link layer is simpler. Addressing can be minimal because each frame has only one possible receiver on the other side. The main concerns are framing, error detection, and sometimes link-level control.
On a shared link, such as a traditional hub based Ethernet segment or a wireless channel, many devices may be connected to the same physical medium. The Data Link layer must handle local addressing so that frames reach the correct device, and media access control so that devices share the medium fairly and avoid constant interference.
Switches change how shared Ethernet works internally, since they separate collision domains, but the concept of many hosts sharing a broadcast domain at Layer 2 remains. Frames still rely on MAC addresses and standard Data Link rules to identify their intended recipients.
Relationship with the Physical and Network Layers
The Data Link layer sits directly above the Physical layer and directly below the Network layer. Each direction has a clear relationship.
Downward, when a higher layer passes data to the Data Link layer, the Data Link layer encapsulates that data into frames, adds local addresses and error detection, and passes a sequence of bits to the Physical layer. The Physical layer then converts these bits into electrical, optical, or radio signals.
Upward, when bits arrive from the Physical layer, the Data Link layer groups them into frames, verifies them using error detection, checks local addresses, and then removes its header and trailer information. It passes the remaining payload, typically a Network layer packet, up to the Network layer.
The Network layer is concerned with addressing across different networks and routing between them. It does not care about how individual links operate. The Data Link layer hides the details of each specific link type and presents a uniform way to send and receive packets over a single hop. This separation allows very different link types, such as Ethernet, Wi Fi, and point to point serial links, to coexist in the same end to end network.
Data Link Layer in Practice
In practical Ethernet based networks, the Data Link layer is where switches operate. A switch reads the destination MAC address of incoming frames and forwards them out only on the port that leads toward the correct device, instead of repeating frames to all ports. This forwarding based on MAC addresses is a core Data Link function.
Technologies such as VLANs also operate at the Data Link layer. VLANs allow one physical switch to carry multiple separate logical networks, identified by tags in the frame header. These tags are interpreted and processed at Layer 2.
Wireless access points use Data Link layer functions to manage associations, acknowledgments, and retransmissions over the air. Even though the medium is different and the frame format is more complex than wired Ethernet, it still belongs to the same OSI layer.
As you continue through the course, specific technologies such as Ethernet frames, MAC addresses, VLANs, Wi Fi, and switching behavior will all build on the concepts introduced here for the Data Link layer.