CS331 — Data Communications & Networking

Protocol Layering,
OSI & TCP/IP Models

A comprehensive study guide covering protocol layers, OSI model, TCP/IP suite, encapsulation, and all seven layers in depth.

01

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.

📘 Definition — Layer

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

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.

🎯 Exam Focus

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.

📌 Section Summary
  • 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
02

The OSI Model

📘 Definition — 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)

7
Application — User-facing network services (HTTP, FTP, SMTP)
Message
6
Presentation — Translation, encryption, compression
Message
5
Session — Setup, management, termination of sessions
Message
4
Transport — Process-to-process reliable delivery
Segment
3
Network — Source-to-destination routing across multiple networks
Packet
2
Data Link — Node-to-node (hop-to-hop) delivery
Frame
1
Physical — Transmission of raw bits over physical medium
Bits
🧠 Memory Trick — Remember All 7 Layers

"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.

📘 Definition — PDU (Protocol Data Unit)

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).

🎯 Exam Focus — Devices at Each Layer

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.

📌 Section Summary
  • 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"
03

Deep Dive: All 7 OSI Layers

🔌 Layer 1 — Physical Layer

📘 Definition

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
💡 Quick Analogy

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

📘 Definition

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)
⚠️ Common Confusion — Data Link vs Network

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

📘 Definition

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

📘 Definition

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
⚠️ Common Confusion — Network vs Transport

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)
💡 Real Example

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

🎯 Exam Focus — PDU Names at Each Layer
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
📌 Section Summary
  • 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
04

Data Encapsulation & Decapsulation

📘 Definition — Data Encapsulation

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)

Application
AH
Data
Presentation
PH
AH
Data
Session
SH
PH
AH
Data
Transport
TH
SH
PH
AH
Data
Network
NH
TH
SH
PH
AH
Data
Data Link
DH
NH
TH
SH
PH
AH
Data
DT
Physical
DH
NH
TH
SH
PH
AH
Data
DT
🧠 Key Insight — Header Colors Explained

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.

🎯 Exam Focus

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.

📌 Section Summary
  • 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
05

The TCP/IP Protocol Suite

📘 Definition

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

5
Application Layer — SMTP, FTP, HTTP, DNS, SNMP, TELNET …
Message
4
Transport Layer — TCP, UDP, SCTP
Segment
3
Network Layer — IP, ICMP, IGMP, ARP, RARP
Packet
2
Data Link Layer — Protocols defined by underlying networks
Frame
1
Physical Layer — LAN and WAN technology
Bits
🎯 Exam Focus — Key Difference from OSI

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
📌 Section Summary
  • 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
06

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
⚠️ Common Confusion — Mapping Between Models
OSI Layer 7
(Application)
OSI Layer 6
(Presentation)
OSI Layer 5
(Session)
TCP/IP
Application
Layer

Layers 1–4 map directly: Physical→Physical, Data Link→Data Link, Network→Network, Transport→Transport.

🧠 Quick Comparison Summary

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.

07

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

🎯 Exam Focus — Address Changes During Routing

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
📌 Section Summary
  • 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
08

⚡ Quick Revision Cheat Sheet

OSI Layer PDUs

Application (7)Message
Presentation (6)Message
Session (5)Message
Transport (4)Segment
Network (3)Packet
Data Link (2)Frame
Physical (1)Bits

Addresses per Layer

Transport (4)Port #
Network (3)IP Address
Data Link (2)MAC Address
Physical (1)None

Delivery Type

TransportProcess→Process
NetworkHost→Host
Data LinkNode→Node
PhysicalBit→Bit

TCP/IP Protocols

ApplicationHTTP, FTP, SMTP
TransportTCP, UDP, SCTP
NetworkIP, ICMP, ARP

Implementation

Layers 7,6,5,4Software
Layer 3Mixed
Layers 2,1Hardware (NIC)

Devices per Layer

Physical (1)Hub, Repeater
Data Link (2)Switch
Network (3)Router

OSI vs TCP/IP

OSI layers7
TCP/IP layers5 (or 4)
OSI developed1970s by ISO
OSI dominatedPre-1990

Key Mnemonics

Top→Bottom: "All People Seem To Need Data Processing"
Bottom→Top: "Please Do Not Throw Sausage Pizza Away"
🧠 The Big Picture — One Sentence per Layer
  • 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
09

🧪 Practice Questions

Q1Which OSI layer is responsible for translating, encrypting, and compressing data?
Correct: C. The Presentation Layer handles translation (e.g., EBCDIC to ASCII), encryption/decryption, and compression. Think of it as the "translator" of the OSI model.
Q2What is the PDU name at the Transport layer?
Correct: C. The Transport layer PDU is called a Segment. Remember: Physical=Bits, Data Link=Frame, Network=Packet, Transport=Segment, Upper layers=Message.
Q3Which layer is responsible for node-to-node (hop-to-hop) delivery using MAC addresses?
Correct: B. The Data Link Layer performs hop-to-hop delivery between directly connected nodes using MAC (physical) addresses. The Network layer does end-to-end delivery using IP addresses.
Q4In TCP/IP, the three top OSI layers (Application, Presentation, Session) are combined into which single layer?
Correct: A. In TCP/IP, the Application layer combines the functionality of OSI's Application, Presentation, and Session layers into one. TCP/IP's Application layer uses protocols like HTTP, FTP, SMTP, DNS.
Q5Which of the following is an advantage of layered network architecture?
Correct: C. Well-defined interfaces between layers allow changing the implementation of one layer with a completely different implementation without affecting the other layers. This is a core advantage of layered architecture.
Q6Which OSI layer ONLY has a header — and which layer has BOTH a header AND a trailer?
Correct: B. The Data Link layer is the only layer with BOTH a header (DH) and a trailer (DT). The trailer is used for error detection (e.g., CRC checksum). All other layers only add headers.
Q7The OSI model was developed by which organization, and in which decade?
Correct: C. The OSI model was developed by ISO (International Organization for Standardization) in the 1970s. It dominated before 1990, after which TCP/IP became the dominant model due to the rise of the internet.
Q8Which type of address changes at every hop as a packet travels from source to destination?
Correct: B. The MAC (physical) address changes at every hop because each router creates a new Data Link frame with the MAC addresses of the next link. The IP address (source and destination) remains unchanged throughout the entire journey.