T TestsWorld
← All topic guides

Computer Networks: formulas, shortcuts & solved examples

What it is

The OSI (Open Systems Interconnection) model splits network communication into seven layers, each providing services to the layer above and using the layer below. Real networks run the TCP/IP stack, but interviewers use OSI as the shared vocabulary for "where does this protocol or device belong?" questions.

Key rules

The seven layers

# Layer PDU Job Examples
7 Application Data Network services for apps HTTP, DNS, SMTP, FTP
6 Presentation Data Encoding, encryption, compression TLS (often placed here), JPEG, ASCII
5 Session Data Open, manage and close sessions RPC, NetBIOS
4 Transport Segment (TCP) / Datagram (UDP) End-to-end delivery, ports, reliability TCP, UDP
3 Network Packet Logical addressing and routing IP, ICMP, routers
2 Data Link Frame MAC addressing, error detection on a link Ethernet, switches, ARP (between 2 and 3)
1 Physical Bits Signals on the medium Cables, hubs, repeaters

TCP/IP mapping

Application (OSI 5–7), Transport (4), Internet (3), Network Access / Link (1–2).

Encapsulation

Going down the stack, each layer adds its header (Data Link also adds a trailer). The receiver strips them in reverse order.

Formulas

  • Transmission delay = Packet size (bits) / Bandwidth (bits per second)
  • Propagation delay = Distance / Signal speed (about 2 × 10⁸ m/s in copper or fibre)
  • Efficiency of a frame = Payload / (Payload + all headers and trailers)
  • Usable hosts in a subnet = 2^(32 − prefix) − 2

Shortcuts

  1. Memory line. Top to bottom: "All People Seem To Need Data Processing" (Application, Presentation, Session, Transport, Network, Data Link, Physical).
  2. Device by address. Works on bits only: hub/repeater (L1). Reads MAC addresses: switch/bridge (L2). Reads IP addresses: router (L3). Reads ports or content: firewall/load balancer (L4–L7).
  3. Port means Transport. Any question mentioning port numbers (80, 443, 22, 53) points to Layer 4, even though the protocol itself lives at Layer 7.

Solved examples

Example 1: Identify the layer

A student in Pune opens a bank's website. Match each event to a layer: (a) the browser's request "GET /login"; (b) the TLS handshake encrypting the page; (c) the router at the ISP choosing the next hop; (d) the laptop's Wi-Fi card writing its MAC address in the frame header.

Solution. (a) Application layer (HTTP). (b) Presentation layer in the OSI view, since it handles encryption; in TCP/IP it sits between Application and Transport. (c) Network layer (IP routing). (d) Data Link layer.

Example 2: Header overhead

An application sends 1,000 bytes. TCP adds a 20-byte header, IP adds 20 bytes, and Ethernet adds 18 bytes (14-byte header plus 4-byte trailer). What is the frame efficiency?

Solution. Total frame = 1,000 + 20 + 20 + 18 = 1,058 bytes. Efficiency = 1,000 / 1,058 ≈ 94.5%. With a larger 1,460-byte payload the total is 1,518 bytes and efficiency rises to about 96.2%, which is why bulk transfers use full-size segments.

Example 3: Transmission versus propagation delay

A 1,500-byte packet is sent over a 10 Mbps link spanning 2,000 km (roughly Delhi to Bengaluru by cable). Signal speed is 2 × 10⁸ m/s.

Solution.

  • Transmission delay = (1,500 × 8) / (10 × 10⁶) = 12,000 / 10,000,000 = 1.2 ms.
  • Propagation delay = 2,000,000 / (2 × 10⁸) = 10 ms.

Here distance dominates, so increasing bandwidth would barely reduce total delay.

Example 4: Usable hosts

A college lab is assigned 192.168.10.0/26. How many hosts can it address?

Solution. Host bits = 32 − 26 = 6. Addresses = 2⁶ = 64. Subtract the network and broadcast addresses: 62 usable hosts. This is a Layer 3 question because it concerns IP addressing.

Common mistakes

  1. Putting switches at Layer 3 by default. A plain switch is Layer 2; only "Layer 3 switches" perform routing.
  2. Calling a TCP PDU a packet. At Transport it is a segment; "packet" refers to Layer 3.
  3. Thinking OSI is what the internet runs. OSI is a reference model; the internet runs TCP/IP.
  4. Mixing up MAC and IP roles. MAC addresses change at every hop; source and destination IP addresses normally stay the same end to end (NAT is the exception).
  5. Adding transmission and propagation delay wrongly in units. Convert bytes to bits and kilometres to metres before dividing.

Practice now: https://www.testsworld.com/mocks

Ready to practise Computer Networks?
Take a free mock test

Related guides