Computer Networks Advanced

TCP/IP Model Layers

Two computers that have never met must exchange data across a chain of networks, some wired, some wireless, some owned by companies neither computer knows. Each network uses its own hardware, its own signalling, and its own addressing rules. A single design problem follows: how can software on one machine reliably reach software on another machine when everything in between is different? The TCP/IP model answers this by splitting communication into a small stack of layers, each responsible for one part of the job and each relying on the layer beneath it. This article introduces that stack, explains what each layer is responsible for, and shows how the layers are arranged around the Internet Protocol (IP), the protocol that lets data cross from one network to another.

The Four-Layer Structure

A protocol is a set of agreed rules that two parties follow to exchange data. A layer is a group of protocols that solve one related problem. The TCP/IP model organises its protocols into four layers, stacked from the hardware up to the software that users see. Each layer provides a service to the layer above it and uses the service of the layer below it, without needing to know how that lower service is implemented.

The four layers are the network access layer, the internet layer, the transport layer, and the application layer. The internet layer is the centre of the design: IP sits there, and most of the other layers are shaped by what IP does and does not guarantee.

spec: static diagram of a vertical stack of four horizontal bands, drawn top to bottom: "Application layer", "Transport layer", "Internet layer", "Network access layer". Beside each band on the right, list example protocols: Application layer: HTTP, DNS, SMTP; Transport layer: TCP, UDP; Internet layer: IP, ICMP; Network access layer: Ethernet, Wi-Fi. Beside each band on the left, give the unit of data it handles: Application layer: messages; Transport layer: segments (TCP) or datagrams (UDP); Internet layer: packets; Network access layer: frames. Draw the Internet layer band in a darker colour and label it "IP is the common thread". Title: TCP/IP model layers.

The four-layer model is a practical simplification. Its network access layer covers the hardware and link concerns that a more detailed model separates into physical and data link layers. That split is treated elsewhere, so here the bottom layer is treated as one unit responsible for moving data across a single link.

Network Access Layer

The network access layer handles communication over one physical link, meaning a single hop between two directly connected devices such as a computer and its switch, or a laptop and a Wi-Fi access point. Its job is to take an IP packet and deliver it to the next device on the same local network, and to hand incoming frames back up to the internet layer.

To do this, the layer wraps each packet in a frame, which adds a header carrying local hardware addresses and a trailer used for error checking. It also decides how bits are represented on the medium and how a receiver knows where a frame begins and ends. The TCP/IP model deliberately places no requirements on this layer beyond its single-hop job. This is why the same IP traffic can run over Ethernet cable, fibre, or radio without any change to the layers above.

The detailed mechanisms of framing, error detection, and local addressing are covered in the child articles on the data link layer. What matters here is the boundary: the network access layer is only ever concerned with the link in front of it, and it has no knowledge of the final destination of the data.

Internet Layer and the Role of IP

The internet layer solves the problem that the network access layer cannot: moving data from a source host to a destination host that may be several networks away. It does this with the Internet Protocol. An IP address is a numeric label assigned to a host's network interface, and it identifies where that interface is located within the overall network. An IP packet (also called a datagram) carries a source IP address, a destination IP address, and the data for the layer above.

Each router on the path examines the destination address in the packet's header and forwards the packet toward the destination, a process called routing. Routers do not care which application created the data or whether it arrived intact. IP offers a best-effort service: it attempts delivery but does not guarantee that packets arrive, arrive in order, or arrive only once. Those guarantees, when needed, are added by the transport layer.

The internet layer also includes ICMP (Internet Control Message Protocol), which carries diagnostic and error messages between hosts and routers. The routing methods that build the forwarding tables routers use, and the address structure that makes routing scale, are covered in the network layer articles.

Because every host and router on the Internet speaks IP, the internet layer is the layer that unifies heterogeneous networks. Everything below it can change, and everything above it can assume that a packet addressed to an IP address has a chance of reaching it.

spec: static diagram showing two end hosts and one router in a row from left to right. Left host labelled "Host A (source)" and right host labelled "Host B (destination)" each show all four layers stacked: Application, Transport, Internet, Network access. The middle router labelled "Router" shows only the Internet and Network access layers. Between Host A and the router, and between the router and Host B, draw a link labelled with a different frame header on each side, labelled "link 1 frame" and "link 2 frame". Across the whole path, draw a horizontal arrow above the layers labelled "IP header: source A, destination B, unchanged end to end". Caption: IP addresses stay fixed while link frames change at each hop.

