Post

Ethernet LAN Switching

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 + forwarding allows 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

FieldSizePurpose
Preamble7 bytesSync, alternating 1s/0s
SFD1 byteMarks start (10101011)
Destination MAC6 bytesReceiver’s MAC
Source MAC6 bytesSender’s MAC
Type/Length2 bytesEtherType (IPv4 = 0x0800, IPv6 = 0x86DD) or length
Payload46–1500 bytesEncapsulated data
FCS4 bytesCRC 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).

🙌 Connect With Me

GitHub LinkedIn YouTube Gmail

This post is licensed under CC BY 4.0 by the author.