Network models · Fundamentals · Module 1
Layers: the OSI and TCP/IP models
Show topologyHide topology
Four devices in a column, joined by three cables. At the top the host H1: its eth0, address ending .10, is cabled to the switch SW1’s Et0/1. SW1’s Et0/0 is cabled to the router R1’s Et0/0, address ending .1. Both of SW1’s cables are one network, 10.0.1.0/24, written on each of them; SW1 itself has no address. R1’s Et0/1, address ending .1, is cabled to the host H2 at the bottom, its eth0 ending .20, in the network 10.0.2.0/24, written on that cable. A legend explains the short forms.
What layers are
One job per layer, in two models
Why describe a network in layers
R1 is a router, but it also runs programs, such as telnet, which here sends one line of typed text to a program on H2. How many separate jobs does that take?
At least four. The text must reach the right program on H2, not just H2 itself. H2 needs an address that also works from other networks, such as H1’s network on the far side of R1. Along the way the data must reach the next device on the cable, and on the cable it travels as signals. Your phone or computer does these same jobs each time it loads a web page.
These four problems have separate solutions, so engineers describe the work as a stack, and a layer is one job in it. Each layer does its job and relies on the layer below for the rest; in turn it provides a service to the layer above it, work done on its behalf.
Two devices must handle each job the same way, or they cannot understand each other. A protocol is the set of rules and formats that two devices follow at the same layer. Ethernet on the cables, IP for addresses across networks and TCP for reaching a program are protocols that R1 and H2 use.
Why split the work at all? One layer can change without changing the others, so a new kind of cable does not change how H2 is named across networks. A fault can also be tracked down one layer at a time.
Because diagrams draw each layer as a box, layers are easy to mistake for devices between the hosts. A layer is a job done inside a device, and R1 and H2 each do several.
OSI: seven layers, the bottom four
When one engineer says “layer 3”, how does another know which job is meant?
Both use the OSI model: a reference model of seven numbered layers, with layer 1 at the bottom. It describes jobs, not software (Figure 1.1).
Seven rows, one per layer, numbered from the top: 7 Application, the program’s own exchange; 6 Presentation, how the data is written; 5 Session, the dialogue between programs; 4 Transport, the right program, end to end; 3 Network, the right host, across networks; 2 Data link, the next device on this link; 1 Physical, bits on the cable or radio. A frame in the accent color holds the bottom four rows. An arrow beside the rows points down, from layer 7 to layer 1.
On the cable to H2, R1’s data is signals. The physical layer (layer 1) sends and receives the bits as signals, on a cable or a radio link.
Over that cable, the data must reach the next device on the same link. The data link layer (layer 2) handles that hop, with addresses unique within one network. One network can hold several links, as SW1’s network holds the links to H1 and to R1. Layer 2 also detects errors that occur in the physical layer.
Data from H1 must also cross into H2’s network, beyond R1. The network layer (layer 3) carries it to the right host across networks, through the devices in between, by IPv4 addresses such as 10.0.2.20.
On H2, the text is for one program. The transport layer (layer 4) gets data to the right program on that host, named by a port number, here 2001. It works end to end, between the two devices at the ends, and can make delivery reliable.
The top three: session, presentation, application
Above the transport layer, what must the two programs still agree on?
First, in their telnet conversation, R1’s program and H2’s may need to agree on who talks when, and where to pick up after a break. The session layer (layer 5) keeps the dialogue between two programs going.
Both must also write the data the same way. The presentation layer (layer 6) gives both ends a common way of writing the data: its format, and changes such as compression.
Their exchange itself follows a protocol, such as Telnet for a text session or HTTP for web pages. The application layer (layer 7) holds such protocols. Your web browser is a program that reaches the network through the application layer.
TCP/IP: four layers, side by side
IP and TCP have a model of their own. How does it line up with OSI’s seven layers?
The TCP/IP model describes the protocols of the Internet in four layers: application, transport, internet and link. It covers the same jobs as OSI, grouped differently (Figure 1.2).
Two columns. On the left, headed OSI, the seven layers from 7 Application at the top to 1 Physical at the bottom. On the right, headed TCP/IP, four boxes, each as tall as the OSI rows it covers, joined to them by thin lines: Application, with HTTP and Telnet, beside OSI 7, 6 and 5; Transport, with TCP and UDP, beside OSI 4; Internet, with IP, beside OSI 3; and Link, with Ethernet, beside OSI 2 and 1. The Application box is drawn in the accent color.
The two middle layers match one to one. TCP/IP’s transport layer is OSI’s transport layer. TCP and UDP work there, and R1’s text for H2 travels in TCP. The internet layer is OSI’s network layer, layer 3, where IP works and carries data from host to host, from R1 to H2 here.
At the bottom, the link layer is the layer of the protocol a host uses to communicate on its directly connected network. It stands beside OSI layers 1 and 2 together.
At the top, TCP/IP’s application layer combines the jobs of OSI’s presentation and application layers, and TCP/IP has no session layer. Where did the session jobs go? Its application layer does them too, in the usual comparison.
So which layer numbers do engineers use? Usually OSI’s, even when they draw the TCP/IP model. Cisco’s documentation, for example, calls IP a layer 3 protocol and TCP a layer 4 protocol. TCP/IP’s one link layer has no numbers 1 and 2, so when you read “layer 2”, the number is OSI’s.
Those OSI numbers can make it look as if R1 and H2 run OSI’s own protocols. They run IP and TCP from the TCP/IP suite, with Ethernet at the link layer, and OSI only names the jobs.
A device is usually named by the highest layer at which it passes other devices’ data on. In the topology, SW1 is a switch, passing data within one network at layer 2, and R1 is a router, passing it between networks at layer 3.
| Layer (OSI) | Job | Protocols here | Devices that work up to here |
|---|---|---|---|
| 7-5 Application, presentation, session | the programs’ exchange | HTTP, Telnet | hosts; also a router, for its own traffic |
| 4 Transport | the right program | TCP, UDP | — |
| 3 Network | the right host, across networks | IP | routers, for the packets they pass on |
| 2 Data link | the next device on this link | Ethernet | switches |
| 1 Physical | bits on the medium | Ethernet (its signals) | hubs |