🧱 Tutorial 6: The Internet Protocol Stack and the OSI Reference Model

Expanded Edition – COMP347 (Revision 10) | TrustOpen University

📑 Table of Contents

🎯 Learning Objectives

Upon completion of this expanded tutorial, students will be able to:

🔭 Overview

This tutorial provides a detailed examination of the Internet protocol stack (TCP/IP model) and the OSI reference model. While the previous tutorial introduced the basic concepts of layering, this tutorial delves into the specific protocols, functions, and interactions at each layer. We explore the header formats of key protocols (TCP, IP, Ethernet), the encapsulation process in depth, and the service models. We also compare the two models and discuss the hourglass architecture and the end‑to‑end principle. Understanding both models is essential for network professionals, as the Internet stack is what we use in practice, while the OSI model provides a valuable conceptual framework.


1. The Internet Protocol Stack (TCP/IP Model)

The Internet protocol stack, also known as the TCP/IP model, consists of five layers. We will examine each layer in depth, including its functions, key protocols, and header formats.

1.1 Application Layer

Purpose: Provides services to user applications and defines the protocols used for specific applications.

1.2 Transport Layer

Purpose: Provides end‑to‑end communication between processes on different hosts, with optional reliability.

1.3 Network Layer

Purpose: Moves packets from source to destination across multiple networks, providing addressing and routing.

1.4 Link Layer

Purpose: Moves frames from one node to the next on the same link, providing node‑to‑node delivery.

1.5 Physical Layer

Purpose: Transmits individual bits across the physical medium, handling the electrical, optical, or radio characteristics.


2. The OSI Reference Model

The OSI (Open Systems Interconnection) model, developed by ISO, is a seven‑layer conceptual framework that standardises network communication.

Layer Name Function Examples
7 Application Provides network services to user applications; application‑specific protocols. HTTP, FTP, SMTP, Telnet
6 Presentation Data formatting, translation, encryption, and compression. Converts data between application and network formats. JPEG, MPEG, TLS (partially), ASCII/EBCDIC conversion
5 Session Establishes, manages, and terminates sessions between applications. Provides dialog control (half‑duplex/full‑duplex) and synchronization (checkpoints). NetBIOS, RPC (partially), SIP (session control)
4 Transport End‑to‑end communication, segmentation, error recovery, flow control, multiplexing. TCP, UDP
3 Network Routing, addressing, forwarding of packets across multiple networks. IP, IPX, AppleTalk
2 Data Link Node‑to‑node delivery, framing, error detection, media access control (MAC). Ethernet, Wi‑Fi, PPP, HDLC
1 Physical Bit transmission, signal encoding, physical interface characteristics. Ethernet PHY, 802.11 PHY, RS‑232

The OSI model includes Presentation and Session layers, which in the Internet stack are handled by the Application layer (e.g., TLS for encryption, cookies or application‑level sessions).


3. Comparison: Internet Stack vs. OSI Model

Aspect Internet Stack (TCP/IP) OSI Model
Number of layers 5 7
Origin Practical, from ARPANET and DARPA Theoretical, from ISO
Adoption Widely implemented and used Primarily conceptual, not widely implemented
Presentation layer Functionality within Application layer Separate layer
Session layer Functionality within Application layer and TCP Separate layer
Connection model Supports both connectionless (UDP) and connection‑oriented (TCP) Connection‑oriented model
Protocol suite TCP/IP suite OSI protocols (rarely used; e.g., X.400, X.500)
Service model Best‑effort at network layer, reliable at transport (TCP) Variety of service models

4. Encapsulation and Decapsulation in Detail

Encapsulation is the process of adding headers (and sometimes trailers) as data passes down the layers. Decapsulation is the reverse process at the receiver.

Example: Sending an HTTP request

