Data Link Layer and LANs
The data link layer moves frames between devices on the same network segment.
MAC addresses
A MAC address is a 48-bit hardware address (for example 3C:22:FB:1A:9B:00) used inside a LAN. IP addresses are for end-to-end routing; MAC addresses are for the next hop.
Devices
| Device | Layer | Behaviour |
|---|---|---|
| Hub | 1 | Repeats bits to all ports |
| Switch | 2 | Learns MAC addresses and forwards frames only to the right port |
| Bridge | 2 | Connects two LAN segments |
| Router | 3 | Forwards packets between networks using IP |
A switch builds a MAC address table: when a frame arrives it records "source MAC is on port N", and floods the frame only if the destination is unknown.
ARP
The Address Resolution Protocol maps an IP address to a MAC address on the local network.
Host A: "Who has 192.168.1.10? Tell 192.168.1.5" (broadcast)
Host B: "192.168.1.10 is at 3C:22:FB:1A:9B:00" (unicast reply)
Results are cached in the ARP table.
Error detection
| Method | Notes |
|---|---|
| Parity bit | Detects odd numbers of bit errors |
| Checksum | Sum of data words (used in IP/TCP/UDP) |
| CRC | Polynomial division; strong burst-error detection; used in Ethernet |
| Hamming code | Detects and corrects single-bit errors |
Medium access control
- CSMA/CD (classic wired Ethernet): listen, send, detect collision, back off.
- CSMA/CA (Wi-Fi): avoid collisions with random back-off and optional RTS/CTS.
VLANs
A VLAN logically splits one switch into several broadcast domains, improving security and reducing broadcast traffic.