Summary
Highlights
The Data Link Layer (Layer 2) of the OSI model is responsible for encapsulating Layer 3 packets (IPv4/IPv6) into frames, adding source and destination MAC addresses, and preparing them for physical transmission. It is broken into two sub-layers: the Logical Link Control (LLC) and the Media Access Control (MAC).
The Logical Link Control (LLC) sub-layer handles communication with upper layers via software, following the 802.2 protocol, and sets up the frame to contain the packet. The Media Access Control (MAC) sub-layer is responsible for completing the addressing details on the frame (MAC addresses) and placing the frame onto the physical layer for transmission, as well as managing media access.
When a frame reaches a router (gateway), the router extracts the packet, discards the old frame, and re-encapsulates the packet into a new frame suitable for external travel (e.g., WAN). This process ensures the packet can traverse different network segments.
There are two main types of network topologies: physical (how devices are physically connected) and logical (how devices are virtually connected via IP addresses, subnets, etc.). Common physical topologies include point-to-point, star (most common in LANs), and mesh. Older topologies like bus and ring are no longer widely used.
Communication can be half-duplex (transmit and receive, but not simultaneously, like a walkie-talkie) or full-duplex (simultaneous transmit and receive, like a telephone). Full-duplex Ethernet can double bandwidth but often requires two ports. Simplex communication (transmit or receive only, like a radio) is also mentioned.
Network access methods include contention-based and controlled access. Contention-based methods, like Carrier Sense Multiple Access with Collision Detection (CSMA/CD) used in older Ethernet networks, mean devices contend for network access. CSMA/CD involves sensing the medium, transmitting when clear, detecting collisions, and backing off if a collision occurs. Switches have largely eliminated the need for CSMA/CD by providing dedicated connections.
For wireless LANs (802.11), Carrier Sense Multiple Access with Collision Avoidance (CSMA/CA) is used. Instead of detecting collisions, wireless devices send a request to the access point to transmit, to avoid collisions proactively. The access point acts like air traffic control, granting permission to transmit.
A data link frame encapsulates a Layer 3 packet by adding a header (front) and a trailer (back). The header specifically includes the source and destination MAC addresses. As a packet travels through different routers, it is removed from one frame and placed into a new frame with new MAC addresses, effectively 'changing frames' until it reaches its final destination.
Common data link protocols for wired LANs include Ethernet and 802.11 (wireless LANs often use this for logical framing). For WAN framing, protocols like PPP (Point-to-Point Protocol), HDLC (High-Level Data Link Control), and Frame Relay are used. All these frames carry encapsulated packets.