Application: "GET /index.html HTTP/1.1" (Message) ↓ Transport (TCP): Adds TCP header (source port, dest port=80, seq#, flags, checksum) → Segment ↓ Network (IP): Adds IP header (source IP, dest IP, TTL, protocol=6 for TCP) → Datagram ↓ Link (Ethernet): Adds Ethernet header (dest MAC, src MAC, type) and trailer (CRC) → Frame ↓ Physical: Bits transmitted

At the receiver, each layer strips its corresponding header and passes the payload up.


5. The Hourglass Model

The Internet architecture is often represented as an hourglass: the wide top is applications (HTTP, SMTP, etc.), the narrow waist is IP (the common protocol), and the wide bottom is the diverse link‑layer technologies (Ethernet, Wi‑Fi, fibre, etc.). This design allows many different applications to run over IP, and IP to run over many different link technologies, enabling interoperability and innovation.


6. The End‑to‑End Principle

The end‑to‑end principle (Saltzer, Reed, Clark, 1984) states that functions should be implemented at the communication endpoints whenever possible, rather than in the network core. The Internet follows this by keeping the core simple (best‑effort IP) and placing reliability, security, and other functions at the endpoints (TCP, TLS). This enables rapid innovation at the application layer without changing the core.


7. Service Access Points and Primitives


8. Protocol Header Examples

TCP Header (20 bytes minimum)

IPv4 Header (20 bytes minimum)

Ethernet Frame (minimum 64 bytes)


📝 Quiz: Tutorial 6

Q1: What are the five layers of the Internet protocol stack, in order from top to bottom?

Answer

Application, Transport, Network, Link, Physical.

Q2: What is the primary function of the transport layer?

Answer

End‑to‑end communication between processes, including segmentation, error control, flow control, and congestion control (in TCP).

Q3: Name three protocols at the application layer and their uses.

Answer

HTTP (web browsing), SMTP (email sending), DNS (domain name resolution). Other examples: FTP, SSH, DHCP.

Q4: What is the difference between TCP and UDP?

Answer

TCP is connection‑oriented, reliable, ordered, with flow and congestion control. UDP is connectionless, unreliable, and has no flow or congestion control.

Q5: What are the seven layers of the OSI reference model?

Answer

Application, Presentation, Session, Transport, Network, Data Link, Physical.

Q6: What is the purpose of the presentation layer in the OSI model?

Answer

Data formatting, translation, encryption/decryption, and compression/decompression.

Q7: How does the Internet stack handle the functions of the OSI presentation layer?

Answer

It handles them at the application layer, with protocols like TLS providing encryption and application‑specific formatting (e.g., JSON, XML).

Q8: What is the difference between routing and forwarding?

Answer

Routing is the process of determining the end‑to‑end path (using routing protocols). Forwarding is the per‑hop action of moving a packet from an input port to the appropriate output port at a router.

Q9: What is the purpose of the data link layer?

Answer

It moves frames from one node to the next on the same link, handling framing, error detection (CRC), and media access control (MAC).

Q10: Why is the Internet protocol stack sometimes called the TCP/IP model?

Answer

Because TCP (Transport) and IP (Network) are the two most important and defining protocols of the Internet stack.

Q11: What is the hourglass model of the Internet architecture?

Answer

It describes the Internet stack with IP at its narrow waist, allowing many applications above and many link technologies below, enabling interoperability and innovation.

Q12: What is the end‑to‑end principle and how does it relate to the Internet's architecture?

Answer

The end‑to‑end principle states that functions should be implemented at the endpoints whenever possible, not in the network core. The Internet follows this by keeping the core simple (best‑effort IP) and placing reliability (TCP) and security (TLS) at the endpoints.


✏️ Exercises: Tutorial 6

Exercise 1 – Layer identification

For each of the following functions, identify the corresponding layer in the Internet stack and the OSI model: (a) error detection using CRC, (b) routing, (c) encryption, (d) session establishment, (e) bit transmission.

Solution

(a) Link layer (Internet) / Data Link (OSI). (b) Network layer / Network. (c) Application layer (Internet) / Presentation (OSI). (d) Application layer (Internet) / Session (OSI). (e) Physical layer / Physical.

Exercise 2 – Encapsulation diagram

Draw a detailed encapsulation diagram for a DNS query (UDP) from a client to a DNS server. Show the headers at each layer and the resulting PDUs.

Solution
Application: DNS query (Message) ↓ Transport (UDP): UDP header (src port, dst port=53, length, checksum) → Datagram ↓ Network (IP): IP header (src IP, dst IP, protocol=17 for UDP) → Datagram ↓ Link (Ethernet): Ethernet header (dest MAC, src MAC, type) + trailer → Frame ↓ Physical: Bits

Exercise 3 – Compare models

Why does the Internet stack not have a separate presentation layer? What are the trade‑offs?

Solution

The Internet stack combines presentation functions into the application layer (e.g., TLS, JSON, XML). This simplifies the stack but puts more responsibility on applications. Trade‑off: less standardisation but more flexibility and efficiency.

Exercise 4 – Header fields

Explain the purpose of the following TCP header fields: Sequence Number, Acknowledgment Number, Flags, Window Size.

Solution

Sequence Number: orders bytes for reassembly and reliability. Acknowledgment Number: confirms received bytes. Flags: control connection (SYN, ACK, FIN, etc.). Window Size: flow control – tells sender how much data can be sent.

Exercise 5 – Service primitives

Map the TCP socket API calls (socket, bind, listen, accept, connect, send, recv, close) to the OSI service primitives (Request, Indication, Response, Confirm).

Solution

connect() → Request/Confirm; accept() → Indication/Response; send/recv → data transfer primitives; close() → Request/Confirm.

Exercise 6 – Hourglass model

Explain how the hourglass model enables the Internet to support new applications without changing the core.

Solution

Because IP provides a minimal, universal service, new applications can be built on top using TCP/UDP without modifying routers. For example, HTTP/3 uses QUIC over UDP, but IP remains unchanged.


📚 Homework: Tutorial 6

Homework 1 – OSI history

Research the history of the OSI reference model. Why was it developed? Why did TCP/IP succeed while OSI largely failed?

Guidance

OSI was comprehensive but complex and slow; TCP/IP was practical, had working implementations, and was incrementally deployable.

Homework 2 – IPv6 benefits

List the main differences between IPv4 and IPv6 headers. What are the benefits of IPv6?

Guidance

IPv6 has larger addresses (128-bit), simplified header (no checksum, no fragmentation), flow label, and built-in security (IPsec).

Homework 3 – MAC vs IP

Explain the relationship between MAC addresses and IP addresses. Which layers do they belong to and why are both needed?

Guidance

MAC addresses are link-layer (Layer 2) and used for local delivery; IP addresses are network-layer (Layer 3) and used for end‑to‑end routing.

Homework 4 – TLS and OSI

In which OSI layer does TLS (Transport Layer Security) operate? Justify your answer. How does this relate to the Internet stack?

Guidance

TLS operates between the application and transport layers, often considered part of the presentation or session layer in OSI; in the Internet stack it is an application-layer protocol.

Homework 5 – Microservices and layering

Explain how modern microservices architectures relate to the concept of protocol layering. Are they following the same principles?

Guidance

Microservices use lightweight protocols and APIs, similar to layering but at the application level; they emphasise modularity and independent deployability.


📌 Summary

This tutorial has provided a detailed examination of the Internet protocol stack and the OSI reference model:

Understanding both models is essential for network professionals. The Internet stack provides the practical implementation, while the OSI model offers a valuable conceptual framework. In the next tutorial, we will explore the World Wide Web and web technologies.