Computer Networks chapters (5)
  1. 01Reference Models & Network Layers
  2. 02Data Link Layer & MAC Protocols
  3. 03Network Layer & IP Addressing
  4. 04Transport Layer (TCP & UDP)
  5. 05Application Layer Protocols & Security

Chapter 01 · CN

Reference Models & Network Layers

4 topics · 1 sections · beginner-friendly study notes · Updated

Share with friends:WhatsAppTelegram

Embed on your site

Free for teachers, schools and blogs. Please keep the attribution link.

Preview

Layered models split networking into manageable pieces.

This chapter covers the seven OSI layers, the TCP/IP model (4 or 5 layers), how encapsulation adds headers on the way down, and which device operates at which layer.

Every networking exam starts with layers.

Knowing the PDU, address type and device at each layer answers a large share of GATE and CCNA questions directly.

Troubleshooting (is it a cable, MAC, IP, port or application problem?

), designing networks and reading packet captures in Wireshark.

1

Network Topologies

A network topology is the arrangement of nodes and links. Physical topology describes the actual cabling; logical topology describes how data flows. Basic types: bus, ring, star, mesh (full and partial), tree and hybrid.

In short: The shape of the network: a shared line, a circle, a hub-and-spokes, or everyone connected to everyone.

Think about it

Link-count and fault-tolerance questions are standard in GATE and semester exams, and topology decides cost, reliability and which MAC protocol is used.

Bus: all nodes share one backbone cable with terminators; cheap, but a cable break stops the network and collisions need CSMA/CD; links = 1 backbone.

Ring: each node connects to exactly two neighbours; data circulates (token ring/FDDI); one break stops a single ring unless a dual ring is used; links = n.

Star: every node connects to a central hub/switch; easy to add nodes and isolate faults but the centre is a single point of failure; links = n.

Full mesh: every pair of nodes has a dedicated link; links = n(n−1)/2, each node needs n−1 ports; very reliable and fast, very costly.

Partial mesh keeps selected links.

Tree: hierarchy of stars on a backbone bus; Hybrid: combination.

Comparison

cabling cost (mesh highest, bus lowest), fault tolerance (mesh best, bus/ring worst), scalability (star/tree best), troubleshooting (star easiest).

Modern Ethernet LANs are physically star (switch) even when logically bus (hub).

Counting: for n devices, star needs n cables, ring needs n cables, bus needs 1 backbone plus n drop lines, full mesh needs n(n−1)/2 cables and n−1 NICs per device.

Key points

  • Physical vs logical topology: Actual cable layout vs the path data signals take.
  • Full mesh: Every node directly connected to every other node.
  • Single point of failure: Component whose failure breaks the whole network (star hub, bus backbone).
  • Full mesh with n = 8 nodes: links = 8×7/2 = 28; ports per node = 7.
  • Star with n = 8 hosts: 8 links; failure of one host link affects only that host, failure of the hub affects all.
  • Topology vs reliability: mesh > star/tree > ring > bus.
2

OSI 7-Layer Model vs TCP/IP

The OSI model divides communication into seven layers from top to bottom: Application (7), Presentation (6), Session (5), Transport (4), Network (3), Data Link (2), Physical (1). Each layer offers services to the layer above and uses services of the layer below.

In short: Think of posting a parcel: write the letter (application), package it (presentation), arrange the dialogue (session), choose end-to-end delivery (transport), route through cities (network), hand to the next truck (data link), and the physical road.

7. Application Layer (HTTP, DNS, SMTP, FTP) — Data Payload 6. Presentation Layer (SSL/TLS Encryption, Compression, MIME) 5. Session Layer (RPC, NetBIOS, Session Checkpointing) 4. Transport Layer (TCP, UDP) — Segments & Port Addressing 3. Network Layer (IPv4, IPv6, ICMP, Routers) — Packets & IP Addresses 2. Data Link Layer (Ethernet, Switches, MAC) — Frames & Error Checking (CRC) 1. Physical Layer (Cables, Fiber, Radio Waves, Hubs) — Raw Bit Streams (0/1)
Reference Models & Network Layers

Think about it

A common vocabulary lets vendors build interoperable products and lets engineers isolate faults by layer.

Physical: transmits raw bits over a medium (voltage, cables, hubs).

Data Link: node-to-node delivery within one link, framing, MAC addressing, error detection, access control.

Network: host-to-host delivery across networks, logical (IP) addressing and routing.

Transport: process-to-process delivery, ports, segmentation, reliability, flow and congestion control.

Session: dialog control, checkpoints, synchronization.

Presentation: translation, encryption and compression.

Application: network services to user programs (HTTP, SMTP, FTP, DNS).

Mnemonic bottom-up: Please Do Not Throw Sausage Pizza Away.

Protocol Data Units: bits (L1), frame (L2), packet/datagram (L3), segment (TCP) or datagram (UDP) (L4), data/message (L5-7).

