Skip to main content

Computer Networks

OSI & TCP/IP Layering

Start Computer Networks here: learn which layer does what, the name of the data unit at each layer, how headers are added during encapsulation, and how to compute simple delay and overhead numbers.

~3 hrs ~0.5–1 marks · Moderate 10 samples · 8 practice · 9 cards

GATE CSE Computer Networks layering — OSI 7-layer and TCP/IP models, layer responsibilities, PDU names, encapsulation overhead, network devices by layer and store-and-forward delay calculations, with sample questions, flashcards and drills.

Learning outcomes

  • List the OSI layers and map them to the TCP/IP model
  • Name the PDU, typical protocols and devices at each layer
  • Compute encapsulation overhead and header efficiency
  • Calculate store-and-forward and packet-switching delay

OSI and TCP/IP reference models

  • A LAYERED architecture splits communication into layers; each layer offers a SERVICE to the layer above and uses the service of the layer below. A PROTOCOL is the set of rules between PEER layers on two machines; the INTERFACE is how adjacent layers on one machine talk.
  • OSI has SEVEN layers (top to bottom): Application, Presentation, Session, Transport, Network, Data Link, Physical. Mnemonic: All People Seem To Need Data Processing.
  • The TCP/IP (Internet) model has FOUR layers: Application, Transport, Internet, and Network Access (Link). Application covers the OSI application + presentation + session layers; Link covers OSI data link + physical. A popular FIVE-layer teaching model splits Link into Data Link and Physical.
  • Physical: raw bit transmission, voltage, cable, hubs and repeaters. Data link: framing, MAC addressing, error detection, flow control between ADJACENT nodes (hop-to-hop), bridges and switches. Network: logical addressing and routing across networks (source-to-destination packet delivery), routers.
  • Transport: process-to-process (end-to-end) delivery using port numbers, reliability, flow and congestion control (TCP) or lightweight datagram service (UDP). Session: dialog control and synchronisation (checkpoints). Presentation: translation, encryption, compression. Application: user-facing protocols (HTTP, SMTP, DNS, FTP).
  • CONNECTION-ORIENTED service sets up a connection first (TCP, virtual circuits) and gives ordered delivery; CONNECTIONLESS service sends each message independently (UDP, IP datagrams). IP itself is connectionless, best-effort and unreliable.
  • Design ideas: layers are independent (a layer can be replaced without changing the others), every layer adds overhead, and OSI is a REFERENCE model (clean service / interface / protocol split) whereas TCP/IP grew out of working protocols. A layer-3 switch is a switch with routing; a GATEWAY converts protocols and can work at any layer up to the application layer.
  • Domains: each hub is one collision domain; every switch PORT is its own collision domain; each router INTERFACE (or each VLAN) is its own broadcast domain. Example: an 8-port switch with 8 hosts gives 8 collision domains and 1 broadcast domain; an 8-port hub gives 1 collision domain and 1 broadcast domain; a router with 4 LAN interfaces gives 4 broadcast domains.
Layer (OSI)PDUExamplesDevices
Application / Presentation / Sessiondata / messageHTTP, SMTP, DNS, FTP, TLSgateway, proxy
Transportsegment (TCP), datagram (UDP)TCP, UDPnone (end hosts)
Networkpacket / datagramIP, ICMP, OSPF, BGProuter, layer-3 switch
Data linkframeEthernet, PPP, 802.11, ARPbridge, switch, NIC
Physicalbitcables, signals, 100BASE-Thub, repeater

Worked example

Problem. At which layer do a router, a switch and a hub work, and which of them separates broadcast domains?

Solution. Router = network layer, switch/bridge = data link layer, hub/repeater = physical layer. Only the ROUTER separates broadcast domains (a switch separates collision domains but forwards broadcasts; a hub does neither).

Seven OSI layers placed beside the four TCP/IP layers with typical protocols and PDU names at each level
OSI (7 layers) vs TCP/IP (4 layers): which OSI layers merge, and the protocol, PDU and device at each level.

