Internet Basics & History

The TCP/IP Model and the OSI Model, Explained Side by Side

Compare the four TCP/IP layers with the seven OSI layers, see where protocols fit and use either model to troubleshoot.

Key takeaways

  • Layered models split networking into separate jobs so that each can be designed, replaced and diagnosed on its own.
  • OSI has seven layers and TCP/IP has four; the transport layers match closely, while TCP/IP merges several of the others.
  • The internet runs on TCP/IP protocols, but OSI layer numbers remain the common shorthand.
  • Real technologies don't always fit neatly, so treat the models as maps rather than laws.

The TCP/IP model describes networking in four layers (link, internet, transport and application) and reflects how the internet is actually built. The OSI model describes it in seven layers (physical, data link, network, transport, session, presentation and application) and is the vocabulary people use to talk about networks, including phrases such as "a layer 2 switch" or "a layer 7 firewall."

You don't have to choose between them. They slice the same job at slightly different points, and once you can translate one into the other, documentation, certification material and vendor jargon become much easier to follow.

Why layer a network at all

Sending a message between two programs involves very different problems: producing electrical or radio signals, sharing a local cable or channel, finding a route across many networks, recovering lost data and making sense of the content. A layered design assigns each problem to its own level.

Each layer offers a service to the layer above and uses the service of the layer below. A web browser doesn't care whether you're on fiber or Wi-Fi. A Wi-Fi radio doesn't care whether it's carrying a video or an email. That independence is what allowed new physical links and new applications to appear without redesigning everything in between, an idea introduced in what a protocol is.

The TCP/IP model: four layers

The internet's own architecture is summarized in RFC 1122, which names four layers.

  1. Link. Everything needed to move data across one directly connected network: Ethernet, Wi-Fi, and the local addressing that goes with them.
  2. Internet. The Internet Protocol, IPv4 or IPv6, plus helpers such as ICMP. It gets packets across multiple networks.
  3. Transport. TCP and UDP, which connect programs to each other using port numbers.
  4. Application. Everything the programs say to one another: HTTP, DNS, SMTP, SSH and many more.

Some textbooks present five layers by splitting the link layer into physical and data link. That is a teaching convenience, and you'll see both versions.

The OSI model: seven layers

The Open Systems Interconnection reference model was published by the International Organization for Standardization in the 1980s, and the matching ITU-T recommendation is X.200. It was meant to guide a complete family of protocols.

No. OSI layer What it covers
7 Application Services that programs use directly
6 Presentation Data representation, encoding, translation
5 Session Setting up and managing dialogs
4 Transport End-to-end delivery between programs
3 Network Addressing and routing across networks
2 Data link Frames and local addresses on one link
1 Physical Signals, cables, radio, connectors

Numbering starts at the bottom. Mnemonics help some learners, but it is more useful to remember the progression: signals, local delivery, global delivery, program-to-program delivery, then three levels concerned with the conversation and its content.

Mapping one onto the other

OSI layers and their TCP/IP counterparts
TCP/IP Application Transport Internet Link OSI equivalent Layers 5, 6 and 7 Layer 4 Layer 3 Layers 1 and 2 Examples HTTP, DNS, SMTP, SSH TCP, UDP IPv4, IPv6, ICMP Ethernet, Wi-Fi TCP/IP Application Transport Internet Link OSI equivalent Layers 5, 6 and 7 Layer 4 Layer 3 Layers 1 and 2 Examples HTTP, DNS, SMTP, SSH TCP, UDP IPv4, IPv6, ICMP Ethernet, Wi-Fi

The transport layers line up well, and so does OSI's network layer with TCP/IP's internet layer. The differences are at the ends.

At the top, TCP/IP leaves session and presentation matters to each application. A web application manages its own login sessions, and character encoding or compression is handled by the application protocol and the software using it. At the bottom, TCP/IP says comparatively little about physical media, because it was designed to run over whatever network was available.

Where familiar things land

Using OSI numbers, which is the habit in industry:

  • Layer 1: copper and fiber cables, radio transmission, plugs, repeaters.
  • Layer 2: Ethernet frames, MAC addresses, ordinary switches, VLAN tags.
  • Layer 3: IP addresses, routers, subnets.
  • Layer 4: TCP, UDP, port numbers.
  • Layer 7: HTTP, DNS, mail protocols, and devices that make decisions based on their content.

A layer 3 switch is one that can also route between networks. A layer 4 load balancer spreads connections using addresses and ports, while a layer 7 load balancer can read the requested URL or headers and choose accordingly. MAC addresses vs. IP addresses explains the boundary between layers 2 and 3 in more depth.

Encapsulation: following one message down

Say your browser sends a request. On the way out, each layer adds its own information.

