What happens when you type a URL into the browser?

Robert Dordai

Software Developer

 

We use the Web every day, but the process and technologies behind this may seem unclear. We open a browser we type the website we want, and in a matter of milliseconds, we get a response. The process of us typing that website, pressing enter, and then getting a response is probably more complicated than we would expect it to be. In this article, I’ll give a high-level look at the steps in the process and the protocols that make this process possible.

 

 

These protocols ordered in these four layers by the TCP/IP model make everything possible. It’s the backbone of the Internet, and HTTP is the backbone of the Web.

HTTP manages communication between web clients (in our case, our browser) and web servers (computers hosting the website’s files). The web client makes an HTTP request to the Web Server for a specific resource, and in return, the Web Server returns an HTTP response to the web client with the requested data.

IP obtains the address to which data you send.

TCP is responsible for data delivery once that IP address has been found. 

Ethernet and other Link layer protocols allow for the physical transmission of data.

 

1. Parsing the URL

https://wikipedia.org:443/wiki/Internet

This is an example of an URL, once we type it into the web browser and press enter the browser will parse it to extract the needed components: 

  • the application protocol used (HTTPS, the secured extension of HTTP
  • the hostname (wikipedia.org), 
  • the port (443) 
  • the path of the required resource (/wiki/Internet)

 

However, we can quickly type wikipedia.org/wiki/Internet and get the same result. This is possible because the browser has default values for both the protocol and the port. In this case, because there is a valid SSL/TLS certificate, it will default to HTTPS and the default port for HTTPS (443).

2. Get the host’s IP address

Now we have our hostname: wikipedia.org. However, on the Internet, we communicate through IP addresses. Luckily for us, we do not need to remember any IP addresses as DNS provides us the mapping between hostnames and their IP addresses. So now, we request the DNS server and will receive the host’s IP address.

3. Building the TCP/IP packet

Once we have the IP address, we can start building the TCP/IP packet that’s going to get through the Internet.
The final packet will have the Application layer data (in this case, the HTTP request) and headers from each layer. These headers allow each protocol (HTTP, TCP, IP, Ethernet) to send the required information so that our packet is successfully sent to the server.

4. Connecting to the Gateway

Our gateway to the Internet, in this case, is our router. Before we can send the packet to Wikipedia’s server, it first needs to be routed through the router. To do this, we need to connect to it physically; to connect to it, we need its MAC address. ARP, which is a Link layer protocol, helps us here and returns us the MAC address for the router.

5. Routing over the Internet

For our packet sent from our local machine to get to Wikipedia’s server, it needs to take many hops. Each hop is a router along the path to the destination. The router helps the request go from one network to the other.

6. TCP handshake

The first thing that the local machine will do is to establish a three-way handshake with Wikipedia’s server now since it knows the route to the server. The TCP connection is successful between the client (web browser) and the server when both agreed to the ordinary rules for data transfer.

7. TLS handshake

After the TCP handshake, the TLS handshake takes place if you are connecting to a secure website. With the TLS handshake, the client and the server agree to the standard terms of secure communication.

8. Processing the request

The server processes the request and sends back an appropriate response.

9. Closing the connection

When the client (web browser) detects that the data transfer is over and the open connection channel is no longer required, it sends a connection closing request to the server. Next time the client wants to communicate with the server, a new connection needs to be established between the two machines.

As a conclusion, what we do when we browse the web is basically making requests to a server via a client for a certain resource. Those requests go through the Internet to the server, which in return gives us a response.