Switch (Layer 2 vs Layer 3) vs Router vs Modem vs Hub
- Switch: connects multiple devices to form or extend a local network Layer 2 or partial layer 3. (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.
- Hub: obsoleted. Replaced by switches.
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.
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.