Switch (Layer 2 vs Layer 3) vs Router vs Modem vs Hub

Last Updated: 2023-08-20


  • Switch: connects multiple devices to form or extend a local network Layer 2 (MAC) or partial layer 3 (IP). (LAN).
  • Router: connects a network to another network (e.g. to the Internet via a modem). full layer 3 features. (WAN).
  • Modem: connects your home network to the Internet.
  • Bridge: Layer 2 (MAC).
  • Hub: obsoleted. Replaced by switches. Layer 1. Hubs broadcast incoming traffic on all ports.

Hubs broadcast incoming traffic on all ports, whereas bridges and switches only route traffic towards their addressed destinations.

Reminder: IP is on Layer 3.


A modem modulates and demodulates electrical signals sent through phone lines, coaxial cables, or other types of wiring; it transforms between digital information and analog signals.

In your home, you may have one box that serves as both modem and router.

It's better to use a separate modem and router. Why? Modem technology changes slowly, but you may want to upgrade your router (e.g. to adopt the latest Wi-Fi technology, like Wi-Fi 6 or 6E).


  • allow you to share a single IP address among multiple network devices.
  • normally have a single LAN port and single WAN port
  • use information in the Layer 3 headers of Ethernet frames.
  • data packets contain the destination IP addresses of where they are headed, this enables routers and modems to communicate with each other using ICMP (Internet Control Message Protocol) to determine the most efficient path for transmitting data packets over the network to their destination point. While switches don't have inherent network protection built in, a router will often have hardware-based firewall protection that is individually configurable to your individual office or home network to give optimum connectivity.


Layer 2 vs Layer 3:

  • Layer 2 (Data Link Layer) switch: only deals with MAC addresses and cares no IP address
  • Layer 3 (Network Layer) switch: combining some features of both Layer 2 switch and routers, has both MAC address table and IP routing table, and handles intra-VLAN communication and packets routing between different VLANs. Supports higher routing such as static routing and dynamic routing.

A switch will have multiple ports for different devices to communicate within the LAN.

Switches use the best of hubs and bridges while adding more abilities. They use the multi-port ability of the hub with the filtering of a bridge, allowing only the destination to see the unicast traffic. Switches allow redundant links and, thanks to Spanning Tree Protocol (STP) developed for bridges, broadcasts and multicasts run without causing storms.

Switches keep track of the MAC addresses in each interface so they can rapidly send the traffic only to the frame's destination.

MEMS Mirros: Microelectromechanical Systems

By actuating MEMS mirros, the same input port can be connected to a different output port.

Most often, fiber optic switches routes data by using microelectromechanical systems (MEMS) to make connections when transmitting data. This involves manipulating micro mirrors to steer optical beams from inputs to outputs.

ToR Switches

the ToR switches are the leaf switches and they are attached to the spine switches.

  • Leaf swtiches are not connected to each other.
  • Spine switches only connect to the leaf switches.

In leaf-spine topology, to prevent any one uplink path from being chosen, the path is randomly chosen so that the traffic load is evenly distributed between the top-tier switches. If one of the top-tier switches were to fail, it only slightly degrades performance in data centers.

Patch Panels vs Switch

  • Patch panels
    • passive devices that are used to organize network cables. They do not route data; they simply act as fiber connection points that are used to interconnect with the network fiber.
    • do not need power.
  • Switches
    • actively filter and route data: they take incoming data and determine where to send it to, then send it only to the intended recipients.


Each network bridge keeps track of the MAC addresses on the network attached to each of its interfaces. When network traffic arrives at the bridge and its target address is local to that side of the bridge, the bridge filters that Ethernet frame, so it stays on the local side of the bridge only.

If the bridge is unable to find the target address on the side that received the traffic, it forwards the frame across the bridge, hoping the destination will be on the other network segment. At times, there are multiple bridges to cross to get to the destination system.