# Q1(a) · Subnet mask

Subject: Computer Networks

Exam: TEE

Reader: https://deep-learning-study-room.vercel.app/cn/#tee/papers/paper-2024-feb-ai-reexam/q1a

Canonical: https://deep-learning-study-room.vercel.app/read/cn/tee/papers/paper-2024-feb-ai-reexam--q1a/

Exact historical variant. Current-syllabus questions solved; excluded topics and source limitations stated.

### Q1(a). Explain why a subnet mask is required in IPv4 addressing. [5 marks]

### Answer

**Definition.** Subnetting divides an address block into smaller prefix-defined blocks. In an ordinary subnet, the network and directed-broadcast addresses bound its usable host range.

**Simple meaning.** Pehle block nikalo; phir first aur last. Uske baad hosts.

Swipe across the diagram to read its labels ↔

![A /24 split into four /26 blocks](https://deep-learning-study-room.vercel.app/cn/fig/subnet-blocks.67a24f46fc.svg)

Diagram: A /24 split into four /26 blocks. Labels: A /24 split into four /26 blocks | A /24 split into four /26 blocks | 1. /26 | First: .0 Last: .63 | Usable: .1 to .62 | 2. /26 | First: .64 Last: .127 | Usable: .65 to .126 | 3. /26 | First: .128 Last: .191 | Usable: .129 to .190 | 4. /26 | First: .192 Last: .255 | Usable: .193 to .254 | Each block: 64 total addresses; 62 ordinary usable hosts. | An address ending in .77 belongs to the .64–.127 block.

One method for every ordinary IPv4 block question

## Understand it step by step

1. Read /p. Host bits h=32−p. Total addresses N=2ʰ, not N−2.
2. Build the mask. Find the first octet that is not 255; block step there is 256−that mask octet.
3. Round that address octet down to a multiple of the step. Preserve preceding octets and set later octets to 0 for the network address.
4. For the broadcast address, use the end of the same interval in the changing octet and set later octets to 255. Equivalently, broadcast is network+(N−1) in 32-bit address arithmetic.
5. For an ordinary broadcast subnet with at least two host bits: first usable=network+1, last usable=broadcast−1, usable count=N−2. /31 point-to-point and /32 routes are exceptions explained separately.



$$
N=2^{32-p}
$$





$$
\text{block step}=256-\text{changing mask octet}
$$





$$
\text{ordinary usable hosts}=2^h-2
$$



#### Practical example

For a /26, the changing fourth octet moves in steps of 64: blocks 0–63, 64–127, 128–191 and 192–255. An address ending in 77 is in the 64–127 block.

A /26 has 32−26=6 host bits, so it contains 2⁶=64 total addresses. Under ordinary IPv4 subnet rules, one is the network address and one is directed broadcast, leaving 64−2=62 usable host addresses.

**Yaad rakho:** Total mein sab count; usable mein boundary ke 2 minus.

An IPv4 address identifies an IP interface. The network prefix selects the destination network; remaining bits identify an address within it. Classful addressing is historical; modern routing uses explicit CIDR prefixes.

| Class | First octet | Default mask | Network / host split | Purpose |
| --- | --- | --- | --- | --- |
| A | 1–126 (ordinary unicast) | 255.0.0.0 (/8) | 8 / 24 bits | Large historical unicast networks; 0 and 127 reserved |
| B | 128–191 | 255.255.0.0 (/16) | 16 / 16 bits | Medium historical unicast networks |
| C | 192–223 | 255.255.255.0 (/24) | 24 / 8 bits | Small historical unicast networks |
| D | 224–239 | No unicast default mask | Not network/host class split | Multicast |
| E | 240–255 | No unicast default mask | Not normal unicast allocation | Reserved/experimental; special addresses exist |

Example: 114.34.2.8 is class A with network 114.0.0.0 and host portion 34.2.8. Class does not override an explicitly supplied CIDR prefix.

Example: 192.168.1.70 AND255.255.255.192 gives network192.168.1.64. The mask distinguishes the network prefix from the host portion. CIDR masks need not equal historical default class masks.