Key points

  • PDU: Protocol data unit: the unit of data at a layer (frame, packet, segment).
  • Service access point: Interface where a layer gives services to the layer above.
  • Peer protocol: Logical communication between the same layer on two hosts.
  • OSI vs TCP/IP: OSI has 7 layers, TCP/IP has 4 (or 5); OSI separates Presentation and Session, TCP/IP folds them into Application; OSI was designed before the protocols (protocol-independent, strict layers), TCP/IP was designed around working protocols; OSI Network layer supports connection-oriented and connectionless service while TCP/IP Internet layer is connectionless only (Transport supports both: TCP and UDP).
  • Mapping: OSI 7,6,5 → TCP/IP Application; OSI 4 → Transport; OSI 3 → Internet; OSI 2,1 → Network Access.
  • Address used: L2 = MAC (physical), L3 = IP (logical), L4 = port number.
  • OSI is a reference model (never fully implemented); TCP/IP is the protocol suite actually used.
3

TCP/IP Protocol Architecture

The TCP/IP model has four layers: Application, Transport, Internet and Network Access (Link). A five-layer teaching version splits the last into Data Link and Physical.

In short: A shorter map of the same journey, built around the protocols the Internet really uses.

Layers pass data down & up

Think about it

Real network programming, configuration and troubleshooting use TCP/IP concepts.

Mapping: OSI Application + Presentation + Session → TCP/IP Application; OSI Transport → Transport (TCP, UDP); OSI Network → Internet (IP, ICMP, ARP sits between L2 and L3); OSI Data Link + Physical → Network Access (Ethernet, Wi-Fi).

Key differences from OSI: TCP/IP merges the top three layers, grew from working protocols rather than a theoretical design, and is connectionless at the internet layer with a choice of connection-oriented (TCP) or connectionless (UDP) transport, while OSI Network layer supports both modes and Transport is connection-oriented.

IP delivers best-effort (no guarantee of delivery, order or duplication protection).

Key points

4

PDU Encapsulation

Encapsulation is the process in which each layer on the sender adds its own header (and sometimes a trailer) around the data received from the layer above. The receiver performs decapsulation, removing headers layer by layer.

In short: Each layer puts the message in a new envelope with its own address label; the receiver opens the envelopes one by one.

Encapsulation: hide inner details

Think about it

Explains how headers carry addresses and control information for each layer.

Application data → Transport adds header (ports, sequence numbers) giving a segment → Network adds IP header giving a packet → Data Link adds header (MAC) and trailer (FCS) giving a frame → Physical sends bits.

Typical sizes: TCP header 20 bytes minimum, UDP header 8 bytes, IPv4 header 20 bytes minimum, Ethernet header 14 bytes plus 4-byte FCS.

Overhead reduces efficiency: efficiency = payload / total bytes sent.

Routers decapsulate to layer 3 and re-encapsulate with a new L2 header at each hop while the IP addresses stay the same (except with NAT); MAC addresses change hop by hop.

Key points

  • Header / trailer: Control information placed before / after the payload.
  • Payload: Data carried inside the PDU of a layer.
  • MTU: Maximum transmission unit: largest payload a link layer frame can carry (1500 bytes for Ethernet).
  • End-to-end: source and destination IP stay constant; source and destination MAC change at every hop.
5

Network devices by layer

Hubs and repeaters work at the Physical layer, bridges and switches at the Data Link layer, routers at the Network layer, and gateways, proxies and application firewalls at higher layers.

In short: Hub repeats bits, switch forwards frames by MAC, router forwards packets by IP.

Think about it

Device roles decide the collision and broadcast domain counts, a staple numerical.

Repeater/hub: regenerates signals; a hub is a multi-port repeater and creates one collision domain and one broadcast domain.

Bridge/switch: learns MAC addresses, forwards only to the correct port; each switch port is its own collision domain, but all ports are in one broadcast domain (unless VLANs are used).

Router: connects different networks, separates broadcast domains (each interface is its own broadcast domain and collision domain), uses IP routing tables.

Layer-3 switch: switching plus routing.

Gateway: translates between different protocol stacks.

Domain counting rule: collision domains = number of switch ports (or hub segments) plus router interfaces; broadcast domains = number of router interfaces (VLANs separate switch domains).

Key points

  • Collision domain: Segment where simultaneous transmissions collide.
  • Broadcast domain: Set of nodes that receive a broadcast frame.
  • VLAN: Logical grouping that splits a switch into separate broadcast domains.
  • Hub: L1, 1 collision domain. Switch: L2, collision domain per port. Router: L3, separates broadcast domains.

Solved examples

Example 01 · Basic

An application sends 1000 bytes of data over TCP/IPv4 on Ethernet (headers: TCP 20, IP 20, Ethernet header 14 + trailer 4). Find the frame size and the efficiency.

Given Data:
  • Payload = 1000 bytes
  • TCP 20, IP 20, Ethernet header 14, FCS 4
Required To Find:

Total bytes on the wire and efficiency

