optional · CSS study notes
Network Layer
🧭
On this page — click any heading below to jump straight to it. ⬅️ Back to P-II.II. Computer Communications & Networks
OSI Layer: Network Layer (L3)
Definition
The Network Layer (OSI Layer 3) is responsible for logical addressing and routing — moving packets from a source host to a destination host, potentially across many intermediate networks, independent of the physical topology of any one of them. It provides host-to-host delivery, distinct from the transport layer's process-to-process delivery.
Core Functions
- Logical addressing — assigns a network-wide unique address (IP) to every host, independent of physical (MAC) address, so routing scales across heterogeneous physical networks.
- Routing — path selection: determining the best next hop toward a destination using routing tables built statically or via dynamic routing protocols.
- Forwarding — the actual per-packet action of moving a packet from an input interface to the correct output interface based on the routing table, performed by every router hop-by-hop.
- Fragmentation and reassembly — splitting a packet that exceeds a link's MTU (Maximum Transmission Unit) into smaller fragments, reassembled at the destination.
- Error and control reporting — via ICMP, though ICMP itself does not guarantee delivery.
Types of IP Addressing
IPv4 (32-bit)
- Written in dotted-decimal notation (four octets, e.g., 192.168.1.1); total address space ≈ 4.3 billion, now practically exhausted for fresh global allocation.
- Classful addressing (historical) — addresses divided into fixed classes:
| Class | Leading Bits | Range (1st octet) | Default Mask | Use |
|---|---|---|---|---|
| A | 0 | 1–126 | /8 | Very large networks |
| B | 10 | 128–191 | /16 | Medium networks |
| C | 110 | 192–223 | /24 | Small networks |
| D | 1110 | 224–239 | N/A | Multicast |
| E | 1111 | 240–255 | N/A | Reserved/experimental |
- Classless Inter-Domain Routing (CIDR) — the modern replacement for rigid classes; a network is described as
address/prefix-length(e.g.,192.168.1.0/26), allowing arbitrary-size subnets and far more efficient address allocation ("supernetting"/"subnetting" as needed). - Address types: Unicast (one specific host), Broadcast (all hosts on a local network, e.g.,
255.255.255.255), Multicast (a defined group of hosts, Class D range).
IPv6 (128-bit) — see the dedicated IPv6 page for full detail; introduced primarily to solve IPv4 exhaustion.
Delivery Types at the Network Layer
- Host-to-host delivery (Network layer) — moving a packet from the originating machine to the destination machine, potentially through many routers.
- Contrast with node-to-node delivery (Data Link layer, one physical hop) and process-to-process delivery (Transport layer, using ports) — this three-way distinction is a classic exam question.
Numericals
Q1 — Subnetting
Given network 192.168.10.0/24, required: 4 equal subnets.
- Borrow 2 bits from the host portion → new mask =
/26(255.255.255.192) - Each subnet has 2⁶ = 64 addresses (62 usable after network + broadcast)
- Subnets:
192.168.10.0/26,.64/26,.128/26,.192/26
Q2 — Usable hosts per subnet
For a /28 subnet:
- Host bits = 32 − 28 = 4 → total addresses = 2⁴ = 16
- Usable hosts = 16 − 2 (network + broadcast) = 14 hosts
Q3 — Fragmentation
Packet payload = 4,000 bytes, link MTU = 1,500 bytes, IP header = 20 bytes.
- Usable payload per fragment = 1,500 − 20 = 1,480 bytes
- Number of fragments = ⌈4,000 ÷ 1,480⌉ = 3 fragments
CSS Exam Angle
- This is the base topic for the entire "Network Layer family" (IPv6, NAT, ICMP, routing protocols) — get IPv4 classful addressing and CIDR subnetting completely solid, since sub-questions build on it.
- A subnetting numerical is very likely — practice converting a required host/subnet count into the correct prefix length quickly.
- Explicitly state the host-to-host vs process-to-process vs node-to-node three-way distinction; it is a favourite short-question format.
Example
When a packet travels from a computer in Islamabad to a server abroad, the network layer at each router along the path reads the destination IP address and forwards the packet toward the next hop — this hop-by-hop forwarding, repeated across possibly a dozen routers, is the network layer in action end to end.
Likely Questions
- Explain the functions of the network layer and describe IPv4 addressing with its classes.
- What is CIDR and how does it improve upon classful addressing?
- Given a network address and required number of subnets, calculate the subnet mask and usable hosts per subnet.
- Differentiate host-to-host, node-to-node, and process-to-process delivery.
📜 Past-Paper Questions & Structured Answers
Questions are paraphrased; answer focus is suggested guidance, not an official marking scheme.
2017 · Paper-II · Q3(c) · 6 marks
Question (paraphrased): Determine usable and broadcast addresses for 10.5.118.3 with mask 255.255.240.0.
Answer focus: Convert mask, locate block, show addresses and host count.
Prefix: 255.255.240.0 has 20 network bits, so it is /20 and leaves 12 host bits.
Block: third-octet step = 256−240 = 16. The value 118 lies in the 112–127 block. Equivalently, 118 AND 240 = 112.
| Result | Address / calculation |
|---|---|
| Network | 10.5.112.0 |
| Next network | 10.5.128.0 |
| Broadcast | 10.5.127.255 |
| First usable | 10.5.112.1 |
| Last usable | 10.5.127.254 |
| Usable host count | 2¹²−2 = 4,094 |
The network identifier and all-host-bits-one broadcast address are excluded from the ordinary usable host range.
2020 · Paper-II · Q4(b) · 6 marks
Question (paraphrased): Find subnet and usable-host counts for 172.23.0.0/23.
Answer focus: State the parent-prefix assumption before counting subnet bits.
Assumption: interpret this classful-style question as subnetting the original Class B block 172.23.0.0/16 into /23 subnets. The /23 notation alone does not specify a parent block.
- Borrowed network bits = 23−16 = 7.
- Number of /23 subnets inside /16 = 2⁷ = 128.
- Host bits in each /23 = 32−23 = 9.
- Addresses per subnet = 2⁹ = 512; usable hosts = 512−2 = 510.
- Mask = 255.255.254.0; third-octet blocks advance by 2. First block: network 172.23.0.0, broadcast 172.23.1.255, usable 172.23.0.1–172.23.1.254.
Qualification: 126 subnets comes from an obsolete rule excluding all-zero/all-one subnets; the modern count is 128. Under a strict CIDR reading, the supplied /23 is one network and further subdivision requires a new prefix, so its subnet count is under-specified.
2023 · Paper-II · Q5(b) · 5 marks
Question (paraphrased): If the Class B network field occupied 20 bits, how many networks could exist?
Answer focus: Account for the fixed class prefix, then calculate.
Class B prefix: the leading two bits are fixed as 10; these identify the class and do not vary between networks.
Variable network bits: 20−2 = 18.
Number of networks: 2¹⁸ = 262,144.
For comparison, the original 16-bit network portion allowed 16−2 = 14 variable bits, or 16,384 networks. The extra four bits multiply the network count by 16. The remaining 12 bits form the host field. This is a hypothetical classful calculation, not current CIDR allocation practice.
2023 · Paper-II · Q3(b) · 7 marks
Question (paraphrased): Must strict source-routing information be copied into every IPv4 fragment? Explain.
Answer focus: Direct answer, independent forwarding, option rule and failure if omitted.
Yes. Each fragment is a separate IP datagram and must be forwarded along the specified route before reassembly at the destination. Routers cannot assume the first fragment has arrived, or retrieve its routing instructions on behalf of later fragments.
Protocol rule: the IPv4 option type includes a copied flag. Strict Source and Record Route has this flag set, so the option is copied during fragmentation. Its route list and current pointer supply the forwarding information each fragment needs.
Example: a datagram must follow S → R1 → R2 → D. If fragmentation occurs before R2, each fragment must carry the option so it follows the remaining required route. Carrying it only in the first fragment could allow later fragments to follow ordinary routing and violate the strict path.
Fragments also carry identification, offset and more-fragments information for reassembly; these identify fragments but do not replace the routing option. Source routing is often restricted operationally; that does not change the protocol answer. Technical rule: RFC 791
2024 · Paper-II · Q4(c) · 6 marks
Question (paraphrased): Explain IP addresses and subnetting using a city/neighbourhood analogy.
Answer focus: Map the analogy to prefix/host bits and work one subnet example.
Address: an IP address identifies an interface within its addressing scope. Think of a network prefix as a neighbourhood and the remaining bits as a house number. Routers read the destination prefix and forward packets toward that neighbourhood.
Subnet mask: it marks the boundary between network and host bits. For example, dividing 192.168.1.0/24 into /26 creates four blocks: .0–.63, .64–.127, .128–.191 and .192–.255. Each contains 64 addresses, normally 62 usable hosts. In the .64/26 subnet, usable houses are .65–.126 and .127 is the broadcast address.
Purpose: a university can assign separate subnets to departments, contain link-layer broadcast traffic, organise address allocation and route between departments through controlled gateways. Security improves only when access rules are enforced; a subnet boundary alone is not a firewall.
Limit of the analogy: private IP addresses may be reused in different networks, and public addresses may be shared through NAT. Thus every device does not need a globally unique public street address.
2025 · Paper-II · Q1 item 20 · 1 mark
Question: What does DHCP supply to a client?
Answer: A — an IP address, normally leased together with configuration such as subnet mask, gateway and DNS server. DHCP does not assign the interface’s MAC address; MAC addresses can also be locally configured or randomised, so they are not necessarily permanently fixed. Paper