Loading W Code...
Internet Protocol Suite - 4 Layer Model
TCP/IP is the practical model used on the Internet today. It was developed by DARPA and has 4 layers instead of OSI's 7 layers.
OSI Equivalent: Application + Presentation + Session
Protocols
HTTP, HTTPS, FTP, SMTP, DNS, DHCP, SSH, Telnet, SNMP
The Application Layer in TCP/IP combines the top 3 layers of OSI. It provides protocols that applications use for network communication.
Key Protocols:
// DNS Resolution Example
$ nslookup google.com
Server: dns.google
Address: 8.8.8.8
Name: google.com
Address: 142.250.190.14
// HTTP Request/Response
GET /api/users HTTP/1.1
Host: api.example.com
Authorization: Bearer token123
HTTP/1.1 200 OK
Content-Type: application/json
{"users": [{"id": 1, "name": "John"}]}
// Common Port Numbers
HTTP: 80 DNS: 53
HTTPS: 443 DHCP: 67/68
FTP: 21 SNMP: 161
SSH: 22 SMTP: 25OSI Equivalent: Transport
Protocols
TCP (Transmission Control Protocol), UDP (User Datagram Protocol)
The Transport Layer provides end-to-end communication services. The two main protocols are TCP (reliable) and UDP (fast).
TCP (Transmission Control Protocol):
UDP (User Datagram Protocol):
// TCP 3-Way Handshake
┌────────┐ ┌────────┐
│ Client │ │ Server │
└───┬────┘ └───┬────┘
│──── SYN (seq=100) ────────>│ Step 1
│ │
│<─ SYN-ACK (seq=300,ack=101)│ Step 2
│ │
│──── ACK (ack=301) ────────>│ Step 3
│ │
│ Connection Established │
// TCP 4-Way Termination
Client ──[FIN]──> Server // Step 1
Client <──[ACK]── Server // Step 2
Client <──[FIN]── Server // Step 3
Client ──[ACK]──> Server // Step 4
// TCP vs UDP Comparison
┌──────────────┬─────────────┬─────────────┐
│ Feature │ TCP │ UDP │
├──────────────┼─────────────┼─────────────┤
│ Connection │ Required │ Not needed │
│ Reliability │ Guaranteed │ Best effort │
│ Ordering │ Maintained │ No order │
│ Speed │ Slower │ Faster │
│ Header Size │ 20 bytes │ 8 bytes │
│ Use Case │ Web, Email │ Gaming, DNS │
└──────────────┴─────────────┴─────────────┘OSI Equivalent: Network
Protocols
IP, ICMP, ARP, RARP, IGMP
The Internet Layer handles logical addressing and routing of packets across networks.
Key Protocols:
IPv4 vs IPv6:
| Feature | IPv4 | IPv6 |
|---|---|---|
| Address Size | 32-bit | 128-bit |
| Format | Dotted decimal | Hexadecimal |
| Example | 192.168.1.1 | 2001:0db8::1 |
| Addresses | ~4.3 billion | 340 undecillion |
// IPv4 Address Classes
┌───────┬─────────────────┬─────────────────┬──────────┐
│ Class │ First Octet │ Default Mask │ Use │
├───────┼─────────────────┼─────────────────┼──────────┤
│ A │ 1-126 │ 255.0.0.0 │ Large │
│ B │ 128-191 │ 255.255.0.0 │ Medium │
│ C │ 192-223 │ 255.255.255.0 │ Small │
│ D │ 224-239 │ N/A │ Multicast│
│ E │ 240-255 │ N/A │ Reserved │
└───────┴─────────────────┴─────────────────┴──────────┘
// Private IP Ranges
Class A: 10.0.0.0 - 10.255.255.255
Class B: 172.16.0.0 - 172.31.255.255
Class C: 192.168.0.0 - 192.168.255.255
// ARP (Address Resolution Protocol)
Who has 192.168.1.1? Tell 192.168.1.100
192.168.1.1 is at AA:BB:CC:DD:EE:FF
// ICMP - Ping Example
$ ping 8.8.8.8
64 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=14.2msOSI Equivalent: Data Link + Physical
Protocols
Ethernet, Wi-Fi (802.11), PPP, ARP, RARP
The Network Access Layer (also called Link Layer) combines OSI's Physical and Data Link layers. It handles physical transmission and framing.
Key Functions:
Common Technologies:
// Ethernet Frame Structure
┌──────────┬─────────┬──────────┬─────────┬──────┬──────────┬─────┐
│ Preamble │ SFD │ Dest MAC │ Src MAC │ Type │ Data │ FCS │
│ 7 bytes │ 1 byte │ 6 bytes │ 6 bytes │ 2 │ 46-1500 │ 4 │
└──────────┴─────────┴──────────┴─────────┴──────┴──────────┴─────┘
// MAC Address Format
AA:BB:CC:DD:EE:FF (48-bit)
└──┬──┘ └───┬───┘
│ │
OUI Device ID
(Vendor) (Unique)
// CSMA/CD (Ethernet Collision Detection)
1. Listen to channel
2. If idle, transmit
3. If collision, stop and send jam signal
4. Wait random time (exponential backoff)
5. Retry transmission
// Wi-Fi Standards
┌──────────┬───────────┬─────────────┐
│ Standard │ Frequency │ Max Speed │
├──────────┼───────────┼─────────────┤
│ 802.11n │ 2.4/5 GHz │ 600 Mbps │
│ 802.11ac │ 5 GHz │ 3.5 Gbps │
│ 802.11ax │ 2.4/5/6GHz│ 9.6 Gbps │
└──────────┴───────────┴─────────────┘| Aspect | OSI Model | TCP/IP Model |
|---|---|---|
| Layers | 7 layers | 4 layers |
| Developed by | ISO | DARPA (US DoD) |
| Approach | Theoretical | Practical |
| Usage | Reference model | Internet standard |
| Reliability | Less reliable | More reliable |
Know the TCP 3-way handshake: SYN → SYN-ACK → ACK
Understand TCP vs UDP differences and use cases
Know common port numbers: HTTP(80), HTTPS(443), SSH(22), DNS(53)
Be ready to explain what happens when you type a URL in browser