what happens when you type www.google.com in your browser
Firstly, you could as yourself what is a web page?
A web page can be said to be a text file formatted in a way your browser (ie. Firefox, safari, chrome, …) can understand it, and this format is called HTML (Hypertext Markup Language).
These files are stored in computers (servers) which store these files and wait for it to be needed and then they deliver.
What is a server?
A server is a computer hardware or software (computer program) that provides functionality and services for other programs or devices (like yours), and these servers can vary in classes, the most common one which we would look at in-depth is a Web Server, which function is to serve static web pages.
There are also application servers which are used to hold an application that will be used to interact with web browsers or other applications and database servers, which have a database in them that can be updated and can request data when needed.
These servers in order to deliver their content, need to have an address so that when a content is needed one can make a letter requesting the desired content, also the machine it self used has an address where the servers can deliver to.
These addresses are called IP(Internet Protocol) Address, which is a set of 4 numbers that range from 0 to 255 separated by periods (ie. 127.0.0.1).
Sending these requests can be done using one of these protocols TCP or UDP.
TCP: this makes sure that all the content that is requested gets delivered, and it happens by sending the file in small packets of data and the receiver replies with a packet with the ACK bit set to the length of the received data(ACK = “acknowledge!”) which confirms that the packet is received, and that’s why TCP tends to be slower that UDP
UDP: on the other hand is usually used to serve live videos or online games, and that’s because UDP is a lot faster than TCP since UDP doesn’t check if data packets was received or not. That’s the reason why if you ever watched live video and if either your internet connection or the host’s drops, you would just stop seeing the video, and when the connection comes back you will only see the current stream and what was missed is forever lost. Same thing for videogames.
So what happens when you type www.google.com in your browser
The first thing that happens after you put the website name and press enter is that your browser looks up in it’s cache to see if that website was visited before and the IP address is known. if it can’t find it, then it asks your operating system to locate the web site. the first place your operating system is going to check for the IP address of the URL (Uniform Resource Locator) you specified is in hosts file (/etc/hosts in Linux and Mac , c:\windows\system32\drivers\etc\hosts in Windows). if the URL is not found inside the file, then the OS will make a DNS request to find the IP address of the website. and it will first ask the Resolver (or Internet Service Provider) server to look up in it’s cache, if the the Resolver does not have it then it asks the root server to ask the .COM TLD (Top Level Domain) server (if your URL ends with . net it will ask the .NET server and so on) the TLD server will check in it’s cache for the websites IP address. if not, then it will have at least one of the authoritative name servers associated with that URL, and after going to the name server, it will return the IP address associated with your URL.
after the OS has the IP address and gives it to the browser, it then makes a GET (a type of HTTP Method) to the IP address. When the request is made the browser again makes the request to the OS which then in turn packs the request in the TCP traffic protocol, and sent to the IP address. On its way, it is checked by both the OS’ and the server’s firewall to make sure that there are no security violations. and when the server receives the request (usually a load balancer that directs traffic to all available server for that website) sends a response with the IP Address of the chosen server along with the SSL (Secure Sockets Layer) certificate to initiate a secure session (HTTPS).
Finally the chosen server then sends the requested files (usually HTML, CSS, and JavaScript files ) back to the OS who in turn gives it to the browser to interpret it, and then you get your website as you see it.
Resources :
server : https://en.wikipedia.org/wiki/Server_(computing)
TCP, UDP : https://sectigostore.com/blog/tcp-vs-udp.
SSL : https://www.keyfactor.com/blog/what-is-ssl
DNS : https://howdns.works/