Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

The Short Answer

TCP/IP is the set of protocols the internet is built on. The name comes from its two best-known members: IP (Internet Protocol), which gives every interface an address and carries packets from network to network, and TCP (Transmission Control Protocol), which makes a reliable, ordered connection between two programs on top of IP. The suite also includes UDP, ICMP, DNS, HTTP, and many more.

The Four Layers

LayerJobExamples
ApplicationWhat programs sayHTTP, DNS, SSH
TransportProgram to programTCP, UDP
InternetHost to hostIP, ICMP
LinkOn one networkEthernet, Wi-Fi

Each layer wraps the data of the layer above in its own header. Some descriptions split the link layer in two and count five layers. The seven-layer OSI model divides the same work more finely; see the OSI model.

What IP Does

IP gives each interface an address and moves packets from source to destination, router by router. It works on a best-effort basis: a packet can be lost, duplicated, or delivered out of order, and IP does nothing about it. Two versions are in use, IPv4 and IPv6; see what is an IP address.

What TCP Adds

  • Connections: both sides agree to talk before any data flows.
  • Reliability: every byte is numbered and acknowledged; missing data is sent again.
  • Order: the receiver puts data back in sequence.
  • Flow and congestion control: the sender slows down when the receiver or the network cannot keep up.

The Three-Way Handshake

  1. The client sends SYN: "I want to connect; here is my starting sequence number."
  2. The server answers SYN-ACK: "Agreed; here is mine."
  3. The client sends ACK, and the connection is open.

The handshake costs one round trip before any data moves, which is why the distance to a server is felt on every new connection. A connection ends with FIN messages from both sides, or at once with a reset (RST).

Ports

An IP address finds the machine; a port finds the program on it. Ports are numbers from 0 to 65535. A server program listens on a known port, such as 22 for SSH, 80 for HTTP, and 443 for HTTPS, while the client uses a temporary high-numbered port. The addresses and ports of both ends together identify each connection, which lets one server hold thousands of connections on port 443 at the same time.

UDP Beside TCP

UDP also uses ports but skips connections, acknowledgments, and ordering. It is lighter and quicker to start, so DNS queries, voice and video, VPNs such as WireGuard, and HTTP/3 (through QUIC) use it and handle loss themselves where they need to. The full comparison is in TCP vs UDP.

The Path of One Web Request

  1. DNS: the browser asks a resolver for the address of example.com, usually over UDP port 53; see what is DNS.
  2. TCP: it opens a connection to that address on port 443 with the three-way handshake.
  3. TLS: client and server agree on keys and the browser checks the certificate; see what is SSL/TLS.
  4. HTTP: the browser sends its request and the server answers with a status code and the page.

Beneath all four steps, IP carries every packet, and Ethernet or Wi-Fi moves it across each link on the way.

See It on a Server

ip a
ss -tln
ss -tn state established

ip a shows the IP addresses of the interfaces. ss -tln lists the TCP ports that programs listen on, and the last command lists open connections with the address and port of both ends. Add -u to include UDP, and -p with sudo to see the program names; see the ss command.

Was this answer helpful?
Loading...