CS 241: Computer Networks › Lesson 1 of 10

Network Models: OSI & TCP/IP

Lesson 1 · OKSTEM College · AS Computer Science

Why Layered Models?

Networks are enormously complex. Layered models tame this complexity by dividing responsibilities into independent layers. Each layer provides services to the layer above and uses services from the layer below — without needing to know how those services are implemented.

Key benefit: You can swap out a layer's implementation (e.g., switch from Wi-Fi to Ethernet) without changing layers above or below.

The OSI Model (7 Layers)

#LayerUnitKey protocols / examples
7ApplicationMessageHTTP, FTP, DNS, SMTP
6PresentationMessageTLS/SSL encryption, JPEG compression
5SessionMessageSession management, RPC
4TransportSegmentTCP, UDP
3NetworkPacketIP, ICMP, routing
2Data LinkFrameEthernet, Wi-Fi (802.11), ARP
1PhysicalBitCables, fiber, radio waves, voltage levels

Mnemonic (top to bottom): All People Seem To Need Data Processing

The TCP/IP Model (4 Layers)

The practical Internet model collapses OSI layers 5–7 into one:

TCP/IP LayerMaps to OSIExamples
Application7, 6, 5HTTP, DNS, SMTP, SSH
Transport4TCP, UDP
Internet3IPv4, IPv6, ICMP
Link (Network Access)2, 1Ethernet, Wi-Fi, PPP

Worked Example — HTTP Request Journey

Application: Browser constructs an HTTP GET request: GET /index.html HTTP/1.1 Host: example.com
Transport: TCP adds source port (e.g., 51234) and destination port (80). Sequence numbers added for reliability. → Segment.
Internet: IP adds source IP (your machine) and destination IP (93.184.216.34). → Packet.
Link: Ethernet adds source MAC and destination MAC (gateway router). → Frame with FCS checksum.
Physical: Frame converted to bits → electrical/optical/radio signal transmitted on medium.
At each router: Physical→Link→Network (routing decision) → Link→Physical. TCP/Application layers not involved in transit.
Destination server reverses the process: bits → frame → packet → segment → HTTP request.

Encapsulation & Decapsulation

As data travels down the sending stack, each layer encapsulates the data by wrapping it with a header (and sometimes a trailer). Going up the receiving stack, each layer decapsulates by removing its header.

Example: HTTP body → [TCP hdr | HTTP body] → [IP hdr | TCP hdr | HTTP body] → [ETH hdr | IP hdr | TCP hdr | HTTP body | ETH trailer]

Practice Problems

Problem 1 — Layer Identification

A packet arrives at a router. The router examines the destination IP address and forwards it toward the destination. Which OSI layer is the router primarily operating at?

Layer 3 (Network). Routers examine IP addresses (Layer 3) to make forwarding decisions. Switches operate at Layer 2 (MAC addresses). Hubs operate at Layer 1 (bits).

Problem 2 — Protocol Matching

Match each protocol to its OSI layer: HTTPS, TCP, IPv6, Ethernet, 802.11 Wi-Fi.

HTTPS → Layer 7 (Application) + Layer 6 (Presentation/TLS). TCP → Layer 4 (Transport). IPv6 → Layer 3 (Network). Ethernet → Layer 2 (Data Link). 802.11 Wi-Fi → Layers 1–2 (Physical + Data Link).

🌐 Encapsulation Visualizer

Knowledge Check

Which OSI layer is responsible for end-to-end reliable delivery between processes?

Data Link provides hop-to-hop (node-to-node) delivery within one network segment.
Network layer provides host-to-host delivery across multiple networks, but not process-to-process reliability.
Correct — TCP (Transport layer) provides reliable, ordered delivery between processes via ports.
Applications use the Transport layer's services; they don't implement reliability themselves.
📖 Quick Recap

Data Link (Layer 2) handles delivery between directly connected nodes using MAC addresses. End-to-end process delivery is Transport (Layer 4).

📖 Quick Recap

IP (Layer 3) routes packets between hosts but is best-effort — no reliability guarantee. TCP (Layer 4) adds reliability and port-based process addressing.

📖 Quick Recap

Application layer protocols like HTTP rely on TCP for reliability. The Application layer itself doesn't manage retransmissions or ordering.

Encapsulation in networking means:

Encryption is done at the Presentation/TLS layer, not a general definition of encapsulation.
Correct — each layer adds its protocol information around the payload from the layer above.
Compression is a Presentation-layer function, not the definition of encapsulation.
That is IP fragmentation, a specific Network-layer function.
📖 Quick Recap

Encapsulation = wrapping data with headers at each layer. Encryption is one specific transformation done by TLS, not the general concept of encapsulation.

📖 Quick Recap

Compression reduces size; encapsulation adds headers. They are different operations, though both can occur.

📖 Quick Recap

Fragmentation divides oversized packets. Encapsulation adds headers to whatever size data is passed down from above.

A switch operates at which OSI layer?

A hub operates at Layer 1 (broadcasts bits). A switch is smarter.
Correct — switches forward frames based on MAC address tables.
A router operates at Layer 3. Switches do not read IP addresses.
Layer 4 devices are application firewalls and load balancers, not standard switches.
📖 Quick Recap

Hubs broadcast every bit to all ports (Layer 1). Switches read MAC addresses (Layer 2) to forward frames only to the correct port.

📖 Quick Recap

Routers examine IP addresses (Layer 3). Switches use MAC address tables (Layer 2). Layer-3 switches exist but are essentially routers.

📖 Quick Recap

Standard switches operate at Layer 2. Layer-4 load balancers inspect TCP/UDP ports but are specialized devices.

In the TCP/IP model, which layer corresponds to OSI layers 5, 6, AND 7?

TCP/IP Transport = OSI Layer 4 only.
TCP/IP Internet = OSI Layer 3 only.
Correct — TCP/IP Application encompasses OSI Session (5), Presentation (6), and Application (7).
TCP/IP Link = OSI Layers 1–2 (Physical + Data Link).
📖 Quick Recap

TCP/IP Transport covers OSI Layer 4 (TCP, UDP). OSI Layers 5–7 are all collapsed into TCP/IP's Application layer.

📖 Quick Recap

TCP/IP Internet covers OSI Layer 3 (IP, ICMP, routing). Layers 5–7 collapse into TCP/IP Application.

📖 Quick Recap

TCP/IP Link layer combines OSI Physical (1) and Data Link (2). Application combines OSI 5, 6, 7.

The purpose of a port number in TCP/UDP is to:

MAC addresses identify interfaces. Port numbers identify processes.
IP addresses identify hosts. Port numbers identify services on a host.
Correct — ports enable multiple services to share one IP address.
QoS/DSCP fields in IP headers handle priority, not port numbers (though firewalls may use ports for policy).
📖 Quick Recap

MAC addresses are used at Layer 2 to identify network interfaces. Port numbers at Layer 4 identify which process/service on a host should receive a packet.

📖 Quick Recap

IP addresses route packets to the correct machine. Port numbers then direct the packet to the correct process (e.g., port 80 = HTTP, port 443 = HTTPS).

📖 Quick Recap

Port numbers are addresses for processes (HTTP=80, SSH=22). Packet priority uses DSCP bits in the IP header.

Next →