How does the Internet Work?
Tags: beginners, webdev, todayilearned
Published: 2021-10-17 22:51:14

One thing that many of us take for granted is the internet.  The internet is this vast distributed network that connects all of us in almost everything we do.  Probably like you, I had no idea how it worked, even at a high level overview.  Today I am going to go over the basics of how a system this vast and independent operates.

First, what is a network?  A network is a group of computers that are connected to each other.  They can share information by passing parts of the whole called packets.  Sometimes the devices sharing packets of information with each other are different.  This required standardization that could be implemented into each device called protocols.  A protocol is a set way of performing certain actions or organizing the data.  Protocols exist for sending data between computers on a local network (IP), making sure they arrive in the right order (TCP), and to format them for websites and web applications (HTTP).

Next I will describe some of the physical components that contribute to the internet:

- Routers: These forward packets to different networks based on their destination.  One way to think of them is if each time you passed through an intersection in your car there was a person there to tell you which direction to go in order to get home.

- Switches: These are similar to routers but they work on a local network.  They take information passed from one source and send it to the computer it was meant to go to.

- Web Servers:  These are high-powered computers that take requests and serve information.  They may need to process requests and apply business logic before responding with the appropriate data which can be computationally intensive.

![Network diagram](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q0mnanle9vy1xgyfs4r9.png)

Now that we have some of the basics understood lets look at the specific steps that go into displaying a website on your computer.

1. DNS query: Computers use IP addresses to find where a website is located on the network.  IP addresses are long and hard to remember so we use DNS to apply an easier naming convention.  Think of it as a phone book for IP addresses.  So a DNS query is essentially looking up an IP address with the URL provided.

2. TCP handshake: This is the process of opening up a connection to the IP address with your browser.

3.  TLS handshake: The browser encrypts the connection to try and prevent malicious individuals from being able to read the packets if they are intercepted.

4.  HTTP request: The browser uses the HTTP protocol to “ask” for information from the web server.

5.  HTTP response: The web server processes the request and provides a response for the browser to render on your computer.  For applications other than a browser it may just provide data.

These are the basics for how the internet and local networks function.  I plan on going deeper in the future about DNS, TCP, TLS and maybe more.  Let me know in the comments if you would find that helpful or if you enjoyed this post.  I hope you all have a great week and happy coding!

**Resources:**

https://www.cloudflare.com/learning/network-layer/how-does-the-internet-work/

https://www.hp.com/us-en/shop/tech-takes/how-does-the-internet-work

https://developer.mozilla.org/en-US/docs/Learn/Common_questions/How_does_the_Internet_work