When communicating with the internet the data encounter wide variety of devices, each device with different Operating System, Architecture, ISP, country etc. In order to solve this the The International Organization for Standardization (ISO) in 1970 standardized the data transmission through OSI model. In this article we will cover about the fundamentals about the OSI model.
What is an OSI model 🤔
Well OSI stands for Open Systems Interconnection is a conceptual framework by which it defines how data will travel in the network. It is not a protocol but it standardizes the transfer of data in the internet, the model divides into 7 layers now we will look at each layer in detail and we will sum up with an real life analogy for better understanding.
Application Layer: Provides an interface to the user app, it is the only layer which directly interact with user, software applications like browser, messaging apps rely on application layer to initiate communication.
Presentation Layer: This layer makes the data readable, presentable or understandable for applications to consume, like encryption and decryption of the data etc. compression and extraction of the data.
Session Layer: The Session Layer manages communication between devices, ensuring data transmission starts and ends correctly, keeping the connection open until data transfer is complete, and acting as a checkpoint to resend any missing data packets.
Transport Layer: It is a direct connection between 2 devices, the user data is broken down into smaller pieces called chunks before sending it to network layer
Network Layer: Here the user data that we have got from the transport layer gets some extra data like IP-header, destination path, router path etc. now again it is divided into smaller units called Packets.
Datalink Layer: The data link layer, similar to the network layer, handles data transfer between devices on the same network by breaking packets into frames and managing flow and error control for intra-network communication.
Physical Layer: It is the lowest layer in the OSI model, here the data is completely transformed to 0’s and 1’s i.e into electrical signals or radio waves.
Protocols used in each layer
Physical Layer: No specific protocols, deals with hardware standards (e.g., Ethernet, USB).
Data Link Layer: Ethernet, Wi-Fi (802.11), PPP, and MAC for framing and addressing.
Network Layer: IP (IPv4/IPv6) for addressing and routing.
Transport Layer: TCP (reliable) and UDP (unreliable, faster).
Session Layer: NetBIOS, RPC, PPTP (for managing sessions).
Presentation Layer: SSL/TLS, JPEG, GIF, MIME (data translation, encryption).
Application Layer: HTTP, HTTPS, FTP, DNS, SMTP, POP3, IMAP (user-facing protocols).
TCP/IP
The TCP/IP model was created in the 1970s with funding from the U.S. Department of Defense (DoD) through DARPA to provide a strong, adaptable, and scalable communication protocol for military and academic use.
The OSI model is theoretical, meant to standardize and guide the design of network protocols and systems.
The TCP/IP model is a practical protocol stack used to enable real-world communication on the internet.
Application Layer:
Purpose: Provides network services directly to end-users or applications.
Examples: HTTP (web browsing), FTP (file transfer), SMTP (email).
Role: Handles user interface, data representation, and communication protocols.
Transport Layer:
Purpose: Ensures reliable data transmission between devices, providing error checking, flow control, and retransmission if necessary.
Examples: TCP (reliable, connection-oriented), UDP (faster, connectionless).
Role: Manages end-to-end communication and segmentation of data for the application.
Internet Layer:
Purpose: Responsible for logical addressing, routing, and forwarding of data packets across different networks.
Examples: IP (IPv4, IPv6) for addressing and routing; ICMP (ping and error messages).
Role: Routes packets from the source to the destination across network boundaries.
Network Access Layer:
Purpose: Defines how data is physically transmitted over the network, handling hardware addressing, access control, and error detection at the data link level.
Examples: Ethernet, Wi-Fi, PPP (Point-to-Point Protocol).
Role: Deals with the physical and data link layer operations like framing, addressing, and error detection.
Working of TCP and UDP
Image Credits cyberhoot
Working of TCP
Connection Setup:
- TCP uses a three-way handshake to establish a connection between the sender and receiver before data transfer begins.
Data Segmentation:
- Data from the Application Layer is broken into segments, each with a TCP header that includes sequence numbers and acknowledgment information.
TCP Packet Structure:
Source Port: Identifies the sending application.
Destination Port: Identifies the receiving application.
Sequence Number: Tracks the order of data.
Acknowledgment Number: Confirms receipt of data.
Flags: Control bits for managing the connection (e.g., SYN, ACK).
Checksum: Verifies data integrity.
Reliable Data Delivery:
TCP ensures reliable data delivery by requiring acknowledgments for each segment sent.
Lost or corrupted segments are retransmitted.
Flow and Congestion Control:
- TCP manages data flow and prevents network congestion through flow control (using window size) and congestion control (using algorithms like TCP Tahoe and Reno).
Connection Teardown:
- After the data is transferred, the connection is closed using a four-way handshake to terminate the session properly.
Working of UDP
UDP is a connectionless, unreliable transport layer protocol designed for speed. Here's how it works:
No Connection Setup:
- UDP doesn't establish a connection before sending data, making it faster than TCP.
Data Segmentation:
- Data from the Application Layer is broken into smaller chunks (datagrams) and sent independently.
UDP Packet Structure:
Source Port: Identifies the sending application.
Destination Port: Identifies the receiving application.
Length: Length of the UDP packet.
Checksum: Verifies data integrity (optional in IPv4, mandatory in IPv6).
Sending and Receiving:
UDP datagrams are sent to the destination device without waiting for acknowledgment.
At the receiver, the datagram is passed to the appropriate application based on the destination port.
No Acknowledgment or Retransmission:
- UDP doesn't acknowledge delivery or retransmit lost packets, leaving error handling to the application.
Out-of-Order Delivery:
- Packets may arrive out of order, and the receiving application must handle this if necessary.
Real life analogy.
Application Layer (Layer 7):
You write the letter, deciding what to say and how.Presentation Layer (Layer 6):
You put the letter in an envelope and choose how to format it.Session Layer (Layer 5):
You set up the time for the letter to be sent or read.Transport Layer (Layer 4):
The post service ensures the letter is delivered reliably and in order.Network Layer (Layer 3):
The addressing on the envelope ensures it gets to the right destination.Data Link Layer (Layer 2):
The local sorting system makes sure it reaches the nearest post office.Physical Layer (Layer 1):
The physical delivery of the letter (mail trucks, airplanes, etc.).
Conclusion:
OSI, TCP, and UDP form the backbone of internet communication by providing structured, reliable, and efficient ways to transmit data across networks. The OSI model acts as a conceptual framework that standardizes the communication process, while TCP ensures reliable, connection-oriented communication with error recovery, and UDP prioritizes speed with minimal overhead, making it ideal for real-time applications. Together, these protocols enable diverse applications and seamless communication across the internet, ensuring that data reaches its destination efficiently and securely.