The seven layers every network is described by

10 min 6 sections 5 practice questions 8 sources citedISC2 objective 4.1

Sending a message across a network is a job done in stages, much as posting a parcel is: someone writes, someone packs, someone addresses, someone carries. The OSI model names seven such stages, called layers, and the TCP/IP model names four. No background is assumed. Security work uses the layer numbers daily, because every device, protocol and attack is described by the layer it works at.

By the end of this unit you will be able to:

  • Name the seven OSI layers in order, with the number and the job of each
  • Match each layer to its unit of data: bits, frame, packet, segment or datagram, data
  • Explain encapsulation and de-encapsulation
  • Map the four TCP/IP layers onto the seven OSI layers
  • Place a device or a protocol at the layer it works at

The booking screen will not load

An illustrative example

On Monday morning the booking screen at a dental surgery shows an error. The receptionist blames the booking company. The dentist blames the broadband. The practice manager finds a cable hanging loose behind the desk and pushes it back in. The error stays.

An engineer on the telephone asks three questions, in a fixed order. Is the small light beside the network socket lit? Can the computer print to the surgery's own printer? Can it open any other website? Each answer clears one part of the path, and the engineer never asks about the booking company until the first three are settled.

Why does the engineer ask about the socket light before asking about the booking website?

A message passes through stages, like a posted parcel

Posting a parcel is several jobs done by different people. One person writes the letter. Another packs it. A clerk writes the address. The sorting office reads only the postcode, and the driver reads only which van. Each does one job and passes the parcel on, and none needs to know how the others work.

Networks are built the same way. The work of moving a message from one program to another is split into stages called layers. Each layer does one job, hands its result to the layer below, and relies on the matching layer in the other computer to undo it. The agreed rules for doing one job are a protocol.

Security depends on this split. Every device, every protective control and every attack acts at one layer and is blind to the rest. A control that reads addresses cannot judge what a message says. A control that checks what a message says does nothing about a cable that has been tapped.

The surgery's fault, found from the bottom up

A lit socket shows that the cable carries a signal. Printing shows that data crosses the surgery's own network. Opening another website shows that data leaves the building and returns. Only when all three work is the booking service itself in question.

The seven OSI layers, from the wire up to the program

The Open Systems Interconnection (OSI) model is an international standard that describes networking in seven layers. They are numbered from 1 at the bottom, nearest the cable, to 7 at the top, nearest the program a person uses. A layer is called by its number as often as by its name.

Two kinds of address appear in the model. A logical address, such as an (IP) address, is given to a device by whoever runs the network. A hardware address is built into the device's network connection by its maker.

The seven layers from top to bottom, with what each one handles
LayerJobData unitExamples
7 ApplicationGives programs their network services: web pages, email, file transfer, looking up namesDataHTTP, SMTP, FTP, DNS, Telnet, SNMP
6 PresentationPuts data in a form both ends can read: character sets, file formats, compression, DataASCII text, JPEG pictures
5 SessionOpens, keeps in step and closes the conversation between two programsDataRemote procedure call (RPC), NetBIOS
4 TransportCarries data from program to program, end to end, and can check that all of it arrivedSegment () or ()TCP, UDP
3 NetworkMoves data from network to network by logical address and chooses the routePacketIP, , , IPsec; routers
2 Data LinkMoves data between devices on one link by hardware address, and detects damageFrameEthernet, Wi-Fi, PPP, L2TP, ARP; switches, bridges
1 PhysicalSends bits, the single ones and zeros, as electrical, light or radio signalsBitsCables, hubs, repeaters

Bottom to top: Please Do Not Throw Sausage Pizza Away. Top to bottom: All People Seem To Need Data Processing.

has two halves. Logical Link Control (LLC) is the upper half and connects to the . Media Access Control (MAC) is the lower half. It decides when a device may send, and it uses the hardware address, which is why that address is also called a MAC address.

sets the direction of a conversation. Simplex is one way only, as a radio broadcast is. Half-duplex is both ways but one at a time, as on a walkie-talkie. Full-duplex is both ways at once, as on a telephone.

Common protocols at each layer and what their names mean

Each layer has well-known protocols, and their full names say what they do.

At , HTTP is the Hypertext Transfer Protocol and SMTP is the Simple Mail Transfer Protocol. The File Transfer Protocol (FTP) moves files, the Domain Name System (DNS) looks up names, Telnet gives a remote text session and the Simple Network Management Protocol (SNMP) watches and sets devices.

At , TCP, the Transmission Control Protocol, and UDP, the User Datagram Protocol, are the two transport protocols.

At layer 3, the Internet Control Message Protocol (ICMP) carries error and test messages. The Internet Group Management Protocol (IGMP) joins devices to group addresses, and IPsec encrypts and checks each packet.

At layer 2, the finds the hardware address for an IP address. The and the Layer 2 Tunnelling Protocol (L2TP) carry frames over a single link or a tunnel.

Encapsulation: each layer wraps what the layer above hands it

