OSI Model Layers Explained: 7 Layer Functions, Encapsulation and a Solved End-to-End Example
Learn what each OSI layer does, then follow one message across two LANs. The worked example tracks ports, IP and MAC addresses, frame size, efficiency and time.
KnowledgeGate Team
Exam prep & CS education

The mnemonic Please Do Not Throw Sausage Pizza Away can recover the OSI layer order, but it cannot tell you which address changes at a router, why a switch works below IP, or how a 1,200-byte message becomes a larger frame. The OSI model links each layer's responsibility to a Host A to Host B trace through ports, IP addresses, MAC addresses, PDU names and byte counts. Use CS Fundamentals for wider networking notes. Every header size in the numerical example is a supplied textbook assumption, not a universal protocol constant.
The OSI model separates responsibilities, not physical boxes
The OSI model is a seven-layer reference model for communication. Each layer serves the one above and uses the one below. A device or program may span layers; there is not one physical box per layer.
Sender data moves from Application through Presentation, Session, Transport, Network and Data Link to Physical, gaining control information. Bits cross the medium; the receiver reverses this order and decapsulates. Peer-layer communication is logical, while data crosses the stack and medium.
The mnemonic recalls order. Responsibility, address and PDU tell you what each layer actually does.
OSI Layers 7 to 5: meaning, representation and conversation state
Layer | Primary responsibility | Textbook examples | Question clue |
|---|---|---|---|
7 Application | Network services visible to application software | HTTP, DNS | Service used by an application |
6 Presentation | Representation, encoding, compression and encryption | UTF-8, data formatting | Format or transform data |
5 Session | Start, coordinate, checkpoint and end a dialogue | Checkpoints, dialogue control | Maintain conversation state |
Layer 7 is where the Application Layer Protocols: DNS and HTTP Guide fits. UTF-8 conversion is Presentation work, a recovery checkpoint is Session work, and DNS hostname resolution is Application work.
Modern Internet software often folds Presentation and Session work into application protocols or libraries. Encryption need not add a distinct Layer 6 header, and a live session need not use a standalone Session-layer protocol.
OSI Layers 4 to 1: delivery, routing, frames and signals
Layer | Primary responsibility | Textbook examples | Question clue |
|---|---|---|---|
4 Transport | Process-to-process delivery, segmentation and service choice | TCP, UDP | Port number |
3 Network | Logical addressing and path selection | IP, router | IP address or packet |
2 Data Link | Delivery on one link, framing, MAC addressing and error detection | Ethernet, switch | MAC address or frame |
1 Physical | Represent bits as signals over a medium | Cable, radio, encoding | Signal or bit |
The PDU ladder is precise: Layers 7 to 5 carry data; Layer 4 carries a TCP segment, UDP datagram, or generic transport PDU; Layer 3 a packet; Layer 2 a frame; and Layer 1 bits. The TCP vs UDP: Transport Layer Explained guide expands the Layer 4 service choice.
Switches usually forward at Layer 2. Routers strip the incoming frame, examine Layer 3 and build a new frame. Ports identify processes, not network routes; MAC addresses are hop-local, not end-to-end across routers.
OSI worked example, part 1: next hop and address changes
Use this path: Host A -> Switch S1 -> Router R1 -> Switch S2 -> Host B.
Host A: IP
10.1.1.10/24, MAC00:11:22:33:44:55, gateway10.1.1.1R1 left: IP
10.1.1.1, MAC00:AA:00:AA:00:01R1 right: IP
172.16.2.1, MAC00:AA:00:AA:00:02Host B: IP
172.16.2.20/24, MAC66:77:88:99:AA:BBTransport ports:
51514 -> 443; starting TTL:64
The prefix comparison in IP Addressing and Subnetting Explained places 10.1.1.10/24 and 172.16.2.20/24 on different /24 networks, so A uses its gateway. On LAN 1, the MAC pair is 00:11:22:33:44:55 -> 00:AA:00:AA:00:01; inside it, IP remains 10.1.1.10 -> 172.16.2.20 and ports remain 51514 -> 443.
S1 forwards that frame. R1 removes the Layer 2 wrapper, routes the packet, lowers TTL from 64 to 63, and builds a LAN 2 frame with MAC pair 00:AA:00:AA:00:02 -> 66:77:88:99:AA:BB. In this no-NAT example, the IP and port pairs stay unchanged. Host B then decapsulates upward.

