Bird
Raised Fist0
Interview Prepcomputer-networkseasyAmazonGoogleMicrosoftTCSInfosysWipro

OSI Model - Seven Layers, Functions & PDUs

Choose your preparation mode3 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
🎯
OSI Model - Seven Layers, Functions & PDUs
easyNETWORKSAmazonGoogleMicrosoft

Imagine sending a letter through a complex postal system where each department adds its own envelope and label to ensure it reaches the right destination safely and efficiently. The OSI model works similarly for data communication.

💡 Beginners often confuse the OSI model layers as just a list to memorize rather than understanding how each layer interacts and transforms data, leading to shallow or incorrect explanations.
📋
Interview Question

Explain the OSI model and its seven layers. What is the Protocol Data Unit (PDU) at each layer, and what are the primary functions of each layer?

The seven layers of the OSI model and their responsibilitiesThe concept of Protocol Data Units (PDU) and how data encapsulation worksHow layers interact and the flow of data from sender to receiver
💡
Scenario & Trace
ScenarioA user opens a web browser and requests a webpage from a remote server.
Application layer creates HTTP request (Data) → Presentation layer formats data (Data) → Session layer establishes connection (Data) → Transport layer segments data into TCP segments (Segment) → Network layer encapsulates segments into IP packets (Packet) → Data Link layer frames packets into Ethernet frames (Frame) → Physical layer converts frames into electrical signals (Bits) → Signals travel over the physical medium to the server.
ScenarioTwo computers on a LAN communicate using Ethernet.
Application layer generates data → Data Link layer adds MAC addresses and forms frames → Physical layer transmits bits over the cable → Receiving computer's Physical layer receives bits → Data Link layer checks frame integrity and extracts packets → Network layer processes IP packets → Transport layer reassembles segments → Application layer receives data.
  • What happens if a layer fails to add or remove its header correctly?
  • How does the OSI model handle data when protocols at different layers are incompatible?
  • What if a device only supports a subset of OSI layers, such as a switch operating only at Layer 2?
⚠️
Common Mistakes
Confusing the order of OSI layers

Interviewer doubts your fundamental understanding of the model

Memorize the correct order and use mnemonics like 'Please Do Not Throw Sausage Pizza Away'

Mixing up PDUs at different layers

Shows superficial knowledge and inability to explain encapsulation

Remember specific PDU names: bits, frames, packets, segments, data

Treating OSI layers as independent rather than interacting

Fails to convey how data flows and is processed end-to-end

Explain encapsulation and decapsulation as a continuous process

Assuming all network devices implement all OSI layers

Interviewer may think you lack practical networking knowledge

Clarify that devices like switches operate mainly at Layer 2, routers at Layer 3

🧠
Basic Definition - What It Is
💡 This level covers the essential knowledge you must have to answer basic interview questions confidently.

Intuition

The OSI model is a conceptual framework that divides network communication into seven distinct layers, each with specific roles.

Explanation

The OSI (Open Systems Interconnection) model is a seven-layer framework designed to standardize and simplify network communication. Each layer has a defined function, such as transmitting raw bits, routing packets, or managing sessions. The model helps different network devices and protocols interoperate by providing a common language and structure. The Protocol Data Unit (PDU) changes names at each layer, reflecting how data is packaged: bits at the Physical layer, frames at the Data Link layer, packets at the Network layer, segments at the Transport layer, and data at the upper layers.

Memory Hook

💡 Think of mailing a letter: writing the letter (Application), putting it in an envelope (Data Link frame), addressing it (Network packet), and sending it through postal routes (Physical signals).

Interview Questions

Can you name the seven OSI layers in order?
  • Physical, Data Link, Network, Transport, Session, Presentation, Application
What is the PDU at the Network layer?
  • Packet
Depth Level
Interview Time30 seconds
Depthbasic

Covers naming layers, basic functions, and PDU terminology; sufficient for screening rounds.

Interview Target: Minimum floor - never go below this

Knowing only this will help you pass initial screening but won't impress in detailed technical interviews.

🧠
Mechanism Depth - How It Works
💡 This level is expected in product company interviews and demonstrates a deeper understanding of data flow and encapsulation.

Intuition

Data communication is a layered process where each OSI layer adds or removes headers/trailers to manage specific tasks, enabling modular and interoperable networking.

Explanation

Each OSI layer performs specific functions and communicates with its peer layer on the receiving side. When sending data, the Application layer generates the message, which passes down through Presentation and Session layers for formatting and session management. The Transport layer segments the data and adds port information for multiplexing. The Network layer adds logical addressing (IP) and routing information. The Data Link layer frames the packet with physical addressing (MAC) and error detection codes. Finally, the Physical layer converts frames into electrical or optical signals for transmission. On the receiving end, each layer strips off its corresponding header/trailer and processes the data accordingly. This encapsulation and decapsulation process ensures reliable and organized communication across diverse networks.

Memory Hook