A message is not sent as the program wrote it. On the way down, each layer adds a header: a short label holding the instructions that the matching layer at the other end will need. Wrapping data in a new header at each layer is encapsulation.

  1. Layers 7, 6 and 5 produce the data: the request as the program wrote it.
  2. Layer 4 adds a transport header that names the program at each end. The result is a segment, or a datagram when UDP is used.
  3. Layer 3 adds a network header with the logical addresses of the two computers at the ends of the journey. The result is a packet.
  4. Layer 2 adds a header with the hardware addresses for one link, and a check value at the end. The result is a frame.
  5. sends the frame as bits.

The receiving computer works in reverse. Each layer reads and removes its own header and passes the rest upward. This is de-encapsulation. The general name for the unit of data at any layer is a protocol data unit (PDU).

How each layer wraps the message on the way down

How each layer wraps the message on the way downFive data units stacked in order: data at layers 7, 6 and 5, segment at layer 4, packet at layer 3, frame at layer 2 and bits at layer 1. Beside the middle three, the header that made each one.Encapsulationgoing down atthe sender;the receiverreverses itData: layers 7, 6 and 5Segment: layer 4Packet: layer 3Frame: layer 2Bits: layer 1Transport header: portsNetwork header: IP addressesLink header and check valueHow each layer wraps the message on the way downFive data units stacked in order: data at layers 7, 6 and 5, segment at layer 4, packet at layer 3, frame at layer 2 and bits at layer 1. Beside the middle three, the header that made each one.Encapsulationgoing down atthe sender;the receiverreverses itData: layers 7, 6 and 5Segment: layer 4Packet: layer 3Frame: layer 2Bits: layer 1Transport header: portsNetwork header: IP addressesLink header and check value
Read this figure as text

A message is not sent as the program wrote it. On the way down each layer adds a header, a short label holding the instructions the matching layer at the other end will need. This wrapping is encapsulation.

  1. Layers 7, 6 and 5 produce the data: the request as the program wrote it.
  2. Layer 4 adds a transport header that names the program at each end by its port. The result is a segment, or a datagram when UDP is used.
  3. Layer 3 adds a network header with the IP addresses of the two computers at the ends of the journey. The result is a packet.
  4. Layer 2 adds a header with the hardware addresses for one link, and a check value at the end. The result is a frame. Layer 1 sends the frame as bits.
  5. The receiving computer works in reverse, from the bottom up: each layer reads and removes its own header and passes the rest upward. This is de-encapsulation. The order going down is data, segment, packet, frame, bits.

Data units going down: data, segment, packet, frame, bits. One phrase for the order: Don't Some People Fancy Biscuits.

A device on the path opens only the wrappers it needs. A switch reads the frame header and nothing inside it. A router removes the frame, reads the packet header and builds a new frame for the next link.

The TCP/IP model: four layers for the same work

The internet does not run the OSI protocols. It runs the TCP/IP family, named after its two best-known protocols, and that family has a model of its own with four layers. The OSI model survives as the shared vocabulary: 'layer 3' and 'layer 7' always mean OSI numbers.

The four TCP/IP layers set against the seven OSI layers
TCP/IP layerAlso calledOSI layers it coversExamples
ApplicationNo other common name7, 6 and 5HTTP, SMTP
TransportHost-to-Host4TCP, UDP
InternetInternetworking3IP
LinkNetwork Access or Network Interface2 and 1Ethernet,

The four-layer model merges what the internet never kept apart. A web browser handles the conversation, the format and the request together, so OSI layers 5 to 7 are one application layer. The cable and the frames sent over it are one link layer.

Common misconception

“The seven layers are seven parts inside a computer, or seven boxes on the network.”

The layers describe work, not parts. One network card does the work of layers 1 and 2. The operating system does layers 3 and 4. A single program such as a browser does layers 5, 6 and 7.

Placing a device or a protocol at its layer

A device is described by the highest layer it has to read to do its job.

Network devices by the highest layer each one reads
DeviceLayerWhat it does
Repeater, hub1Repeats the signal to every port without reading it
Bridge, switch2Reads the hardware address in the frame and sends the frame out of one port
Router3Reads the logical address in the packet and chooses the next network
Gateway, proxy7Opens the request itself and can translate it or check its content

A firewall, a device that allows or blocks traffic by rule, may read as far as layer 3, layer 4 or layer 7, depending on its kind. The deeper a device reads, the more it can decide and the more work each message costs it.

Some protocols fit the model badly. Transport Layer Security (TLS), which encrypts web traffic, runs above TCP and below the application. It is usually placed at layer 4, the transport layer, and sometimes at layer 5 or 6 because it encrypts.

The Address Resolution Protocol (ARP), which finds the hardware address that belongs to an IP address, travels directly inside a frame and is placed at layer 2.

Common misconception

“A switch decides where to send data by looking at the IP address.”

An ordinary switch works at layer 2. It reads the hardware address in the frame and never opens the packet. Choosing a path by IP address is the router's job, at layer 3.