Encapsulation, overheads and delay

  • ENCAPSULATION: when data moves down the stack, each layer adds its own HEADER (the data link layer adds a header AND a trailer). At the receiver the headers are removed in reverse order (decapsulation). The payload of one layer is the whole PDU of the layer above.
  • Typical header sizes: TCP 20 bytes (up to 60), UDP 8 bytes, IPv4 20 bytes (up to 60), Ethernet header 14 bytes + 4-byte FCS trailer = 18 bytes (the 8-byte preamble is usually not counted).
  • Header efficiency (useful fraction) = payload / (payload + all headers + trailers). Small payloads are very inefficient because of fixed headers.
  • Hop-to-hop vs end-to-end: layers 1 to 2 work between adjacent nodes; layer 3 gives end-to-end addressing but every router handles each packet; layers 4 and above work only in the end hosts.
  • FOUR delays on a packet-switched path: PROCESSING (examine header, check errors), QUEUING (waiting for the output link), TRANSMISSION (push all bits onto the link = L/R) and PROPAGATION (travel across the medium = d/s). Total nodal delay is the sum of the four.
  • STORE-AND-FORWARD: a router must receive the whole packet before forwarding it. One packet of L bits over N links of rate R takes N * (L / R) in transmission time. Splitting a message into P packets pipelines the transfer.
  • LINK CAPACITY (bits in flight) = R * Tp: the number of bits that fit on the wire at once. If Tp > Tt the first bit reaches the far end before the last bit has left the sender. Typical signal speed is 2 x 10^8 m/s in copper and fibre (3 x 10^8 m/s in vacuum).
  • CIRCUIT vs PACKET switching: a circuit-switched call pays a SET-UP time, then sends at a fixed rate with no queuing (total = setup + L/R + Tp); packet switching has no set-up and shares links statistically, so queuing delay appears but utilisation is higher. A virtual circuit is a packet-switched path set up once with a short VC identifier per hop.
  • END-TO-END THROUGHPUT of a path is the rate of the BOTTLENECK link (the minimum), not the sum or average. If n equal flows share a bottleneck of rate R each gets R / n.

Formulas to remember

  • Transmission delay Tt = L / R (bits / bits-per-second)
  • Propagation delay Tp = d / s (distance / signal speed)
  • Bits in flight on a link = R * Tp; path throughput = min over links of R
  • One packet over N store-and-forward links: N * L / R (ignoring Tp and queuing)
  • Message of P equal packets over N links: (N + P - 1) * L / R
  • Header efficiency = payload / (payload + headers)

Worked example

Problem. An application sends 1000 bytes using TCP over IP over Ethernet. Find the frame size and the header efficiency. Then find the time to push a 10-packet message (1000 bits per packet) across 3 store-and-forward links of 1 Mbps.

Solution. Frame = 1000 + 20 (TCP) + 20 (IP) + 18 (Ethernet) = 1058 bytes; efficiency = 1000 / 1058 = 94.5%. For the message: L/R = 1000 / 10^6 = 1 ms, so time = (N + P - 1) * L/R = (3 + 10 - 1) * 1 ms = 12 ms. Delay check: a 1500-byte packet (12,000 bits) on a 10 Mbps, 2000 km link (signal speed 2 x 10^8 m/s) has Tt = 12,000 / 10^7 = 1.2 ms and Tp = 2 x 10^6 / 2 x 10^8 = 10 ms, so one link takes 11.2 ms and the wire holds 10^7 * 0.01 = 100,000 bits. Because Tp > Tt the first bit arrives before the last bit is sent.

Data gaining TCP, IP and Ethernet headers and trailer as it moves down the layers, growing from 1000 to 1058 bytes
Encapsulation of 1000 bytes: +20 TCP, +20 IP, +14 Ethernet header, +4 FCS = 1058-byte frame, 94.5% efficiency.

Addresses, scope and what a router changes

  • A packet is addressed at THREE levels at once: PORT (16 bits, identifies the process), IP ADDRESS (32 bits, identifies the host interface) and MAC ADDRESS (48 bits, identifies the NIC on the current link). Layers 1 and 2 work hop by hop, layer 3 gives end-to-end addresses but is processed at every router, layers 4 and above exist only in the end hosts.
  • At every router the incoming frame is DECAPSULATED, the IP header is read, TTL is decremented and the header checksum recomputed, the next hop is chosen from the forwarding table, and the packet is re-encapsulated in a NEW frame with new source and destination MAC addresses and a new FCS. IP source and destination and the port numbers are unchanged (NAT is the exception).
  • ARP finds the MAC address of the NEXT HOP on the same LAN: the sender broadcasts "who has IP x?" and the owner replies by unicast. When the destination is outside the subnet, the host ARPs for its DEFAULT GATEWAY, never for the remote host. For a path with L links the frame is built L times.
  • MTU is the largest NETWORK-layer packet a link can carry, i.e. the frame payload (1500 bytes on Ethernet). The maximum Ethernet frame is 1518 bytes because the 14-byte header and 4-byte FCS are added around that payload.
  • Reliability is an END-TO-END responsibility (TCP checks the whole path); link-layer error control only improves performance on lossy links such as wireless.
Header fieldLayerChanged at a router?
Source / destination MAC2yes, rewritten at every hop
Frame CRC (FCS)2yes, recomputed for the new frame
Source / destination IP3no (NAT rewrites them)
TTL and IP header checksum3yes, TTL - 1 and checksum recomputed
TCP / UDP ports and payload4 and upno (NAT rewrites ports; fragmentation splits the payload)