💡 Imagine nesting dolls where each doll represents a layer adding its own wrapper; the receiver unwraps them in reverse order to get the original message.

Interview Questions

Explain how data encapsulation works in the OSI model.
  • Data is wrapped with headers/trailers at each layer
  • Each layer adds its own control information
  • Encapsulation enables modular communication and error handling
What happens at the Transport layer?
  • Segmentation of data
  • Adding port numbers for multiplexing
  • Ensuring reliable delivery (TCP) or connectionless delivery (UDP)
How do PDUs differ across layers?
  • Bits at Physical layer
  • Frames at Data Link layer
  • Packets at Network layer
  • Segments at Transport layer
  • Data at upper layers
Depth Level
Interview Time2-3 minutes
Depthintermediate

Demonstrates understanding of encapsulation, layer responsibilities, and data flow; suitable for on-site interviews.

Interview Target: Target level for FAANG on-sites

Mastering this level distinguishes you from most candidates and shows readiness for system design and troubleshooting questions.

📊
Explanation Depth Levels
💡 Choose your explanation depth based on interview stage and company expectations.
LevelInterview TimeSuitable ForRisk
Basic Definition30sScreening call or initial roundsToo shallow for on-site or technical deep-dives
Mechanism Depth2-3 minutesOn-site interviews at product companiesRequires good preparation; missing details can lose points
💼
Interview Strategy
💡 Use this guide to structure your explanation clearly and confidently before every mock or real interview.

How to Present

Start with a brief definition of the OSI model and its purpose.Use a simple analogy or example to illustrate the layered approach.Explain the function of each layer and the PDU associated with it.Discuss how data encapsulation and decapsulation work during transmission.Mention common edge cases or exceptions to show depth.

Time Allocation

Definition: 30s → Example: 1min → Mechanism: 2min → Edge cases: 30s. Total ~4min

What the Interviewer Tests

Your clarity on layer functions, ability to explain encapsulation, and understanding of how data flows through the model.

Common Follow-ups

  • What is the difference between the OSI and TCP/IP models? → OSI is conceptual with 7 layers; TCP/IP has 4 layers and is practical.
  • How does the OSI model help in troubleshooting network issues? → By isolating problems to specific layers.
💡 These follow-ups test your ability to connect concepts and apply knowledge practically.
🔍
Pattern Recognition

When to Use

Interviewers ask about the OSI model when assessing your foundational networking knowledge or troubleshooting skills.

Signature Phrases

'Explain the OSI model''What are the seven layers?''What is the PDU at each layer?''How does data flow through the OSI layers?'

NOT This Pattern When

Similar Problems

Practice

(1/5)
1. Trace the sequence of events when an external client accesses an internal web server via port forwarding configured on a NAT router.
easy
A. The router changes the destination IP and port to the internal server's IP and port, forwards the packet, and rewrites the source IP of the reply back to the router's public IP.
B. The router changes the destination IP and port to the internal server's IP and port, then forwards the packet; the server replies directly to the client.
C. The router only changes the destination IP but leaves the port unchanged; the internal server receives the packet and replies to the router.
D. The router forwards the packet without any translation; the internal server replies directly to the external client.

Solution

  1. Step 1: Understand port forwarding (DNAT)

    Port forwarding rewrites destination IP and port of incoming packets to internal server's IP and port.
  2. Step 2: Trace reply path

    The server replies to the router's internal IP, which rewrites the source IP back to its public IP before sending to the external client.
  3. Step 3: Analyze options

    The router changes the destination IP and port to the internal server's IP and port, forwards the packet, and rewrites the source IP of the reply back to the router's public IP correctly describes both forward and reply translation. The router changes the destination IP and port to the internal server's IP and port, then forwards the packet; the server replies directly to the client is incorrect because the server cannot reply directly to the client without NAT rewriting. The router only changes the destination IP but leaves the port unchanged; the internal server receives the packet and replies to the router misses port translation. The router forwards the packet without any translation; the internal server replies directly to the external client ignores NAT translation entirely.
  4. Final Answer:

    Option A -> Option A
  5. Quick Check:

    Port forwarding requires bidirectional NAT translation [OK]
Hint: Port forwarding rewrites destination IP/port inbound and source IP outbound
Common Mistakes:
  • Assuming server replies directly to external client
  • Forgetting port translation in forwarding
  • Ignoring reply path NAT rewriting
2. Which of the following statements about geo-routing in CDNs is INCORRECT?
medium
A. Geo-routing decisions can be influenced by DNS resolution or IP anycast
B. Geo-routing directs user requests to the nearest edge server to minimize latency
C. Geo-routing always guarantees the lowest latency path regardless of network congestion
D. Geo-routing helps distribute load geographically to avoid overloading a single edge server