A question, worked through

Staff at a charity are visiting gambling websites from office computers. The trustees want those sites blocked by name and all other web use left alone. The office has a switch that joins the computers and a router that joins the office to the internet. The security manager is asked what kind of device could enforce the rule.

Which device would BEST meet the trustees' requirement?

  1. A switch that filters frames by hardware address
  2. A router that filters packets by network address
  3. A firewall that filters segments by port number
  4. A proxy that reads each request at the application layer
Decide on your answer, then open the reasoning
  1. The requirement is to decide by the name of the website. The name is part of the request the browser writes, which is application data at layer 7.
  2. Rule out a: a switch reads hardware addresses at layer 2. Those identify devices on the office network, not websites.
  3. Rule out c: a port number at layer 4 identifies a kind of service. Every website uses the same web ports, so a port rule blocks all web use or none.
  4. Between b and d: a router could block the addresses the gambling sites use today. One address can serve many sites, and sites change address, so the rule would block too much or too little.
  5. Only a device that opens the request can see the name of the site. That is d.

Answer: D. A proxy that reads each request at the application layer

Choosing between good answers

A question asks what a device can base a decision on
name the highest layer it reads: a hub nothing, a switch hardware addresses, a router network addresses, a proxy the content.
A question gives a layer number
read it as an OSI number, even though real networks run TCP/IP.
A question names a unit of data
match it to its layer: segment 4, packet 3, frame 2, bits 1.
Two answers place a control at different layers
choose the layer where the thing to be judged is visible: an address at layer 3, a port at layer 4, content at layer 7.
A question asks the layer of TLS
choose the transport layer, layer 4, if it is offered.

Check your understanding

5 questions on this unit, easiest first. Confirm an answer to see the reasoning for it, then the right answer, the other options and the rule to reuse. Your answers are kept in this browser and feed readiness and review.

These questions are drafts that no named reviewer has approved yet.

Question 1 of 5

A technician is showing a new colleague how a laptop sends a web request. Put the steps in the order they happen as the request passes down the layers of the sending laptop.

Put the steps in order with the buttons beside each one. The whole order has to be right.

  1. 1The frame is sent along the cable as bits
  2. 2A network header with the logical addresses of both ends makes a packet
  3. 3A transport header naming the program at each end makes a segment
  4. 4A header with hardware addresses for one link and a check value makes a frame
  5. 5The browser produces the request as data at the top three layers

What to remember

  • The OSI model has seven layers: Physical, Data Link, Network, Transport, Session, Presentation and Application, numbered 1 to 7.
  • The units of data from the top down are data, segment or datagram, packet, frame and bits.
  • Encapsulation adds a header at each layer on the way down. De-encapsulation removes them on the way up.
  • TCP/IP has four layers: Application covers OSI 5 to 7, Transport covers 4, Internet covers 3 and Link covers 1 and 2.
  • A hub works at layer 1, a switch at 2, a router at 3 and a proxy at 7. A device cannot act on a layer it does not read.

Say it from memory

  1. Name the seven OSI layers from 1 to 7 with the data unit of each, then the four TCP/IP layers that cover them.

    1 Physical (bits), 2 Data Link (frame), 3 Network (packet), 4 Transport (segment for TCP, datagram for UDP), 5 Session, 6 Presentation and 7 Application (data). In TCP/IP, Link covers 1 and 2, Internet covers 3, Transport covers 4 and Application covers 5 to 7. Encapsulation adds a header at each layer on the way down.

    Read this part again

  2. Why does splitting networking into layers matter for security?

    Every device, every protective control and every attack acts at one layer and is blind to the rest. A control that reads addresses cannot judge what a message says. A control that checks what a message says does nothing about a cable that has been tapped.

    Read this part again

  3. At which OSI layer does each of these sit: SMTP, UDP, ICMP and ARP?

    SMTP, the Simple Mail Transfer Protocol, sits at layer 7. UDP, the User Datagram Protocol, is a transport protocol at layer 4. ICMP, which carries error and test messages, sits at layer 3. ARP, which finds the hardware address for an IP address, sits at layer 2.

    Read this part again

  4. What happens to a frame at a switch and at a router, and what is the receiving computer's undoing of the wrappers called?

    A switch reads the frame header and nothing inside it. A router removes the frame, reads the packet header and builds a new frame for the next link. The receiving computer reads and removes each layer's header and passes the rest upward, which is de-encapsulation.

    Read this part again

  5. What other names do the TCP/IP transport, internet and link layers go by?

    The transport layer is also called Host-to-Host. The internet layer is also called Internetworking. The link layer is also called Network Access or Network Interface.

    Read this part again

  6. At which layer does each device work: hub, switch, router, and gateway or proxy?

    A device is described by the highest layer it has to read. A repeater or hub works at layer 1, a bridge or switch at layer 2 and a router at layer 3. A gateway or proxy works at layer 7, because it opens the request itself.

    Read this part again

Sources