← 🧱 Layering, Delays & Switching
Subtopic 1 of 4

1.1Layers and encapsulation

The idea

A network is built in layers. Each layer talks to the same layer on the other machine and uses the layer below it. On the way down every layer wraps the data with its own header (encapsulation); on the way up each layer unwraps its own header.

Think of it like this: Posting a parcel: you put the letter in an envelope, the post office puts that in a bag with a routing label, and a truck carries the bag. Each handler reads only its own label.

Why it exists

GATE asks which device works at which layer, what the unit is called at each layer, and how many times a packet is processed at a router. All of that follows from the wrapping picture.

How it works

  1. Application data goes to the transport layer, which adds ports and makes a segment.
  2. The network layer adds IP addresses and makes a packet.
  3. The data link layer adds MAC addresses and a CRC trailer and makes a frame.
  4. A router unwraps only down to the network layer, picks the next hop and builds a new frame.

Worked example: Source S, two routers, destination D. How many times is the network layer used, and the data link layer?

Network layer is used at S, R1, R2 and D: 4 times. There are 3 links and each link has 2 ends: the data link layer is used 6 times.

Now play with it

  • →Click Next step and watch headers pile up around the data.
  • →In the table, find the device that works at layer 2 and the address it uses.
application data
Start: the application hands over its data
  • Application layer: Data (message) (HTTP request)
  • Transport layer: Segment = TCP header + data (adds ports, sequence number, checksum)
  • Network layer: Packet / datagram = IP header + segment (adds source and destination IP)
  • Data link layer: Frame = header + packet + trailer (adds MAC addresses and a CRC trailer)
  • Physical layer: Bits on the wire (signals, no header)
LayerPDU nameAddress usedDeviceExample protocols
Application (5, 6, 7)messagenone (name or URL)gatewayHTTP, SMTP, DNS, FTP
Transport (4)segment (TCP), datagram (UDP)port numbernone (end hosts)TCP, UDP
Network (3)packet or datagramIP addressrouterIP, ICMP, OSPF
Data link (2)frameMAC addressswitch, bridgeEthernet, PPP, ARP*
Physical (1)bitnonehub, repeatercables, signalling

*ARP sits between layers 2 and 3. A router uses layers 1 to 3 on every hop; the transport and application layers exist only at the end hosts.

Check yourself

At a router the frame header that arrived is

Remember: Hosts use all layers, routers layers 1 to 3, switches layers 1 to 2, hubs layer 1. Frame, packet, segment, message.
Exam notes (the dense version)

The OSI model has 7 layers (physical, data link, network, transport, session, presentation, application); the TCP/IP stack has 4 or 5 (link, internet, transport, application). Each layer adds its own header on the way down. The PDU names are: message (application), segment (TCP) or datagram (UDP), packet or datagram (network), frame (data link), bits (physical). Devices: hub and repeater at layer 1, switch and bridge at layer 2, router at layer 3. A router rebuilds the data link header on every hop but never touches the transport layer.

Previous year questions: Layering, Delays & Switching (7)

PYQs are grouped by topic, so this is the full set for Layering, Delays & Switching; try the ones that match this subtopic. Open all 7 on the topic page.