Solution

  1. Step 1: Understand geo-routing purpose

    Geo-routing aims to route users to nearby edge servers to reduce latency.
  2. Step 2: Analyze Geo-routing always guarantees the lowest latency path regardless of network congestion

    Geo-routing does not always guarantee lowest latency because network congestion or routing policies can affect actual latency.
  3. Step 3: Confirm other options

    Geo-routing directs user requests to the nearest edge server to minimize latency is correct as geo-routing targets proximity. Geo-routing decisions can be influenced by DNS resolution or IP anycast is true since DNS and IP anycast are common geo-routing methods. Geo-routing helps distribute load geographically to avoid overloading a single edge server is valid because geo-routing balances load across regions.
  4. Final Answer:

    Option C -> Option C
  5. Quick Check:

    Geo-routing optimizes for proximity but cannot guarantee lowest latency in all network conditions.
Hint: Geo-routing ≠ always lowest latency due to network dynamics
Common Mistakes:
  • Assuming geo-routing always picks the fastest path
  • Ignoring network congestion effects
  • Confusing geo-routing with load balancing only
3. Which of the following statements about reverse proxies is INCORRECT?
medium
A. Reverse proxies always cache all content to reduce backend load
B. Reverse proxies can improve security by hiding backend server details
C. Reverse proxies can perform SSL termination to offload encryption work
D. Reverse proxies distribute incoming requests among multiple backend servers

Solution

  1. Step 1: Understand reverse proxy caching

    Reverse proxies may cache some content but do not always cache all content; caching is selective based on configuration.
  2. Step 2: Other statements

    Reverse proxies hide backend details (A), perform SSL termination (C), and load balance requests (D) -- all correct.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    Reverse proxies do not always cache all content [OK]
Hint: Reverse proxies cache selectively, not always.
Common Mistakes:
  • Assuming reverse proxies cache everything
  • Confusing reverse proxy with CDN caching behavior
4. Which of the following statements about HTTP 4xx and 5xx status codes is INCORRECT?
medium
A. 4xx status codes indicate client-side errors, meaning the client must modify the request to succeed.
B. 5xx status codes indicate server-side errors, meaning the server failed to fulfill a valid request.
C. A 403 status code means the client is forbidden from accessing the resource, even if authenticated.
D. A 404 status code means the server is temporarily unavailable and the client should retry later.

Solution

  1. Step 1: Review meanings of 4xx and 5xx status codes

    4xx = client errors; 5xx = server errors.
  2. Step 2: Analyze each statement

    4xx status codes indicate client-side errors, meaning the client must modify the request to succeed. is correct: 4xx means client must fix request.
    5xx status codes indicate server-side errors, meaning the server failed to fulfill a valid request. is correct: 5xx means server failed.
    A 404 status code means the server is temporarily unavailable and the client should retry later. is incorrect: 404 means 'Not Found', not temporary unavailability; 503 indicates temporary server unavailability.
    A 403 status code means the client is forbidden from accessing the resource, even if authenticated. is correct: 403 means forbidden access regardless of authentication.
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    404 is about missing resource, not server availability.
Hint: 404 = Not Found, 503 = Service Unavailable
Common Mistakes:
  • Confusing 404 with temporary server errors
  • Assuming 403 means unauthenticated rather than forbidden
  • Mixing client and server error categories
5. If a real-time chat application needs to support thousands of clients with intermittent connectivity and occasional message bursts, which limitation of WebSockets should be considered, and what fallback mechanism is most appropriate?
hard
A. WebSocket cannot handle intermittent connectivity; fallback to opening multiple WebSocket connections per client
B. WebSocket does not support message ordering; fallback to SSE to guarantee ordered delivery
C. WebSocket connections consume significant server resources per client; fallback to HTTP Long Polling to reduce persistent connections
D. WebSocket has high latency for message bursts; fallback to HTTP/2 multiplexing to improve throughput

Solution

  1. Step 1: Identify WebSocket resource usage

    Each WebSocket connection requires server resources to maintain persistent connections, which can be costly at scale.
  2. Step 2: Consider intermittent connectivity

    Clients with intermittent connectivity may cause connection drops, increasing server load.
  3. Step 3: Evaluate fallback options

    HTTP Long Polling can reduce persistent connections by using short-lived requests, making it a suitable fallback.
  4. Step 4: Analyze other options

    WebSocket does not support message ordering; fallback to SSE to guarantee ordered delivery is incorrect; WebSocket supports message ordering. WebSocket cannot handle intermittent connectivity; fallback to opening multiple WebSocket connections per client is wrong because opening multiple connections per client worsens resource usage. WebSocket has high latency for message bursts; fallback to HTTP/2 multiplexing to improve throughput misattributes latency issues to WebSocket and suggests unrelated HTTP/2 multiplexing.
  5. Final Answer:

    Option C -> Option C
  6. Quick Check:

    WebSocket resource cost + intermittent clients -> fallback to Long Polling
Hint: WebSocket scales poorly with many persistent connections; Long Polling reduces connection count
Common Mistakes:
  • Assuming WebSocket handles intermittent connectivity gracefully without resource impact
  • Believing WebSocket lacks message ordering
  • Confusing HTTP/2 multiplexing with WebSocket fallback