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.

published: reading time: 20 min read author: Geek Workbench updated: November 23, 2026
Quick Summary

OSI and TCP/IP offer different ways to describe where a network request may fail. This guide compares the models and follows HTTPS through DNS, routing, TCP, TLS, and HTTP, with examples such as timeouts, refused connections, and handshake errors. Use the checks to investigate one stage at a time, while treating the diagrams as guides rather than exact maps of every implementation.

OSI and TCP/IP Network Models

Introduction

When a request fails, the OSI and TCP/IP models give you a way to narrow the search. If DNS returns no address, changing the HTTP handler will not help; if TCP connects but TLS fails, the client has reached a later stage and the evidence points elsewhere.

This guide compares the two models, traces an HTTPS request through the stack, and uses resolver, route, socket, and TLS evidence to troubleshoot common failures. The models organize the investigation, while the actual protocol behavior tells you where to look next.

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:

  1. The application creates an HTTP request with a method, path, headers, and possibly a body.
  2. 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.
  3. TCP carries the encrypted byte stream between client and server ports. It handles sequencing, retransmission, and flow control.
  4. IP addresses the datagram and lets routers forward it between networks.
  5. 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.
  6. 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.

Follow one failing request

Suppose one request to https://api.example.com/orders returns HTTP 503. That response shows TCP and TLS completed, but the status alone does not tell you whether the proxy, load balancer, or origin created the error. The layer label organizes the checks; logs and measurements help identify the faulty component.

$ curl -sv --connect-timeout 5 https://api.example.com/orders -o /dev/null
< HTTP/2 503
< x-request-id: req-example

This is illustrative output. For the same destination, check each boundary from the affected client:

For these commands, select one IPv4 address from DNS in the same shell:

TARGET_IP="$(getent ahostsv4 api.example.com | awk 'NR == 1 { print $1 }')"
Boundary Next diagnostic test What the result tells you
Name resolution Run getent ahosts api.example.com on the failing client and compare the returned addresses with a working client or the service’s expected records. A missing or unexpected address points to resolver configuration or stale service records.
Link and routing Check ip -brief link, then run ip route get "$TARGET_IP". The interface state and selected route show whether the host has a path toward that address. Check the neighbor entry for the selected gateway if local delivery fails.
Transport Run nc -vz -w 3 "$TARGET_IP" 443 from the same client network. A timeout or refusal on this separate probe conflicts with the successful curl result. Check whether conditions changed, then inspect the listener, firewall rules, and return path before changing policy.
TLS Run openssl s_client -connect "$TARGET_IP:443" -servername api.example.com -verify_hostname api.example.com -verify_return_error -brief </dev/null. Check that the handshake completes and certificate verification succeeds for the requested hostname. Keep SNI set to that hostname.
HTTP Repeat the request with curl -sv and retain the request ID. Compare that ID with reverse-proxy and upstream logs, then inspect upstream health and the source of the 503. Since the request returned 503 after TLS, compare its request ID with proxy and origin logs to find which component returned it.

These probes make separate connections, so run them from the same network path and close to the time of the failure. If the affected client uses IPv6, set TARGET_IP to its resolved IPv6 address and bracket that address in the openssl -connect value. If an intermediate probe fails while the original request succeeds, compare the address family, destination IP, SNI, proxy settings, and timing before drawing a conclusion.

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

1. How do the OSI model and TCP/IP model differ?
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.
2. What happens to an HTTPS request as it travels through the stack?
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.
3. Why is the OSI model useful during debugging?
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.
4. Does a successful TCP connection prove an HTTPS request will succeed?
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.
5. Why is it misleading to assign every Internet protocol to exactly one OSI layer?
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.
6. What changes to a packet as a router forwards it to the next network?
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.
7. DNS returns the expected address, but a client times out connecting to the service. What would you check next?
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.
8. Why might a host packet capture show TCP segments larger than the interface MTU?
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.
9. Where does TLS fit in the OSI and TCP/IP models?
TLS usually protects application data above TCP in the deployed stack. Its encryption and data-formatting functions are often compared with OSI presentation-layer responsibilities, but TLS is not a formal OSI layer. Treat the comparison as a way to discuss responsibilities, not a strict protocol assignment.
10. What does a successful ping tell you when HTTPS is failing?
It shows that an ICMP echo exchange worked along that path at that moment. It does not prove that TCP port 443 is reachable, that TLS negotiation succeeds, or that the web application responds. Test each stage separately from the affected network.
11. How would you investigate a service that works from one subnet but times out from another?
Compare the selected routes and connection results from both subnets, then check firewalls, security groups, and network ACLs on the differing paths. Confirm the service listener and the return route as well; outbound reachability alone does not guarantee a working response path. Use flow or host logs to identify where packets stop.
12. A hostname resolves to both IPv4 and IPv6 addresses, but only some clients connect. What would you compare?
Compare which address family each client selects, then test the IPv4 and IPv6 paths separately from the affected networks. Check routes, firewall rules, listeners, and return paths for both families; a working IPv4 route does not prove IPv6 is configured correctly.
13. What changes when a router forwards a packet to another network?
The router processes the incoming link-layer frame, chooses a next hop from its routing table, and sends the IP packet in a new frame for the outgoing link. The link-layer addresses therefore change at each hop. The router also updates fields such as the IP hop limit or TTL; network address translation may change addresses when configured.
14. What is the practical difference between TCP and UDP?
TCP provides an ordered byte stream with connection setup, retransmission, and flow control. UDP sends datagrams without built-in delivery or ordering guarantees, so an application that needs those properties must provide them itself. Choose based on the protocol and its requirements, not on a layer diagram alone.
15. Does port 443 prove that a service is using HTTPS?
No. Port numbers are conventions, and services can run on nonstandard ports or use a familiar port for different traffic. Confirm the listener configuration and inspect the protocol negotiation or application response; the port number alone does not identify the service.
16. What does a successful TLS handshake tell you, and what does it not tell you?
It shows that the peers negotiated TLS parameters and, when certificate validation succeeds, the client accepted the server identity for that connection. It does not prove that the application request is authorized or will succeed. Check the HTTP response and application logs separately.
17. Where does DNS fit in the OSI and TCP/IP models?
DNS is usually treated as an application-layer protocol because it provides a service to applications. Queries commonly use UDP and can use TCP, so the transport carrying a DNS message is a separate concern. The models help describe those roles but do not make DNS resolution part of the HTTP request itself.
18. How does a connection refusal differ from a connection timeout?
A refusal usually means the client received a reset or other immediate rejection, often because no service is listening or a control actively rejected the connection. A timeout means no usable response arrived before the deadline. Neither result identifies the cause on its own; compare listener state, firewall and flow logs, and the return path.
19. Why can a packet capture show different packet sizes at different points?
Segmentation, retransmission, tunnels, network translation, and NIC offload can all affect what a capture point sees. A host capture may show a large buffer before the NIC segments it, while a capture after a router sees a different link-layer frame. Record where the capture was taken before comparing it with another trace.
20. What precautions should you take before collecting or sharing a packet capture?
Get approval, filter to the hosts and time window needed, and use the smallest capture scope that can answer the question. Payloads may contain credentials, personal data, or unencrypted content. Restrict access, store the file safely, redact sensitive material before sharing, and delete it under the approved retention policy.

Further Reading

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.

#networking #encapsulation #tcp-ip

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.

#networking #troubleshooting #tcpdump

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.

#networking #web #troubleshooting