Skip to main content

Open Systems Interconnection (OSI) reference model

  • The Open Systems Interconnection (OSI) model describes how data travels from one device to another across a network.
  • It has seven layers, each responsible for a different part of the communication process.
  • When data travels from the top (Application) down to the bottom (Physical), this is called encapsulation because each layer adds its own information, like headers and trailers.
  • When the data is received, the process reverses, known as decapsulation.
  • The data changes form as it moves: Data → Segment → Packet → Frame → Bits

Layer 7 – Application Layer

The Application layer handles everything needed for user applications to interact over a network. It provides network services directly to programs like web browsers, email clients, or chat apps.

Without DNS, we wouldn’t be able to access websites by name, and without protocols like SMTP or IMAP, we couldn’t send or receive emails. File transfers happen through FTP, and remote sessions use SSH or RDP.

Web browsing runs on HTTP or HTTPS, where HTTP is the “what” — the actual data being sent — and SSL/TLS is the “how” — the method that secures it. HTTPS simply means HTTP is running inside an SSL/TLS encrypted tunnel.

For example, when you send a message like “Hey, are we still meeting for lunch?” through a messaging app, the app formats your text using its communication protocol (such as XMPP) and sends it across the network. The device handling this process could be your phone or computer, and the data unit at this layer is simply Data.

Layer 6 – Presentation Layer

The Presentation layer ensures that data sent from one device can be properly understood by another, even if they use different systems or formats. It acts as a translator, handling formatting, compression, and encryption/decryption.

For example, if you’re sending an image, the raw file from your camera is huge, so the Presentation layer compresses it using a format like JPEG before sending it. When received, it decompresses the image for viewing. Similarly, when you type the letter “A,” your computer represents it as the number 65 in ASCII or as Unicode in UTF-8. The Presentation layer makes sure that when the data reaches another system, it still shows up as the correct letter “A” instead of random characters.

This layer also handles encryption, like when SSL/TLS encrypts HTTPS traffic.

Layer 5 – Session Layer

The Session layer is responsible for starting, maintaining, and ending communication sessions between devices or applications. It keeps track of ongoing conversations, ensuring that data exchanges happen in an organized and synchronized way.

This layer can also set checkpoints during large data transfers, so if a connection is interrupted, the transfer can resume from the last saved point instead of restarting from the beginning.

A common example is when you’re connected to a remote server — the Session layer maintains that connection until you log out. The data unit at this layer is still Data.

Layer 4 – Transport Layer

The Transport layer manages how data moves from one device to another and ensures that it arrives completely and correctly.

It segments large amounts of data into smaller pieces and adds headers with port numbers so that data reaches the correct application on the receiving end. It also handles error detection, retransmission, and flow control.

The two main protocols here are TCP and UDP.

TCP is connection-oriented, reliable, and ensures data arrives in order.

UDP is connectionless, faster, and used when speed matters more than reliability, such as in streaming or gaming.

The data unit at this layer is a Segment.

Layer 3 – Network Layer

The Network layer is all about routing data between different networks. It determines the best path for data to travel and uses logical addressing through IP addresses.

It takes the segment from the Transport layer and adds an IP header that includes both the source and destination IP addresses.

Common protocols at this layer include IP (IPv4 and IPv6) for addressing, ICMP for diagnostics (like ping), and ARP/RARP for mapping between IP and MAC addresses.

For example, your phone with IP address 192.168.1.5 might send a packet to a web server with IP 104.16.248.249. However, ARP doesn’t find the MAC address of that distant server — it only resolves the MAC address of your default gateway (the router) so the data can leave your network.

The data unit here is a Packet.

The Data Link layer, often called the “switch layer,” is responsible for node-to-node or device-to-device communication on the same local network (LAN).The communication on the local network segment (e.g., within your home Wi-Fi or a single office LAN). It cannot directly address a device on a different network across the internet.

It ensures reliable and error-free delivery using MAC addresses.

This layer adds both a header and a trailer around the packet. The header contains the source and destination MAC addresses, while the trailer contains the Frame Check Sequence (FCS), which detects transmission errors.

The Data Link layer also determines how devices share the physical medium. This is about preventing collisions. On a Wi-Fi network, it's like the rules for who gets to talk in a meeting. You wait for a quiet moment before you speak. On a wired network, a switch manages this intelligently so each device has a dedicated lane.

The destination MAC address here isn’t the server’s — it’s the MAC of the next hop, usually your router. As the packet travels through the network, each router removes the old MAC addresses and adds new ones, while the IP addresses remain the same. Example

  • You are in your city (your home network) and want to send a letter to a friend in another country (a server on the internet).
  • Your House: You write the letter (data) with the final address "Friend's Public IP Address".
  • Local Courier (Data Link Layer): The courier doesn't know other countries. So, you give the letter to the International Airport (your router). The shipping label reads: "To: Airport's MAC Address".
  • The Airport (Your Router): It receives the letter, strips off the local shipping label (the old MAC header), and puts on a new label for the next leg of the journey. The new label might say "To: Cargo Plane's MAC Address". The letter inside, with the final IP address, remains unchanged.
  • This repeats at every hop until the letter reaches its final destination.