Worked example

Problem. Host A sends a file to host B through routers R1 and R2 (three Ethernet links, rates 10, 4 and 8 Mbps). How many frames are built per packet, which ARP lookups are needed and how long does an 8 MB (8 x 10^6 bytes) transfer take, ignoring delays and overhead?

Solution. Each packet is placed in a frame 3 times (by A, R1 and R2) with different MAC addresses each time while the IP addresses stay A and B. At most 3 ARP requests are needed: A asks for the MAC of R1 (its default gateway, not B), R1 asks for R2, R2 asks for B. The path throughput is the bottleneck rate min(10, 4, 8) = 4 Mbps, so the time is 64 x 10^6 bits / 4 x 10^6 bps = 16 s.

Table of layers with their identifiers, hop-to-hop or end-to-end scope and key jobs, plus what changes at a router
Port, IP and MAC addresses by layer, hop-by-hop vs end-to-end scope, and which header fields a router rewrites.

Exam tips

  • A router rewrites MAC addresses and TTL at every hop; IP addresses and ports stay the same (without NAT).
  • Memorise PDU names: bit, frame, packet, segment (TCP) or datagram (UDP), message/data.
  • Router = layer 3, switch/bridge = layer 2, hub/repeater = layer 1; only routers split broadcast domains.
  • Transport is the lowest end-to-end layer; layers below it work hop by hop.
  • For pipelined store-and-forward use (N + P - 1) * L/R; for a single packet use N * L/R.
  • ARP resolves IP to MAC (layer 2/3 boundary), ICMP rides on IP (network layer), and ping uses ICMP echo.
Exam pattern · 10 questions

GATE sample questions & answers

10 GATE-style MCQs for OSI & TCP/IP Layering with full explanations. Attempt each question before revealing the answer.

Q1 Classic GATE layering

Which layer of the OSI model is responsible for routing packets from source to destination across multiple networks?

  • A) Data link
  • B) Network
  • C) Transport
  • D) Session
Show answer & explanation

Answer: B

Routing and logical addressing are functions of the network layer; the data link layer only moves frames between adjacent nodes.

Q2

The protocol data unit (PDU) of the TCP protocol is called a:

  • A) bit
  • B) frame
  • C) packet
  • D) segment
Show answer & explanation

Answer: D

TCP data units are segments; UDP data units are datagrams; the network layer unit is a packet; the data link layer unit is a frame.

Q3

How many OSI layers lie strictly between the data link layer and the application layer?

  • A) 2
  • B) 3
  • C) 4
  • D) 5
Show answer & explanation

Answer: C

Between data link (2) and application (7) are network, transport, session and presentation = 4 layers.

Q4

A network switch (learning bridge) operates at which OSI layer?

  • A) Physical
  • B) Data link
  • C) Network
  • D) Transport
Show answer & explanation

Answer: B

A switch forwards frames using MAC addresses, which is a data link layer function.

Q5

An application sends 500 bytes using TCP over IP over Ethernet. With TCP header 20 bytes, IP header 20 bytes and Ethernet header plus trailer 18 bytes, the size of the frame on the wire is:

  • A) 538 bytes
  • B) 558 bytes
  • C) 578 bytes
  • D) 598 bytes
Show answer & explanation

Answer: B

500 + 20 + 20 + 18 = 558 bytes.

Q6

Which is the lowest layer that provides end-to-end (process-to-process) communication between the two hosts?

  • A) Physical
  • B) Data link
  • C) Transport
  • D) Presentation
Show answer & explanation

Answer: C

The transport layer is the first layer implemented only in the end hosts and it uses port numbers to identify processes.

Q7

A 1500-byte packet crosses 3 store-and-forward links, each of rate 12 Mbps. Ignoring propagation and queuing delay, the total transmission time is:

  • A) 1 ms
  • B) 3 ms
  • C) 12 ms
  • D) 36 ms
Show answer & explanation

Answer: B

L = 1500 * 8 = 12000 bits; L/R = 12000 / (12 * 10^6) = 1 ms per link; 3 links give 3 ms.

Q8

A message is split into 5 equal packets and sent over 4 store-and-forward links. If one packet takes 2 ms to transmit on one link, the time to deliver the whole message (ignoring propagation) is:

  • A) 8 ms
  • B) 10 ms
  • C) 16 ms
  • D) 20 ms
Show answer & explanation

Answer: C

(N + P - 1) * L/R = (4 + 5 - 1) * 2 ms = 16 ms.

Q9

The application layer of the TCP/IP model corresponds to which OSI layers?

  • A) Application only
  • B) Application and presentation
  • C) Application, presentation and session
  • D) Transport and session