Transport Layer

Knowing which host to send to is not enough, because a host runs many programs at once. The transport layer solves the problem of delivering data to the correct program on the destination host, and of providing the reliability that IP alone does not provide.

It achieves program-level delivery with port numbers. A port is a 16-bit number that identifies an endpoint for a particular program or service on a host. A pair of IP address and port number forms a socket, which is the endpoint an application uses to communicate. A web server usually listens on port 80 for plain HTTP, while a mail server commonly uses port 25 for SMTP.

The transport layer offers two main protocols. TCP (Transmission Control Protocol) provides a connection-oriented, reliable byte stream: it establishes a connection before exchanging data, numbers the data so it can be reordered, and retransmits anything lost. UDP (User Datagram Protocol) provides a connectionless service that sends individual messages with minimal overhead and no delivery guarantee. Applications choose between them according to whether reliability or low overhead matters more.

The mechanisms by which TCP achieves reliable ordered delivery and how it controls the rate of sending are covered in the transport layer articles. Here, the key idea is that the transport layer converts IP's best-effort delivery into whatever end-to-end service the application needs.

spec: static diagram of one host labelled "Host with IP address 203.0.113.5" drawn as a large rectangle. Inside it, three application boxes labelled "Web browser", "DNS resolver", and "Mail client". Each application connects down through a socket to the transport layer band labelled "TCP and UDP, demultiplexed by port number". Arrows from the transport band to labels: "port 443 (HTTPS)" from TCP, "port 53 (DNS)" from UDP, "port 25 (SMTP)" from TCP. Caption: a port number selects the program that receives the data on a host.

Application Layer

The application layer is where the user-facing protocols live. Each application protocol defines the messages two programs exchange to accomplish a task. Applications do not handle packets, routes, or retransmission; they rely on the transport layer to deliver their messages to the right port on the right host.

Three examples illustrate the range of tasks. DNS (Domain Name System) translates human-readable names such as www.example.com into IP addresses, so that other applications can then open connections. HTTP (Hypertext Transfer Protocol) lets a client request resources, such as web pages, from a server, and the server reply with them. SMTP (Simple Mail Transfer Protocol) moves email from one mail server to another. Each of these protocols defines its own message format and rules, but all of them are built on the same lower layers and inherit the same addressing and delivery behaviour.

The detailed message exchanges of these protocols are covered in the application layer articles. The point to take forward is that the application layer defines what the communication means, while the layers below define how the message reaches its destination.

How Layers Cooperate Through Encapsulation

The layers work together through a process called encapsulation. When an application sends a message, the transport layer adds its own header to form a segment or datagram. The internet layer then adds an IP header to form a packet. Finally, the network access layer adds a frame header and trailer around the packet before transmitting it. Each layer treats everything it receives from above as opaque payload, so it does not need to understand the contents.

At the receiving end the process runs in reverse, called decapsulation. Each layer reads and removes its own header, then passes the payload upward. Because each layer only reads its own header, a change in one layer, such as switching from Ethernet to Wi-Fi, leaves the headers of the other layers untouched. This separation is the main practical benefit of the layered design.

spec: static diagram of nested rectangles showing encapsulation, drawn from outside to inside. Outermost box labelled "Frame header (network access)" with "Frame trailer" on its right edge. Inside it a box labelled "IP header (internet)". Inside that a box labelled "TCP or UDP header (transport)". Innermost box labelled "Application data (HTTP, DNS, or SMTP message)". Beside the nested boxes, a vertical arrow labelled "Sender: each layer adds its header going down the stack" and a second arrow labelled "Receiver: each layer removes its header going up the stack".

Taken together, the four layers form a chain of responsibilities: the application defines the message, the transport layer delivers it to the right program with the required reliability, the internet layer moves it across networks using IP addresses, and the network access layer carries it across each individual link. The remaining articles in this topic examine each of these responsibilities in depth, and the next topic relates these four layers to the seven-layer OSI model.

AI-generated study article from SophistAI. Sign up free to study it with an AI tutor.

Loading SophistAI