CS Atlas GATE 2027
Computer Networks course
0 / 90 complete

Computer Networks/Phase 3 · Network Layer

Lesson 3.1.1 · Item 41 of 90

IPv4 address structure, dotted decimal, net-id vs host-id

Read at your own pace. Try the questions before opening the answers.

On this page

Recall warm-up

  1. Does a switch divide a collision domain, a broadcast domain, or both?
    Stuck? Peek at 2.4.2 Ethernet efficiency; switched vs shared Ethernet
    • Shared Ethernet efficiency η = 1/(1 + 5a) (course default); variants 1/(1 + 5.44a), 1/(1 + 6.44a).
    • Switched full-duplex: no collisions, no CSMA/CD, full rate per link.
    • Collision domains: hub = 1; switch/router = 1 per interface.
    • Broadcast domains: only routers split them.

    Read lesson 2.4.2

  2. After the 3rd collision in binary exponential backoff, how many slot choices exist?
    Stuck? Peek at 2.3.4 Binary exponential backoff; probability of winning
    • After the n-th collision: K uniform in {0, …, 2^min(n,10) − 1}; wait K × slot; abort after 16.
    • Slot = 512 bit times (51.2 µs at 10 Mbps).
    • P(A wins) = #{K_A < K_B} / (a·b); both at range 2: win 1/4, tie 1/2.
    • Capture: A at range 2 vs B at range 4 → A wins 5/8.

    Read lesson 2.3.4

  3. Which layer adds a logical address that identifies the final destination host across networks?
    Stuck? Peek at 1.1.3 Encapsulation, headers, PDU names, addresses and devices per layer
    • Encapsulation: payload + header (+ trailer at data link); decapsulation in reverse.
    • PDUs: message (app) → segment (transport) → packet/datagram (network) → frame (data link) → bits.
    • Addresses: link (per hop, changes) · network (end to end, fixed) · which-program id · names.
    • Devices: hub/repeater 1 · bridge/switch 2 · router 3 · gateway/host up to 7.
    • Efficiency = data / (data + all headers + trailer).

    Read lesson 1.1.3

The Hook

In Phase 2, a 48-bit MAC address got our frame across one local network. But MAC addresses are flat hardware serial numbers burned into cards at the factory — a laptop in Chennai and a laptop in Delhi could have almost identical MAC numbers. If every router in the world had to keep a list of all 10 billion MAC addresses on Earth, every router's memory would explode.

Phase 3 puts our message inside a network-layer envelope (a datagram) stamped with a hierarchical IPv4 address — like a postal PIN code where the first digits name the city and area, and the last digits name the house on that street.

Predict First

Why can post offices route a letter across the country by reading only the first 3 digits of a 6-digit PIN code, whereas they could never do that with a national citizen ID card number?

,

Because a PIN code is hierarchical (grouped by location: state → district → post office), so distant sorting centres only need one table entry per region. A citizen ID is flat (assigned by birth/registration order, like a MAC address) and tells you nothing about where the person currently lives.

Core Concept

32 bits and the 2³² address space

An IPv4 address is a 32-bit binary number that uniquely and universally identifies a host's connection (interface) to a network.

IPv4 address: a 32-bit identifier split into four 8-bit groups called octets (4 bytes total). Total address space = 2³² = 4,294,967,296 (≈ 4.3 billion) addresses.

Because a router connects two or more networks, a router has one IPv4 address per connected link (interface).

11000000101010000000000100001010Octet 1 (192)Octet 2 (168)Octet 3 (1)Octet 4 (10)
32 bits grouped into four 8-bit octets: 192.168.1.10.

Dotted-decimal notation

Humans cannot read 32-bit binary strings without going cross-eyed, so we convert each 8-bit octet into its decimal value (0 to 255) and separate the four numbers with dots.

Dotted-decimal notation: a.b.c.d where each octet satisfies 0 ≤ a, b, c, d ≤ 255, with no leading zeros.
Octet binaryPlace-value sumDecimal
11000000128 + 64192
10101000128 + 32 + 8168
0000000111
000010108 + 210
Converting 11000000.10101000.00000001.00001010 → 192.168.1.10.

Two-level hierarchy: Net-ID + Host-ID

Every IPv4 address is divided into two contiguous parts:

  • Network part (net-id) — the leftmost n bits. All hosts on the same LAN share the exact same net-id. Distant routers inspect only the net-id.
  • Host part (host-id) — the remaining h = 32 − n rightmost bits. Identifies the specific interface inside that network.
Network Part (n bits)
Identifies the network (like the PIN code). Shared by every host on the same LAN.
Host Part (32 − n bits)
Identifies the individual interface inside that network (like the house number).
n + h = 32 bits always.

Putting it together

  • IPv4 addresses are 32-bit hierarchical identifiers written as four decimal octets (0–255).
  • The left n bits (net-id) identify the network; the right 32−n bits (host-id) identify the interface on that network.
  • Unlike flat 48-bit MAC addresses, hierarchical IPv4 addresses let routers route by looking only at the net-id.

Visual

32-bit IPv4 address
Split into 4 octets
8 bits each (0–255)
Left n bits = Net-ID
which network?
Right (32−n) bits = Host-ID
which host on that network?
Structure of an IPv4 address.

Worked Examples

