Getting everything ready for you…

Loading courses, problems and your progress. This takes just a moment.

0s

Notes › Computer Networks

Network Devices and Common Ports

Devices by OSI layer

Device Layer Works with What it does
Repeater 1 Physical signals regenerates a weak signal to extend a cable
Hub 1 Physical bits copies every signal to all ports — dumb, many collisions
Bridge 2 Data link MAC connects two LAN segments, filters by MAC
Switch 2 Data link MAC learns which MAC is on which port and sends frames only there
Layer-3 switch 3 IP switch with routing built in (VLANs)
Router 3 Network IP connects different networks, picks paths using routing tables
Gateway up to 7 protocols connects networks that use different protocols (also: "default gateway" = your router)
Modem 1 signals modulates/demodulates between digital and the ISP line (DSL, cable, fibre ONT)
Access point 2 Wi-Fi frames lets wireless devices join a wired LAN
Firewall 3–7 IP, ports, apps allows/blocks traffic by rules
Proxy 7 HTTP etc. makes requests on behalf of clients (forward proxy) or servers (reverse proxy)
Load balancer 4 or 7 TCP / HTTP spreads requests across servers — see Load Balancing

A home "Wi-Fi router" is usually a router + switch + access point + DHCP server + NAT + firewall (+ modem) in one box.

How a switch learns (MAC table)

  1. A frame arrives on port 3 from MAC AA → the switch records "AA is on port 3".
  2. Destination MAC known → send only to that port. Unknown → flood to all ports except the incoming one.
  3. Entries expire after a while (aging).

Collision and broadcast domains

Device Breaks collision domains? Breaks broadcast domains?
Hub / repeater ❌ (all ports = 1 collision domain) ❌
Switch / bridge ✅ (each port is its own) ❌ (unless VLANs)
Router ✅ ✅ (each interface is its own)
Example: a router with 2 interfaces, each to a switch with 4 PCs → collision domains = 8 (switch ports to PCs) + 2 (router–switch links) = 10; broadcast domains = 2.

Hub vs switch vs router

Hub Switch Router
Layer 1 2 3
Address used none MAC IP
Sends to everyone the right port the right network
Duplex half full full
Connects devices in a LAN devices in a LAN LANs / to the internet

VLANs

A VLAN splits one physical switch into several logical networks (e.g. Students, Staff, Guests) — each is its own broadcast domain. Traffic between VLANs must go through a router or layer-3 switch. Trunk links carry many VLANs using 802.1Q tags.

Firewalls

Forward vs reverse proxy

Forward proxy Reverse proxy
sits in front of clients sits in front of servers
hides who the client is, filters, caches TLS termination, load balancing, caching, hides servers
office/school proxy, VPN-like Nginx, Cloudflare, API gateways

Ports

A port (0–65535) identifies the application on a host; IP + port + protocol = a socket.

Port Protocol Transport Use
20 / 21 FTP data / control TCP file transfer (insecure)
22 SSH / SFTP TCP secure remote login
23 Telnet TCP remote login (insecure)
25 SMTP TCP sending email between servers (587 for client submission, 465 SMTPS)
53 DNS UDP (+TCP) name resolution
67 / 68 DHCP server / client UDP IP assignment
69 TFTP UDP simple file transfer
80 HTTP TCP web
110 POP3 TCP download email (995 secure)
123 NTP UDP time sync
143 IMAP TCP read email on the server (993 secure)
161 / 162 SNMP UDP network monitoring
443 HTTPS TCP (+UDP for HTTP/3) secure web
3306 MySQL TCP database
5432 PostgreSQL TCP database
6379 Redis TCP cache
27017 MongoDB TCP database
3389 RDP TCP Windows remote desktop
3000 / 5173 / 8080 dev servers TCP Node/React/Vite, Tomcat

Mnemonic: 21 FTP, 22 SSH, 23 Telnet, 25 SMTP, 53 DNS, 80 HTTP, 443 HTTPS — "21-22-23-25, 53, 80, 443".

Useful commands

ping google.com            # reachable? round-trip time
tracert google.com         # Windows (traceroute on Linux/macOS)
ipconfig /all              # Windows IP, gateway, DNS  (ip a on Linux)
nslookup codify.dev        # DNS lookup
netstat -ano               # open connections and ports (ss -tulpn on Linux)
curl -I https://example.com  # response headers

Interview one-liners

More Computer Networks notes