Introduction
The data link layer prepares network layer packets for transmission over a specific medium. It handles local delivery, media access, frame formatting, and error detection on a single link.
Purpose of the Data Link Layer
The data link layer receives packets from the network layer and encapsulates them into frames. It also controls how devices place and receive data on the medium.
Main responsibilities include:
- Framing packets for local transmission
- Identifying local source and destination devices
- Controlling access to the medium
- Detecting transmission errors
- Supporting different physical media
Data Link Sublayers
IEEE LAN technologies commonly divide the data link layer into two sublayers.
| Sublayer | Role |
|---|---|
| Logical Link Control (LLC) | Identifies the network layer protocol carried in the frame. |
| Media Access Control (MAC) | Handles local addressing, framing, and media access rules. |
The MAC sublayer is especially important in Ethernet and wireless networks because it defines how devices share the medium.
Topologies
A topology describes how devices are arranged or how data flows.
A physical topology shows physical placement and cabling. A logical topology shows how frames move from one device to another.
WAN topologies may include point-to-point, hub-and-spoke, or mesh designs. LAN topologies are commonly built around switches, where many devices connect to a central switching device.
Half-Duplex and Full-Duplex Communication
In half-duplex communication, a device can send or receive at a given time, but not both simultaneously. This can create collisions when devices share the medium.
In full-duplex communication, devices can send and receive at the same time. Modern switched Ethernet commonly uses full-duplex communication.
Access Control Methods
When multiple devices share a medium, they need rules for deciding when to transmit.
| Method | Description |
|---|---|
| Contention-based access | Devices compete for the medium and transmit when it appears available. |
| Controlled access | Devices take turns or receive permission before transmitting. |
CSMA/CD
Carrier Sense Multiple Access with Collision Detection (CSMA/CD) was used in older shared Ethernet environments. A device listened before transmitting. If a collision occurred, devices stopped, waited, and tried again.
Modern switched Ethernet greatly reduces or eliminates collisions because each switch port is its own collision domain and usually operates in full duplex.
Data Link Frame
A frame contains the information needed for local delivery. Although frame formats vary by technology, Ethernet frames commonly include:
- Preamble and start frame delimiter
- Destination MAC address
- Source MAC address
- Type or length field
- Encapsulated data
- Frame Check Sequence (FCS) for error detection
Diagram description: A frame diagram usually displays the frame as a row of labeled fields. It shows that the packet is placed inside a frame with MAC addressing and error-checking information.