IP Addressing and Routing

IP addressing identifies hosts and networks; a CIDR prefix splits the 32-bit IPv4 address into network and host parts, and routers forward packets by the longest prefix match against their routing tables.

Key formulas & points

Skim these first — then read the full notes below.

  • Private ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16
  • NAT maps private addresses to a public one
  • IPv6 is 128-bit, has no broadcast, and uses anycast

Topic details

Introduction

This Tanenbaum topic covers logical addressing and forwarding. You perform subnetting and CIDR calculations, compute network and broadcast addresses and usable host counts, understand NAT and private ranges, and see why routers use longest-prefix matching.

Key relations & formulas

Formulas (Indian textbook notation)

  • IPv4is32bitdotteddecimal;anprefixyields2(32n)addressesIPv4 is 32-bit dotted decimal; \frac{a}{n} prefix yields 2^(32-n) addresses

Formulas (Indian textbook notation)

  • networkprefix=IPANDsubnetmasknetwork prefix = IP AND subnet mask

Formulas (Indian textbook notation)

  • routerschoosethelongestmatchingprefixrouters choose the longest matching prefix

Notation and sign conventions

Relation 1 —
IPv4 is 32-bit dotted decimal; \frac{a}{n} prefix yields 2^

Formulas (Indian textbook notation)

  • IPv4is32bitdotteddecimal;anprefixyields2(32n)addressesIPv4 is 32-bit dotted decimal; \frac{a}{n} prefix yields 2^(32-n) addresses
Write this relation with symbols exactly as in Data Communications & Networking — Behrouz Forouzan before substituting numbers. Examiners award partial marks for a correct setup even when arithmetic slips.
Relation 2 —
networkprefix=IPANDsubnetmasknetwork prefix = IP AND subnet mask

Formulas (Indian textbook notation)

  • networkprefix=IPANDsubnetmasknetwork prefix = IP AND subnet mask
Write this relation with symbols exactly as in Data Communications & Networking — Behrouz Forouzan before substituting numbers. Examiners award partial marks for a correct setup even when arithmetic slips.
Relation 3 —
routerschoosethelongestmatchingprefixrouters choose the longest matching prefix

Formulas (Indian textbook notation)

  • routerschoosethelongestmatchingprefixrouters choose the longest matching prefix
Write this relation with symbols exactly as in Data Communications & Networking — Behrouz Forouzan before substituting numbers. Examiners award partial marks for a correct setup even when arithmetic slips.

Concept in depth

An IP address encodes both which network a host is on and which host it is, and the subnet mask (or CIDR prefix) marks the boundary. ANDing an address with its mask yields the network prefix, from which the range of host addresses follows — with the all-zeros and all-ones host patterns reserved for the network and broadcast addresses, so usable hosts are two fewer than the total. Routers store many prefixes and forward each packet using the most specific (longest) matching prefix, which lets general default routes coexist with specific ones. NAT stretches the scarce IPv4 space by letting many private hosts share one public address, a problem IPv6 solves outright with its vastly larger 128-bit space.

Assumptions and validity limits

State assumptions explicitly before using any relation for ip addressing and routing — steady state, uniform properties, linear elastic material, ideal gas, incompressible flow, etc., as applicable.
Wrong assumptions invalidate the entire solution even when the formula is correct. In Computer Networks viva and GATE descriptive questions, listing valid assumptions often earns separate marks.

Step-by-step problem approach

1. Read the question and list given data with SI units (common in Computer Networks papers).
2. Draw a neat labelled diagram where applicable — examiners in Indian universities award diagram marks even when arithmetic slips.
3. Identify which relation from this topic applies to ip addressing and routing.
4. Use equation 1:
IPv4 is 32-bit dotted decimal; \frac{a}{n} prefix yields 2^
.
5. Use equation 2:
networkprefix=IPANDsubnetmasknetwork prefix = IP AND subnet mask
.
6. Substitute values, compute, and verify units and sign (direction).
7. State conclusion in one line — e.g. safe/unsafe, stable/unstable, feasible/infeasible.

Applications & exam relevance

IP Addressing and Routing appears in internet and enterprise IT. In Indian it software curricula this topic is tested because it connects theory to layered network protocols.
GATE and semester exams often combine ip addressing and routing with earlier units — revise prerequisites before attempting mixed problems.
Industry interview panels sometimes ask: "Where did you use ip addressing and routing?" — answer with a lab, mini-project, or plant visit example if possible.

Common mistakes in exams

Students forget to subtract the network and broadcast addresses when counting usable hosts, miscompute the mask from the prefix length, and confuse longest-prefix match with first-match. Treating private addresses as routable on the public internet is a conceptual error.

Quick revision checklist

Before attempting ip addressing and routing problems, confirm you can:
1. Private ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16
2. NAT maps private addresses to a public one
3. IPv6 is 128-bit, has no broadcast, and uses anycast
Revise the solved examples in Data Communications & Networking — Behrouz Forouzan and one previous-year GATE or university paper for this unit.

Worked examples

Try the problem first — open the solution when you are ready to check.

CIDR host count

Problem

For the subnet 192.168.10.0/27, find the total and usable host addresses.

Solution

Host bits = 32 − 27 = 5, so total = 2⁵ = 32 addresses; usable = 32 − 2 = 30 (excluding the network and broadcast addresses).

Conceptual check — IP Addressing and Routing

Problem

In a Computer Networks semester or GATE paper you are asked: "State the main assumption, the governing relation, and one practical consequence of ip addressing and routing." What should a complete answer include?

📖 Standard books (India)

  • Data Communications & NetworkingBehrouz Forouzan

    Read: Syllabus unit

    OSI, TCP/IP, and network protocols