Prefix Length and Binary Number System

SA
StudyAI Editorial
Reviewed by StudyAI tutors
· Published Updated

From the networking curriculum

Prefix Length and Binary Number System

TL;DR

Routers and computers use binary, while humans use decimal numbers, requiring an understanding of both to work with IPv4 addresses. A subnet mask, or its shorthand, the prefix length, defines the network and host parts of an IPv4 address. Correctly understanding subnet masks and prefix lengths is crucial for efficient network segmentation and traffic management.

1. The Mental Model

Think of an IPv4 address as a street address. The network portion is like the street name and block, defining where the whole network lives. The host portion is like the specific house number on that street. The subnet mask, or prefix length, is what tells you exactly where the street name ends and the house number begins.

2. The Core Material

Understanding Binary and IPv4 Addresses

Routers and computers understand information in binary, which is a system of 0s and 1s. Humans, however, typically work in decimal numbers (0-9). An IPv4 address is a 32-bit hierarchical address made up of four blocks, each ranging from 0 to 255. It's split into two main parts: the network portion and the host portion.

Subnet Masks and Prefix Lengths

A subnet mask is essential for determining which part of an IPv4 address is the network and which is the host. It also has a default form for each IP class, which indicates the number of available IP addresses for a given network.

The prefix length is a simpler way to represent the subnet mask. It's written in "slash notation" (e.g., /8, /24). The prefix length tells you the number of bits set to 1 in the subnet mask. An IPv4 address is a 32-bit address. So, a /24 prefix length means the first 24 bits of the subnet mask are 1s, and the remaining 8 bits are 0s.

Here's how subnet masks and prefix lengths relate:

graph TD
    A["IPv4 Address (32-bit)"] --> B["Network Portion"];
    A["IPv4 Address (32-bit)"] --> C["Host Portion"];
    SM["Subnet Mask"] --> B;
    SM["Subnet Mask"] --> C;
    PL["Prefix Length"] --> SM;
    PL === SN["Slash Notation (/N)"];
    SM_Bin["Subnet Mask in Binary"] --> PL_Bits["Number of '1' bits"];
    PL_Bits --> PL;

For example, a common subnet mask is 255.255.255.0. In binary, this looks like:
11111111.11111111.11111111.00000000

If you count the 1s, there are 24 of them. So, the prefix length for 255.255.255.0 is /24. This means the first 24 bits define the network, and the last 8 bits define the hosts. The number of hosts is related to the remaining bits (the host portion), indicated by 'h' in the source material.

Types of IPv4 Addresses Within a Network

Within a network determined by the subnet mask, there are three types of IP addresses:
* Network address: Identifies the entire network.
* Host addresses: Used for individual devices on the network.
* Broadcast address: Sends a packet to all other devices on that specific network.

  • Unicast transmission sends a packet to a single destination IP address.
  • Multicast transmission sends a packet to a group of IP addresses.
  • Broadcast transmission sends a packet to all destination IP addresses on the local network.

Public and Private IPv4 Addresses

IP addresses are managed by the Internet Assigned Numbers Authority (IANA) and Regional Internet Registries (RIRs). IPv4 addresses can be either public or private.
* Private IPv4 addresses are specific ranges (like 10.0.0.0/8) that are not routable on the internet. They are commonly used by organizations for internal hosts and can be reused in different private networks.
* Public IPv4 addresses are globally unique and routable on the internet.

Network Segmentation and Broadcast Domains

Routers prevent broadcasts from propagating beyond their immediate network interface. Each router interface defines a broadcast domain. Large broadcast domains can cause problems because excessive broadcast traffic can negatively impact network performance and lead to "deadlock" (though your source uses the term 'dealock').

Subnetting is the process of dividing a large network into smaller subnetworks (segments). This helps:
* Reduce overall network traffic.
* Improve network performance.
* Limit the number of devices affected by abnormal broadcast traffic.

Networks are most easily subnetted at the octet boundary (e.g., /8, /16, /24), meaning the prefix length ends exactly after a full octet of 1s in the subnet mask.

3. Worked Example

Let's say you have an IPv4 address 192.168.1.100 and a prefix length of /24.

  1. Identify the prefix length: /24 tells us the first 24 bits are for the network, and the remaining 8 bits are for hosts.
  2. Determine the subnet mask: A /24 prefix means 24 ones, followed by 8 zeros:
    11111111.11111111.11111111.00000000
    Converting this to decimal gives us the subnet mask: 255.255.255.0.
  3. Identify the network portion: With a 255.255.255.0 subnet mask, the first three numbers of the IP address 192.168.1 represent the network.
  4. Identify the host portion: The last number 100 represents the host on that network.

So, for 192.168.1.100/24, the network is 192.168.1.0 and the host is 100.

4. Key Takeaways

  • Computers use binary, numbers made of 0s and 1s, while humans use decimal numbers.
  • An IPv4 address is a 32-bit address with a network part and a host part.
  • A subnet mask or prefix length tells you where the network part ends and the host part begins.
  • The prefix length is simply the count of '1' bits in the subnet mask, written as /N.
  • Private IPv4 address ranges are reserved for internal networks and are not routed on the internet.
  • Subnetting helps break down large networks into smaller, more manageable broadcast domains to improve performance and reduce traffic.

Common Mistakes to Avoid

  • Confusing the network portion with the host portion—always refer to the subnet mask or prefix length.
  • Forgetting that a /24 prefix length means 24 binary ones, not 24 decimal numbers.
  • Assuming all IP addresses are publicly routable; remember the existence of private IP ranges.
  • Underestimating the impact of large broadcast domains on network performance.

5. Now Try It

Take the IPv4 address 172.16.10.50 and the prefix length /16. First, convert the prefix length to its corresponding decimal subnet mask. Then, identify the network address for 172.16.10.50 based on that subnet mask.

What success looks like: You should be able to clearly state the subnet mask in decimal format and the resulting network address.

Frequently asked about Prefix Length and Binary Number System

# Prefix Length and Binary Number System ## TL;DR Routers and computers use binary, while humans use decimal numbers, requiring an understanding of both to work with IPv4 addresses. A subnet mask, or its shorthand, the prefix length, defines the network and host parts of an IPv4 Read the full notes above.

Prefix Length and Binary Number System is a core topic in networking. Most exam papers test it via a mix of definitions, worked examples, and applied problems. The notes above cover the high-yield sub-topics, common pitfalls, and the kind of questions examiners typically set.

Yes. Every note in the StudyAI Campus Hub is free to read. Create a free account if you want to clone the full plan, generate your own notes from your textbook, or get AI-powered practice quizzes and flashcards.

More from networking


Get the full networking curriculum

Clone the complete plan to your dashboard for unlimited AI-generated notes, practice quizzes, and a personalised revision schedule.

Create Free Account