All about OSI MODEL
Today, i'm going to talk about O.S.I MODEL and Difference between layer 2 and layer 3.
What’s The OSI Model?
A theoretical model created by ISO so that manufacturers could create protocols from this reference module. It is a 7-layer model that was created for packet-switched networks and not for circuit switching.
In theory, each layer would be responsible for a specific protocol, but in practice most existing protocol stacks use more than one layer to work. We'll see that in TCP/IP!
Data Transmission - OSI MODEL
Each layer takes the information passed through the top layer and adds information for which it is responsible, moving to the layer below and so on. This process is called encapsulation.
In a practical example, communication would work as follows:
A user who asks their email program to download the emails, is actually causing their email program to initiate a data transmission in layer 7 - application - of the protocol used, asking to download the emails from the email server. This layer processes the order, adds the headers of its competence, and sends to layer 6 (presentation). This process continues until layer 1 (physical) sends the data frame to network cabling, when it will then hit the receiving device, which will reverse the process until its application, in this example, an email server. Below is an image that illustrates the process:
Layer 7 - Application
The application layer serves as an interface between the protocol stack and the application that requested or will receive information over the network. For example, if you want to download your email with your email application, it will contact the application layer of the network protocol stack being used, placing this order.
These are examples of TCP/IP protocols of this layer: HTTP (web), FTP (file transfer), SMTP (email)...
Layer 6 - Presentation
The presentation layer serves as a translator, converting the form of the data received by the application layer into a common format to be used in data transmission, that is, a format understood by the protocol used. An example is the pattern conversion form of characters other than ASCII. Other uses of this layer are: data compression and encryption.
In data compression, this layer receives the data from layer 7 and compresses to a common format (usually WinZip) and sends the data, making the transmission faster. The person responsible for decompressing this data is layer 6 of the receiver.
To increase transport security, an encryption scheme can be used, and this data will only be decrypted in layer 6 of the receiver.
These are examples of protocols of this layer: SSL, TLS...
Layer 5 - Session
The session layer allows two applications on different computers to establish a communication session. Applications define how data transmission will be done and place markings on the data being transmitted; if the network fails, computers restart data transmission from the last markup received by the receiving computer.
An example: you are downloading an email from the server and your internet falls, when the network comes back, your task will continue from the point where it stopped, and you do not need to restart the activity (this feature is implementation, that is, if it requires it to be implemented in order for it to work).
In practice, this layer is not used separately; most protocol stacks apply it next to the application layer.
Layer 4 - Transport
The transport layer is responsible for picking up data sent by the session layer and splitting it into data packets (called data segments in this layer) that will be passed to the network layer.
At the receiver, this layer is responsible for picking up packets received from the emitter's network layer and reassembling the original data segments to send them to the session layer, checking to which protocol operating above the transport layer the data should be delivered, as it is possible to have multiple protocols operating simultaneously above this layer.
An example would be you are operating something on the internet and downloading the emails at the same time; the layer will need to know where to send the received data.
Functions of this layer include:
- Information about which protocol operating on the layer above this the data package should be delivered, allowing multiple connections, that is, making it possible to use multiple protocols.
- Flow control by placing packets in order if they have arrived out of order.
- Checks errors, typically sending the transmitter a recognition information (ACK), informing that the packet has been successfully received.
- Checks for no packet loss or duplication. (TCP)
- Defines QoS (quality of service).
The transport layer separates the application level layers (five to seven) from the physical level layers (one to three).
In a summary: Layers one to three are concerned with how data will be transmitted and received to the network, more specifically with the frames transmitted by the network.
Already the five to seven layers are concerned about the data contained in the packets, to be sent or received for responsible application.
Layer four, transport, connects these two groups.
Layer 3 - Network
The network layer is responsible for the logical addressing of data packets and also for translating logical addresses into physical addresses. Data packages may have different priorities; for example: you will have no problem receiving an email with a delay of 2sec, but if the delay occurs in a video conference, the damage is greater.
This layer is responsible for prioritizing the delivery of certain data packets (resource called QoS)
Data packets need to use two types of address: logical and physical.
Logical addressing is independent of the network architecture being used; this allows a data packet from a computer on an Ethernet (wired network) network, for example, to correctly reach the target on a network using another architecture.
This control is done on layer 3 of the OSI model and on the TCP/IP stack is controlled by the IP protocol, hence the IP address name.
To cross each local network segment, data packets need to know the physical address of the source and destination NIC. This addressing is done by layer two (data link) of the OSI model, and therefore controlled by the hardware and varies as it goes "walking" through the network.
An example: suppose that communication between a computer A and a computer B, located on different networks. The data frame will exit computer A containing the logical address of the destination of computer B, however, as the physical address it will use the address of the network router; when the data frame reaches the router, the router changes the physical destination address of the received frame to the physical address of the destination router. When the frame reaches the router of the target network, it finally switches the physical destination address to the address of the network card of computer B.
In summary: every path of the logical destination address remains unchanged, but the physical destination address is being changed to make the data frame "walk" to the next point in the middle of the path between the computers.
Logical addressing is controlled by layer 3 of the OSI MODEL and physical addressing is controlled by layer 2 of the OSI model.
Routers are part of this layer and therefore determine the route that packets will follow and their traffic priorities/conditions.
Protocols such as RIP, OSPF, and BGP are attached to the TCP/IP layer but only work with routers.
Layer 2 - Data Link
Layer 2 takes packets received from the network layer and transforms into frames or cells that will be traversed over the network, adding information such as the source and destination NIC address, control data, error correction data (checksum).
Frame: Has configurable size.
Cell: always the same size.
If the data package received from layer three is larger than the size of the data frame being used by the network, the packet is divided into x frames so that the packet is fully transmitted.
The frame created by this layer is sent by the physical layer, being converted into electrical signals that are sent through the medium (cable or air).
This layer also checks that the medium is available and can be used for this purpose.
Layers two and one are controlled by low-level protocols, i.e. network architecture (Ethernet, Frame relay...), and therefore controlled by hardware (computer or peripheral network card responsible); different from other layers that are controlled by software, i.e. protocol stacks.
The data link layer also checks the checksum to see if the data has arrived fully, re-calculating the checksum. If the data is OK, send a confirmation of receipt (ACK); if there is an error, layer two of the transmitter resends the data to the receiver for re-checking. Most architectures do not use this process, relying only on the transport layer for this task; WI-FI networks use this process.
Switches are equipment used in this layer; the most common network architectures are Ethernet and Wi-Fi. In these architectures the layer is controlled by the logical link control (IEEE.802.2) protocols - identical for the two architectures - and middle access control (MAC) that varies according to the architecture.
Layer 1 - Physical
The physical layer takes the frames sent by layer two and carries out the frame modulation encoding, transmitting the frames through electrical, light or radio frequency signals, depending on the medium the network uses - metal cables, optical fiber or wireless network.
The role of this layer is done by the network card of networked devices.
This layer does not care about the medium that the data will circulate; at most, she worries about the type of connector and the type of cable used to transmit and receive the data, the cable itself is not the responsibility of this layer.
It is hardware-controlled and varies according to the architecture used; Hubs are examples of equipment used in this layer.
Questions or Suggestions? Contact me in my social networks.