๐Ÿ”
๐Ÿ‘ถ Kids๐Ÿ“š Books๐Ÿ“ Blog About Contact ๐Ÿš€ Get Started Free

Routing & Switching

Master the core functions of network traffic management. Explore Layer 2 switching, MAC address tables, Layer 3 routing, routing protocols, and static vs. dynamic routing.

Routing vs. Switching: Core Differences

In network engineering, **Switching** and **Routing** are the two primary mechanisms used to direct data packets from their source to their destination. While they perform similar conceptual tasks, they operate at different layers of the OSI model and handle data traffic at different boundaries:

Aspect Switching (Layer 2) Routing (Layer 3)
OSI Layer Data Link Layer (Layer 2). Network Layer (Layer 3).
Addressing Used Physical **MAC Addresses** (burned into NICs). Logical **IP Addresses** (configured in software).
Boundary Operates **inside** a single local network (LAN) segment. Operates **between** different networks (WAN/LAN boundaries).
Data Unit Frames. Packets.
Primary Device Network Switch. Router.
Domain Impact Forwards broadcasts; splits collision domains. Blocks broadcasts; splits broadcast domains.

How a Switch Works: The MAC Address Table

A network switch acts as a high-speed controller connecting devices within a LAN. To ensure frames are sent directly to their intended targets rather than broadcasting them to all devices (like a hub does), a switch builds and maintains a dynamic database called a **MAC Address Table** (or CAM table). It does this using a five-step lifecycle:

  1. Learning โ€” When a device sends a frame, the switch reads the source MAC address and records it in the table alongside the physical port the frame entered (e.g., MAC `00:0a:95:9d:68:16` is on Port 3).
  2. Flooding โ€” If the switch receives a frame destined for a MAC address not yet in its table, it floods (broadcasts) the frame out of all ports (except the port it arrived on).
  3. Forwarding โ€” Once the target device replies, the switch records the target's port. The next time a frame is sent to that MAC address, the switch forwards it directly to that port (unicast forwarding).
  4. Filtering โ€” If the source and destination MAC addresses are on the same physical port segment, the switch drops (filters) the frame, reducing local congestion.
  5. Aging โ€” To prevent the table from filling with inactive devices, entries are deleted after a period of inactivity (typically 300 seconds).

Routing Protocols: Interior vs. Exterior Gateway Protocols

Routers forward packets across networks using **Routing Tables**. These tables are populated manually (static routing) or dynamically via **Routing Protocols** that allow routers to share information about network topology. These protocols are classified into two groups:

1. Interior Gateway Protocols (IGP)

Used to route data within a single organization's autonomous system (like a corporate network or university campus):

  • Distance Vector (e.g., RIP - Routing Information Protocol): Routers share their entire routing tables with neighbors at fixed intervals. RIP uses **hop count** (the number of routers a packet passes through) to determine the best path. It has a limit of 15 hops, making it legacy and unsuitable for large networks.
  • Link-State (e.g., OSPF - Open Shortest Path First): Instead of sharing tables, routers share link-state advertisements (LSAs) containing the status of their active interfaces. Every router builds a complete map of the network and calculates paths using Dijkstraโ€™s algorithm. Highly scalable, fast convergence.
  • Hybrid (e.g., EIGRP - Enhanced Interior Gateway Routing Protocol): A Cisco-proprietary protocol combining distance-vector and link-state characteristics, using bandwidth, delay, reliability, and load to calculate path costs.

2. Exterior Gateway Protocols (EGP)

Used to route data between different autonomous systems. The internet is built on EGPs:

  • Path Vector (e.g., BGP - Border Gateway Protocol): The routing protocol of the Internet. BGP coordinates path decisions between ISPs, managing routing tables containing hundreds of thousands of routes based on network policies and path vectors (autonomous system hops).

Static vs. Dynamic Routing

Network engineers choose between static and dynamic methods based on network complexity:

  • Static Routing โ€” Network paths are manually entered into the routing table by an administrator.
    • *Pros:* Low CPU/RAM overhead on routers, highly secure (no routing updates shared), complete control over paths.
    • *Cons:* Highly manual; does not scale. If a link goes down, the path does not redirect automatically, leading to network downtime.
  • Dynamic Routing โ€” Protocols dynamically adjust paths based on network conditions.
    • *Pros:* Automatic redirection if a link fails, highly scalable for large networks, minimal manual updates.
    • *Cons:* Higher router resource usage, complex troubleshooting, routing protocols can be vulnerable to spoofing.

Frequently Asked Questions (FAQ)

โ“ What is the difference between a collision domain and a broadcast domain?

  • A Collision Domain is a network segment where data packets can collide with each other during transmission (e.g., devices connected to a hub). Standard switch ports split collision domains.
  • A Broadcast Domain is a network segment where a broadcast frame (sent to all devices) is received by all hosts. Standard switches forward broadcasts. Routers block broadcasts, splitting broadcast domains.

โ“ What is a Layer 3 Switch?

A Layer 3 switch is a hybrid device. It performs high-speed local switching (Layer 2) using specialized hardware, but also contains routing capabilities (Layer 3) to forward packets between virtual local area networks (VLANs) without needing an external router. It is faster than a standard router for internal routing but lacks WAN connectivity features.

โ“ What is a routing metric?

A routing metric is a mathematical value assigned by a routing protocol to evaluate the cost of a path. Routers choose the path with the lowest metric. Metrics vary by protocol: RIP uses hop count, OSPF uses cost (calculated from interface bandwidth), and EIGRP uses a composite formula based on bandwidth and link delay.

โ“ What is convergence in routing?

Convergence is the time it takes for all routers in a network to update their routing tables and agree on the new network topology after a change has occurred (such as a link failing or a new router being added). Fast convergence is critical to prevent routing loops and packet drops.

What's Next?

Advance your network routing studies: