Why networks are built in layers, the OSI and TCP/IP stacks and the job of each layer, encapsulation and header overhead, and which device works at which layer (with collision and broadcast domains).
Before you start
Bits, bytes and rate units
Overhead questions mix bytes with bits per second; 1 byte = 8 bits and network rates use powers of 10 ( bit/s).
1. Why layering: services, protocols and interfaces
A network is split into layers. Each layer offers a service to the layer above and uses the service of the layer below. It never needs to know how the lower layer works.
A protocol is the set of rules two peer entities (the same layer on two machines) follow: message format, order and actions. Peers talk logically; the data actually travels down one stack, across the wire and up the other.
An interface is the boundary between two adjacent layers on the same machine. The point where a service is offered is a service access point (SAP); at the transport layer, ports play this role.
Why it helps: each layer can be designed, tested and replaced on its own (change Wi-Fi to Ethernet without touching TCP), and a complex job is broken into small ones.
What it costs: every layer adds a header, so bytes and processing grow; some work is repeated (error checking happens at the link and again at the transport layer); and a layer cannot use information hidden in another layer.
Two principles GATE likes:
Hop-by-hop vs end-to-end. Physical, data link and network layers run on every device along the path. Transport and application layers run only on the two end hosts.
Connection-oriented vs connectionless service can be offered at any layer (TCP vs UDP, virtual circuit vs datagram).
2. The OSI reference model
The OSI model has seven layers. Learn each one's job and its data unit (PDU).
#
Layer
Main job
PDU
7
Application
Services for the user: file transfer, mail, web
message
6
Presentation
Translation of data formats, encryption, compression
message
5
Session
Dialog control (who talks when), synchronisation with checkpoints
message
4
Transport
Process-to-process delivery, ports, segmentation, end-to-end reliability, flow and congestion control
segment
3
Network
Host-to-host delivery across networks, logical (IP) addressing, routing, fragmentation
packet
2
Data link
Hop-to-hop (node-to-node) delivery on one link, framing, physical (MAC) addressing, error detection, medium access
frame
1
Physical
Bits on the medium: voltage, timing, encoding, connectors
bit
A quick way to keep the addresses straight: MAC address (48 bits) at layer 2, IP address (32 bits for IPv4) at layer 3, port number (16 bits) at layer 4.
OSI is a reference model; real networks run the TCP/IP stack, but GATE questions still name OSI layers.
OSI's seven layers beside the five-layer TCP/IP stack. Session and presentation fold into the TCP/IP application layer; the right column is the PDU name.
3. The TCP/IP protocol stack
The Internet uses the TCP/IP stack. Most textbooks and GATE use the five-layer form: application, transport, network, data link, physical. (Some books merge the bottom two into one link or host-to-network layer and call it four layers; the ideas are the same.)
TCP/IP layer
Typical protocols
Application
HTTP, DNS, SMTP, FTP, DHCP
Transport
TCP, UDP
Network
IP, ICMP, routing protocols (RIP, OSPF)
Data link
Ethernet, Wi-Fi (802.11), PPP; ARP sits between link and network
Physical
cables, radio, signal encoding
Differences from OSI:
There is no separate session or presentation layer. If an application needs encryption or dialog control, it does that itself (for example TLS under HTTPS).
TCP/IP was built from working protocols; OSI was designed first as a model.
The hourglass idea: many applications on top, many link technologies below, and a single network-layer protocol (IP) in the narrow middle that every device must run.
4. Encapsulation and header overhead
On the way down, each layer treats what it gets from above as opaque payload and adds its own header (the data link layer usually also adds a trailer, such as the CRC). On the way up, each layer reads and strips its own header and passes the rest up. This is encapsulation and decapsulation.
If an application message of bytes passes through layers that add headers of bytes, the bytes actually sent are and the efficiency (useful fraction) is
At a router, the frame header and trailer are removed and a new frame is built for the next link (new source and destination MAC addresses). The IP header is kept but the router decrements TTL and recomputes the header checksum. Transport and application headers are not touched (NAT is the exception). A switch reads the frame's MAC addresses but forwards the frame unchanged.
In GATE numericals, read which layers add a header: the physical layer usually adds none, and a trailer counts towards the frame size.
Each layer wraps the unit from the layer above in its own header; the data link layer adds a trailer too.
5. Devices by layer; collision and broadcast domains
Device
Highest layer it uses
Separates collision domains?
Separates broadcast domains?
Repeater, hub
1 (physical)
No
No
Bridge, switch
2 (data link)
Yes, each port is one
No
Router
3 (network)
Yes
Yes, each interface is one
Gateway / host
up to 7
Yes
Yes
A hub copies every incoming bit to all other ports, so everything attached to it forms one collision domain.
A switch forwards a frame only towards its destination port, so each switch port is its own collision domain. But it floods broadcast frames to every port, so all its ports stay in one broadcast domain.
A router does not forward layer-2 broadcasts, so each router interface starts a new broadcast domain.
Counting rule: collision domains = (number of switch or bridge ports in use) + (number of hub segments) + (direct router-to-router links). Broadcast domains = number of router interfaces that lead to a separate LAN, assuming no VLANs.
Formulas to remember
Size after encapsulationMessage bytes; = header (and trailer) bytes added by layer
Header efficiencyFraction of transmitted bytes that is application data
Transmission time of the frame in bytes, link rate in bit/s
Common mistakes
Mixing up host-to-host (network layer) and process-to-process (transport layer) delivery.
Thinking a switch separates broadcast domains; only a router (or VLANs) does that.
Forgetting the data link trailer, or adding a header for the physical layer, in overhead sums.
Assuming the router keeps the incoming frame header; it builds a new frame for every hop.
Treating encryption and compression as transport-layer jobs; in OSI they belong to the presentation layer.
Worked examples
Try each step yourself, then reveal the working.
Example 1: Header overhead and transmission time
numerical
An application hands a 942-byte message to TCP. TCP adds a 20-byte header, IP adds a 20-byte header and the data link layer adds 18 bytes (header plus trailer). The physical layer adds nothing. Find the frame size, the efficiency, and the transmission time on a 2 Mbps link.
Step 1: Add up everything the lower layers attach.
Try it on paper first.
Example 2: Name the layer
conceptual
Which OSI layer does each job? (a) choosing the path through several routers, (b) delivering data to the right process using port numbers, (c) marking where a frame starts and ends, (d) compressing and encrypting data, (e) inserting checkpoints so a long transfer can resume.
Step 1: Separate host-to-host from process-to-process delivery.
Try it on paper first.
Example 3: Counting collision and broadcast domains
numerical
A router has two interfaces. Interface 1 connects to a switch that has 4 hosts. Interface 2 connects to a hub that has 3 hosts. How many collision domains and broadcast domains are there?
Step 1: Count the switch ports in use.
Try it on paper first.
Example 4: What a router changes in a passing packet
conceptual
Host A sends a TCP segment to host B. The path is A → switch → router → B. What does the switch do to the frame, and what does the router change?
Step 1: Up to which layer does the switch look?
Try it on paper first.
Previous year questions
2 official GATE CSE questions on this topic, newest first.
10 questions: up to 2 official PYQs and original practice questions, with GATE marking (MCQ wrong answers lose marks). Score 60% or more to pass. A new set is drawn each time.
Mark as mastered
Loading your progress…
My revision notes
Notes written by the GATEiit team against the official GATE CSE syllabus; being checked by a reviewer. Updated 2026-11-21. Spotted a mistake? Use Report an issue on any question, or contact us.