FOUNDATIONS / SYSTEM CONCEPT BRIEF

Network devices

Network devices move data between computers at different layers of the network.

BeginnerPhase 01 / Topic 15 of 17RequirementsTrade-offsFailure modes
01

Overview

Network devices move data between computers at different layers of the network. A hub (layer 1) repeats every signal to every port. A switch (layer 2) learns which device is on which port using MAC addresses and forwards frames only where needed. A router (layer 3) connects different networks and forwards packets by IP address, choosing paths using routing tables.

A home "router" usually combines several devices in one box - a modem (converts the provider's signal to Ethernet), a router with NAT, a switch, a Wi-Fi access point, a DHCP server, and a firewall. In data centers these roles are separate, and load balancers, firewalls, and gateways sit on top of the same foundations.

A building's mail system

A hub is someone shouting every letter to the whole floor. A switch is a mail clerk who knows which desk each person sits at. A router is the post office that sends letters to other buildings and cities by address.

02

When to use it

  • Understanding how a request physically reaches a server.
  • Explaining latency, broadcast domains, and network segmentation.
  • Designing VPCs, subnets, and on-premises networks.
  • Debugging connectivity problems.
03

Where it shows up in interviews

Request journey

Recognize it when: "What happens when you type a URL?" at the network level.

  • Explain how a packet reaches a web server
  • Design network segmentation for a company
Cloud networking

Recognize it when: subnets, gateways, and routing in a VPC.

  • Design a secure three-tier VPC
  • Connect on-premises to the cloud
04

Where it is used in real software

Home networks

ISP gateways combine modem, router, NAT, DHCP, Wi-Fi access point, and firewall in one device.

Data centers

Leaf-spine architectures use top-of-rack switches connected to spine switches for predictable, low-latency east-west traffic.

Cloud VPCs

AWS route tables, internet gateways, and NAT gateways are software-defined versions of routers and NAT devices.

05

Key terms

MAC address
Hardware address used by switches within a local network (layer 2).
IP address
Logical address used by routers across networks (layer 3).
Routing table
Rules mapping destination networks to next hops.
NAT
Rewrites private addresses to a public one so many devices share one IP.
Broadcast domain
Set of devices that receive each other's broadcasts; routers separate them.
06

How it works, step by step

  1. 1
    Device sends a frame

    The laptop wraps an IP packet in an Ethernet or Wi-Fi frame addressed to the gateway's MAC address.

  2. 2
    Switch forwards locally

    The switch looks up the destination MAC in its table and sends the frame out one port.

  3. 3
    Router forwards between networks

    The router reads the destination IP, consults its routing table, applies NAT, and sends it toward the ISP.

  4. 4
    Internet routers hop the packet

    Each router forwards to the next hop until the destination network is reached.

  5. 5
    Destination network delivers

    The server's router and switch deliver the packet to the server's network card.

A packet leaving a home network
Step 1 / 4
Laptop
Switch
Router + NAT
Modem
ISP
Server

STEP 1The laptop sends a frame to the gateway's MAC address. The switch forwards it only to the router's port.

07

Device comparison

What each device looks at and does

Step 1 / 5
DeviceOSI layerUsesBehavior
Hub1 (physical)Nothing (signals only)Repeats to all ports; collisions and wasted bandwidth
Switch2 (data link)MAC addressesLearns ports; forwards to the right device
Router3 (network)IP addressesConnects networks; chooses paths; often NAT
Modem1-2Provider signalConverts cable/DSL/fiber to Ethernet
Access point2MAC addressesBridges Wi-Fi clients to the wired network

NOWDevice: Hub | OSI layer: 1 (physical) | Uses: Nothing (signals only) | Behavior: Repeats to all ports; collisions and wasted bandwidth

Switches keep local traffic efficient; routers connect networks and define boundaries.

08

Implementation

# Your interfaces, IP, and MAC addressip addr            # Linux  (macOS: ifconfig) # Default gateway (your router)ip route | grep default     # Linux  (macOS: netstat -rn | grep default) # MAC addresses the machine has learned on the local network (ARP table)arp -a # Every router hop between you and a servertraceroute example.com # Is the path healthy? Packet loss and latency per hopmtr -rwzc 20 example.com
09

Complexity and performance

Switch forwardingO(1) table lookup

In hardware at line rate.

Router lookupLongest-prefix match

Specialized hardware (TCAM) or tries.

10

Trade-offs

Flat vs segmented networks

A flat network is simple but lets broadcasts and attacks spread; routing between subnets adds isolation and control at the cost of configuration.

Combined vs dedicated devices

All-in-one home devices are convenient; dedicated devices in data centers scale better and fail independently.

11

Variants and related techniques

Layer 3 switches

Switches that also route between VLANs at hardware speed.

Software-defined networking

Cloud providers implement routers, switches, and firewalls in software controlled by APIs.

12

Common mistakes

  • Calling every box a router.

    Fix: Distinguish modem, router, switch, and access point roles when explaining network paths.

  • Assuming a private IP is reachable from the internet.

    Fix: Private addresses are translated by NAT; inbound access needs port forwarding, a load balancer, or a public IP.

13

Interview questions

What is the difference between a switch and a router?

A switch forwards frames within one local network using MAC addresses. A router connects different networks and forwards packets using IP addresses and routing tables, often also performing NAT.

How does a router choose where to send a packet?

It finds all routing table entries whose network contains the destination IP and picks the most specific one (longest prefix match), falling back to the default route 0.0.0.0/0.

14

Practice problems

ProblemDifficultyWhat it trains
Trace a packet from laptop to serverEasyDevice roles.
Design subnets and routes for a three-tier appMediumSegmentation.