Few years ago during my CS degree, I could remember my lecturer explaining the Open Systems Interconnection (OSI model) under networking and could still remember how complex it seems, and I had to memorize everything to pass the exam. I thought I will never need to understand it as a software engineer. Fast-forward to some months ago trying to understand how load balancing works in layer 7 and layer 4, I had to restudy the OSI model again, this time around not as a student but as a software engineer. I had to relearn what I thought I never needed to learn.
What is OSI model?
OSI model is an initial for Open System Interconnection, and it standardized the communication in the computer system. It is what the internet, mobile, LAN, and router uses to establish communication. In a simple term, it is how data is passed from system A to system B either with LAN or Wi-Fi.
The OSI model consists of 7 different layers and each layer contains a different protocol. The layers are the Application layer, Presentation layer, Session layer, Transport layer, Network layer, Data-Link layer, and the Physical layer. Let's explain how data moves from the topmost layer to the last layer.
Application Layer (Layer 7): This is where System A (the client) makes a request to System B. So let's say System A sent a GET/POST request to System B, this request contains a bunch of information, such as headers, cookies, content-type, body, etc., which is summed up into a string, passed to the rest of the OSI models as byte data. This layer also consists of other protocols like HTTP, FTP, TELNET, and SMTP.
Presentation Layer (Layer 6): This layer might be optional if you are using HTTPS as data sent through HTTPS is already encrypted. The presentation layer encrypts data coming from the application layer. This layer transforms the data(string) into byte and also compresses the data before sending it to the next layer and uses the SSL for encryption and decryption.
Session Layer (Layer 5): Session Layer is simple as it's just appending a session to the data coming from the presentation layer. This layer checks the authentication and authorization of the user/data being sent.
Transport Layer (Layer 4): This breakdown the data into a sequential, manageable segment, and each segment is attached to the source and destination port. It also controls the amount of data being transmitted and uses Automatic Repeat Request to retransmit data in case of any error. The transport layer uses UDP(User Datagram Protocol) and TCP (Transmission Control Protocol).
Network Layer (Layer 3): After receiving the segment from the transport layer, the network layer attaches both destination and source IP Address to form packets. This layer also determines the best path for data delivery from source to the determination.
Data Link Layer (Layer 2): Breaks down the packets received from the network layer and the mac address of both the sender and receiver are appended to the packet to form frames.
Physical Layer (Layer 1): On the physical layer, the frames received from the data link layer are converted into 0's and 1's (of course that's what the system understands) i.e. bits that are converted into signals.
NOTE: This is not in any way a comprehensive detail of the OSI model especially from a networking perspective. This is a brief breakdown to help you understand how systems communicate and send data to each other through the OSI model.