learn/phase-1/p1-w3/lesson 01
Week 3 · lesson 1

Protocols, Ports & TCP vs UDP

Hands-on. Builds port and protocol fluency.

What you'll learn

  • Define a protocol and name the everyday ones (HTTP, HTTPS, FTP, SSH, DNS, SMTP).
  • Use the IP-as-building, port-as-room analogy to explain ports.
  • Choose TCP vs UDP for a given use case and justify it.

Protocols, Ports & TCP vs UDP

What is a protocol?

A protocol is a set of rules for how devices communicate over a network.

Just as humans use languages to understand each other, computers use protocols. Without an agreed protocol, two machines exchange bytes that mean nothing to each other.

Common ones you will meet constantly:

ProtocolJob
HTTPtransfers web pages
HTTPSsecure (encrypted) version of HTTP
FTPtransfers files
SSHsecure remote access to a shell
DNSconverts domain names into IP addresses
SMTPsends email

Ports: rooms inside a building

If an IP address is a building's street address, a port is a specific room inside it. One server (one IP) can run many services at once, each listening on its own port, so the port number says which program should receive the packet.

The four to know cold: 22 SSH, 80 HTTP, 443 HTTPS, 53 DNS.

TCP vs UDP

Two transport protocols carry almost everything, and they make opposite trade-offs:

TCP  →  reliable, ordered, error-recovery   (web, email, SSH, file transfer)
UDP  →  connectionless, no recovery, fast    (gaming, streaming, voice, DNS)
  • TCP sets up a connection (the SYN/SYN-ACK/ACK handshake), guarantees delivery, and re-sends lost data. Choose it when every byte must arrive correctly.
  • UDP just fires packets and hopes. There is no handshake and no re-send. Choose it when speed matters more than perfection, a dropped frame in a video call is better than a frozen call.

A quick test: would you rather the data be late but perfect (TCP) or fast but lossy (UDP)? Your answer picks the protocol.

Try it

Run ss (or netstat) in the terminal to see which ports are listening on a host, and notice the protocol column. Then nmap example.com shows the same idea from the outside: which ports a remote host has open.

Check your understanding

3 questions

Type an answer and press Check. Grading is keyword-based and forgiving, so short answers are fine.

  1. 1

    A scan reports ports 22, 80, and 443 open on a host. Name the service running on each.

  2. 2

    You must download a file where every byte must arrive intact and in order. TCP or UDP?

  3. 3

    ss shows a process listening on 0.0.0.0:53 over UDP. Which service is that almost certainly?