Computer Science · College · BCA, BTech & MCA
Computer Networks: OSI 7-Layer Model & TCP/IP Protocol Suite
Master computer networking fundamentals: The 7 Layers of the OSI reference model, Protocol Data Units (PDUs), TCP vs UDP transport protocols, and 3-Way Handshake mechanics.
1The OSI 7-Layer Reference Model & Data Encapsulation
Computer Networks: OSI 7-Layer Model & TCP/IP Protocol Suite
Master computer networking fundamentals: The 7 Layers of the OSI reference model, Protocol Data Units (PDUs), TCP vs UDP transport protocols, and 3-Way Handshake mechanics.
- 1Subject — Computer Science
- 2Target Audience — BCA, BTech & MCA Students
- 3Topic Core — 7 Layers, Packet Encapsulation & Transport Protocols
TheOSI (Open Systems Interconnection)reference model, created by ISO, standardizes telecommunications and networking protocols intoseven modular abstraction layers. As data descends from the sender application, each layer appends its own control header in a process calledData Encapsulation.
OSI 7 Layers Master Summary Table
| Layer # & Name | Protocol Data Unit (PDU) | Primary Responsibilities | Representative Protocols / Hardware |
|---|---|---|---|
| Layer 7: Application | Data | Network access interface for software applications, authentication, UI endpoints | HTTP, HTTPS, FTP, SMTP, DNS, SSH |
| Layer 6: Presentation | Data | Syntax translation, ASCII/Unicode character encoding, data compression, and SSL/TLS encryption | TLS 1.3, JPEG, MPEG, MIME, gzip |
| Layer 5: Session | Data | Establishes, maintains, synchronizes, and terminates interactive communication sessions | RPC, NetBIOS, PPTP, Sockets APIs |
| Layer 4: Transport | Segment (TCP) / Datagram (UDP) | End-to-end process-to-process delivery, port multiplexing, segmentation, flow and congestion control | TCP, UDP, SCTP (Ports 0–65535) |
| Layer 3: Network | Packet | Logical addressing (IP addresses) and path determination (packet routing across heterogeneous networks) | IPv4, IPv6, ICMP, OSPF, BGP (Routers) |
| Layer 2: Data Link | Frame | Hop-to-hop node transfer, physical MAC addressing, media access control, error detection (CRC) | Ethernet (802.3), Wi-Fi (802.11), ARP, Switches |
| Layer 1: Physical | Bits (0s & 1s) | Raw bitstream transmission over physical media (voltages, radio frequencies, optical pulses) | Cables (Cat6, Fiber), Hubs, Modems |
Layer 7: Application
- Protocol Data Unit (PDU)
- Data
- Primary Responsibilities
- Network access interface for software applications, authentication, UI endpoints
- Representative Protocols / Hardware
- HTTP, HTTPS, FTP, SMTP, DNS, SSH
Layer 6: Presentation
- Protocol Data Unit (PDU)
- Data
- Primary Responsibilities
- Syntax translation, ASCII/Unicode character encoding, data compression, and SSL/TLS encryption
- Representative Protocols / Hardware
- TLS 1.3, JPEG, MPEG, MIME, gzip
Layer 5: Session
- Protocol Data Unit (PDU)
- Data
- Primary Responsibilities
- Establishes, maintains, synchronizes, and terminates interactive communication sessions
- Representative Protocols / Hardware
- RPC, NetBIOS, PPTP, Sockets APIs
Layer 4: Transport
- Protocol Data Unit (PDU)
- Segment (TCP) / Datagram (UDP)
- Primary Responsibilities
- End-to-end process-to-process delivery, port multiplexing, segmentation, flow and congestion control
- Representative Protocols / Hardware
- TCP, UDP, SCTP (Ports 0–65535)
Layer 3: Network
- Protocol Data Unit (PDU)
- Packet
- Primary Responsibilities
- Logical addressing (IP addresses) and path determination (packet routing across heterogeneous networks)
- Representative Protocols / Hardware
- IPv4, IPv6, ICMP, OSPF, BGP (Routers)
Layer 2: Data Link
- Protocol Data Unit (PDU)
- Frame
- Primary Responsibilities
- Hop-to-hop node transfer, physical MAC addressing, media access control, error detection (CRC)
- Representative Protocols / Hardware
- Ethernet (802.3), Wi-Fi (802.11), ARP, Switches
Layer 1: Physical
- Protocol Data Unit (PDU)
- Bits (0s & 1s)
- Primary Responsibilities
- Raw bitstream transmission over physical media (voltages, radio frequencies, optical pulses)
- Representative Protocols / Hardware
- Cables (Cat6, Fiber), Hubs, Modems
2Transport Layer Protocols: TCP vs UDP & The 3-Way Handshake
At the Transport Layer, applications select between two foundational protocols based on whether they prioritize reliability or speed:
- TCP (Transmission Control Protocol)isconnection-oriented, ensuring in-order, error-checked, guaranteed packet delivery.
- UDP (User Datagram Protocol)isconnectionless and lightweight, transmitting datagrams with minimal latency and zero handshaking overhead.
Architectural Comparison: TCP vs UDP
| Characteristic | TCP (Transmission Control Protocol) | UDP (User Datagram Protocol) |
|---|---|---|
| Connection Status | Connection-oriented (requires 3-Way Handshake prior to transmission) | Connectionless (transmits datagrams immediately without handshake) |
| Reliability | Guaranteed delivery via sequence numbers and ACKs; retransmits lost packets | Best-effort delivery; lost packets are permanently dropped with no retransmission |
| Ordering | Guaranteed in-order delivery; reorders out-of-sequence packets at destination | No ordering guarantees; packets arrive in arbitrary sequence |
| Flow & Congestion Control | Yes — dynamic Sliding Window flow control and congestion avoidance (AIMD) | None — sender transmits at application speed regardless of network saturation |
| Header Size | 20 to 60 bytes (includes sequence/acknowledgment numbers, flags, options) | Fixed 8 bytes (source port, dest port, length, checksum) |
| Use Cases | Web (HTTP/HTTPS), Email (SMTP), File Transfer (FTP), Shell (SSH) | Live video streaming, VoIP calls, DNS queries, Online multiplayer gaming |
Connection Status
- TCP (Transmission Control Protocol)
- Connection-oriented (requires 3-Way Handshake prior to transmission)
- UDP (User Datagram Protocol)
- Connectionless (transmits datagrams immediately without handshake)
Reliability
- TCP (Transmission Control Protocol)
- Guaranteed delivery via sequence numbers and ACKs; retransmits lost packets
- UDP (User Datagram Protocol)
- Best-effort delivery; lost packets are permanently dropped with no retransmission
Ordering
- TCP (Transmission Control Protocol)
- Guaranteed in-order delivery; reorders out-of-sequence packets at destination
- UDP (User Datagram Protocol)
- No ordering guarantees; packets arrive in arbitrary sequence
Flow & Congestion Control
- TCP (Transmission Control Protocol)
- Yes — dynamic Sliding Window flow control and congestion avoidance (AIMD)
- UDP (User Datagram Protocol)
- None — sender transmits at application speed regardless of network saturation
Header Size
- TCP (Transmission Control Protocol)
- 20 to 60 bytes (includes sequence/acknowledgment numbers, flags, options)
- UDP (User Datagram Protocol)
- Fixed 8 bytes (source port, dest port, length, checksum)
Use Cases
- TCP (Transmission Control Protocol)
- Web (HTTP/HTTPS), Email (SMTP), File Transfer (FTP), Shell (SSH)
- UDP (User Datagram Protocol)
- Live video streaming, VoIP calls, DNS queries, Online multiplayer gaming
TCP 3-Way Handshake Connection Establishment
- 1
Step 1: SYN (Synchronize)
Client sends SYN packet with an initial sequence number (ISN = x) to server
- 2
Step 2: SYN-ACK (Synchronize-Acknowledge)
Server allocates buffers and replies with SYN flag, its own ISN = y, and ACK = x + 1
- 3
Step 3: ACK (Acknowledge)
Client acknowledges server with ACK = y + 1; connection enters ESTABLISHED state
3OSI vs TCP/IP Protocol Model Mapping
While the OSI model is an ideal 7-layer theoretical framework, the real-world Internet operates on the pragmaticTCP/IP 4-Layer Model(or 5-layer hybrid model) created by DARPA.
OSI 7-Layer to TCP/IP 4-Layer Architectural Mapping
| OSI 7 Layers | TCP/IP 4-Layer Model | Protocols at this Layer |
|---|---|---|
| Application (7), Presentation (6), Session (5) | Application Layer | HTTP, HTTPS, SSH, DNS, SMTP, FTP |
| Transport (4) | Transport / Host-to-Host Layer | TCP, UDP |
| Network (3) | Internet Layer | IPv4, IPv6, ICMP, ARP |
| Data Link (2), Physical (1) | Network Access / Link Layer | Ethernet, Wi-Fi, Fiber Optic, DSL |
Application (7), Presentation (6), Session (5)
- TCP/IP 4-Layer Model
- Application Layer
- Protocols at this Layer
- HTTP, HTTPS, SSH, DNS, SMTP, FTP
Transport (4)
- TCP/IP 4-Layer Model
- Transport / Host-to-Host Layer
- Protocols at this Layer
- TCP, UDP
Network (3)
- TCP/IP 4-Layer Model
- Internet Layer
- Protocols at this Layer
- IPv4, IPv6, ICMP, ARP
Data Link (2), Physical (1)
- TCP/IP 4-Layer Model
- Network Access / Link Layer
- Protocols at this Layer
- Ethernet, Wi-Fi, Fiber Optic, DSL
Remember
- The OSI model has 7 layers: Physical (bits), Data Link (frames), Network (packets), Transport (segments), Session, Presentation, Application.
- Data encapsulation prepends headers at each descending layer on the sender, and decapsulates on the receiver.
- TCP guarantees reliable, ordered byte streams via a 3-Way Handshake (SYN, SYN-ACK, ACK) and sliding-window flow control.
- UDP trades reliability for speed with an 8-byte header, making it optimal for DNS, streaming, and gaming.
Check yourself
Question 1
Which OSI layer is responsible for translating data between different character encodings (e.g. EBCDIC to ASCII) and handling data encryption (TLS/SSL)?Question 2
What is the minimum header size of a standard TCP segment compared to a UDP datagram?