OSI worked example, part 2: byte-by-byte encapsulation
Assume a 1,200-byte application payload; 20 bytes added across Layers 7 to 5; a 20-byte Transport header; a 20-byte Network header; and an 18-byte Data Link header plus 4-byte trailer. Physical adds no counted bytes. These values belong only to this question.
Upper-layer data:
1,200 + 20 = 1,220 bytes.Transport PDU:
1,220 + 20 = 1,240 bytes.Network packet:
1,240 + 20 = 1,260 bytes.Data Link frame:
1,260 + 18 + 4 = 1,282 bytes.Physical transmission:
1,282 x 8 = 10,256 bits.At
10 Mb/s:10,256 / 10,000,000 = 0.0010256 s = 1.0256 ms.
Total overhead is 1,282 - 1,200 = 82 bytes. Application-payload efficiency is (1,200 / 1,282) x 100 = 93.60% approximately.
Host B proves decapsulation by reversing the additions: 1,282 - 22 = 1,260, 1,260 - 20 = 1,240, 1,240 - 20 = 1,220, and 1,220 - 20 = 1,200 bytes. R1 replaces only the Layer 2 wrapper for the next hop in this simplified trace. It does not deliver the payload through all seven layers.

OSI and TCP/IP mapping: similar jobs, different grouping
OSI Application, Presentation and Session broadly map to TCP/IP Application; OSI Transport to Transport; OSI Network to Internet; and OSI Data Link plus Physical to Link or Network Access. Different grouping makes this a mapping, not an identity.
Match the trace: DNS -> Application, port 443 -> Transport, 172.16.2.20 -> Network, 66:77:88:99:AA:BB -> Data Link, and 10,256 bits -> Physical. The values keep the same jobs.
OSI vs TCP/IP Model for GATE compares the two stacks and their PYQ traps. The seven-layer OSI view instead follows addresses across two LANs and calculates overhead from supplied values.
How exams test the OSI model and where answers go wrong
Questions may ask you to order layers; match a function, device, protocol, address or PDU; follow encapsulation; track fields across switches and routers; calculate size, overhead, efficiency or time from supplied values; or map OSI to TCP/IP. These are question forms, not official weightage.
Correct these recurring traps:
Not every destination address belongs to Network. IP is end-to-end here; MAC is hop-local.
A router does not automatically change both endpoint IPs. With no NAT, it changes the frame addresses and TTL.
A reference-layer function need not produce a separate real-world header.
Never import remembered header sizes. Use the values supplied in the question.
Audit the arithmetic. If Layer 2 overhead rises from 22 to 30 bytes, the frame is 1,260 + 30 = 1,290 bytes, total overhead is 90 bytes, and efficiency is (1,200 / 1,290) x 100 = 93.02% approximately. If the original link rate doubles to 20 Mb/s, time is 10,256 / 20,000,000 = 0.0005128 s = 0.5128 ms, exactly half of 1.0256 ms.
The seven-layer short version and your next step
Application serves applications; Presentation represents data; Session manages dialogue; Transport serves processes and uses ports; Network routes packets with logical addresses; Data Link moves frames on one link with MAC addresses; Physical carries bits as signals.
For a 20-minute revision, redraw the path and both MAC pairs, then recompute 1,200 -> 1,282 bytes -> 10,256 bits -> 1.0256 ms. Explain why the router changes Layer 2 but not the destination IP in this no-NAT trace.
Zero to Hero: Complete CS Course is the structured route for a broader first pass through Computer Networks.
Keep learning
OSI Model & Layers MCQs: 12 Solved Questions on PDUs and Encapsulation
Test OSI layers, PDUs, encapsulation and router traversal through solved MCQs, with explanations, a byte-by-byte frame trace and a layer-visit method.
TCP/IP Model Explained: Four Layers, Worked Encapsulation and Exam Traps
Learn the four TCP/IP layers through one complete packet journey. The worked example calculates headers, MTU fit, frame efficiency and serialization time step by step.
OSI vs TCP/IP Model for GATE: Which Layer Does What, with PYQ Traps
Map every OSI and TCP/IP layer to its function, PDU, address and device. Then trace an HTTP request through encapsulation and fix the usual layer traps.
Network Hardware Basics for GATE CS: Devices, OSI Layers, and Collision Domain Counting
Stop mixing up hubs, switches, and routers. Learn the device layers, domain-counting rules, transmission media, and a worked topology for GATE and interviews.





