Skip to main content
SingaporeComputer ScienceSyllabus dot point

How are devices addressed on the internet, and how does a subnet mask split a network from a host?

Explain IPv4 addressing, the role of the subnet mask in separating network and host parts, and the motivation for IPv6

A focused answer to the H2 Computing outcome on IP addressing. The structure of an IPv4 address, how a subnet mask divides network and host bits, calculating hosts per subnet, and why IPv6 was introduced.

Generated by Claude Opus 4.88 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this dot point is asking
  2. The answer
  3. Examples in context
  4. Try this

What this dot point is asking

SEAB wants you to explain IPv4 addressing, how a subnet mask separates the network and host parts of an address, and why IPv6 was introduced. The central idea is that an IP address has two parts - which network and which host on it - and the subnet mask is what tells a device where the split falls, so it can decide whether to deliver locally or via a router.

The answer

IPv4 addresses

An IPv4 address is 32 bits, written as four octets (8-bit numbers) in dotted-decimal, each 00 to 255255:

192.168.1.10  =  11000000.10101000.00000001.00001010192.168.1.10 \;=\; 11000000.10101000.00000001.00001010

Every address has two parts: a network part (which network) and a host part (which device on it). The split is not fixed - the subnet mask defines it.

The subnet mask

A subnet mask marks which bits are network and which are host: a 11 for each network bit, a 00 for each host bit. For example:

255.255.255.0  =  11111111.11111111.11111111.00000000255.255.255.0 \;=\; 11111111.11111111.11111111.00000000

This is 24 network bits and 8 host bits, often written as /24. A device finds its network address by a bitwise AND of its IP with the mask.

Hosts per subnet

With hh host bits there are 2h2^h addresses, but two are reserved:

  • the network address (all host bits 0), naming the network itself, and
  • the broadcast address (all host bits 1), reaching every host.

So usable hosts:

usable hosts=2h2\text{usable hosts} = 2^h - 2

For an 8-bit host part, 282=2542^8 - 2 = 254.

Deciding local versus remote

To send a packet, a device ANDs both its own and the destination IP with the mask. If the resulting network addresses match, the destination is on the same local network and it sends directly; if they differ, it sends to its default gateway (router) to forward toward the other network. This is the practical purpose of the mask.

Why IPv6

IPv4's 32 bits give only 2324.32^{32} \approx 4.3 billion addresses, which have been exhausted by the explosion of connected devices. IPv6 uses 128-bit addresses, giving 21282^{128} - an astronomically larger space - plus simpler headers and built-in autoconfiguration. The address shortage is the main reason for the move.

Examples in context

Example 1. A home router. Your router gives devices private addresses like 192.168.1.x192.168.1.x with a /24 mask, so up to 254 hosts share the local network. When a device requests a website, the mask comparison shows the destination is on another network, so the packet goes to the router (the default gateway) to reach the internet.

Example 2. The rise of IPv6. As phones, sensors and appliances all came online, the 4.34.3 billion IPv4 addresses ran out, forcing stopgaps like address sharing. IPv6's 21282^{128} addresses are enough to give every device its own globally unique address with room to spare, which is why providers are steadily deploying it.

Try this

Q1. How many usable host addresses does a subnet with 8 host bits provide? [2 marks]

  • Cue. 282=2542^8 - 2 = 254, subtracting the network and broadcast addresses.

Q2. How does a device use the subnet mask to decide if a destination is local? [2 marks]

  • Cue. It ANDs both its own and the destination IP with the mask; matching network addresses mean local (send directly), differing mean send to the router.

Q3. State the main reason IPv6 was introduced. [1 mark]

  • Cue. IPv4's 32-bit address space (about 4.3 billion) was exhausted; IPv6's 128-bit space removes the shortage.

Exam-style practice questions

Practice questions written in the style of SEAB exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

Original6 marksA network uses the IPv4 address 192.168.1.0192.168.1.0 with subnet mask 255.255.255.0255.255.255.0. (a) How many bits identify the network and how many identify the host? (b) How many usable host addresses does this subnet provide? (c) Identify the network address and the broadcast address.
Show worked answer →

(a) The mask 255.255.255.0255.255.255.0 is 11111111.11111111.11111111.0000000011111111.11111111.11111111.00000000 in binary - 24 network bits and 8 host bits.

(b) With 8 host bits there are 28=2562^8 = 256 addresses, but two are reserved: the all-zeros host is the network address and the all-ones host is the broadcast address. So usable hosts =282=254= 2^8 - 2 = 254.

(c) The network address is the all-zeros host: 192.168.1.0192.168.1.0. The broadcast address is the all-ones host: 192.168.1.255192.168.1.255.

Markers reward 24 network and 8 host bits from the mask, 282=2542^8 - 2 = 254 usable hosts (subtracting network and broadcast), and the two reserved addresses .0 and .255.

Original5 marks(a) Explain how a device uses the subnet mask to decide whether a destination is on the same local network. (b) Explain the main reason IPv6 was introduced and one feature it offers over IPv4.
Show worked answer →

(a) The device performs a bitwise AND of its own IP address with the subnet mask to get its network address, and does the same with the destination IP. If the two network addresses match, the destination is on the same local network and the device sends directly; if they differ, the destination is on another network, so the device sends the packet to its default gateway (router) for forwarding.

(b) IPv4 uses 32-bit addresses, giving about 4.34.3 billion addresses (2322^{32}), which have been exhausted by the growth of internet-connected devices. IPv6 uses 128-bit addresses (21282^{128}), a vastly larger space that removes the shortage. A feature: a far larger address space (also acceptable: simplified headers, built-in support for autoconfiguration, or no need for widespread NAT).

Markers reward the AND-with-mask comparison of network addresses to decide local versus remote (gateway), IPv4 32-bit exhaustion as the motivation, and IPv6's 128-bit address space as the fix.

Related dot points