Network – How to explain the data flow of OSI model layers in a single picture

dataNetworknetwork-corenetworkingosi

enter image description hereTake an example of searching www.example.com in a web browser. I have some confusions at each layer and they are

  1. We have opened a web browser and searched for www.example.com. Now, As far as I know, the Application layer appends a header of HTTPS GET request to example.com, resolves IP address using DNS. That means, the IP address is known at this layer itself, but why is the IP address appended at the Network layer and not at the Application layer?. And how does it resolve the IP address of google.com? Does it follow the same 7-layer model to resolve IP addresses or it is a separate task and follows different scenario.

  2. Okay… now the application layer passed the PDU to the presentation layer. Here it translates, encrypts and compresses the PDU. Does it always perform these three function at physical layer.?

  3. Well, now the PDU gets passed to the session layer. I read somewhere that it create session between sender and receiver, maintains session, authenticates, authorizes and synchronizes. what do you mean by creating a session, how come it creates a session between sender and receiver without even getting to the next layers.

  4. Ok, somehow the PDU got to the Transport layer. Here it divides the PDU into transmittable segments. And appends each segment with a sequence number, ACK number, port number etc. But, how does it know the port number of server (ie 443 for HTTPS request?) and what about client port numbers. And the main question here is how it handles TCP 3-way handshaking. Handshaking means it needs to send SYN packet to the destination via a route and must receive ACK through the same path. My query is, how it does 3-way handshaking without even getting to the lower layers

  5. Now it appends IP addresses of sender and receiver to the PDU along with some other control information. Why it adds an IP address here, not at application layer. PDU is called a packet here in network layer.

  6. Now it appends the MAC address of the next device the host is connected to along with some other information. My doubt is, does the data link layer append the MAC address of router to transmit the data to another router?

  7. Now, the Frames become signal and transmitted over a channel (LAN cable) to the switch connected to the computer. It is a physical layer.

What happens next is my analogy. correct me if I'm wrong anywhere.

Now, at the switch, the signal become frames and changes the MAC address to next devices it connects, for example the switch is connected to a router. So, the switch appends MAC address of the router and make those frames as a signal and transmits over a channel connected to the switch.

Now, the router takes the data, removes the MAC addresses, so that it can look the IP addresses and forwards the data to the next node (probably router) by looking into the routing table based on the destination address. That means, does the router append the MAC address of the next router.

And continues till it reaches the server.

At the receiving side router (the last router), does the router append MAC address of the server while transmitting?
Ok.. somehow the requested data gets to the server. Does the server itself remove the data link headers, network layer headers?

And finally request has reached to server's application layer by unwrapping the headers layer by layer in the server.

Now, does it follow the same steps to send the requested web page to the client?

Best Answer

The fundamental thing to understand is the separation of layers: don't try to understand all the layers at the same time. And probably best not to start with complex ones like HTTPS. Also it's vital to remember that the OSI seven layer model is just a story to help explain similarities and differences of networking processes; it is not followed by the internet model of networking.

Try first with basic layer 2 and layer 3 frames and packets, then with simple protocols, perhaps Daytime (RFC 867), then HTTP, then DNS, then your example.

Try not to think of "appending addresses", think in terms of each layer doing its job. When we think of the TCP connection from client to server, we completely ignore all the packet activity. When we think about packets, we ignore TCP streams and ethernet frames. When we think of the frames out of the client, we ignore all IP behaviour.

To get to your questions, try a top-down view:

  • First, client does a DNS request to its locally configured DNS resolver, whose IP address it knows.
  • If successful it makes a TCP connection to the server's IP address, on the well-known port number 443.
  • If successful it starts talking HTTPS over that connection. Part of that is the web page content returning.

Once that's clear, then you can drill down into how each of those works.