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 + 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).

πŸ™Œ Connect With Me

GitHub LinkedIn YouTube Gmail

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