The whole idea

The OSI model splits network communication into 7 layers. Each layer has one job, serves the layer above it, and hides its internal details. Data is wrapped as it moves down the sender and unwrapped as it moves up the receiver.

1. The seven layers

LayerNamePDU / data unitWhat to remember
7ApplicationDataProvides network services to end-user applications: web, email, file transfer, DNS.
6PresentationDataMakes data understandable: translation/formatting, encryption/decryption, compression/decompression.
5SessionDataStarts, manages and ends communication sessions; manages dialogue/token control.
4TransportSegment (TCP) / Datagram (UDP)Delivers a complete message from process to process using ports, segmentation, reassembly, flow control and error control.
3NetworkPacketDelivers packets from source to destination, possibly across many networks. Uses IP addresses and routing.
2Data LinkFrameDelivers data across one local link/network. Uses MAC addresses, framing, error detection and access control.
1PhysicalBitsSends 1s and 0s as electrical, optical or radio signals through the medium.

Mnemonics

Top to bottom (7 -> 1):
All People Seem To Need Data Processing

Bottom to top (1 -> 7):
Please Do Not Throw Sausage Pizza Away

2. What each layer does

Layer 7 - Application: “What service does the user need?”

  • The interface between network services and applications.
  • Examples: HTTP/HTTPS (web), FTP (files), SMTP (sending email), DNS (names to IP addresses).
  • Do not confuse it with the application itself: it provides the network functions used by the application.

Layer 6 - Presentation: “What format should the data use?”

Responsible for the way data is presented to the application

Layer 5 - Session: “Which conversation is this?”

  • Session Layer

    • Organises multiple communication sessions happening at the same time.
    • Ensures data is sent to the correct session.
  • Session Initiation and Teardown

    • Starts a communication session between devices.
    • Allows data transfer during the session.
    • Ends and releases the session when communication is complete.
    • Start → Transfer data → End
  • Token Management

    • Controls which device is allowed to transmit data.
    • A token acts as permission to send data.
    • Used when only one device can transmit at a time.
    • Depends on the communication mode:
      • Simplex: data flows in one direction only.
      • Half-duplex: both sides can transmit, but not simultaneously.
      • Full-duplex: both sides can transmit simultaneously.
  • Session-to-Transport Connection Mapping

    • Used in connection-oriented communication.
    • Maps each session to the correct transport-layer connection.
    • Ensures that incoming data is delivered to the correct session.
  • Memory Shortcut

    • Start and end sessions
    • Token controls who transmits
    • Map data to the correct session

Layer 4 - Transport: “Which program, and did the whole message arrive?”

  • Responsible for process-to-process delivery of entire message

  • Transport Layer

    • The transport layer is responsible for process-to-process delivery.
    • It ensures that data reaches the correct running program on the destination computer.
  • Service-Point Addressing

    • Computers can run many programs at the same time.
    • Therefore, data must be delivered to the correct process, not just the correct computer.
    • The transport layer uses a service-point address, also called a port address.
    • Network layer: delivers packets to the correct computer.
    • Transport layer: delivers the message to the correct process on that computer.
  • Segmentation and Reassembly

    • The transport layer divides a message into smaller segments.
    • Each segment is given a sequence number.
    • Sequence numbers help the receiver:
      • Reassemble the message in the correct order
      • Detect missing segments
      • Replace lost segments
  • Connection Control

    • The transport layer can be:
      • Connectionless
      • Connection-oriented
    • Connectionless
      • Each segment is treated as an independent packet.
      • No connection is set up before sending.
    • Connection-oriented
      • A connection is established before data is sent.
      • Data is transferred through the connection.
      • The connection is terminated after all data is sent.
  • Flow Control

    • Flow control prevents the sender from overwhelming the receiver.
    • At the transport layer, flow control is end-to-end.
    • This means it occurs between the sender and receiver, not just across one link.
  • Error Control

    • Error control ensures the whole message arrives correctly.
    • At the transport layer, error control is process-to-process.
    • It checks for:
      • Damaged data
      • Lost data
      • Duplicated data
    • Error correction is usually done through retransmission.
  • Memory Shortcut

    • Ports → correct process
    • Segments → split message
    • Sequence numbers → rebuild message
    • Connection control → connection or no connection
    • Flow control → avoid overwhelming receiver
    • Error control → fix loss, damage, duplication

Key distinction:

  • Data Link = device to device across one link.
  • Transport = process to process across the whole journey.