Show answer & explanation

Answer: C

TCP/IP merges the OSI session, presentation and application layers into a single application layer.

Q10

The ping utility uses ICMP echo messages. ICMP is classified as a protocol of the:

  • A) data link layer
  • B) network layer
  • C) transport layer
  • D) application layer
Show answer & explanation

Answer: B

ICMP is carried inside IP datagrams and reports network-layer errors, so it belongs to the network (Internet) layer.

Topic drill · 8 questions

8 practice questions — OSI & TCP/IP Layering

Extra page-specific practice beyond the GATE samples. Attempt all 8, then reveal answers to check your reasoning.

P1

Which OSI layer is responsible for data translation, encryption and compression?

  • A) Application
  • B) Presentation
  • C) Session
  • D) Transport
Show answer & explanation

Answer: B) Presentation

Syntax translation, encryption and compression are presentation-layer services.

P2

Dialog control and synchronisation with checkpoints are functions of which layer?

  • A) Session
  • B) Transport
  • C) Network
  • D) Data link
Show answer & explanation

Answer: A) Session

The session layer manages dialogs and inserts synchronisation points.

P3

A hub operates at which layer?

  • A) Physical
  • B) Data link
  • C) Network
  • D) Transport
Show answer & explanation

Answer: A) Physical

A hub just repeats electrical signals on all ports; it has no knowledge of frames or addresses.

P4

A host sends 1460 bytes of TCP data over IP over Ethernet (TCP 20, IP 20, Ethernet 18 bytes of header and trailer). The header efficiency is approximately:

  • A) 90.5%
  • B) 96.2%
  • C) 98.6%
  • D) 100%
Show answer & explanation

Answer: B) 96.2%

Frame = 1460 + 58 = 1518 bytes; 1460 / 1518 = 0.9618, about 96.2%.

P5

A 1 Mb message is sent as 10 packets of 100 kb over 2 store-and-forward links of 1 Mbps (ignore propagation). The total time is:

  • A) 1.0 s
  • B) 1.1 s
  • C) 1.2 s
  • D) 2.0 s
Show answer & explanation

Answer: B) 1.1 s

L/R = 100 kb / 1 Mbps = 0.1 s; (N + P - 1) * 0.1 = (2 + 10 - 1) * 0.1 = 1.1 s.

P6

Which of the following protocol-to-layer pairings is correct?

  • A) ARP - transport layer
  • B) UDP - network layer
  • C) HTTP - application layer
  • D) Ethernet - network layer
Show answer & explanation

Answer: C) HTTP - application layer

HTTP is an application-layer protocol; UDP is transport, Ethernet is data link, and ARP works between the link and network layers.

P7

How many layers does the (original) TCP/IP model have?

  • A) 3
  • B) 4
  • C) 5
  • D) 7
Show answer & explanation

Answer: B) 4

Application, Transport, Internet and Network Access (Link). The 5-layer version splits the link layer.

P8

Which device separates broadcast domains?

  • A) Repeater
  • B) Hub
  • C) Layer-2 switch
  • D) Router
Show answer & explanation

Answer: D) Router

Routers do not forward broadcast frames or limited broadcasts, so each router interface is its own broadcast domain.

Topic FAQs

What is the difference between the OSI and TCP/IP models?

OSI is a 7-layer reference model; TCP/IP has 4 layers (or 5 in the teaching version) and merges application, presentation and session into one application layer and physical + data link into the link layer. TCP/IP is the protocol suite actually used on the Internet.

Which layer is responsible for routing and which for process-to-process delivery?

The network layer does routing and logical (IP) addressing between hosts; the transport layer delivers data between processes using port numbers.

What are the PDU names at each layer?

Application: data/message; transport: segment (TCP) or datagram (UDP); network: packet/datagram; data link: frame; physical: bits.

Why is the pipelined store-and-forward formula (N + P - 1) * L/R?

The first packet needs N link-times to reach the destination; each of the remaining P - 1 packets then arrives one link-time later, so the total is N + (P - 1) link-times of L/R each.

Quick revision · 9 cards

9 flashcards — OSI & TCP/IP Layering

Hover a card to reveal the answer with a 3D flip. On touch devices, tap the card or use Show answer.

Q1 List the OSI layers from top to bottom.
Q2 PDU names by layer?
Q3 Which devices work at layers 1, 2 and 3?
Q4 Which layer adds both a header and a trailer?
Q5 Hop-to-hop vs end-to-end layers?
Q6 What are the four components of nodal delay?
Q7 Store-and-forward time for P packets over N links?
Q8 Which OSI layer handles encryption and compression?
Q9 Is IP connection-oriented or connectionless?