Formula Applied:—
Step-by-Step Solution:
Step 1: Segment = 1000 + 20 (TCP) = 1020 bytes.
Step 2: Packet = 1020 + 20 (IP) = 1040 bytes.
Step 3: Frame = 1040 + 14 (header) + 4 (FCS) = 1058 bytes.
Step 4: Efficiency = 1000 / 1058 ≈ 0.945 = 94.5%.
Final Answer: Frame = 1058 bytes; efficiency ≈ 94.5% (overhead 58 bytes).

Approach note: Add headers layer by layer, from transport down to data link.

Example 02 · Intermediate

One router has 3 interfaces, each connected to a separate switch. Every switch connects 4 hosts plus its uplink to the router (5 used ports per switch). Count the collision domains and broadcast domains.

Given Data:
  • 3 router interfaces, one per LAN
  • Each switch: 4 host ports + 1 uplink port
Required To Find:

Collision domains and broadcast domains

Formula Applied:—
Step-by-Step Solution:
Step 1: Every link in a switched LAN (host–switch or switch–router) is a separate collision domain.
Step 2: Per LAN: 4 host links + 1 uplink link = 5 collision domains.
Step 3: Three LANs: 3 × 5 = 15 collision domains.
Step 4: Each switch is one broadcast domain and the router separates them, so broadcast domains = 3 (one per router interface).
Final Answer: 15 collision domains and 3 broadcast domains.

Approach note: Collision domains are counted per switch port/link; broadcast domains per router interface (or VLAN).

Example 03 · Basic

Match: (1) end-to-end reliability (2) routing (3) MAC addressing (4) HTTP. To which OSI layers?

Given Data:
    Required To Find:

    Four layer names

    Formula Applied:—
    Step-by-Step Solution:
    Step 1: Reliability/ports → Transport
    Step 2: Routing/IP → Network
    Step 3: MAC → Data Link
    Step 4: HTTP → Application
    Final Answer: 1 Transport, 2 Network, 3 Data Link, 4 Application

    Approach note: Remember: Application messages, Transport segments, Network packets, Data-link frames.

    Example 04 · Intermediate

    A 1500-byte IP packet crosses 3 routers (4 hops). Ignoring extras, how many times is the IP header examined by forwarding devices, and how many times is the Ethernet header rewritten?

    Given Data:
      Required To Find:

      Counts

      Formula Applied:—
      Step-by-Step Solution:
      Step 1: Each router examines the IP header to forward → 3 times
      Step 2: Ethernet/MAC header is rewritten on every hop → 4 hops
      Final Answer: IP header examined at each router (3 times along the path); link-layer header rewritten each of the 4 hops.

      Approach note: IP is end-to-end addressing; MAC is hop-by-hop.

      Real-world applications

      Networks

      Using Reference Models & Network Layers in real projects

      Troubleshooting (is it a cable, MAC, IP, port or application problem?), designing networks and reading packet captures in Wireshark.

      Mechanism: Write small programs, read errors carefully, then grow complexity only after the basics are solid.

      Common mistakes

      ❌ Myth: A switch breaks broadcast domains.

      Why this is wrong: A switch forwards broadcast frames out of all ports, so all hosts stay in the same domain.

      ✅ Verified Truth: Switches break collision domains; routers (or VLANs) break broadcast domains.

      ⚠️ Exam Tip: Memorise: switch = more collision domains, router = more broadcast domains.

      ❌ Myth: MAC and IP addresses both remain unchanged from source to destination.

      Why this is wrong: The MAC address is link-local and is replaced at every hop; the IP address stays end to end.

      ✅ Verified Truth: IP is end to end; MAC is hop to hop.

      ⚠️ Exam Tip: Draw two routers and show MAC rewriting.

      ❌ Myth: OSI is the model the Internet runs on.

      Why this is wrong: The Internet uses the TCP/IP suite; OSI is mainly a reference and teaching model.

      ✅ Verified Truth: OSI = reference; TCP/IP = implemented.

      ⚠️ Exam Tip: Mention both when asked to compare.

      Revision notes

      Layered models split networking into manageable pieces. This chapter covers the seven OSI layers, the TCP/IP model (4 or 5 layers), how encapsulation adds headers on the way down, and which device operates at which layer.

      High-Yield Quick Revision Points

      1. OSI bottom-up: Physical, Data Link, Network, Transport, Session, Presentation, Application
      2. PDUs: bit, frame, packet, segment/datagram, data
      3. Address types: MAC (L2), IP (L3), port (L4)
      4. TCP/IP: Application, Transport, Internet, Network Access
      5. Hub L1, switch L2, router L3
      6. MAC changes per hop; IP is end to end

      Practice questions

      Question 1 · MCQ (GATE)

      Which OSI layer is responsible for process-to-process delivery?

      Question 2 · MCQ (GATE / CCNA)

      A router operates at which layer?

      Question 3 · MCQ (GATE)

      The PDU at the Data Link layer is called a:

      Question 4 · MCQ (GATE)

      Which layer handles encryption and compression in the OSI model?

      Question 5 · MCQ (CCNA)

      How many broadcast domains are there if a single router with 4 active interfaces connects four switched LANs?