Tuesday, July 11, 2017

how computer/host reaches webserver and get is reply or how google works in network way

How Google works:

OSI does not come into picture here. Keep in mind that although the OSI model is what we study, we don't use OSI in real work networks. We use the TCP/IP Network Model.  The OSI model is still taught due to it's usefulness in separating concepts into modules (layers).  The OSI model is translated to the TCP/IP model as follows. 



When you are trying to open a web page on your PC this is what typically happens (I am just putting the basic concepts together for understanding, most of the steps below are much more elaborate, complicated and involves more devices, protocols  & lot of other details than shown below) 
  • You typically  type an web address (Uniform resource locator) in a Web browser. Web browser uses something called  Hypertext Transfer Protocol which is an Application layer protocol.
  • Behind the scene the web browser get the IP address of the URL you typed (say http://www.quora.com) using a process can Domain Name Systemwhich is also an Application layer protocol. 
    (The process is much more complicated than what is shown in figure)
  • Your browser now creates a HTTP packet which says  "Hey I am interested to GET the web page from Quora's server".
  • Below pictures shows the communication when seen in perspective of HTTP.
  • The packet is still in your PC & haven't got out. The browser gives the HTTP packet to a process running in your PC called TCP (Transmission Control Protocol) which is a Transport Layer protocol.
  • This is an adjacent layer interaction on same device i.e. the higher layer (HTTP) asks for the next lower-layer protocol (TCP) to perform the service, the lower layer provides a service to the layer above it. This interaction is repeated till the data reaches the last layer.
  • TCP's main function is to talk with the TCP process running on Quora's server and to establish a session (think it as the job of TCP is to create a pipe between you and quora's server so that data can be sent via the pipe)
  • TCP now put its own info on top of HTTP packet. These info are required to maintain the session/pipe.
  • The packet is still in your PC & haven't yet got out. TCP now handovers the TCP packet to an IP process (Internet Protocol) which is an Internet Layer protocol.
  • The main job of IP is addressing and routing i.e.  figure out a way to send the packet from your PC to the IP address of Quora. You can imagine IP as a postal service. Postal service has 2 address (sender's and receivers) & they route the letters via different postal offices before delivering it to final destination.
  • IP now put its own info on top of TCP packet. These info are required for routing in the internet.
    • The packet is still in your PC & haven't yet got out. IP now handovers the packet to network access/network interface layer. Network access layer defines the protocols and hardware required to deliver data across some physical network. Most of the PC users Ethernet.
    • Your PC now encapsulates the IP packet between an Ethernet header and Ethernet trailer, creating an Ethernet frame. Ethernet contains something called MAC address which is used to send frame locally (Local area network)
    • Now your PC physically transmits the bits of this Ethernet frame, using electricity flowing over the Ethernet cabling.
    • The packet is now out of your PC. It reaches Quora's web server. The web server physically receives the electrical signal over a cable, and re-creates the same bits by interpreting the meaning of the electrical signals.
    • Web server now de-encapsulates the IP packet from the Ethernet frame by removing and discarding the Ethernet header and trailer. Similarly it reads the TCP information and finally hands it over to HTTP process which understands the HTTP get request.
    • Web server now send sends back to you the web page in the similar steps. 
    • Same process repeats, you receive the web page sent by the server which is then shown on your browser.  
  • And this is how all the layers are in action when you open a webpage.

Ref: https://www.quora.com/What-is-the-role-of-OSI-layers-when-we-open-a-webpage
http://www.thegeekstuff.com/2012/08/journey-of-a-packet
http://www.cs.bu.edu/~best/courses/cs109/modules/getwebpage/
https://web.stanford.edu/class/msande91si/www-spr04/readings/week1/InternetWhitepaper.htm

Layer 2 and layer 3 level forwarding:

No comments:

Post a Comment