Menu

Thursday, August 1, 2013

Useful Q & A on Networking - Part 1

Q 1. What happens at every layer of the OSI model when we type "www.google.com" in the browser? 

Ans. The following sequence of steps takes place every time we type the name of a website in a browser->
1) Your PC will need to resolve "www.google.com" to an IP address. It will therefore need to send a 
query to your DNS server ( usually your ISP's DNS).

2) The PC constructs a DNS query packet with a destination IP address equal to your DNS server 
and a destination MAC address of your router (gateway).

3) The DNS query process begins to resolve the IP address of the given URL.

4) Once your PC (web browser application) receives the IP address of the destination web server, it will construct a HTTP GET request and send it to Google's web server. (As per OSI model at application layer [layer 7] application software which is client web browser now know the IP address of google.com). After that it pass that information down to presentation layer.

5) Presentation layer[ layer 6] converts that HTTP request into a standard format which is HTTP format so that the other layers can understand.and pass that information down to session layer.

6) Session layer[ layer 5] at client side creates session for www.google.com which is HTTP session so that it can be separated from other sessions.and pass that information down to transport Layer.

7) Transport Layer[ layer 4]  at client side chooses TCP for every HTTP session which is reliable connection which creates virtual connection by using three way hand-shake before sending actual data [HTTP Request]. This layer also prepares segments by adding source and destination port number. Source port is chosen by upper layer which is random number range from 1024 to 65535  and destination port number is here 80, which is well known port number used for HTTP services.

Layer 4 assign source port number to distinguish the web browser application from every other program running on computer and it also used to identify which application should receive return traffic. The destination port number is used to make sure that messages coming from web browser gets and sent to web server program running on the server and is not grabbed by other program. After preparing segment, layer 4 at client side pass that information down to network layer.

8) Network Layer [ layer 3] at client side  prepares packet by adding source and destination IP address. It also check whether destination IP address is on local network or it is on remote network. If it is on local network it checks ARP cache to find mac address of local device. If cache is empty it sends ARP message to resolve IP address into MAC address. Here the device is on remote network so client PC sends ARP to find MAC address of default gate way [192.168.1.1]. Every devices on that network segment gets that ARP request because as it layer 2 broadcast message destined for all devices on that broadcast domain but only the default gateway, which is 192.168.1.1, replies with its MAC address. Then network layer passes this information down to data link layer.

9) Data link layer[ layer 2]  prepares frame by adding source and destination MAC address of default gate way[192.168.1.1]. It also rund CRC which simply checks the data and frame header bits and add that result in to frame check sequence (FCS) field. Then, passes this information down to Physical layer.

10) Physical layer[ layer 1]: converts all this information in 1's and 0's and sends it to destination device using Ethernet cable.

11) Google's Web server will reply and start sending your application the necessary data using TCP session.

12) The application will start to draw and present the website on your screen.

At the server side, i.e. Google:

1) At Physical layer, server receives the bits. Layer 2 of server builds frames and runs CRC and checks answer with FCS field. If answer didn't match then the frame is discarded. If it matches then the destination MAC address is checked. Here, destination MAC address is right, so it checks Ethernet type field to find the protocol used at network layer (which is IP). It retrieves the packet from the frame and gives to IP at network layer.

2) Network layer checks destination IP address and in our case it matches so it checks protocol type field to find the protocol used at Layer 4 (which is TCP). Now network layer of server sends all information up to TCP at layer 4.

3) At transport layer, destination port number is checked which is well know port number 80, which is destined to web server application running on that particular server i.e. in our case www.google.com. So it passes all those information up to google web server. Google web server sends acknowledgement message to client to ensure that it has received its request. Finally, it sends the web page in the form of packet by packet over the network to client. This information gives google web page to our client web browser.

No comments:

Post a Comment