How the Internet Works
Tags: webdev, beginners, tutorial, writing
Published: 2022-11-19 20:45:02

One general mistake we make as beginners is not understanding how the web works. How the codes we create get transformed into websites that can be displayed on any device from anywhere in the world. 
It is quite tricky to want to skip this part in our learning process but in the long run, it becomes quite useful to have some basic knowledge on how the internet works. 

---
The internet system is made up of two components. The hardware and the protocols.

##**The Hardware**##
The hardware includes everything that carry information from cables that carry heavy bits of information to your personal devices. These components together create what is called a _network of networks_.This network is further divided to the **clients** and the **servers**.

![Server-to-client](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/di6v4n0gn896l6njegme.png)<figcaption>source:wikipedia</figcaption>

The clients are the devices(could be from phones, laptops, PCs, and browsers) which we use in sending requests for information from the servers which store up huge chunks of information. These servers provide the response(information) we receive in our devices.

##**The Protocols**##
The hardware cannot send and receive information without the **protocols**. These protocols are the sets of rules guiding how information moves on the internet. The most important ones being the **Internet Protocol(IP)/Transfer Control Protocol(TCP)**.  The IP provides a common language for machines and devices to understand the passed request/information using IP addresses. We also have the **Hypertext Transfer protocol(HTTP)** which is the set of rules responsible for transferring files such as HTML and multimedia resources over the internet.

![An IP Address](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p387ipey2ei81qlcek6k.png)
**IP Address** - These are a set of numbers with which machines use in communicating with one another within the massive amount of devices in the internet space. Every device connected to the internet has a unique IP Address.

Now let's get into how all these come together.

##**The Web Flow**##

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aaaf8cwjhy3vgo9iubt1.png)<figcaption>Image source: Geeks4Geeks</figcaption>
When we send a request(HTTP request) through our device browsers( the client) (an example is typing in a url such as www.google.com in our web browser), the request goes over the **Domain Name System(DNS) server** which is responsible for looking to see if  there is a server that matches your request i.e www.google.com server. Once the requested server is found, the DNS server converts that request to an IP address so that the server can understand the request. 

If the server approves your request, it sends a "200 OK" message to the client(your device) and then the server sends the HTTP response in sets of **packets**.
If the DNS server does not find the requested server, it sends an "Error 404" message to the client computer.

These packets are pieces of the HTTP response webpage which the server sends to the client. These packets contain <u>headers</u> and <u>footers</u> that tell your device what is in the packet and the packets are arranged to show you the requested webpage.

**Transfer control protocol(TCP)** sorts out how these packets are transferred between one IP address(server) and another(client). It also controls how the packets are rearranged on the client's device.

_So how does your device know which DNS server to use?_

When you connect your device to your home network or **Internet Service Provider**, you have a router which determines your computer's IP address. It also adds some network configuration Information which also Includes some DNS servers for translating the requests to IP addresses.

**And there you have it! A basic rundown of how the web works.**

And I'm hoping it is as simplified enough for your understanding

---
##**Thanks for Sticking!✨**##
I'm hopeful you've gained something reading this article and I value your time reading it. 
Thank you so much for reading❤

_Every comment, corrections and discussion are welcome!😊
_ See you soon. Byeee❤