Skip to content
Home Tutorials Roadmaps Courses
Log in Join free
Computer Science Beginner FREE

OSI Model

Lesson 2 of 17 Beginner Interactive

The OSI model has 7 layers describing how network communication works.

Syntax

COMPUTER-SCIENCE
7. Application  — HTTP, FTP, SMTP
6. Presentation — SSL/TLS, encryption
5. Session     — API, sockets
4. Transport   — TCP, UDP
3. Network     — IP, routing
2. Data Link   — MAC, Ethernet
1. Physical    — cables, signals
OSI Model Layers
PYTHON
layers = {
    7: ("Application", "HTTP, FTP, SMTP"),
    6: ("Presentation", "SSL/TLS, Encoding"),
    5: ("Session", "NetBIOS, RPC"),
    4: ("Transport", "TCP, UDP"),
    3: ("Network", "IP, ICMP, Router"),
    2: ("Data Link", "Ethernet, MAC, Switch"),
    1: ("Physical", "Cables, Hubs, Signals")
}

print("OSI Model Layers:")
for num, (name, protocols) in sorted(layers.items(), reverse=True):
    print(f"  Layer {num}: {name:12} | {protocols}")

Practice

1
Exercise

Name all 7 OSI layers.

Answer
Physical, Data Link, Network, Transport, Session, Presentation, Application.

Quick Quiz

1

Which layer does IP operate at?

IP operates at Layer 3 (Network).

Interview Questions

It standardizes network communication into layers, making it easier to understand, troubleshoot, and develop network technologies.