Sub topic 3
Layer 7: Application, Protocols That Applications Speak
Assume you know what an IP address, web server, router, and terminal are. This chapter focuses on how applications use network protocols and how the OSI layers help locate faults.
Layer 7: Application Protocols
The OSI application layer is the boundary where network services meet user applications. It does not mean the browser or email program itself. It means the protocols those programs use.
Examples include:
- HTTP and HTTPS for web requests
- DNS for mapping names to IP addresses
- SMTP for sending email
- SSH for secure remote login
An application-layer protocol defines messages, fields, and expected replies. For example, an HTTP client can send a GET request, and a server can return a status such as 200 OK.
import socket
request = b"GET / HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\n\r\n"
with socket.create_connection(("example.com", 80), timeout=5) as connection:
connection.sendall(request)
response = connection.recv(200)
print(response.decode("ascii", errors="replace").splitlines()[0])This example uses TCP to transport an HTTP message. HTTP is Layer 7; TCP is Layer 4. The operating system handles the lower layers.
Data Units and Devices
A protocol data unit, or PDU, is the name for data at a particular layer.
| Layer | Typical PDU | Example device or protocol |
|---|---|---|
| 7, Application | Message | HTTP, DNS |
| 4, Transport | Segment or datagram | TCP, UDP |
| 3, Network | Packet | IP router |
| 2, Data Link | Frame | Ethernet switch |
| 1, Physical | Bits | Cable or radio |
A switch mainly forwards frames using MAC addresses. A router forwards packets using IP addresses. The same transmitted information can therefore have several names as headers are added and removed.
OSI Versus TCP/IP
The practical TCP/IP model combines the OSI session and presentation layers with the application layer. It usually has four layers:
- Application: OSI Layers 5–7
- Transport: OSI Layer 4
- Internet: OSI Layer 3
- Network access: OSI Layers 1–2
OSI is useful for vocabulary and diagnosis. TCP/IP more closely describes the protocol family used on the internet.
Using Layers to Troubleshoot
Test from the bottom upward. The first failed test narrows the search.
ip link show # Interface and Layer 2 state
ip addr show # IP configuration
ping -c 4 example.com # IP reachability
nc -zv example.com 443 # TCP port access
curl -I https://example.com # TLS and HTTP behaviorA successful ping does not prove that HTTPS works. It tests a different protocol and layer.
Exercise
DNS works, ping succeeds, but curl to HTTPS fails. Which layers should you investigate first?
Show answer
Check Layer 4 for access to TCP port 443, then the TLS and HTTP behavior at the application boundary. The lower IP path is probably working.