Physical and Data Link Layers
The Physical Layer
The Physical Layer is the lowest layer of the stack, responsible for transmitting raw bitstreams (0s and 1s) over a physical medium. It defines the electrical, mechanical, and functional specifications for the hardware.
Transmission Media
| Medium | Rate | Distance | Typical Use |
|---|---|---|---|
| Twisted Pair | 100Mbps - 10Gbps | ~100m | Office/Home LANs |
| Fiber Optics | 10Gbps - 100Gbps | Tens of KM | Backbone/Data Centers |
| Radio Waves | ~Gbps | Tens of Meters | Wi-Fi / Cellular |
Key Physics Concepts:
- Bandwidth: The maximum possible data rate of a channel.
- Signal-to-Noise Ratio (SNR): Determines the reliability of the signal.
- Shannon’s Theorem: $C = B \times \log_2(1 + S/N)$. This formula defines the theoretical speed limit of any physical communication channel.
The Data Link Layer
While the Physical Layer sends bits, the Data Link Layer sends Frames. Its mission is to ensure reliable data transfer between two directly connected nodes.
Core Responsibilities
- Framing: Wrapping Network-layer packets into frames with a distinct header and trailer.
- Physical Addressing: Using MAC Addresses to identify devices within a local network.
- Error Detection: Utilizing CRC (Cyclic Redundancy Check) to detect if bits were flipped during transmission.
- Medium Access Control: Deciding which device gets to "talk" when multiple devices share the same wire or airwaves.
The MAC Address
The Media Access Control address is a 48-bit (6-byte) unique identifier burned into the network interface card (NIC).
Format: AA:BB:CC:DD:EE:FF
─────── ───────
OUI (Mfr ID) Unique Device ID
Broadcast Address: FF:FF:FF:FF:FF:FF (Targeting everyone in the local segment)
Hardware: Hubs vs. Switches
| Device | Layer | Intelligence |
|---|---|---|
| Hub | Physical | "Dumb": Broadcasts incoming data to ALL ports. Causes collisions. |
| Switch | Data Link | "Smart": Learns MAC addresses and forwards data ONLY to the destination port. |
The MAC Table: A switch maintains a dynamic mapping of MAC Address → Port. When a frame arrives for a specific MAC, the switch looks up its table and creates a dedicated circuit to that port, allowing for full-duplex, high-speed communication without collisions.
ARP: Bridging IP and MAC
The Address Resolution Protocol (ARP) is the "translator" between the Network Layer (IP) and the Data Link Layer (MAC).
- The Problem: To send an Ethernet frame, you need the target's MAC. But you only know their IP.
- The Request: Host A broadcasts an "ARP Request": "Who has IP 192.168.1.5? Send your MAC to me."
- The Reply: Host B (the owner of that IP) replies with a unicast message: "I am 192.168.1.5, my MAC is BB:BB..."
- The Cache: Host A stores this in its ARP Table for future use (typically valid for 20 minutes).
Architectural Insights
The MTU Bottleneck
The MTU (Maximum Transmission Unit) is the largest frame size the Data Link layer can handle (usually 1500 bytes for Ethernet). If the IP layer tries to send something larger, it must be "fragmented." Fragmentation is computationally expensive and slow; modern protocols (like IPv6 and TCP) try to avoid it by doing Path MTU Discovery to find the smallest bottleneck in the path.
Why MAC stays, but IP changes
You might wonder why we need both. Think of the MAC address as your Social Security Number (it stays with you forever), while the IP address is your Postal Address (it changes depending on where you are located). The IP gets you to the right "neighborhood" (network), while the MAC gets you to the right "house" (machine) once you arrive.