Networking

TCP/IP Model Explained: 4 Layers, Protocols and Examples

The TCP/IP model describes how data moves across a network in four layers: link, internet, transport and application. Each layer has its own protocols and hands data to the layer next to it, so Ethernet or Wi-Fi sits at the link layer, IP at the internet layer, TCP and UDP at the transport layer, and HTTP or DNS at the application layer.

The four layers come from RFC 1122, the standard that lists what every internet host must implement. It calls the whole set "the Internet protocol suite" and says a host "typically must implement at least one protocol from each layer". The name TCP/IP comes from the two best-known protocols in that suite, TCP and IP.

The four layers at a glance

Layer (top to bottom)What it doesExample protocolsUnit of data
ApplicationThe protocol an application speaks to its peer on another hostHTTP, DNS, SMTP, SSHMessage or stream
TransportEnd-to-end communication between programs, identified by port numbersTCP, UDPSegment (TCP) or datagram (UDP)
InternetAddressing hosts and carrying datagrams from source host to destination host across networksIP (IPv4, IPv6), ICMPPacket or datagram
LinkDelivery on the directly connected networkEthernet, Wi-Fi, ARPFrame

The unit names are common usage rather than strict definitions, and people often say "packet" for all of them. The layer names and their order are what the RFC defines.

What each layer does

Link layer

RFC 1122 says that to communicate on its directly connected network, a host must implement the protocol used to interface to that network, and it calls this "a link layer or media-access layer protocol". In practice that is your Ethernet or Wi-Fi connection. Devices on the same link are identified by MAC addresses. The link layer only cares about the next hop, not the final destination.

Internet layer

This layer is where IP lives. RFC 791 says the Internet Protocol "implements two basic functions: addressing and fragmentation". It calls on local network protocols to carry the datagram to the next gateway or destination host, and it is called on by host-to-host protocols above it. Routers work at this layer: they read the destination address and pass the datagram along.

RFC 1122 is blunt about what IP does not do. It is "a connectionless or datagram internetwork service, providing no end-to-end delivery guarantees", so IP datagrams "may arrive at the destination host damaged, duplicated, out of order, or not at all". Anything better has to come from a higher layer. Whether an address is routable on the open internet is a separate question, covered in public vs private IP addresses.

Transport layer

RFC 1122 says the transport layer "provides end-to-end communication services for applications". Two protocols dominate:

  • TCP is a reliable, connection-oriented service. RFC 9293 states that it "provides a reliable, in-order, byte-stream service to applications". It sets up a connection with a three-way handshake (SYN, then SYN and ACK, then ACK) before data flows.
  • UDP is a connectionless datagram service. It sends independent messages and does not retransmit them.

Both identify the sending and receiving program with port numbers. In TCP, the source and destination port fields are each 16 bits wide, so a port is a number from 0 to 65,535 (216 minus 1). Choosing between the two is a trade-off between guarantees and overhead: see TCP vs UDP.

Application layer

RFC 1122 describes this as the top layer of the suite, and says it "essentially combines the functions of the top two layers", presentation and application, of the OSI reference model. Everything an application does with the network in its own words belongs here: HTTP requests, email delivery with SMTP, remote shells with SSH, and name lookups with DNS. "Application layer" means the protocol, not the program. Your browser is not the layer, but the HTTP it sends is.

How data moves down and up the layers

When a program sends data, each layer wraps it with its own header before passing it down. This wrapping is called encapsulation. RFC 9293 describes the transport step directly: "TCP segments are sent as internet datagrams", and "a TCP header follows the IP headers". For a web request the nesting looks like this:

[ link header | IP header | TCP header | HTTP request ]

The sender builds it from the inside out: the application produces the HTTP request, TCP adds its header, IP adds its header, and the link layer adds a frame header for the next hop. The receiver reverses the process, removing one header per layer until the application gets the original request. Routers along the way unwrap only as far as the internet layer, read the IP header, then wrap the datagram in a new link-layer frame for the next hop.

Seeing the layers in a real connection

Running curl -v https://example.com shows several layers at work. This is example output, abridged, and addresses and details will differ on your machine:

* Host example.com:443 was resolved.
*   Trying 192.0.2.10:443...
* Connected to example.com (192.0.2.10) port 443
> GET / HTTP/1.1
< HTTP/1.1 200 OK
  1. Application: "was resolved" is a DNS lookup that turned the name into an IP address.
  2. Internet and transport: "Connected to ... port 443" means a TCP connection to an IP address and a port. The address is the internet layer's job, and the port and the connection belong to TCP.
  3. Link: not visible in curl. Your network adapter put each datagram into an Ethernet or Wi-Fi frame addressed to your router.
  4. Application: GET / HTTP/1.1 is the request and HTTP/1.1 200 OK is the reply.

Troubleshooting with the layers

Because each layer depends on the one below it, test from the bottom up and stop at the first failure:

LayerQuestionQuick check
LinkIs the cable or Wi-Fi connected?Adapter status, link lights
InternetCan I reach the router and then a remote address?ping the gateway, then ping 1.1.1.1 (see the ping command guide)
Application (DNS)Do names resolve?nslookup example.com
TransportDoes the port accept connections?Test-NetConnection example.com -Port 443 in PowerShell
ApplicationDoes the service answer correctly?curl -v https://example.com

If pinging an IP address works but pinging a name fails, the network path is fine and name resolution is the problem.

Limits of the model

RFC 1122 itself warns that "strict layering is an imperfect model, both for the protocol suite and for recommended implementation approaches". Real protocols cross the lines. ARP, for example, maps IP addresses to link-layer addresses and is placed at the link layer in the table above, though some texts put it between link and internet. TLS sits between the transport connection and the application data and has no layer of its own in the four-layer model. Treat the layers as a way to locate a problem or a protocol, not as a rule every protocol obeys.

Frequently asked questions

How many layers does the TCP/IP model have?
Four in the standard that defines it: RFC 1122 describes an application layer, a transport layer, an internet layer and a link layer. Some textbooks split the link layer into separate physical and data link layers and teach five. The protocols are the same either way; only the way the bottom is drawn differs.
What is the difference between the TCP/IP model and the OSI model?
The TCP/IP model describes the protocols the internet actually uses and has four layers. The OSI model is a separate seven-layer reference model. RFC 1122 says the TCP/IP application layer essentially combines the top two OSI layers, presentation and application. People use OSI layer numbers (layer 2 switch, layer 7 load balancer) as vocabulary for TCP/IP equipment.
Is IP part of TCP or separate from it?
Separate. IP belongs to the internet layer and only moves datagrams from one host to another without guarantees. TCP belongs to the transport layer above it and adds reliability. Every TCP segment is carried inside an IP datagram, which is why the suite is named after both.
Where do HTTP, DNS and TLS fit in the TCP/IP model?
HTTP and DNS are application layer protocols. TLS has no separate layer in the four-layer model: it runs on top of a transport connection and below the application data it protects, so it is usually grouped with the application layer in TCP/IP diagrams.

Sources