Encapsulating one web request
1 Application The browser composes an HTTP request, usually protected by TLS. 2 Transport TCP splits the bytes into segments and adds port numbers. 3 Internet IP adds source and destination addresses, making a packet. 4 Link Ethernet or Wi-Fi wraps it in a frame with local addresses. 5 Signals The frame leaves as electrical, light or radio signals. Application The browser composes an HTTP request, usually protected by TLS. 1 Transport TCP splits the bytes into segments and adds port numbers. 2 Internet IP adds source and destination addresses, making a packet. 3 Link Ethernet or Wi-Fi wraps it in a frame with local addresses. 4 Signals The frame leaves as electrical, light or radio signals. 5

The names change with the layer: segment for TCP (and datagram for UDP), packet for IP, frame at the link. At each router along the way, the link frame is removed and a new one is built for the next hop, while the IP packet inside continues toward its destination. Address translation at a home router also rewrites some addresses and ports, a reminder that real networks bend the ideal picture. See how packets travel across the internet.

Things that don't fit neatly

Several important technologies straddle the lines.

  • TLS sits above TCP and below HTTP. People variously call it layer 4.5, 5, 6 or simply part of the application layer.
  • ARP, which finds the MAC address for a local IPv4 address, works between layers 2 and 3.
  • QUIC provides transport features while running on top of UDP and building in encryption.
  • Tunnels and VPNs put packets inside other packets, so a layer can appear more than once in one stack.

Arguing about the correct number rarely helps. Ask instead what information a device or protocol reads and what service it provides.

Why TCP/IP won but OSI stayed

In the 1980s many governments and companies expected OSI protocols to take over. TCP/IP, however, already worked, was freely documented and shipped with widely used versions of Unix. By the 1990s it was clearly the practical choice, a contest recounted in how TCP/IP won the protocol wars.

Most OSI protocols faded, but the seven-layer reference model survived because it is a precise teaching and discussion tool. It gives engineers from different backgrounds a shared set of labels.

Reading the layers in a real capture

Packet analyzers such as Wireshark make the models visible. Select one captured web request on your own computer and the details pane shows nested sections, each corresponding to a header added during encapsulation.

Frame            what was captured, with its length and time
Ethernet II      source and destination MAC addresses
Internet Protocol  source and destination IP addresses, TTL
Transmission Control Protocol  ports, sequence numbers, flags
Transport Layer Security    encrypted application data

Reading from top to bottom walks you up the stack. You'll notice that Wireshark doesn't label anything "session" or "presentation," because it names actual protocols. You'll also notice that encryption hides the HTTP request inside the TLS section: the lower layers remain readable, since routers need addresses to forward packets, while the content does not.

Capture only on networks and devices you own or are authorized to examine, since traffic can contain other people's information. Packet capture with Wireshark for beginners covers filters and safe habits.

Worked examples with layer numbers

It helps to practice assigning symptoms and devices to layers.

  • "The link light is off." Layer 1. Check the cable, the port and the power.
  • "I'm connected, but I got a 169.254 address." The link works, but your device didn't receive an address from DHCP, so you can't communicate properly at layer 3.
  • "I can ping an IP address but not a name." Layers 1 to 3 are fine. Name resolution, an application-layer service, is failing.
  • "The connection is refused." You reached the machine, but nothing is listening on that port, or something rejected it, which points to layer 4.
  • "The browser shows a 500 error." Everything below worked well enough to deliver an answer. The problem is in the server's application.
  • "The switch has a duplicate MAC address warning." Layer 2, on the local network.

Each statement narrows the search. That is the practical payoff of the vocabulary: two people can agree in a sentence which half of the problem has already been ruled out.

Troubleshooting by layer

Layers give you an order of attack. Starting at the bottom avoids debugging an application when a cable is loose.

  1. Physical: check power, cables and link lights, or the Wi-Fi signal.
  2. Data link: confirm you've joined the right network and authenticated.
  3. Network: check your IP address with ipconfig (Windows), ip addr (Linux) or ifconfig (macOS), then ping your router.
  4. Transport: see whether the needed port accepts a connection. In Windows PowerShell:
Test-NetConnection example.com -Port 443

On macOS or Linux, nc -vz example.com 443 does a similar check where netcat is installed.

  1. Application: check name resolution, certificates and the server's response.

A top-down approach also works when only one application fails: if everything else on the machine is fine, the lower layers are probably healthy. Either way, change one thing at a time and note what you saw.

Common questions

Which model should a beginner learn first?

Learn the four TCP/IP layers to understand how the internet behaves, then memorize OSI's numbers for layers 1, 2, 3, 4 and 7. Those five come up constantly in product descriptions and job conversations.

Is a router always a layer 3 device?

Routing is a layer 3 function. A home "router" also acts as a switch, a Wi-Fi access point, a firewall and an address translator, so the single box works at several layers at once.

What is the "layer 8" joke?

It's informal humor for problems caused by people or organizations rather than technology. It isn't part of either model.

Written for 4Internet with AI writing tools and not reviewed line by line by a person. Check anything you rely on with the maker, provider or standard concerned. Report an error.

Keep reading

All 45 articles in Internet Basics & History →

Latest news on this topic