Ethernet LAN Switching
π Demystifying Ethernet LAN Switching Fundamentals
Ethernet LAN switching is the backbone of modern networking. Whether youβre a beginner, preparing for an interview, or brushing up on your fundamentals, understanding how frames move inside a LAN is crucial. Letβs break it down in a simple yet technical way.
1οΈβ£ What is a LAN?
A Local Area Network (LAN) is a group of devices within a limited area (like an office or home) that can communicate without a router.
π Think of it as a Layer 2 domain β all devices in the same LAN can talk directly using MAC addresses.
- Example: Two PCs connected to the same switch belong to the same LAN.
- If they need a router to communicate, they are in different LANs.
2οΈβ£ Switches: The Layer 2 Architects
A switch operates at the Data Link Layer (Layer 2) of the OSI model.
- It reads the Ethernet header (not the IP header like a router).
- Its job? Forward frames intelligently based on MAC addresses.
In short:
- Router β Layer 3 β IP addresses
- Switch β Layer 2 β MAC addresses
3οΈβ£ Anatomy of an Ethernet Frame
An Ethernet frame is the PDU (Protocol Data Unit) of Layer 2.
πΉ Key Components
- Preamble (7 bytes) β Alternating 1s and 0s for synchronization.
- SFD (Start Frame Delimiter, 1 byte) β Marks where the frame begins (
10101011). - Destination MAC (6 bytes) β Who the frame is going to.
- Source MAC (6 bytes) β Who sent the frame.
- Type/Length (2 bytes) β Either the EtherType (IPv4, IPv6) or the length.
- Payload β Actual data (e.g., IP packet).
- FCS (Frame Check Sequence, 4 bytes) β Uses CRC to detect errors.
π‘ MAC Addresses in Action
- 48 bits (6 bytes), written in hexadecimal (e.g.,
0C:F5:A4:52:B1:01). - First 3 bytes β OUI (Organizationally Unique Identifier) (manufacturer).
- Last 3 bytes β Unique per device.
4οΈβ£ How Switches Learn and Forward Frames
Switches use a MAC Address Table (CAM Table) to make forwarding decisions.
πΉ MAC Learning
- When a switch receives a frame, it records the Source MAC + Port in the MAC table.
- These are dynamic MAC addresses.
- If unused for 5 minutes β they are removed (MAC aging).
πΉ Frame Forwarding Logic
- Known Unicast β If MAC is in the table, forward to that specific port.
- Unknown Unicast β If MAC not in the table, flood out all ports (except incoming).
- Broadcast β Always flooded (e.g., ARP request).
π Cisco Commands:
1
2
show mac address-table
clear mac address-table dynamic
5οΈβ£ ARP: Connecting IP and MAC
Switches forward at Layer 2, but hosts use IP addresses at Layer 3. Thatβs where ARP (Address Resolution Protocol) comes in.
- ARP Request β Broadcast asking βWho owns IP X.X.X.X?β
- ARP Reply β Unicast response: βThatβs me, hereβs my MAC.β
- Stored in the ARP Table for efficiency.
πΉ Broadcast MAC address β FF:FF:FF:FF:FF:FF
## 6οΈβ£ Ping: The Connectivity Test
ping is the simplest and most powerful connectivity tool.
- Uses ICMP Echo Request & Echo Reply (unicast).
- Tests reachability and measures Round Trip Time (RTT).
- Cisco IOS:
!!!!!= successful replies.....= timeouts
7οΈβ£ Broadcast Domains and Flooding
A broadcast domain is the set of devices that receive broadcast frames.
- All devices in the same switch or connected switches (without a router) are in one broadcast domain.
- Routers separate broadcast domains.
π Quick Interview Questions
1. What is the difference between a LAN and VLAN?
2. What happens when a switch receives a frame with an unknown MAC?
3. What is the function of the FCS in an Ethernet frame?
4. How does ARP work?
5. How is a broadcast domain different from a collision domain?
π― Key Takeaways
Switches work at Layer 2, using MAC addresses.
Ethernet frames are the fundamental units of LAN communication.
MAC learning + forwardingallows efficient traffic flow.
ARP bridges IP and MAC for host-to-host communication.
Ping & ARP are your best friends for troubleshooting.
β By mastering these basics, youβll be ready for both real-world networking and interview challenges. This is the foundation of switching before diving into advanced topics like VLANs, STP, and trunking.
β‘ Cheat Sheet
Quick revision notes for learners & interview prep π
πΉ LAN Basics
- LAN (Local Area Network): Devices communicate without a router (Layer 2 domain).
- Broadcast Domain: Devices that receive broadcast frames. Routers break broadcast domains.
πΉ Switch Fundamentals
- Layer: Operates at Layer 2 (Data Link).
- Forwarding Decision: Based on MAC address (Ethernet header).
- MAC Address Table (CAM Table): Stores MAC β Port mapping.
πΉ Ethernet Frame Structure
| Field | Size | Purpose |
|ββ-|ββ|βββ-|
| Preamble | 7 bytes | Sync, alternating 1s/0s |
| SFD | 1 byte | Marks start (10101011) |
| Destination MAC | 6 bytes | Receiverβs MAC |
| Source MAC | 6 bytes | Senderβs MAC |
| Type/Length | 2 bytes | EtherType (IPv4=0x0800, IPv6=0x86DD) OR length |
| Payload | 46β1500 bytes | Encapsulated data |
| FCS | 4 bytes | CRC error checking |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
ETHERNET
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+---------------+---------------+------+---------+----+
| Preamble | Destination Address | Source Address |
| (8 Bytes) | (6 Bytes) | (6 Bytes) |
+-+-+-+-+-+-+-+-+---------------+---------------+------+---------+----+
| Type (2B) | Data (46β1500 Bytes) |
+-+-+-+-+-+-+-+-+-----------------------------------------+-----------+
| Frame Check Sequence (4 Bytes) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
IEEE 802.3
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+---+---------------+---------------+------+-------------+----+
|Preamble|SOF| Destination Address | Source Address | |
| (7B) |1B | (6 Bytes) | (6 Bytes) | |
+-+-+-+-+---+---------------+---------------+------+-------------+----+
| Type (2B) | Data (46β1500 Bytes) |
+-+-+-+-+-+-+-+-+-----------------------------------------+-------+---+
| Frame Check Sequence (4 Bytes) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
πΉ MAC Address
- Length: 48 bits (6 bytes).
- Format: Hexadecimal β
0C:F5:A4:52:B1:01. - Parts:
- First 3 bytes β OUI (Manufacturer).
- Last 3 bytes β Unique device value.
πΉ Switch Forwarding Logic
- Known Unicast: Forward out specific port.
- Unknown Unicast: Flood to all ports (except incoming).
- Broadcast: Always flooded (
FF:FF:FF:FF:FF:FF).
π MAC Learning: Switch learns Source MAC + Port.
π MAC Aging: Entries removed after 5 minutes (default).