Why Do We Use Protocol Layers?
Computer network architecture is extremely complex — there are too many different components, devices, and functions involved. The question is: how do we manage this complexity?
The solution is to organize network functions into layers.
A layer is a logical grouping of all the processes or functions required for effective data exchange. Each layer provides services to the layer above it through a well-defined interface.
Key Principles of Layering
- Layer N-1 provides services to Layer N through a well-defined interface (boundary).
- Each interface defines what information, operations, and services a layer must provide for the layer above it.
- Layers are distributed across all nodes in the network — not just at one device.
- Peer communication: Layer N on one machine communicates logically with Layer N on another machine.
Advantages of Layered Architecture
🧩 Simplicity
Breaks complex communication into simpler, smaller problems. Each layer handles one specific job. Easier to implement in hardware or software.
🔒 Independence
Each layer can be implemented independently of the others. Different manufacturers can supply hardware/software for different layers — encouraging collaboration and competition.
🔄 Flexibility
A layer's implementation can be changed completely without affecting other layers, as long as the interface stays the same.
🏭 Standardization
Well-defined interfaces allow interoperability between devices from different vendors and manufacturers worldwide.
The exam may ask: "What are the advantages of layered architecture?" Know all four advantages above. Also know that well-defined interfaces allow changing one layer's implementation without affecting others.
- Layers break complexity into manageable, simpler pieces
- Each layer serves the layer above via a defined interface
- Layers can be independently implemented and modified
- All nodes in a network use the same layered structure
- Two standard protocol stacks: OSI and TCP/IP
The OSI Model
The Open System Interconnect (OSI) model was developed by ISO (International Organization for Standardization) in the 1970s. It provides a framework for standardization.
An open system is a set of protocols that allows any two different systems to communicate, regardless of their underlying architecture.
🔍 What OSI Describes
Describes how data and network information moves from an application in one computer to an application in another computer.
📅 Historical Context
OSI dominated before 1990. After that, TCP/IP became dominant because it was already implemented in ARPANET (forerunner of the internet).
The 7 OSI Layers (Top → Bottom)
"All People Seem To Need Data Processing"
→ Application, Presentation, Session, Transport, Network, Data Link, Physical
For bottom-up: "Please Do Not Throw Sausage Pizza Away"
How OSI Protocols Are Implemented
💻
Software
Layers 7, 6, 5, 4
(Application through Transport)
🔀
Mixed
Layer 3
(Network layer)
🔌
Hardware
Layers 1 & 2
(Physical & Data Link in NIC)
Peer-to-Peer Communication
Peers are entities (processes, hardware devices) on two or more machines communicating at a given layer.
Each layer on the sending node communicates logically with its peer layer on the receiving node, using formatted blocks of data called Protocol Data Units (PDUs).
Important: The control information in each PDU is read and executed ONLY by the peer layer on the receiving node.
PDU = Data (payload) from the next higher layer + Control information of the current layer
Control information is placed in header fields (and a trailer for the Data Link layer only).
Physical layer devices: Network card (NIC), Hub, Repeater
Data Link layer device: Switch
Network layer device: Router
Note: "Some devices do not use all layers" — e.g., a hub only uses Physical layer. The more layers a device supports, the more complex it is.
- OSI = 7 layers developed by ISO in the 1970s, dominated before 1990
- PDU = payload + control info; only the peer layer reads control info
- Upper layers (4-7) = software; Layer 3 = mixed; Layers 1-2 = hardware (NIC)
- Mnemonic: "All People Seem To Need Data Processing"
Deep Dive: All 7 OSI Layers
🔌 Layer 1 — Physical Layer
The Physical layer is responsible for the movement of individual bits from one hop (node) to the next. It deals with the actual communication media.
What it defines:
- Physical characteristics of interfaces and transmission media
- Topology — how devices are connected to each other
- Connector specs — shape, size, number of pins (e.g., RJ-45)
- Voltages and currents used for signaling
- Transmission mode — duplex type (half/full)
- Representation of bits — encoding into Electrical or Optical signals
- Data Rate = transmission rate = bandwidth (bits per second)
- Synchronization of bits — sender and receiver clocks must match
The Physical layer is like the road and the trucks — it doesn't care what's in the truck (data), it just handles how the truck physically moves from A to B.
🔗 Layer 2 — Data Link Layer
The Data Link layer is responsible for moving frames from one hop (node) to the next (node-to-node delivery, also called hop-to-hop).
PDU Name: Frame
- Framing — divides the stream of bits into units called frames
- Physical Addressing — adds sender and receiver MAC addresses (also called local/hardware/NIC/LAN addresses) to the frame header
- Node-to-Node delivery — moves frames across DIRECT connections only (hop by hop)
Data Link Layer: Hop-to-hop delivery (node to adjacent node). Uses MAC address (physical). Changes at every hop.
Network Layer: End-to-end delivery (source all the way to destination). Uses IP address (logical). Stays the same throughout the journey.
🌐 Layer 3 — Network Layer
The Network layer is responsible for the delivery of individual packets from the source host to the destination host — across multiple networks.
PDU Name: Packet (or Datagram)
- Logical Addressing (IP Address) — unique global address identifying each host on the internet
- Routing — routers examine the packet's destination IP and forward it toward its final destination
- Source-to-Destination delivery across MULTIPLE networks (end-to-end)
Note: If two systems are on the same link, there is theoretically no need for a network layer.
🚚 Layer 4 — Transport Layer
The Transport layer is responsible for the delivery of a message from one process to another (process-to-process delivery). It ensures the entire message arrives intact and in order.
PDU Name: Segment
- Process Addressing — uses port numbers to identify which application/process to deliver data to
- Segmentation — breaks large messages into segments
- Whole message delivery — ensures all segments arrive and reassembles them in order
Network layer: Host-to-host delivery of individual packets. Each packet treated independently (no relationship between packets).
Transport layer: Process-to-process delivery of the entire message. Ensures all pieces arrive and are in the right order.
Think of it this way: Network layer delivers the letters (packets), Transport layer makes sure you received the whole book (message).
🤝 Layer 5 — Session Layer
Main job: Setting up, managing, and terminating sessions (connections) between different applications.
- Session separation — keeps different applications' data separate (e.g., multiple FTP downloads, multiple browser tabs)
- Dialog control — Full/Half duplex: processes either send and receive at the same time (full) or at different times (half)
- Synchronization checkpoints — allows long transmissions to resume from where they left off after a crash
🖥️ Layer 6 — Presentation Layer
Main job: Translation between data formats so different devices can communicate (interoperability).
- Translation — Sender format → Common format → Receiver format (e.g., EBCDIC to ASCII)
- Encryption / Decryption — securing data for transmission
- Compression — reducing the number of bits (especially for multimedia)
If you type "Cisco" on a Mainframe using EBCDIC encoding, it would show up as "¢¹½³?" on a PC using ASCII — the Presentation layer fixes this by converting formats.
📱 Layer 7 — Application Layer
Main job: Provides the user interface and network services that allow user applications to access the network.
- HTTP — Web browsing (Internet Browser)
- Telnet — Remote host access
- FTP — File transfer, access, and management
- SMTP — Mail services
PDU Name: Message
| Layer | Number | PDU Name | Address Used |
|---|---|---|---|
| Application / Presentation / Session | 7/6/5 | Message | — |
| Transport | 4 | Segment | Port Address |
| Network | 3 | Packet / Datagram | IP Address |
| Data Link | 2 | Frame | MAC Address (Physical) |
| Physical | 1 | Bits | — |
- Physical: raw bits, cables, voltages, encoding — PDU = Bits
- Data Link: hop-to-hop using MAC address — PDU = Frame
- Network: end-to-end using IP address — PDU = Packet
- Transport: process-to-process using Port — PDU = Segment
- Session: manages connections and dialog between apps
- Presentation: translates, encrypts, compresses data
- Application: user interface; HTTP, FTP, SMTP, Telnet
Data Encapsulation & Decapsulation
Encapsulation is the process where each layer adds its own control information (header, and in the case of Data Link, a trailer) to the data received from the layer above. The lower layer "wraps" the PDU from the upper layer without any knowledge of its content.
PDU = Data (payload from next higher layer) + Control information (headers/trailers of current layer)
Encapsulation at Each Layer (Sender Side — Top to Bottom)
DH = Data link Header | NH = Network Header | TH = Transport Header | SH = Session Header | PH = Presentation Header | AH = Application Header | DT = Data link Trailer
Note: Only the Data Link layer has BOTH a header AND a trailer (for error detection). All others only have headers.
Decapsulation (Receiver Side — Bottom to Top)
At the receiving node, the process is reversed. Each layer reads its own header/trailer, acts on the control information, and then strips it off before passing the remaining data up to the next layer above.
By the time the data reaches the Application layer, all headers/trailers have been removed, and only the original data remains.
Layer N-1 carries the PDU of Layer N without any knowledge of its content. This principle is called encapsulation. Control information is only read and acted upon by its peer layer at the receiving end.
- Encapsulation = each layer adds its own header (Data Link also adds a trailer)
- PDU = payload (from above layer) + header (current layer's control info)
- Only the Data Link layer has both a header AND a trailer
- Decapsulation = receiver strips headers layer by layer from bottom to top
- Control info is read only by the peer layer on the other machine
The TCP/IP Protocol Suite
TCP/IP is a suite of protocols developed in the 1970s. Named after the two most important protocols (TCP and IP), but includes many others (UDP, ICMP, ARP, etc.).
TCP/IP consists of 5 layers (in the version taught in this course).
TCP/IP Layers and PDUs
The three top layers in the OSI model (Application, Presentation, Session) are combined into a single Application layer in TCP/IP.
The bottom four layers correspond directly between both models.
The original TCP/IP model had only 4 layers (combining Data Link + Physical into "Network Access" or "Host-to-Network").
Key Protocols at Each TCP/IP Layer
| Layer | Key Protocols | Role |
|---|---|---|
| Application | HTTP, FTP, SMTP, DNS, SNMP, TELNET | User-facing services |
| Transport | TCP, UDP, SCTP | Process-to-process delivery |
| Network | IP, ICMP, IGMP, ARP, RARP | Host-to-host routing |
| Data Link | Defined by underlying networks (Ethernet, Wi-Fi, etc.) | Hop-to-hop delivery |
| Physical | Underlying LAN/WAN technology | Bit transmission |
- TCP/IP has 5 layers (or 4 in original version)
- OSI's top 3 layers = TCP/IP's single Application layer
- Transport layer protocols: TCP, UDP, SCTP
- Network layer uses IP + helping protocols (ICMP, ARP, etc.)
- Data Link + Physical use underlying LAN/WAN technology
OSI vs TCP/IP — Side by Side
| Feature | OSI Model | TCP/IP Model |
|---|---|---|
| Number of layers | 7 | 5 (or 4 in original) |
| Developed by | ISO (International Organization for Standardization) | ARPA / US Government |
| Developed in | 1970s | 1970s |
| Dominance period | Before 1990 | After 1990 (still dominant) |
| Upper layers | Application + Presentation + Session (3 layers) | Application (1 layer) |
| Primary use | Reference model / Framework | Actual implementation in the internet |
| Protocol at Layer 3 | No specific protocol defined | IP (and ARP, ICMP, etc.) |
| Transport protocols | No specific protocol defined | TCP, UDP, SCTP |
(Application)
(Presentation)
(Session)
Application
Layer
Layers 1–4 map directly: Physical→Physical, Data Link→Data Link, Network→Network, Transport→Transport.
OSI = Teaching model (great for understanding, less used in practice)
TCP/IP = Real-world model (what the internet actually runs on)
OSI is like a perfect textbook — TCP/IP is what actually shipped.
Types of Addresses in Networking
There are three types of addresses used in network communication, each at a different layer:
🔌 Physical Address
Layer: Data Link (Layer 2)
Also called: MAC address, hardware address, NIC address, LAN address
Scope: Local — changes at each hop
Example: 00:1A:2B:3C:4D:5E
🌐 IP Address
Layer: Network (Layer 3)
Also called: Logical address, Internet address
Scope: Global — unique per host on internet, stays same throughout journey
Example: 192.168.1.1
⚡ Port Address
Layer: Transport (Layer 4)
Also called: Port number
Scope: Identifies a specific process/application on a host
Example: HTTP=80, HTTPS=443, FTP=21
As a packet travels from source to destination through routers:
- IP address (source & destination) — NEVER changes during the journey (stays the same end-to-end)
- MAC address (physical) — CHANGES at every hop (each router creates a new frame with new MAC addresses for the next link)
- Port number — stays the same throughout
- Physical (MAC) address = Layer 2, local scope, changes each hop
- IP address = Layer 3, global scope, stays same entire trip
- Port address = Layer 4, identifies process/application
- TCP and UDP use port addresses; IP uses IP addresses; Ethernet uses MAC addresses
⚡ Quick Revision Cheat Sheet
OSI Layer PDUs
Addresses per Layer
Delivery Type
TCP/IP Protocols
Implementation
Devices per Layer
OSI vs TCP/IP
Key Mnemonics
- 7 Application: I am the door to the network for users (HTTP, FTP, email)
- 6 Presentation: I translate, encrypt, and compress data between systems
- 5 Session: I open, manage, and close sessions between applications
- 4 Transport: I make sure the whole message gets there, process to process (TCP/UDP)
- 3 Network: I find the best path and route packets using IP addresses
- 2 Data Link: I move frames hop by hop using MAC addresses
- 1 Physical: I convert everything to 0s and 1s and push them through the wire