Browser generates an HTTP GET request. This is raw application data - the payload that the user actually wants to send. PDU = Data. Protocol: HTTP.
💡 The Application layer is where user-facing protocols live: HTTP, FTP, DNS, SMTP. It creates the message but has no idea how it will travel across the network.
Line:# No code - conceptual layer
# HTTP GET /index.html HTTP/1.1
# Host: www.example.com
💡 The Application layer only cares about 'what' to send, not 'how'. It hands the data down to Presentation.
send
Layer 6 - Presentation: encode/encrypt data
Presentation layer handles data formatting, encryption (SSL/TLS), and compression. For HTTPS it would encrypt the HTTP data here. PDU still = Data.
💡 The Presentation layer is the 'translator' - it ensures data is in a format both sides understand. Think of it as converting data to a common language and optionally encrypting it.
Line:# SSL/TLS encryption happens here for HTTPS
# Data encoding: ASCII, UTF-8, JPEG, MPEG
💡 For plain HTTP the Presentation layer passes data through. For HTTPS it wraps data in TLS encryption here.
send
Layer 5 - Session: manage connection dialog
Session layer establishes, manages, and terminates sessions between applications. It adds synchronization checkpoints for long transfers and manages dialog control (who speaks when). PDU = Data.
💡 Think of the Session layer as the 'meeting coordinator' - it sets up the connection, manages the conversation flow, and tears it down when done.
Line:# Session establishment, checkpointing
# NetBIOS, RPC operate here
💡 For HTTP, the Session layer is mostly transparent. For longer file transfers it adds checkpoints so transfers can resume after interruption.
send
Layer 4 - Transport: segment into TCP segments, add ports
Transport layer breaks data into segments and adds source/destination port numbers (e.g. src=54321, dst=80 for HTTP). TCP adds sequence numbers for ordering and reliability. PDU changes to Segment.
💡 Port numbers are the key addition at Layer 4. They identify which application receives the data on the destination (port 80=HTTP, 443=HTTPS, 22=SSH). TCP also adds sequence numbers to reassemble segments in order.
💡 The Transport layer is the first layer that creates end-to-end communication between processes. Network layers below only see IP addresses, not ports.
send
Layer 3 - Network: add IP header, create packet
Network layer adds source and destination IP addresses. This is where routing decisions are made - how to get from client IP to server IP across potentially many routers. PDU changes to Packet.
💡 IP addresses are logical addresses that identify devices across different networks. Routers operate at this layer - they read the IP header and decide where to forward the packet next.
💡 MAC addresses (Layer 2) only work within a single network. IP addresses (Layer 3) work globally - that's why we need both layers.
send
Layer 2 - Data Link: add MAC addresses, create frame
Data Link layer adds source and destination MAC addresses for the local network segment. Also adds a trailer with CRC error-detection code. PDU changes to Frame.
💡 MAC addresses identify devices on the same local network (like room numbers in a building). The IP address is the city+street address; the MAC is the apartment number within that building.
Line:# Ethernet frame:
# dst_mac=AA:BB:CC:11:22:33 (next hop router)
# src_mac=FF:EE:DD:44:55:66 (client NIC)
# + CRC trailer for error detection
💡 The MAC destination here is the router's MAC, not the server's MAC. Layer 2 is only for the current network hop; IP handles the full journey.
send
Layer 1 - Physical: convert to bits, transmit
Physical layer converts the Frame into electrical signals (copper cable), light pulses (fiber optic), or radio waves (WiFi). These bits travel across the physical medium to the receiver. PDU = Bits.
💡 The Physical layer has no concept of addresses or structure - it just transmits raw 0s and 1s. The actual voltage levels, frequencies, and encoding schemes are defined here.
Line:# Electrical signals on copper wire
# Light pulses on fiber optic
# Radio waves on WiFi (802.11)
💡 Every other layer is software/firmware. The Physical layer is hardware - the actual wire, fiber, or air carrying the signal.
receive
Receiver Layer 2 - Data Link: check CRC, extract packet
Receiver's Physical layer collects bits and reconstructs the Frame. Data Link layer checks CRC for errors. If valid, strips the Ethernet header and trailer, extracts the IP Packet, passes it up to Network layer.
💡 This is decapsulation - the receiver undoes what the sender did, layer by layer in reverse order. Each layer removes its own header/trailer.
Line:# Check CRC: if error → drop frame
# Strip Ethernet header + CRC trailer
# Extract IP packet → pass to Layer 3
💡 Decapsulation is the reverse of encapsulation. The receiver reconstructs the original message by stripping headers from outermost to innermost.
Network layer reads the IP header, verifies destination IP matches this host. Strips IP header, extracts TCP Segment, passes up to Transport layer.
💡 The Network layer checks 'Is this packet meant for me?' by comparing the destination IP to its own IP address. If yes, strip the IP header and pass up.
Line:# Check dst_ip == my_ip
# Strip IP header
# Extract TCP segment → pass to Layer 4
💡 Routers along the path also operate at Layer 3 - they read the IP header, decide the next hop, and forward without going above Layer 3.
receive
Receiver Layer 4 - Transport: reassemble, deliver to port 80
Transport layer reads TCP header. Checks destination port (80 = HTTP server process). Uses sequence numbers to reassemble multiple segments in order. Sends TCP ACK. Strips TCP header, passes Data up.
💡 Port 80 tells the OS which application should receive this data - the web server. Sequence numbers ensure segments are assembled in the correct order even if they arrived out of order.
Line:# Check dst_port → route to HTTP server process
# Use seq_num to reassemble segments in order
# Send TCP ACK back to sender
# Strip TCP header → extract Data
💡 TCP ACKs are sent back to the sender to confirm receipt. If ACK is not received, the sender retransmits - this is TCP's reliability guarantee.
receive
Receiver Layers 5,6,7 - deliver HTTP request to web server
Session layer manages the ongoing connection. Presentation layer decrypts (for HTTPS) and decodes data. Application layer (web server) receives the HTTP GET request and processes it to send back the webpage response.
💡 The last three layers undo what the sender's layers did: Session tracks the dialog, Presentation decrypts, Application processes the message. The web server now sees the original HTTP GET request.
Line:# Session: maintain dialog context
# Presentation: decrypt TLS, decode format
# Application: HTTP server processes GET /index.html
💡 The response from the web server travels down all 7 layers on the server side and up all 7 layers on the client side - the exact same process in reverse.
# Python socket = Application/Transport layers
import socket
# Application layer: create HTTP request
request = b'GET /index.html HTTP/1.1\r\nHost: example.com\r\n\r\n'
# Transport + Network layers: handled by OS TCP/IP stack
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # TCP socket
sock.connect(('93.184.216.34', 80)) # OS handles TCP handshake (Layer 4) + IP routing (Layer 3)
# Send: OS encapsulates through L4 (TCP) → L3 (IP) → L2 (Ethernet) → L1 (NIC)
sock.send(request) # Application hands data to Transport layer
# Receive: OS decapsulates from L1 → L2 → L3 → L4 → delivers to socket buffer
response = sock.recv(4096)
print(response.decode()) # Application layer reads the HTTP response
📊
OSI Model - Watch an HTTP Request Flow Through All 7 Layers
The key insight: data goes DOWN the layers on the sender (each layer adds a header), crosses the network as bits, then goes UP the layers on the receiver (each layer removes its header). This is called encapsulation and decapsulation.
Step 1/11
·Active fill★Answer cell
Application layer creates HTTP GET request. PDU = Data. Handed to Presentation layer.
Hop: 1
Layer 7: Application (Sender)
Layer 6: Presentation (Sender)
Layer 5: Session (Sender)
Layer 4: Transport (Sender)
Layer 3: Network (Sender)
Layer 2: Data Link (Sender)
Layer 1: Physical (Sender)
Layer 1: Physical (Receiver)
Layer 2: Data Link (Receiver)
Layer 3: Network (Receiver)
Layer 4: Transport (Receiver)
Layer 5: Session (Receiver)
Layer 6: Presentation (Receiver)
Layer 7: Application (Receiver)
📦Packet
↗ fromApp_Tx
↘ toPres_Tx
📄 payloadData (HTTP GET)
🔌 protocolHTTP
Layer 7 (App) → Data created: HTTP GET /index.html
Presentation layer formats and optionally encrypts data. PDU = Data.
L5→Data (session) | L6→Data (decrypt) | L7 (App) → HTTP GET received by web server
Key Takeaways
✓ Encapsulation (sender): each layer adds its header going DOWN - Data→Segment→Packet→Frame→Bits.
Mnemonic bottom-up: Please Do Not Throw Sausage Pizza Away (Physical, Data Link, Network, Transport, Session, Presentation, Application).
✓ Decapsulation (receiver): each layer removes its header going UP - Bits→Frame→Packet→Segment→Data.
The receiver is a mirror of the sender. Every header added on one side is removed on the other.
✓ PDUs by layer: Bits (L1), Frame (L2), Packet (L3), Segment (L4), Data (L5-L7).
In interviews, if asked 'what PDU at Layer X', recall: 1=Bits, 2=Frame, 3=Packet, 4=Segment, 5-7=Data.
Practice
(1/5)
1. You need to design a RESTful API endpoint that retrieves user profile information without modifying any server data. Which HTTP method should you use to ensure the operation is safe and does not change server state?
easy
A. GET
B. POST
C. PUT
D. DELETE
Solution
Step 1: Understand the safety property of HTTP methods
GET is defined as a safe method, meaning it does not modify server state and is used to retrieve data.
Step 2: Analyze other methods
POST, PUT, and DELETE modify server state and are not safe methods.
Final Answer:
Option A -> Option A
Quick Check:
GET is the only safe method here, suitable for data retrieval without side effects.
Hint: GET = safe read, POST/PUT/DELETE = state change
Common Mistakes:
Confusing POST with GET as both can send data
Thinking PUT is safe because it replaces data
Assuming DELETE can be used to retrieve data
2. Which of the following statements about IPv6 headers is INCORRECT?
medium
A. IPv6 headers have a fixed length of 40 bytes, simplifying processing
B. IPv6 headers include a checksum field to ensure header integrity
C. IPv6 removes the header checksum present in IPv4 to reduce processing overhead
D. IPv6 headers support extension headers to add optional information
Solution
Step 1: Recall IPv6 header structure
IPv6 headers have fixed length and no checksum field.
Step 2: Analyze options
IPv6 headers have a fixed length of 40 bytes, simplifying processing is correct; IPv6 headers are fixed at 40 bytes. IPv6 headers include a checksum field to ensure header integrity is incorrect; IPv6 does not have a checksum field. IPv6 removes the header checksum present in IPv4 to reduce processing overhead is correct; checksum was removed to speed up processing. IPv6 headers support extension headers to add optional information is correct; extension headers provide optional info.
Final Answer:
Option B -> Option B
Quick Check:
IPv6 relies on upper-layer checksums, not header checksum.
Hint: IPv6 headers have no checksum field [OK]
Common Mistakes:
Assuming IPv6 headers have checksums like IPv4
Confusing extension headers with fixed header fields
3. Which of the following statements about Distance Vector routing is INCORRECT?
medium
A. Routers using Distance Vector routing have complete knowledge of the entire network topology
B. Distance Vector routing can suffer from the count-to-infinity problem causing slow convergence
C. Distance Vector routing updates are sent only to immediate neighbors
D. Split horizon and poison reverse are techniques used to prevent routing loops in Distance Vector
Solution
Step 1: Recall Distance Vector knowledge scope
Distance Vector routers only know routes advertised by neighbors, not the full network topology.
Step 2: Analyze each statement
Distance Vector routing can suffer from the count-to-infinity problem causing slow convergence is true; count-to-infinity is a known Distance Vector issue. Distance Vector routing updates are sent only to immediate neighbors is true; updates go only to neighbors. Split horizon and poison reverse are techniques used to prevent routing loops in Distance Vector is true; split horizon and poison reverse help prevent loops.
Step 3: Identify incorrect statement
Routers using Distance Vector routing have complete knowledge of the entire network topology is false because complete topology knowledge is a characteristic of Link State routing, not Distance Vector.
Final Answer:
Option A -> Option A
Quick Check:
Distance Vector routers have partial, neighbor-based knowledge only.
Hint: Full topology knowledge -> Link State, not Distance Vector
4. If a company wants to improve both security and performance for a public-facing web application, which combined deployment of firewall, proxy, and reverse proxy is most effective?
hard
A. Deploy a proxy server between backend servers and clients without a firewall
B. Use only a reverse proxy to handle all security filtering and caching
C. Rely solely on a firewall to filter traffic and improve performance
D. Deploy a firewall at the network edge, a forward proxy for client requests, and a reverse proxy in front of backend servers
Solution
Step 1: Firewall role
Firewall at network edge filters unauthorized traffic, providing security.
Step 2: Forward proxy role
Forward proxy manages client requests, can enforce policies and cache content.
Only reverse proxy (B) or only firewall (C) miss layered defense and performance optimization; no firewall (A) reduces security.
Final Answer:
Option D -> Option D
Quick Check:
Combined deployment leverages strengths of all components [OK]
Hint: Layered defense: firewall + proxies for security and performance.
Common Mistakes:
Assuming one component can handle all roles
Ignoring the need for firewall in security
5. If a load balancer using IP Hash algorithm encounters clients behind a NAT (Network Address Translation) device, what is a potential challenge and how can it be mitigated?
hard
A. Clients behind NAT have different IPs, causing inconsistent routing; mitigation is to disable IP Hash and use Round Robin
B. Multiple clients share the same public IP, causing all their requests to be routed to the same server; mitigation involves using additional session identifiers beyond IP
C. NAT devices block IP Hash algorithms; mitigation is to switch to Least Connections
D. IP Hash cannot detect unhealthy servers behind NAT; mitigation is to increase health check frequency
Solution
Step 1: Understand NAT impact on IP Hash
NAT causes multiple clients to share a single public IP address.
Step 2: Effect on IP Hash routing
Since IP Hash uses client IP, all clients behind the same NAT get routed to the same backend server, potentially causing load imbalance.
Step 3: Mitigation strategies
Using additional session identifiers (cookies, tokens) can differentiate clients beyond IP, improving distribution.
Step 4: Why other options are incorrect
Clients behind NAT have different IPs, causing inconsistent routing; mitigation is to disable IP Hash and use Round Robin incorrectly states clients behind NAT have different IPs; they share one. NAT devices block IP Hash algorithms; mitigation is to switch to Least Connections falsely claims NAT blocks IP Hash. IP Hash cannot detect unhealthy servers behind NAT; mitigation is to increase health check frequency confuses health checks with NAT issues.
Final Answer:
Option B -> Option B
Quick Check:
NAT causes IP Hash collisions; use extra session info to mitigate.
Hint: NAT causes IP Hash collisions; add session IDs
Common Mistakes:
Assuming IP Hash works perfectly behind NAT
Thinking NAT changes client IPs individually
Confusing NAT issues with health check problems
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.