Data Link Layer
The data link layer is the second layer of the OSI model. It is responsible for node-to-node delivery of frames across a single link. Its duties include framing, physical addressing, flow control, error control, and access control.
Framing
Framing divides the bit stream from the physical layer into manageable units called frames. Methods include character count, byte stuffing (flag bytes with escape characters), and bit stuffing (inserting bits to avoid flag patterns). Each frame carries source and destination addresses, data, and error-checking information.
Error Detection
Errors occur during transmission due to noise. Detection methods include parity check (single-bit), checksum (sum of data segments), and Cyclic Redundancy Check (CRC), which is the most powerful. CRC uses polynomial division to generate a remainder appended to the frame; the receiver performs the same division to detect errors.
Error Correction
Error correction can be done by retransmission (ARQ — Automatic Repeat Request) or forward error correction (FEC) using Hamming codes. Hamming code adds redundant bits at power-of-2 positions to detect and correct single-bit errors.
Flow Control
Flow control prevents the sender from overwhelming the receiver. Stop-and-Wait sends one frame at a time and waits for an ACK. Sliding Window allows multiple frames in transit, improving efficiency. The window size determines how many unacknowledged frames can be outstanding.
ARQ Protocols
Stop-and-Wait ARQ retransmits on timeout or NAK. Go-Back-N ARQ retransmits all frames from the lost one onward (sender window > 1, receiver window = 1). Selective Repeat ARQ retransmits only the damaged frame (both windows > 1), which is more efficient but more complex.
Medium Access Control
When multiple devices share a link, MAC protocols determine who transmits. Random access methods include ALOHA, Slotted ALOHA, CSMA, CSMA/CD (Ethernet), and CSMA/CA (Wi-Fi). Controlled access includes reservation, polling, and token passing. Channelisation includes FDMA, TDMA, and CDMA.
Ethernet and IEEE 802.3
Ethernet (IEEE 802.3) is the dominant LAN technology. It uses CSMA/CD for access control. Frame format includes preamble, destination/source MAC addresses, type/length, data, and FCS. Modern Ethernet runs at 10 Mbps, 100 Mbps (Fast), 1 Gbps (Gigabit), and 10 Gbps or higher.
Summary
The data link layer provides reliable node-to-node communication through framing, error handling, flow control, and media access. Understanding these mechanisms is critical for grasping how networks function at the physical level.