Easy

Which of these dotted-decimal strings are valid IPv4 addresses? (i) 192.168.1.256 (ii) 10.0.1 (iii) 11000000.00000000.00000010.00000001 in dotted decimal.

Show the full solution

(i) Invalid: 256 > 255 (needs 9 bits). (ii) Invalid: only 3 octets instead of 4. (iii) Binary octets are 192, 0, 2, 1 → valid address 192.0.2.1.

Medium

A network uses the leftmost 22 bits as its net-id. How many bits are in the host-id, and how many total IPv4 addresses exist in this network block?

Show the full solution

Host bits h = 32 − 22 = 10 bits. Total addresses in the block = 2¹⁰ = 1024.

GATE

Express the IPv4 address 172.16.25.10 as a single 32-bit hexadecimal number and as a 32-bit unsigned integer.

Show the full solution

Convert each octet to 2-digit hex: 172 = 10×16 + 12 = AC, 16 = 10, 25 = 1×16 + 9 = 19, 10 = 0A → hex is 0xAC10190A.
As a 32-bit unsigned integer: 172×2²⁴ + 16×2¹⁶ + 25×2⁸ + 10 = 2885681152 + 1048576 + 6400 + 10 = 2886736138.

GATE Traps

  • An IPv4 address identifies a network interface, not a whole machine — a router with 3 links has 3 different IPv4 addresses.
  • Each octet is 0 to 255 inclusive; 256 is NEVER valid in dotted-decimal.
  • Do not confuse total addresses in a block (2ʰ) with usable host addresses (covered in 3.1.2–3.1.3).

Memory Hook

IPv4 = 4 bytes = 32 bits. Net-ID gets you to the street; Host-ID knocks on the door.

Connect the Dots

Every IPv4 address splits into n network bits and 32 − n host bits. Next question (3.1.2): When a router sees 192.168.1.10, how did the early Internet know where the net-id ended and the host-id began without any extra number attached?

Self-Test

  1. MCQ

    How many bits and bytes long is an IPv4 address?

    1. 32 bits (4 bytes)
    2. 48 bits (6 bytes)
    3. 64 bits (8 bytes)
    4. 128 bits (16 bytes)
  2. MSQ

    Which of the following are TRUE about IPv4 addresses?

    1. A router connecting three LANs has three distinct IPv4 addresses.
    2. All hosts on the same LAN share the same net-id.
    3. An octet in dotted-decimal can take values from 0 to 256.
    4. Total IPv4 address space is 2³².
  3. NAT

    If the network part of an IPv4 address is 20 bits long, how many bits remain for the host part?

    Write your answer before opening the key.

  4. MCQ

    What is the dotted-decimal form of 10101100.00010000.00000100.00001001?

    1. 172.16.4.9
    2. 172.32.4.9
    3. 168.16.4.9
    4. 172.16.8.9

Rule Card

  • IPv4 address = 32 bits = 4 octets (0–255 each), total space = 2³².
  • Split: Net-ID (left n bits) + Host-ID (right h = 32 − n bits).
  • Identifies a network interface (routers have one IP per link).

Concept Ledger

  • IP address
  • IPv4 address (32 bits)
  • octet
  • dotted decimal
  • network part (net-id)
  • host part (host-id)
  • address space 2³²

Answer Vault

Try the questions first. Open when you are ready to check.

Warm-up answers

  1. Each switch connection is its own collision domain, while the whole switched LAN remains a single broadcast domain.
  2. 2³ = 8 choices (0 through 7).
  3. The Network Layer (Layer 3), inside the packet/datagram header.

Self-test answers

  1. A — An IPv4 address has 4 octets × 8 bits = 32 bits = 4 bytes.
    • B: 48 bits (6 bytes) is a MAC address.
    • C: Not IPv4.
    • D: 128 bits is IPv6.
  2. ABD — Each interface gets its own IP; hosts on a LAN share net-id; total space is 2³². Octet max is 255.
    • C: 8 bits represent 0..255 (256 values total, max value 255).
  3. 12 — 32 − 20 = 12 bits.
  4. A — 10101100₂ = 128+32+8+4 = 172; 00010000₂ = 16; 00000100₂ = 4; 00001001₂ = 9.
    • B: Second octet is 16, not 32.
    • C: First octet is 172, not 168.
    • D: Third octet is 4, not 8.

Flashcards

  1. Size of an IPv4 address vs MAC address?
    Reveal answerIPv4 = 32 bits (4 bytes, dotted decimal); MAC = 48 bits (6 bytes, hex).
  2. What does an IPv4 address actually identify: a host or an interface?
    Reveal answerA network interface (a router with k links has k IPv4 addresses).
  3. If net-id is n bits, how many addresses are in that network block?
    Reveal answer2³²⁻ⁿ addresses.

Exam shortcuts

  • Fast octet binary memorize: 128, 192, 224, 240, 248, 252, 254, 255 are 1, 2, 3, 4, 5, 6, 7, 8 leading ones in an octet. — converting common network octets between binary and decimal in seconds.
  • Block size from net-id bits: if net-id has n bits, total addresses in that network = 2³²⁻ⁿ. — any contiguous n-bit network prefix.

Ready for the next idea?

Mark this item complete when you’ve finished reading and working through it.