Lesson 10 — Intermediate
Networking: OSI & TCP/IP
OSI model networking ka blueprint hai — data kaise travel karta hai sender se receiver tak. 7 layers, har layer ka apna kaam hai.
OSI Model — 7 Layers
# OSI (Open Systems Interconnection) Model
# Mnemonic: "All People Seem To Need Data Processing"
Layer 7: Application — User Interface (HTTP, FTP, SMTP)
Layer 6: Presentation — Data Format (SSL/TLS, Encryption)
Layer 5: Session — Connection Management (NetBIOS)
Layer 4: Transport — End-to-End Delivery (TCP, UDP)
Layer 3: Network — Routing & Addressing (IP, Router)
Layer 2: Data Link — MAC Address, Frame (Switch)
Layer 1: Physical — Bits on wire (Cable, Hub)
# Data Flow:
Sender: L7 — L6 — L5 — L4 — L3 — L2 — L1
Receiver: L1 — L2 — L3 — L4 — L5 — L6 — L7
# Each layer adds header (encapsulation):
Application Data — Segment (L4) — Packet (L3) — Frame (L2) — Bits (L1)
Mental Model: OSI jaise postal system. tum letter likhte ho (Application), envelope mein daalte ho (Presentation), post office stamp lagata hai (Session), delivery type select karte ho — speed post/registered (Transport), address likhte ho (Network), courier boy aata hai (Data Link), truck mein load hota hai (Physical).
Har Layer Detail
# Layer 7: Application
? End-user services — HTTP, HTTPS, FTP, SMTP, DNS
? Browser, email client, file transfer
? Device: Software (browser, app)
# Layer 6: Presentation
? Data translation, encryption, compression
? SSL/TLS encryption yahan hota hai
? ASCII to EBCDIC conversion
# Layer 5: Session
? Sessions establish, maintain, terminate
? Checkpointing, recovery
? NetBIOS, RPC
# Layer 4: Transport
? Reliable/unreliable delivery
? TCP (reliable, connection-oriented)
? UDP (unreliable, connectionless, fast)
? Port numbers: HTTP=80, HTTPS=443, SSH=22
? Segmentation, flow control
# Layer 3: Network
? Logical addressing (IP address)
? Routing — best path find karna
? Packet forwarding
? Device: Router
? Protocols: IP, ICMP, OSPF, BGP
# Layer 2: Data Link
? Physical addressing (MAC address)
? Framing, error detection
? Switch yahan kaam karta hai
? Protocols: Ethernet, Wi-Fi, PPP
? MAC addresses: AA:BB:CC:DD:EE:FF
# Layer 1: Physical
? Bits on wire (0s and 1s)
? Cables, hubs, repeaters
? Electrical/optical signals
? Device: Hub, Cable, NIC
TCP/IP Model
# TCP/IP Model (Practical) — 4 Layers
| OSI Layer | TCP/IP Layer | Protocols |
|-----------------|---------------|------------------------|
| Application | Application | HTTP, FTP, DNS, SMTP |
| Presentation | Application | SSL/TLS |
| Session | Application | Session management |
| Transport | Transport | TCP, UDP |
| Network | Internet | IP, ICMP, ARP |
| Data Link | Network Access| Ethernet, Wi-Fi |
| Physical | Network Access| Cables, Hubs |
# Why TCP/IP over OSI?
? OSI theoretical hai (7 layers)
? TCP/IP practical hai (4 layers) — actually use hota hai
? Internet TCP/IP pe based hai
# TCP vs UDP:
TCP: Reliable, ordered, connection-oriented
? Web browsing, email, file transfer
? 3-way handshake, flow control, error recovery
UDP: Unreliable, fast, connectionless
? Gaming, video streaming, DNS queries
? No overhead, low latency
Network Devices by Layer
# Layer 1: Hub
? Bits sab ports pe broadcast karta hai
? No intelligence, no filtering
? Collision domain same
# Layer 2: Switch
? MAC address table use karta hai
? Sirf relevant port pe data bhejta hai
? Collision domain alag per port
? Full-duplex communication
# Layer 3: Router
? IP address based routing
? Different networks ko connect karta hai
? Best path select karta hai (routing table)
? Internet = billions of routers
# Layer 4-7: Firewall/Load Balancer
? Packet inspection (L4)
? Content filtering (L7)
? Load balancing (L7)
# Layer 7: Proxy Server
? Client aur server ke beech
? Caching, security, anonymity
Exercise
Question: OSI model mein kitni layers hoti hain? (1 word)
Question: TCP aur UDP mein se kaunsa reliable hai? (1 word)
Common mistakes
- OSI layers yaad karna bhooolna: "All People Seem To Need Data Processing" — ye mnemonic yaad karo.
- TCP vs UDP confusion: TCP = reliable (web, email), UDP = fast (gaming, streaming). Use case decide karta hai.
- Router vs Switch: Router = Layer 3 (IP based), Switch = Layer 2 (MAC based). Alag cheezein hain.
- Encapsulation skip: Har layer header add karti hai — ye process encapsulation hai. Data flow samajhna zaroori hai.
Lesson complete?
OSI & TCP/IP samajh aa gaya? Ab HTTP, DNS, HTTPS seekhte hain — web ke core protocols.