Track 1 • Module G1 of 4 • Layer 2 vs. Layer 3

Switches (Layer 2) vs. Routers (Layer 3), MAC Addresses, ARP & VLANs

Why does every computer have both a MAC Address and an IP Address? And what is the exact difference between a Switch and a Router? Run the 3 interactive flows below and watch the Live L2/L3 Envelope Inspector inside the diagram!

✉️
The Envelope-Inside-an-Envelope Analogy: The Layer-3 IP Header is the permanent ink letter addressed from Sender City/Street (Src IP) to Final Destination City/Street (Dst IP)—it stays the same for the whole trip. The Layer-2 MAC Header is the outer courier pouch that only says "Which device in this room holds the packet next?" A Switch reads the outer MAC pouch inside one room. A Router opens the outer MAC pouch, reads the inner IP address, and puts on a brand-new MAC pouch for the next room!
Next: Module G2 (IPs, CIDR & Subnets) → ← Back to General Networking Hub
Interactive Switch (L2) & Router (L3) Frame/Packet Simulator
🏠 Subnet 1: Office LAN (192.168.1.0/24) Devices here share a Layer-2 Switch • Default Gateway = 192.168.1.1 💻 PC-A (Sender) IP: 192.168.1.10 MAC: AA:AA:11 Switch Port 1 • VLAN 10 GW: 192.168.1.1 🖥️ PC-B (Neighbor) IP: 192.168.1.20 MAC: BB:BB:22 Switch Port 2 • VLAN 10 Same /24 IP Prefix! 🔌 L2 Ethernet Switch Only reads Layer-2 MAC Header! CAM / MAC Address Table Port 1 → AA:AA:11 (V10) Port 2 → BB:BB:22 (V10) Port 3 → R1:FA:01 (Rtr) ✓ MACs Learned (No ARP needed) 🧭 L3 Default Router Connects Subnet 1 & Subnet 2 eth0: 192.168.1.1 MAC: R1:FA:01 eth1: 10.0.5.1 (R1:FA:02) At Every Router Hop: 1. Strips old L2 MAC Frame 2. Keeps L3 IP, TTL - 1 3. Wraps new L2 MAC Frame 🏢 Subnet 2 (10.0.5.0/24) Different IP Network • GW: 10.0.5.1 🗄️ App Server-C IP: 10.0.5.50 MAC: CC:CC:33 Lives in Subnet 2 Reachable ONLY via Router! 📦 LIVE ENVELOPE INSPECTOR (Watch Layer-2 MAC Change While Layer-3 IP Stays Constant!) 🏷️ OUTER ENVELOPE: Layer-2 Ethernet Frame (Hop-by-Hop) SRC MAC: AA:AA:11 → DST MAC: BB:BB:22 ✉️ INNER LETTER: Layer-3 IP Packet (End-to-End) SRC IP: 192.168.1.10 → DST IP: 192.168.1.20 (TTL: 64)
Layer 2 MAC Header = Rewritten at every router hop Layer 3 IP Header = Stays constant end-to-end (unless NAT is used)