7. Discussion of the use of layers

It is now time to understand the process of layer-based communication in more detail. We will discuss this using the example of sending an e-mail. Originally, internet users created emails using email programs or web browsers. The application layer correctly encodes this data and passes it to the transport layer.

This layer divides the data into smaller parts, segments that are easier to transmit over the network. It also adds control information that allows us to later assemble the segments on the end device in the correct order (although this is not always added, depending on the protocol used in this layer), but most importantly, it also adds the application port number (the application port on the server and the port on the client), information that allows us to later determine that this is an email and not a web page. 

These segments are then transported to the Internet layer, where IP addresses are assigned - the sending device and the receiving device. This process is used so that the router (i.e. the intermediary device between the sender and receiver of the message) knows where to send the message. From this point, our segment is addressed by the packet.

The packet then goes to the network access layer, where a frame is created and provides the physical address of the sending device and the physical address of the router to which the computer to which the message is being sent is connected. With this address, the frames can then reach this router, which then sends them to the WAN.

However, before the transmission itself, the frame is encoded into bits and passed through the router to the destination device.

When these bits are received by the destination host, there's a process of decapsulation, in which frames are converted into packets, packets are converted into segments and the transport layer reassembles them in the correct order. Once this process is complete, the data is sent to the application layer, where the message is displayed. When we want to display a web page or send a file over the Internet, the communication process will be similar, except that different application layer protocols will be used to handle the sending of web pages or files instead of sending and receiving emails.

The communication process between the devices discussed here is simplified and we call it a contract. We have omitted the process of data transfer between intermediary devices (i.e. routers). The routing process, i.e. the transfer of data between routers in a wide area network and the possibility of using different transmission media in the process from sender to receiver, is a vast and complex issue that we will not discuss here.