Skip to content

Protocol basics

HTTP Basics

  • HTTP is an application layer protocol over TCP which is a transport layer protocol, which in turn is over IP.
  • A connection must be established between the client and server before they can communicate with each other, and HTTP uses the reliable TCP transport protocol to make this connection.
  • By default, web traffic uses TCP port 80.
  • A TCP stream is broken into IP packets, and it ensures that those packets always arrive in the correct order without fail.

Client-side Connection Handling

  • On a client, an HTTP application is identified by a tuple. Establishing a connection between two endpoints is a multi-step process and involves the following:

  • resolve IP address from host name via DNS

  • establish a TCP connection with the server using 3-way handshake
  • send an HTTP request
  • wait for a response
  • close connection

Server-side Connection Handling

The server mostly listens for incoming connections and processes them when it receives a request. The operations involve:

  1. establishing a socket to start listening on port 80 (or some other port)
  2. receiving the request and parsing the message
  3. processing the response
  4. setting response headers
  5. sending the response to the client
  6. close the connection if a Connection: close request header was found