What is OSI Model?
The Open Systems Interconnection model basically provides a standard for the communication of different computers.
Why do we need a communication model?
- The application must have a knowledge of the underlying network medium.
- The application does not matter about is a fiber or a radio signal and etc.
- If we don’t have a standard, you always need to upgrade your network equipment.
- The model provides a decoupled innovation and this means you are free to make any innovation without affecting the rest of the model.
What are layers in OSI Model?
Layer 1: Physical Layer
- Each frame becomes a string of bits. (wifi, ethernet, fiber)
- It is the hardware part of the OSI model
- Hub, cables, and ethernet work in this layer
Layer 2: Data Link Layer
- It consist of two main parts. (LLC, MAC)
- LLC (Logical Link Control) and MAC (Media Access Control) basically responsible for the control of whether the sent data is transmitted without error.
- Data is sent from the network layer to the physical layer. In this stage, the data is divided into certain parts, which we call frames. Basically frames are packets that allow sending data within a certain control.
- Data Frame has 3 main parts (Data, Header, Trailer)
- This parts includes CRC, data and there are constructs such as special sign bits that indicate the start and end
- Most operations take place inside the network card.
- LLC provides the connection with Layer 3 and Layer 2.
- LCC is responsible from Flow Control *Adds the MAC address of the destination and source devices to data frame
- Switch work at this layer
Layer 3: Network Layer
- Information is added to the data packet when it needs to be sent to a different network and that the routers will use.
- The aim is to exchange data with the shortest routes (via routers).
- Encapsulation (Adding Layer 3 Header) (IPV4 or IPV6) (Sender)
- Decapsulation (Removing Layer 3 Header) (Receiver)
- Includes time to live, protocol, fragment offset, flag, version and etc.
- Source Address : IP Of the source
- Destination Address : Destination IP address
- Time to live: It is the lifetime of a package. It has an 8-bit value. This value is reduced by 1 for each router pass and if it is 0 the packet is discarded.
- Flag: It is to check whether the processed packet is the last packet of the data. If the More Fragment value is 1, it is indicated that there are other parts to be processed. If MF equals to zero and Fragment Offset equals to 0, this data is unfragmented.
- Version: IP
Layer 4: Transport Layer
- Transport Layer is responsible for end-to-end communication between the two devices. This includes taking data from the layer 5 (session layer) and breaking it up into chunks called as segments before sending it to layer 3 (network layer).
- The transport layer on the receiving device is responsible for reassembling the segments into data the session layer can consume.
- Increases the Quality of Service (QoS) of the network.
- Responsible for flow control and error control.
Layer 5 : Session Layer
- Responsible for opening and closing communication between the two devices.
- The session layer also synchronizes data transfer with checkpoints. We can set a checkpoint that controls the data transfer in every 5 MB. This provides if your connection lost you can continue where you lost the connection.
Layer 6 : Presentation Layer
- The presentation layer is responsible for translation, encryption, and compression of data.
- Prepares the data presentable for applications to consume
Layer 7: Application Layer
- The application layer is the layer closest to the user.
- Meets end user’s services
- This layer is responsible for application services for file transfers, e-mail, and other network software services.
- Only layer that directly interacts with data from the end user
- FTP, HTTP, Telnet
Sender Example
Layer 7 — Application Layer
POST requests with JSON data to HTTPS server (Axios, fetch or etc.)
Layer 6 — Presentation
Serialize JSON to flat byte strings
Layer 5 — Session
Request to establish TCP connection/TLS
Layer 4 — Transport
Sends SYN request target port 443
Layer 3 — Network
SYN is placed an IP packet(s) and adds the source/dest IPs
Layer 2 — Data link
Each packet goes into a single frame and adds the source/dest MAC addresses
Layer 1 — Physical
Each frame becomes string of bits which converted into either a radio signal (wifi), electric signal (ethernet), or light (fiber)
Receiver Example
Layer 1 — Physical
Radio, electric or light is received and coverted into digital bits
Layer 2 — Data link
The bits from Layer 1 is assembled into frames
Layer 3 — Network
The frames from layer 2 are assmbled into IP packet
Layer 4 — Transport
The IP packets from layer 3 are assembled into TCP segments
Deals with congestion control/flow control/retransmission in case of TCP
Layer 3 — Session
The connection session is established or identified
We only arrive at this layer when necessarry (three way handsake is done)
Layer 2 — Presentation
Deserialize flat byte strings back to JSON for the app to consume
Layer 1 — Application
Application understands the JSON POST rquest and your apache request receive event is triggered
References:
https://www.cloudflare.com/learning/ddos/glossary/open-systems-interconnection-model-osi/
Originally published in medium.
Top comments (0)