Skip to topic
    ← Back to course topics

    Subnet masking — AQA A-Level Computer Science

    Subnet masking is the process of dividing an IP address into network and host identifiers using a bitwise AND operation with a subnet mask. This technique enables efficient routing, hierarchical network structuring, and improved security and traffic management across local and wide area networks.

    Subnet masking explained

    A network can be divided into smaller networks called subnets to improve organisation, performance and security.

    Read the full explanation

    Each subnet is identified using a subnet mask, a 32-bit value that is applied to an IP address to separate the network part from the host part. In the mask, binary 1s mark the network bits and binary 0s mark the host bits. For example, the mask 255.255.255.0 (11111111.11111111.11111111.00000000) means the first 24 bits identify the network, so 192.168.1.25 belongs to network 192.168.1.0 with host 25. By applying the mask to an address with a bitwise AND, the network address of the subnet can be found, and devices whose addresses give the same result belong to the same subnet. Students should be able to identify the subnet a device belongs to and recognise that the same address gives a different network part under a different mask.

    Your focus

    1. Know that networks can be divided into subnets and know how a subnet mask is used to identify

    Which command word is this?

    Show all intermediate mathematical and binary working clearly, ending with a precise decimal, binary, or CIDR result as requested.

    Subnet masking exam tips

    Topic Overview

    Subnet masking is a fundamental networking technique in AQA A-Level Computer Science that allows network administrators to divide a single physical IP network into smaller, logical sub-networks (subnets). By using a subnet mask, devices and routers can instantly distinguish between the portion of an IP address that designates the network and the portion identifying the specific host device.

    Understanding subnetting is crucial because it resolves address exhaustion, improves network performance by containing broadcast traffic within smaller domains, and tightens security. It connects core theoretical topics such as bitwise boolean logic with real-world infrastructure like IPv4 routing, Classless Inter-Domain Routing (CIDR), and packet transmission.

    Key Concepts
    • →Structure of an IPv4 Address: A 32-bit numeric identifier split into four 8-bit octets, conceptually divided into a Network Identifier and a Host Identifier.
    • →Role of the Subnet Mask: A 32-bit sequence of contiguous binary 1s followed by contiguous binary 0s, where 1s filter the network address and 0s isolate the host address.
    • →Bitwise ANDing: The logical process executed by routers and network cards (NICs) where each bit of an IP address is combined with the corresponding bit of the mask (1 AND 1 = 1; anything else = 0) to yield the network ID.
    • →Reserved Host Addresses: In any subnet, the host ID with all zeros represents the network identifier itself, and the host ID with all ones represents the broadcast address, meaning usable hosts = 2^n - 2.
    • →CIDR (Classless Inter-Domain Routing): Shorthand prefix notation (e.g., /24) indicating the exact count of contiguous network bits in the subnet mask.
    Marking Points
    • States that a network can be divided into smaller subnets.
    • Explains that a subnet mask uses binary 1s for network bits and binary 0s for host bits.
    • Explains that applying the mask to an IP address identifies the subnet the address belongs to.
    • Shows that devices with the same network address after masking are on the same subnet.
    Examiner Tips
    • 💡When given an address and mask, write both in binary and mark the 1s and 0s before identifying the network part.
    • 💡Check the answer by confirming that devices in the same subnet produce the same network address when the mask is applied.
    • 💡Explain the purpose of subnetting briefly, such as organising a network or limiting broadcast traffic.
    • 💡Always convert non-standard mask octets (e.g. 192, 224, 240, 248, 252) directly into 8-bit binary to avoid calculation slips during bitwise AND operations.
    • 💡Memorise standard powers of 2 (128, 64, 32, 16, 8, 4, 2, 1) and cumulative octet sums (128, 192, 224, 240, 248, 252, 254, 255) to quickly parse CIDR prefixes.
    • 💡When explaining how a router uses a subnet mask, explicitly mention both the destination IP address and the bitwise AND logic to capture all assessment criteria.
    Common Mistakes
    • Describes the subnet mask as the device's address rather than a value that separates network and host bits.
    • Reverses the meaning of the bits, treating 0s as network bits and 1s as host bits.
    • Concludes that two devices are on different subnets when they share the same network address after masking.
    • Thinking a subnet mask physically alters the IP address: The mask does not alter the IP address; it acts as a binary filter used by routing software to interpret which segment of the address belongs to the local network.
    • Assuming all calculated addresses can be assigned to host devices: Students often forget to subtract 2 (network ID and broadcast ID) when calculating usable host addresses.
    • Believing subnet masks can have arbitrary alternating 1s and 0s: A valid subnet mask must consist of strictly contiguous 1s followed by strictly contiguous 0s.
    Revision Plan
    1. 1Day 1-2: Review binary conversion and drill bitwise AND operations with 8-bit values.
    2. 2Day 3-5: Practice identifying network IDs, broadcast addresses, and usable host ranges from given IP addresses and subnet masks.
    3. 3Day 6-8: Master CIDR prefix notation calculations, specifically converting between /n format and dotted-decimal representation.
    4. 4Day 9-10: Work through multi-step AQA past paper exam questions involving subnet design scenarios and host capacity calculations.
    Exam Question Types
    • 📋Binary calculation questions: Calculating the network address or broadcast address given an IPv4 address and a subnet mask in dotted-decimal or CIDR format.
    • 📋Network design questions: Determining the required subnet mask to accommodate a specified number of subnets or hosts per subnet.
    • 📋Short-answer conceptual questions: Explaining the technical purpose of a subnet mask and how routers use it to make forwarding decisions.
    Command Word Expectations (AQA)
    Calculate

    Show all intermediate mathematical and binary working clearly, ending with a precise decimal, binary, or CIDR result as requested.

    Explain

    Provide a coherent explanation linking technical causes to effects, detailing how the mechanism (e.g., bitwise ANDing) achieves a specific outcome (e.g., routing decision).

    State

    Provide a single concise fact, address, or number without requiring detailed justification or extended working.

    How Students Lose Marks (Examiner Pitfalls)
    Pitfall: Confusing CIDR notation prefix length with available host bits or failing to subtract 2 for network and broadcast addresses.
    ❌ Weak Answer (Loses Marks):A /26 mask has 26 bits, so there are 64 hosts per subnet.
    Example improved answer:A /26 prefix allocates 26 bits to the network identifier, leaving 32 - 26 = 6 bits for the host identifier. The total number of addressable hosts is 2^6 - 2 = 64 - 2 = 62 usable IP addresses, as the all-zero host address is reserved for the network ID and the all-ones host address is reserved for the broadcast address.
    Examiner Tip: Always state explicitly that 2 addresses are reserved (network and broadcast) whenever asked for the number of usable or assignable host devices.
    Pitfall: Performing decimal calculations instead of converting IP octets to binary when applying a non-standard subnet mask.
    ❌ Weak Answer (Loses Marks):You just multiply the IP address octet by the subnet mask octet to find the subnet.
    Example improved answer:To determine the network ID, convert both the IP address and the subnet mask into 8-bit binary octets, perform a bitwise logical AND operation between corresponding bits, and convert the resultant binary values back to dotted-decimal notation.
    Examiner Tip: Show full 8-bit binary conversions for at least the octet where the division occurs; examiners award working marks for accurate binary ANDing.
    Step-by-Step Worked Solutions

    Question: A computer has the IPv4 address 192.168.10.77 and a subnet mask of 255.255.255.224. Calculate the Network ID (Subnet Address) and the Broadcast Address for this subnet.

    1. 1.Step 1: Identify the critical octet where the subnet boundary falls. The first three octets of the mask are 255, meaning the first three octets of the IP address remain unchanged (192.168.10). The fourth octet of the mask is 224, and the IP fourth octet is 77.
    2. 2.Step 2: Convert the fourth octet values to 8-bit binary. IP: 77 = 01001101. Mask: 224 = 11100000.
    3. 3.Step 3: Perform a bitwise AND operation on the fourth octet: (01001101 AND 11100000) = 01000000. 01000000 in decimal is 64. Therefore, the Network ID is 192.168.10.64.
    4. 4.Step 4: Determine the broadcast address by keeping the network bits (first 3 bits: 010) and setting all host bits (remaining 5 bits) to binary 1: 01011111. 01011111 in decimal is 64 + 16 + 8 + 4 + 2 + 1 = 95.
    5. 5.Step 5: State the final addresses clearly in dotted decimal format.
    Final Answer: Network ID: 192.168.10.64; Broadcast Address: 192.168.10.95

    Question: An organisation is allocated the network block 172.16.0.0/16 and requires at least 50 separate subnets, each capable of hosting at least 500 computers. Determine an appropriate new subnet mask in CIDR notation and justify your choice.

    1. 1.Step 1: Determine the required host bits. To host at least 500 computers, solve 2^h - 2 >= 500. For h = 8, 2^8 - 2 = 254 (insufficient). For h = 9, 2^9 - 2 = 512 - 2 = 510 (sufficient). Thus, a minimum of 9 host bits is required.
    2. 2.Step 2: Determine the maximum network/subnet prefix length allowed by the host requirement. Total IPv4 bits = 32. Maximum prefix = 32 - 9 = /23.
    3. 3.Step 3: Verify the number of available subnets with a /23 prefix. Original network is /16. Subnet bits borrowed = 23 - 16 = 7 bits. Number of subnets = 2^7 = 128 subnets.
    4. 4.Step 4: Compare against requirements. 128 subnets satisfies the requirement of at least 50 subnets, and 510 hosts per subnet satisfies the requirement of at least 500 hosts.
    Final Answer: Appropriate subnet mask: /23 (or 255.255.254.0), providing 128 subnets with 510 usable hosts each.
    Active Recall Memory Test
    What boolean logic operation does a router execute between an IP address and its subnet mask?
    Key Fact: Bitwise AND operation.
    Why can you not assign the very first and very last address of a subnet to a host device?
    Key Fact: The first address is reserved as the Network ID, and the last address is reserved as the broadcast address.
    How many total usable host addresses are provided by a /28 subnet mask?
    Key Fact: 14 usable addresses (32 - 28 = 4 host bits; 2^4 - 2 = 16 - 2 = 14).
    What is the dotted-decimal representation of a /18 subnet mask?
    Key Fact: 255.255.192.0.
    Frequently Asked Questions
    What is the difference between a default gateway and a subnet mask?
    A subnet mask is a bitmask used locally by a host or router to split an IP address into network and host components. The default gateway, by contrast, is the actual IP address of the local router interface that forwards packets destined for remote networks outside the local subnet.
    Why does a subnet mask always have contiguous binary ones?
    Subnet masks define a clean hierarchical division where the most significant bits represent the network and the least significant bits represent the host. Having contiguous ones ensures that the network identifier occupies an unbroken sequence of high-order bits, which routing protocols rely on for prefix-based table lookups.
    How do I calculate the number of subnets created when borrowing bits?
    To calculate the number of subnets created, use the formula 2^s, where s is the number of bits borrowed from the original host portion. For example, borrowing 3 host bits creates 2^3 = 8 subnets.
    What is CIDR and why is it used instead of classful addressing?
    Classless Inter-Domain Routing (CIDR) replaces the rigid legacy Class A, B, and C systems with flexible variable-length subnet masks denoted by prefix notation (e.g., /27). It prevents severe IPv4 address wastage by allowing network blocks to match an organisation's exact host capacity requirements.
    What happens if a computer's subnet mask is configured incorrectly?
    If a host has an incorrect subnet mask, it will miscalculate its local network boundaries. It may attempt to send packets to local peers via the default gateway or attempt to broadcast directly to remote systems, resulting in lost connectivity and routing failures.