The data unit at this layer is a Frame.

The Physical layer deals with the actual transmission of bits — the ones and zeros — across the physical medium.

It converts frames into electrical signals, light pulses, or radio waves depending on the medium.

It defines everything about the physical connection: cables, connectors, voltages, frequencies, and transmission rates. Examples include Ethernet cables (Cat5e, Cat6), fiber optics, and wireless signals like Wi-Fi or Bluetooth.

Problems at this layer often cause errors like CRC or FCS mismatches, which usually come from damaged cables, loose connectors, interference (EMI), or mismatched speed and duplex settings.

The data unit here is Bits.

The "Perfect Partnership" for Sending a "Like"

The Goal: Your "Like" must travel from your app to the social media server accurately and securely.

Layer 7: Application Layer - The User

Role: You, the person.

Action: You click the "Like" button. You have the idea and the intent ("I want to like this post").

Partnership: You rely on the app (the next layer down) to turn your intent into a language the computer understands. You don't know how it's done, you just issue the command.

Layer 6: Presentation Layer - The Universal Translator & Encryptor

Role: The Translator and Security Agent.

Action: The translator takes your "Like" command and does two things:

Translation: It formats the data into a standard language (like JSON) that both your app and the server understand.

Encryption: It puts the command into a secure, locked box (SSL/TLS encryption). Only the server has the key to open it.

Partnership: The translator relies on the Application layer for the intent, and on the Session layer to establish a secure line to send the locked box. It doesn't care about the network, only about the representation and security of the data.

Layer 5: Session Layer - The Session Manager

Role: The Corporate Event Planner.

Action: Before any data is sent, the event planner:

Calls the social media server and says, "Hello, are you ready to communicate?" (establishes the session).

Manages the conversation, ensuring your "Like" is sent and the "Like received" confirmation comes back.

Ends the call when the transaction is complete (terminates the session).

Partnership: The event planner uses the secure, translated data from Layer 6 and relies on the Transport layer to guarantee the entire conversation is delivered reliably. It manages the "when" of the communication.

Layer 4: Transport Layer - The Logistics & Quality Control Manager

Role: The Post Office Supervisor.

Action: The supervisor takes the secure, session-managed "Like" package and prepares it for shipment.

Segmentation: If the package is too big, they break it into smaller, numbered envelopes (segments).

Guaranteed Delivery (TCP): They keep a log of every envelope sent. If an envelope gets lost, they re-send it. They also ensure the envelopes are given to the Network layer in the correct order.

Addressing for Services: They write the destination port number (e.g., port 443 for HTTPS) on the envelope—the specific "department" within the server that handles "Likes."

Partnership: The supervisor relies on the Session manager for the data to send and on the Network layer to handle the complex addressing across towns and cities. Their job is end-to-end integrity.

Layer 3: Network Layer - The National Postal System

Role: The Address and Routing Expert.

Action: This expert takes the envelope from the Transport layer and puts it inside a larger, standard-sized postal crate.

Logical Addressing: They stamp the crate with logical IP addresses—"From: [Your Public IP]" and "To: [Social Media Server's IP]". This is the address for the entire building, not a person inside.

Routing: They look at the destination IP and decide the best path through the internet ("Should this crate go through Chicago or Atlanta?"). This is the packet.

Partnership: The routing expert doesn't care about the contents of the crate (the segment). They only care about the IP addresses and finding the best path. They rely on the local couriers (Data Link layer) to move the crate between each stop on the journey.

Role: The Local Courier Service.

Action: The courier operates only within one city (your local network). They take the postal crate and prepare it for the next local hop.

Physical Addressing: They put a local shipping label on the crate with MAC addresses—"From: Your Laptop's MAC" and "To: Your Router's MAC".

Error Checking: They seal the crate with a tamper-evident seal (FCS Trailer). This is the frame.

Partnership: The courier is the "last mile" expert. They rely on the Physical layer truck drivers to actually move the frame. They check the seal on incoming frames to ensure they weren't damaged in transit on their local road.

Layer 1: Physical Layer - The Trucks & Highways

Role: The Trucks, Roads, and Airwaves.

Action: This is the physical infrastructure. The truck driver takes the sealed frame from the Data Link layer and converts it into a physical signal—electrical voltages over a cable, light pulses over fiber, or radio waves over Wi-Fi.

Partnership: The driver is "dumb." They don't understand the addresses, the contents, or the seals. They just drive. They are susceptible to potholes (cable damage), weather (interference), and traffic jams (collisions). They rely entirely on the Data Link layer to check their work for errors.

The Complete, Interdependent Journey

Your "Like" is transformed as it moves down the partnership chain: Your Intent -> Secure, Translated Command -> Managed Session -> Guaranteed Segment -> Routed Packet -> Local Frame -> Physical Bits

At the destination server, the process happens in reverse, with each layer handing off its successfully completed task to the layer above, until the server's Application layer finally registers your "Like."

This is the perfect partnership: Each layer has a specialized job and trusts the layers above and below it to handle their own specific responsibilities, creating a robust and efficient system.