OSI and TCP/IP Network Models
Compare the OSI and TCP/IP models, trace an HTTPS request through their layers, and use the models to narrow network failures without confusing abstractions.
The OSI model organizes network functions into seven reference layers; TCP/IP describes the deployed Internet suite with a different grouping. This guide compares their boundaries, follows an HTTPS request from DNS through local-link delivery, and explains why real protocols rarely map one-to-one. It then gives a diagnostic sequence for routes, TCP, TLS, and HTTP, with failure examples and observability checks to help narrow an incident using evidence.
OSI and TCP/IP Network Models
Introduction
The OSI and TCP/IP models give teams a shared way to describe where network behavior belongs. They help narrow failures by layer, but OSI is a reference model while TCP/IP describes a deployed protocol suite; their layers do not map one-to-one in every implementation.
This guide compares the models, maps their responsibilities, and follows an HTTPS request across them. It also shows how to use the models to choose the next diagnostic check without treating a layer label as proof of root cause.
The seven OSI layers
The OSI model runs from the user’s data down to the physical medium, then back up at the destination:
| Layer | Name | What it describes | Familiar examples |
|---|---|---|---|
| 7 | Application | Network services used by applications | HTTP, DNS, SMTP |
| 6 | Presentation | Data representation, encoding, and transformations | Character encoding, serialization, encryption concepts |
| 5 | Session | Establishing and managing communication sessions | Session control concepts in application protocols |
| 4 | Transport | Process-to-process delivery, ports, reliability, and flow control | TCP, UDP |
| 3 | Network | Addressing and forwarding between networks | IP, routers |
| 2 | Data Link | Delivery on a local link and frame addressing | Ethernet, Wi-Fi link layer, switches |
| 1 | Physical | Signals and the medium carrying bits | Copper, fiber, radio |
Layers 5 and 6 are useful ways to discuss functions, but most Internet protocols do not appear as distinct protocol layers matching those boxes. For example, TLS handles encryption above TCP, but people sometimes describe its functions using OSI presentation-layer language. That is a conceptual comparison, not a claim that TLS is formally an OSI layer-6 protocol.
The Internet protocol suite
Many courses teach TCP/IP as a four-layer model:
| TCP/IP layer | Role | Examples |
|---|---|---|
| Application | Application protocols and their data formats | HTTP, DNS, SSH, SMTP |
| Transport | Communication between processes on hosts | TCP, UDP |
| Internet | Addressing and forwarding across interconnected networks | IPv4, IPv6, ICMP |
| Link | Communication over the local network technology | Ethernet, Wi-Fi |
Some diagrams split the Link layer into Data Link and Physical, producing a five-layer teaching model. Names and boundaries vary by textbook. The four-layer version groups the local-link and signaling functions together because Internet protocols can run over different link technologies.
How the models map
This is a useful approximate mapping:
| OSI | TCP/IP | Relationship |
|---|---|---|
| Application, Presentation, Session | Application | TCP/IP groups application protocols and functions that OSI discusses across three layers. |
| Transport | Transport | Both describe host-to-host process communication, though protocol details vary. |
| Network | Internet | Both cover logical addressing and forwarding between networks. |
| Data Link, Physical | Link | TCP/IP groups local delivery and the medium beneath it. |
The models answer slightly different questions. OSI is a reference model for discussing responsibilities. TCP/IP is a protocol suite with deployed protocols and a practical layering convention. A protocol may span functions that a reference model separates, and implementations do not always follow textbook boundaries neatly.
Trace an HTTPS request
Suppose a browser fetches https://api.example.com/orders. The operating system first needs an address for the hostname, commonly by using DNS. After resolving it, the client selects a route and sends traffic toward the server. A typical HTTP/1.1 or HTTP/2 connection then uses TLS over TCP.
Conceptually, the client builds the outgoing data like this:
- The application creates an HTTP request with a method, path, headers, and possibly a body.
- TLS encrypts the HTTP data and adds TLS record framing. This function is often compared with OSI presentation concerns, while still being part of the practical application-over-transport stack.
- TCP carries the encrypted byte stream between client and server ports. It handles sequencing, retransmission, and flow control.
- IP addresses the datagram and lets routers forward it between networks.
- Ethernet or Wi-Fi carries a frame across the current local link. At each routed hop, the link-layer frame is replaced for the next link; the end-to-end IP packet continues toward its destination, subject to routing and network translation.
- The receiving host processes the data in reverse, until its application can handle the HTTP request.
flowchart TD
A[HTTP request: application data] --> B[TLS records: encrypted application bytes]
B --> C[TCP segment: source and destination ports]
C --> D[IP datagram: source and destination addresses]
D --> E[Ethernet or Wi-Fi frame: local link delivery]
E --> F[Physical signals: bits on the medium]
F --> G[Router forwards IP datagram on the next link]
G --> H[Server receives and unwraps data]
This is a simplified picture. Segmentation, retransmission, fragmentation, tunnels, proxies, and offload features can change what a packet capture shows. The diagram explains responsibilities rather than promising one neat object per layer at every point in a real system.
When to Use
Use the models to describe where a symptom appears, to plan a troubleshooting sequence, or to explain how protocols depend on one another. For example, if DNS resolution fails, investigate the resolver path before debugging the HTTP handler. If TCP connects but the client receives an HTTP 503, the network path carried the request far enough for an application-level response.
When NOT to Use
Do not use the models as a rigid classification test. Real protocols can cross the boundaries in a diagram, and a single failure can involve several layers. Do not infer the cause from an OSI layer number alone. Gather evidence from the actual stack: resolver output, routes, socket state, packet captures, TLS logs, and application responses.
A practical diagnostic sequence
Replace api.example.com with the affected service. These Linux commands check name resolution, the selected route, an HTTPS attempt, and visible TCP sessions:
getent ahostsv4 api.example.com
ip route get 203.0.113.25
curl -sv --connect-timeout 5 https://api.example.com/ -o /dev/null
ss -tnp dst :443
203.0.113.25 is a documentation address, so substitute a real resolved address before running the route check. curl -v can reveal whether the client reached DNS, connected to TCP, negotiated TLS, and received an HTTP status. Redact authorization headers, cookies, and tokens before sharing verbose output. To inspect packets, capture only the required host and port with an approved packet-capture tool; payloads may contain sensitive metadata or unencrypted data.
Interpret results in sequence. No DNS answer points toward resolver configuration or DNS reachability. A missing route points toward local routing or interface configuration. A TCP timeout may come from filtering, a broken return path, or an unavailable destination; a refusal usually means a reachable host rejected the connection or nothing accepted that port. A completed TLS handshake followed by an HTTP error moves attention toward the proxy or application. See network ports and firewalls for listener binding and firewall checks.
Production Failure Scenarios
DNS works on a laptop but fails in a container. The container may use a different resolver, search domain, or network policy. Compare resolver configuration and lookup results from the affected runtime, then monitor DNS errors separately from application failures.
TCP connects, but the HTTPS request hangs. The server may stop responding during TLS negotiation or after receiving the request. Compare client and server timestamps, inspect TLS and proxy logs, and capture handshake metadata where policy permits. Set connection and response timeouts so callers do not wait forever.
A service is reachable from one subnet but not another. Routes, security groups, network ACLs, or host firewall rules may differ. Check the effective path in both directions and validate from the failing source network. Avoid opening broad rules before identifying the boundary dropping traffic.
A deployment sends traffic to the wrong instance. Stale DNS records, an incorrect service-discovery entry, or a proxy pool can direct clients to an old address. Compare the resolved address with the intended deployment and attach instance identity to health and access logs.
A packet capture looks different from the textbook diagram. TCP segmentation offload and receive coalescing can make host captures show large segments that never appeared that way on the wire. Capture at another point or account for NIC offload before treating the capture as proof of malformed traffic.
Trade-Off Table
| Approach | Useful for | Cost or limitation |
|---|---|---|
| OSI seven-layer model | Precise discussion of responsibilities and teaching fundamentals | Can encourage false precision when real protocols cross boundaries |
| TCP/IP four-layer model | Relating common Internet protocols to deployed stacks | Groups several link functions and leaves fewer named boundaries |
| Five-layer teaching model | Separating local frame delivery from physical signaling | A teaching convention; not a separate deployed protocol suite |
| Layer-by-layer diagnosis | Keeping an incident investigation organized | Can become slow if teams check layers mechanically without following evidence |
Pick the model that makes the current conversation clearer, then name the concrete protocol or component under investigation.
Observability Checklist
- Record DNS lookup latency, failure rate, and resolver identity.
- Track connection attempts, TCP timeouts, refusals, retransmissions, and established socket counts.
- Measure TLS handshake failures separately from HTTP status codes and application latency.
- Include source, destination, protocol, port, and request or trace identifiers where safe.
- Correlate load balancer, firewall flow, host, proxy, and application logs by timestamp.
- Keep a known-good probe from each important network boundary; a probe from one subnet does not prove reachability from another.
- Set packet-capture scope and retention according to the incident need and data-handling policy.
Security and Compliance Notes
Encryption does not hide every network detail. IP addresses, ports, timing, packet sizes, and often DNS queries can remain visible to network observers, depending on the protocol and configuration. Use TLS for application data in transit, verify certificates, and avoid downgrading security to make a connection succeed.
Packet captures and verbose client traces may expose personal data, tokens, hostnames, or request metadata. Limit collection to the hosts and duration required, restrict access, redact secrets before attaching logs to tickets, and follow retention and regulatory requirements. Network segmentation and least-privilege firewall policy still matter when application traffic is encrypted.
Common Pitfalls / Anti-Patterns
- Treating the OSI and TCP/IP diagrams as exact translations instead of overlapping models.
- Calling every problem above Ethernet an “application-layer” issue, or blaming a single layer based on one symptom.
- Assuming that a successful ping proves an HTTPS service is reachable. ICMP handling and TCP port reachability are separate checks.
- Assuming a TCP connection proves TLS or HTTP works. Each handshake and response adds another boundary to inspect.
- Treating a port number as a protocol guarantee. Services can use nonstandard ports, and firewall rules do not identify application semantics.
- Forgetting that routing is bidirectional: a working outbound route does not guarantee a return path.
Quick Recap Checklist
- State whether you are using the OSI reference model or the TCP/IP model.
- Remember that OSI layers map approximately to TCP/IP layers, not one-to-one.
- Trace the request through DNS, route selection, transport, TLS, and application handling.
- Check both the outbound path and the return path.
- Use logs and measurements to confirm a layer hypothesis before changing production rules.
Interview Questions
OSI is a seven-layer reference model that separates communication responsibilities. TCP/IP is both the name commonly used for the Internet protocol suite and a four-layer model for describing it. The TCP/IP application layer groups functions represented by OSI's application, presentation, and session layers, while its link layer groups OSI data-link and physical concerns. The mapping is approximate.
The client creates HTTP data, protects it with TLS, and sends the resulting byte stream over TCP. IP carries datagrams between networks, while the local link technology carries frames to the next hop. The server processes the data in reverse. DNS resolution and route selection happen before or as the connection is established.
It gives teams a way to divide a broad failure into checks such as name resolution, routing, transport connectivity, TLS, and application behavior. The model structures an investigation; it does not identify the root cause by itself. Use measurements and logs to choose the next check.
No. TCP only establishes a transport connection. TLS negotiation can still fail, and the application can return an error or fail to respond. Check each stage and record its result separately.
Expected answer points:
- OSI is a reference model for responsibilities; deployed protocols do not always follow its boundaries.
- TCP/IP groups functions differently, and protocols such as TLS span concerns often associated with multiple OSI layers.
- Use the model to organize discussion, then name the protocol or component involved.
Expected answer points:
- The router removes the incoming link-layer frame and forwards the IP datagram according to its routing table.
- It sends the datagram in a new link-layer frame for the next hop.
- The end-to-end IP packet continues across the path, though routing or network translation can modify relevant fields.
Expected answer points:
- Check the selected route and test TCP reachability from the affected client network.
- Verify that the service is listening on the expected address and port.
- Inspect host and network firewall rules, security groups, and the return path before changing policy.
- Compare results from a working network boundary to isolate where behavior differs.
Expected answer points:
- TCP segmentation offload can let the host stack pass a large buffer to the NIC for segmentation.
- Receive coalescing can combine segments before the capture point sees them.
- Check capture location and NIC offload settings before treating the host capture as an on-wire packet trace.
Further Reading
- Network ports and firewalls explains listeners, routes, and firewall boundaries in deployment troubleshooting.
- TCP, IP, and UDP explains the protocols that sit within the layered models.
- Packet capture and network troubleshooting applies packet-level evidence to incident diagnosis.
- Network observability covers metrics, logs, traces, and flow records for following a request.
- RFC 1122: Requirements for Internet Hosts: Communication Layers documents requirements for the Internet host communication layers.
- RFC 9293: Transmission Control Protocol (TCP) specifies modern TCP behavior.
- RFC 8200: Internet Protocol, Version 6 (IPv6) Specification specifies IPv6.
Conclusion
OSI gives networking a seven-layer vocabulary; TCP/IP groups the protocols and functions used by the Internet into a practical stack. Their layers overlap without matching perfectly. For troubleshooting, trace the request from name resolution and routing through transport, TLS, and the application, then use observed evidence to narrow the fault. The diagrams help organize the work, but the protocol and component logs explain what actually happened.
Category
Related Posts
Network Encapsulation: Follow a Packet Across the Stack
Follow an HTTPS request from a browser through transport, IP, and link layers, and learn how headers, MTU, routers, and packet captures fit together.
Packet Capture and Network Troubleshooting: Layered Workflow
Use a layered workflow to diagnose DNS, route, TCP, TLS, and HTTP failures with ping, curl, tcpdump, and Wireshark, then collect useful incident evidence.
Trace and Secure a Web Request
Trace a web request from DNS through routing, TCP, TLS, and HTTP with safe commands, then classify failures and review least-privilege security evidence.