Layer 3 - Network: “Where should the packet go?”

  • Network Layer

    • The network layer is responsible for source-to-destination delivery of packets.
    • It provides two main functions:
      • Logical addressing
      • Routing
  • Logical Addressing

    • If a packet passes a network boundary, the network layer adds a header to the packet from the upper layer.
    • This header includes the logical addresses of the sender and receiver.
    • The logical address helps to distinguish the source and destination systems.
    • In TCP/IP networks, the logical address usually refers to the IP address.
  • Routing

    • Routing is needed when independent networks or links are connected to form an internetwork, also known as a network of networks.
    • Connecting devices such as routers or switches help route packets to their final destination.
    • The network layer provides the mechanism for routing packets across networks.
  • When Two Hosts Are on the Same Network

    • The network layer is still needed to achieve source-to-destination delivery.
    • However, no routing is needed.
    • The sender creates an IP packet with:
      • Source IP address
      • Destination IP address
    • Based on the destination IP address, the system decides whether the destination is on the same network or a different network.
    • If the destination is on the same network:
      • The system uses Address Resolution Protocol (ARP) to find the destination MAC address.
      • The data link layer sends the frame directly to the destination host.
      • No routing is performed because no router is needed.
      • The packet remains within the same network.
  • When Two Hosts Are on Different Networks

    • If two systems are attached to different networks, routers are needed between the networks.
    • The network layer is needed to achieve source-to-destination delivery with routing.
    • The sender creates an IP packet with:
      • Source IP address
      • Destination IP address
    • Based on the destination IP address, the system decides whether the destination is on the same network or a different network.
    • If the destination is on a different network:
      • The packet is sent to a router, also known as the default gateway.
      • Each router examines the destination IP address.
      • Each router decides the next hop for the packet.
      • The packet travels across multiple networks until it reaches the destination host.
  • Even on the same network, Layer 3 is used to decide that no routing is needed.

  • Delivers data between two directly connected devices on the same local network/link.

  • Encapsulates packets into frames.

  • flow control: If the rate at which the data is absorbed by the receiver is less than the rate produced at the sender, the data link layer imposes a flow control mechanism to prevent overwhelming the receiver

  • Error control: The data link layer adds reliability to the physical layer by adding mechanisms to detect and retransmit damaged or lost frames. It also uses a mechanism to recognize duplicate frames. Error control is normally achieved through a trailer added to the end of the frame

    • detection method: Parity bits, Checksums, CRC
  • Access control: When two or more devices are connected to the same link, data link layer protocols are necessary to determine which device has control over the link at any given time.

Use Media Access Control (MAC) to avoid collisions

2 sub layers

  • Logical Link Control (LLC)
    • Provide interface with network layer
    • Handle error checking and flow control
  • Media Access Control (MAC)

A basic Ethernet frame contains:

Destination MAC | Source MAC | Type | Data (packet) | FCS

MAC address facts: 48 bits, usually written as six hexadecimal pairs, e.g. 00:1A:2B:3C:4D:5E.

  • First 3 bytes (00:1A:2B) - OUI (Organizationally Unique Identifier): identifies the manufacturer
  • Last 3 bytes (3C:4D:5E) - Device-specific identifier, assigned by the manufacturer.

Layer 1 - Physical: “How are the bits signalled?”

  • Represents data as bits: 0s and 1s.
  • Converts bits into electrical, optical or radio signals.
  • Defines the medium, data rate, timing/synchronisation and physical connections.
  • Examples of media: twisted-pair cable, fibre-optic cable, radio/Wi-Fi.
  • Transmission modes:
    • Simplex: one-way only.
    • Half-duplex: both directions, but one at a time.
    • Full-duplex: both directions simultaneously.

3. The PDU sequence

Memorise this order:

Data -> Segment/Datagram -> Packet -> Frame -> Bits

At the receiver, reverse it:

Bits -> Frame -> Packet -> Segment/Datagram -> Data

4. Encapsulation and decapsulation

Sender: encapsulation

  1. Application creates data.
  2. Transport divides it into segments/datagrams and adds transport information.
  3. Network adds IP information to make a packet.
  4. Data Link adds MAC header/trailer to make a frame.
  5. Physical sends the frame as bits.

Each layer treats the complete output of the layer above as its data.

Receiver: decapsulation

The receiver removes each layer’s header/trailer in reverse order until the original data reaches the application.

5. What happens at a router?

A router does partial decapsulation:

  1. Receives bits and forms a frame.
  2. Removes the Data Link header/trailer.
  3. Reads the Network layer destination IP.
  4. Chooses the next hop.
  5. Creates a new frame for the next link.
  6. Sends it as bits.

A router normally does not unpack the data up to the Transport, Session, Presentation or Application layers.

Important addressing idea

  • IP address: end-to-end logical destination; used for routing.
  • MAC address: local/next-hop destination; used only across the current link.
  • Therefore, the MAC addresses can change at each router hop, while the packet’s IP addresses identify the original source and final destination.

6. Host layers vs media layers

  • Host layers: Layers 7-4 - mainly operate between the end devices.
  • Media layers: Layers 3-1 - move data through the network.
  • Routers mainly operate at Layer 3.
  • Switches mainly operate at Layer 2.
  • Hubs/repeaters operate at Layer 1.

7. High-value comparisons

CompareDifference
MAC vs IPMAC identifies a device on the local link; IP identifies the logical source/destination across networks.
Data Link vs NetworkData Link handles one local link; Network handles source-to-destination routing.
Transport vs NetworkNetwork gets data to the correct computer; Transport gets it to the correct program.
TCP vs UDPTCP is reliable and connection-oriented; UDP is faster, connectionless and less reliable.
Encapsulation vs decapsulationEncapsulation adds headers/trailers going down; decapsulation removes them going up.
Frame vs packetA frame is a Layer 2 unit for one link; a packet is a Layer 3 unit for the journey between networks.

8. One-sentence exam answer

The OSI model is a seven-layer reference model: Application, Presentation, Session, Transport, Network, Data Link and Physical. It standardises network communication by giving each layer a specific responsibility, from providing services to applications at Layer 7 to transmitting bits through a physical medium at Layer 1.

Final memory checklist

I should be able to recall:

  • The 7 layer names in order and the two mnemonics.
  • The main job of every layer in one sentence.
  • IP = routing/end-to-end, MAC = local link/next hop, port = correct process.
  • TCP vs UDP.
  • Encapsulation and decapsulation.
  • Why a router reads Layer 3 and creates a new Layer 2 frame for each hop.