Calculate network, mask, host range and broadcast from an address/prefix.
The focus of this experiment is to calculate IPv4 network, broadcast and conventional host range. Students then compare CIDR prefix sizes and special-case subnet semantics, and verify addresses using bit masks and route-prefix reasoning. The Concepts view explains the operation before the practical work; the Simulation view is used to examine reference and changed inputs, not to substitute for actual measurements.
Learning objectives
Calculate IPv4 network, broadcast and conventional host range.
Compare CIDR prefix sizes and special-case subnet semantics.
Verify addresses using bit masks and route-prefix reasoning.
Identify the configured inputs (Host address; Prefix length) and record the corresponding observed outputs with units where applicable.
Compare the reference calculation or decision with an independent implementation or authorized observation; state any discrepancy and the applicable model boundary.
Expected learning outcomes
On completion, students can calculate IPv4 network, broadcast and conventional host range, compare CIDR prefix sizes and special-case subnet semantics, and verify addresses using bit masks and route-prefix reasoning.
Required deliverables
Submit the derivation or state trace for the named operation, the exact reference and changed configurations, the associated simulator or practical evidence, and a short validation statement addressing verify addresses using bit masks and route-prefix reasoning. Separate predicted values from observations.
Prerequisite knowledge and related learning
Review the following catalogue prerequisites before starting. After completion, continue to ARP & next-hop resolution.
The browser instrument and the specified local software or network environment. Use the experiment’s documented topology and distinguish modeled values from actual packet observations.
Begin with a manual prediction, record the baseline, change one independent condition at a time, and compare the resulting trace or measurements with the original prediction. Record observations and uncertainty separately from reference values. Follow the experiment’s specific procedure, safety limits, and acceptance checks.
N02 · learning outcome
Understand the experiment
IPv4 subnet boundary and usable range
Network and host fields are determined by prefix length, not punctuation.
Scientific architecture · IPv4 subnetting & CIDR
Scientific concept map: IPv4 address — 32-bit value; CIDR prefix — Network mask; Bitwise AND — Network address; Host bits — Range and broadcast; Subnet membership — Compare prefixes.
Scientific foundations and analytical reasoning
CIDR divides address bits into prefix and host bits. For conventional IPv4 subnets /1–/30, usable hosts are 2^(32−p)−2; /31 and /32 differ.
Before operating the equipment or executing the program, derive the expected outcome using the required theoretical work in Experiment. Use the diagram to identify the variables and system boundaries.
Scientific theory · Binary masks and address ranges
An IPv4 address has 32 bits. A prefix of length p selects the first p bits, and the subnet mask is p ones followed by zeros. The network address is address AND mask; the broadcast address sets all host bits to one. Ordinary /1 through /30 networks exclude network and broadcast from host allocation; /31 point-to-point and /32 are special cases.
Worked example and engineering interpretation
For 192.0.2.77/26, the block size is 64; the network is 192.0.2.64, broadcast is 192.0.2.127 and conventional host range is .65–.126. There are 62 conventional host addresses. Membership depends on the masked address, not only on the first three decimal octets.
Engineering principles · additional worked teaching example
A prefix /n reserves n network bits; IPv4 host bits=32−n. /27 has block size32, mask255.255.255.224. 198.51.100.45 belongs to .32–.63, usable .33–.62 under conventional subnet rules.
From theory to experiment
Predict the reference result before operating the workbench; check the actual intermediate state, units and constraints. The existing simulation, implementation and procedure below are distinct sources of evidence.
How to investigate IPv4 subnetting & CIDR
Calculate network, mask, host range and broadcast from an address/prefix.
Analytical investigation means collecting an observation, identifying the mechanism, using a calculation or state trace to explain it, and checking your conclusion against evidence. Controlled comparison means changing one independent variable, holding the remaining relevant conditions constant, and measuring a dependent variable against a baseline. Experimental validation means comparing a predicted result to a reproducible observation or assertion; agreement inside a model does not certify hardware. Evidence-based reasoning connects a specific observation to a theoretical rule and states uncertainty, not merely an opinion. Performance characterization records a named metric and its units across conditions; sensitivity analysis changes one parameter across several values. A threat assessment links an asset, threat, consequence and evidence to a mitigation.
Experiment-specific guided practice
Objective: Calculate network, mask, host range and broadcast from an address/prefix.
Set Host address = 192.0.2.73; Prefix length = 26. Observe the calculated results and trace.
Restore the reference values. A /31 is for point-to-point use; /32 is a single host route. Do not subtract two addresses from these special cases.
Reference check:
Model boundary:
Independent task and submission evidence
2. Change Prefix length = 30. Baseline: 192.0.2.64/26, mask 255.255.255.192, 62 usable addresses. /30: network 192.0.2.72, 2 hosts. Restore /26. Record the named input, prediction, actual output and one limitation; restore the original condition and repeat.
Before execution write the independent variable and its levels, dependent observation with units where applicable, baseline, controlled variables, measurement method and expected result. For a state machine use state/event/output rather than inventing a numeric metric. Record failures and repeat the baseline. A weak conclusion is “it works”; a supported conclusion names the changed setting, observed value/state, corresponding rule and one limitation.
Trial
Changed setting
Fixed settings
Predicted result
Actual observation / units
Evidence / uncertainty
A: baseline
Reference
Record
Predict
Record
Record
B: one change
Record
Same as A
Predict
Record
Record
A: repeat
Restore
Same as A
Predict
Record
Record
Completion: submit the filled table, relevant simulator screenshot or terminal/notebook output, reasoning with units/assumptions, and one limitation. Preserve the independent assessment questions; this guide does not fill their answers.
Calculate network, mask, host range and broadcast from an address/prefix.
A /31 is for point-to-point use; /32 is a single host route. Do not subtract two addresses from these special cases.
Worked engineering reasoning and boundary conditions
IPv4 subnet mask separates prefix and host bits. For an ordinary /27 subnet, 32 addresses and 30 conventional usable host addresses. A /31 point-to-point link has special rules; /32 is single address. Example 192.0.2.64/27 spans .64–.95.
Use the diagram to follow the calculation or state progression. Keep the teaching configuration separate from the independent exercise values; compare observations with the actual model and implementation.
Mathematical representation and interpretation
IPv4 prefix capacity
p denotes the prefix length; the second expression assumes a conventional broadcast subnet with network and broadcast addresses, not /31 or /32 special cases.
Explore the teaching example independently of the simulator. Each step reveals an operation, data relationship or calculated state. The Simulation view has separate editable inputs.
Step 1 of 4 · IPv4 address
IPv4 address
IPv4 address
192.0.2.64/27
Host bits
IPv4 address
192.0.2.64/27
Host bits
32−27=5
Block
IPv4 address
192.0.2.64/27
Host bits
32−27=5
Block
32 addresses .64–.95
Capacity
IPv4 address
192.0.2.64/27
Host bits
32−27=5
Block
32 addresses .64–.95
Capacity
30 conventional usable
Teaching example only; inspect live calculations or real practical evidence separately.
Recall the concept before revealing its explanation.
0 / 3 revealed
N02 · 01 / 08For the assigned IPv4 host, what are the /26 network, mask and host count, and how does /30 change them?Reveal explanation
Network and directed broadcast addresses are excluded for ordinary /26 subnets; /31 and /32 have different usage rules.
N02 · 06 / 08An IPv4 address and prefix are given. Select every technically valid statement.
A. Bitwise AND with the mask identifies the network address.
B. For ordinary /24 subnets, all-one host bits identify broadcast.
C. Changing host bits changes the prefix length.
D. The broadcast address is always the first address of the subnet.Reveal explanation
Applied scenario
Correct: A. Bitwise AND with the mask identifies the network address.; B. For ordinary /24 subnets, all-one host bits identify broadcast.
N02 · 07 / 08In IPv4 subnetting & CIDR, which reference and changed settings are prescribed for Prefix length?Reveal explanation
Controlled configuration
Prefix length: 26 → 30; hold the remaining settings fixed.
N02 · 08 / 08What expected result distinguishes the reference and changed trials in IPv4 subnetting & CIDR?Reveal explanation
Loading experiment-specific apparatus…Previous model / additional reference tools
Simulation task
Calculate network, mask, host range and broadcast from an address/prefix.
Explore the model using its own controls. Record a prediction before changing a condition. Compare the reference with a changed condition, then use the Experiment tab for the procedure, acceptance criteria and notebook. Model outputs and physical observations must remain separate.
Interactive engineering workbenchN02 · Existing model
Interactive computational experiment
Configure and observe
Model-linked protocol trace
Animated IPv4 subnetting & CIDR
Change the controls above; the trace and numerical summary update from the computed model results. Animation timing is for learning, not measured protocol latency.
Recent trace eventsInspect numerical or encoded protocol details
Readout from the original computational model; not physical measurements.
Loading instrument…
Awaiting model display.
Experimental instrumentation · A/B
Compare two model conditions
Capture a baseline, change one experimental condition, run the model if required and capture the comparison. Snapshots contain visible controls and display text, not physical sensor readings. Review before exporting.
Ask Dr. Mohammad locally, or prepare an experiment-aware prompt for ChatGPT, Gemini or Claude. The external providers open in their own tabs; nothing is automatically submitted.
Public course objective, displayed commands, source excerpts and procedure. Private assessment content is not collected.
Prepare a contextual AI prompt
0 characters
Common secret and email patterns are redacted on preparation; this is not a comprehensive privacy filter. Review the entire editable prompt, including student work and unpublished research, before sharing. The providers apply their own accounts, privacy settings and limits.
Prepare → review → copy & open your selected provider → paste and submit there.
Independent theoretical exercises
Before the simulation or practical, solve both experiment-specific tasks. List the given inputs, show the intermediate calculation or state trace, identify the expected observation, and state a limitation. Show formulas and intermediate calculations where relevant, or draw the requested state/sequence diagram. These are independent classroom fixtures; where they differ from the reference configuration below, do not treat them as measured values. Compare your predictions with the corresponding experiment afterwards.
01 · Predict and derive using the given inputs
For 192.0.2.73/26 calculate mask, network, broadcast, first/last usable and host count using binary or block size.
Engineering method — A prefix /n reserves n network bits; IPv4 host bits=32−n. /27 has block size32, mask255.255.255.224. 198.51.100.45 belongs to .32–.63, usable .33–.62 under conventional subnet rules. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
02 · Compare or justify using evidence
Split 192.0.2.0/24 into /26s, list four networks and determine which contains .73.
Engineering method — A prefix /n reserves n network bits; IPv4 host bits=32−n. /27 has block size32, mask255.255.255.224. 198.51.100.45 belongs to .32–.63, usable .33–.62 under conventional subnet rules. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
03 · Subnet calculation
Subnet calculation · Independent work
For 192.0.2.142/28 derive mask, network, broadcast and usable host range.
Subnet calculation — A prefix /n reserves n network bits; IPv4 host bits=32−n. /27 has block size32, mask255.255.255.224. 198.51.100.45 belongs to .32–.63, usable .33–.62 under conventional subnet rules. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
Work is saved locally when browser storage is available. Export it for submission; no remote upload or automatic grade is assigned.
Expanded independent theoretical exercise bank
Progress from calculation and interpretation to diagnosis and controlled engineering design. Complete the questions without opening the simulation first; show intermediate steps.
Foundational · Apply the principle
Independent theoretical exercise · N02-01
For 192.0.2.101/26 determine network and broadcast.
Intermediate · Calculate or trace
Independent theoretical exercise · N02-02
Give conventional host range and capacity for that subnet.
Intermediate · Interpret the result
Independent theoretical exercise · N02-03
Do .126 and .129 belong to same /26 subnet?
Advanced · Analyze a condition
Independent theoretical exercise · N02-04
Smallest ordinary subnet for 50 hosts?
Advanced · Diagnose or compare
Independent theoretical exercise · N02-05
Why is the first address of /26 generally not assigned to a normal host?
Challenging · Engineering verification
Independent theoretical exercise · N02-06
A host has /24 while router uses /26. Explain one possible failure.
Challenging numerical variant 1
Calculation · Independent work
A /28 IPv4 subnet uses conventional network and broadcast exclusions. Reserve 2 usable addresses for infrastructure. Each sensor requires two usable addresses (primary and standby). How many complete sensors can be assigned?
Challenging numerical variant 2
Calculation · Independent work
A /27 IPv4 subnet uses conventional network and broadcast exclusions. Reserve 5 usable addresses for infrastructure. Each sensor requires two usable addresses (primary and standby). How many complete sensors can be assigned?
Challenging numerical variant 3
Calculation · Independent work
A /26 IPv4 subnet uses conventional network and broadcast exclusions. Reserve 3 usable addresses for infrastructure. Each sensor requires two usable addresses (primary and standby). How many complete sensors can be assigned?
Step-by-step experimental procedure
Calculate network, mask, host range and broadcast from an address/prefix.
1 · Reference workbench configuration
Use the named reference workbench and its reference inputs. Additional live instruments may have different controls; use the matching instrument. Record virtual and practical results separately.
Host address192.0.2.73
Prefix length26
2 · Perform the investigation in order
Set Host address = 192.0.2.73; Prefix length = 26. Observe the calculated results and trace.
A /31 is for point-to-point use; /32 is a single host route. Do not subtract two addresses from these special cases.
Required evidence: Record the ipv4 subnetting & cidr comparison and justify the changed outcome from the calculated trace.
Model boundary: A /31 is for point-to-point use; /32 is a single host route. Do not subtract two addresses from these special cases.
Controlled investigation · reproducible evidence
Method. Use the existing reference workbench configuration and the named controlled changes below. A controlled variable stays fixed while the independent variable is intentionally changed; the dependent variable is the resulting observed output. First predict each trial from the Concepts page. Run the baseline, then change only the specified setting and record the outcome. For deterministic traces one execution per case and a repeated verification are sufficient; for timing or stochastic measurements repeat at least five times, recording each run, median and range. Reset to the reference state between independent comparisons.
Trial
Independent change
Dependent observation
Reference
Use reference inputs above
Record actual outcome and units
Controlled change
Prefix length = 30
Record actual outcome and units
Evidence: attach the completed comparison table, one trace or screenshot per condition, and actual practical terminal/hardware evidence where applicable. Explain any prediction mismatch and distinguish modeled behavior from measured results.
Loading laboratory-specific procedure…
Python / Google Colab notebook
Original independent networking reference; loopback traffic only where applicable. Validated locally in a fresh Jupyter kernel. Download, then upload to Google Colab.
Restore reference. Confirm the same baseline results, then vary one field at a time. Record the changed configuration and explain any difference.
Export both baseline and changed evidence before leaving. Do not infer physical execution from model output.
Local execution check
In the extracted website directory inside Ubuntu WSL or Linux (not in the browser terminal), run:
BASH · Command
python3 verification/network_practical.py subnet
✓ Expected: JSON containing each passing control and "passed": true. The program exits nonzero if a control fails. No network services need to be installed; sockets are bound to loopback on temporary ports and closed automatically. IPv6 requires an available ::1 interface. Record the actual output separately from model evidence.
Experimental notebook
Record your own results. Values are not prefilled or independently verified.
Record, discuss & verify
Notebook imports use the related core lab R3 and retain N02 in the method and attachment. The supplemental labs do not change the core prerequisite graph or graded completion counters.
Download this notebook and open Google Colab. Select File → Upload notebook and choose the downloaded .ipynb.
Read the Markdown instructions before each executable cell. Use a Python runtime, run cells from top to bottom, and resolve imports if necessary.
Perform the baseline and controlled changes. Save the notebook with actual outputs and your written interpretation.
Execution scope: Default computational cells passed isolated local Python execution; physical equipment and live services require separate verification.
01Instructions · Markdown
# n02 · IPv4 subnetting & CIDR
**PSUT IoT Engineering Studio — Dr. Mohammad Alja’afreh**
## Introduction
Calculate network, mask, host range and broadcast from an address/prefix.
## How to run
1. Download this notebook from the laboratory page. Open Google Colab → File → Upload notebook.
2. Select a Python CPU runtime. Run cells from top to bottom using Shift+Enter, or Runtime → Run all.
3. Read the printed observations and assertions. Change one parameter at a time and rerun the relevant cell.
4. Save your own outputs and compare them to the portal Experiment tab.
**Execution boundary:** Original independent networking reference; loopback traffic only where applicable. Do not run the hardware or service commands in Colab. No real credentials are needed. The notebook is self-contained.
02Instructions · Markdown
## Experiment-specific preparation
Calculate network, mask, host range and broadcast from an address/prefix.
**Reference procedure (use the matching simulator/WSL tool where named, not an unrelated service):**
1. Set Host address = 192.0.2.73; Prefix length = 26. Observe the calculated results and trace.
2. Change Prefix length = 30. Baseline: 192.0.2.64/26, mask 255.255.255.192, 62 usable addresses. /30: network 192.0.2.72, 2 hosts. Restore /26.
3. Restore the reference values. A /31 is for point-to-point use; /32 is a single host route. Do not subtract two addresses from these special cases.
**Evidence:**
**Boundary:**
03Instructions · Markdown
## 1. Objectives and reference condition
- Reproduce the specific computational mechanism in this laboratory.
- Inspect the output, compare the reference condition with a changed or rejected condition where implemented, and explain any discrepancy.
- Distinguish actual local Python execution from mock, physical and external-service observations.
## 2. Environment check
04Python · executable cell
PYTHON · Code cell
# =====================================================================
# N02 | Code cell 01 | IPv4 subnetting & CIDR
# Purpose: 1. Objectives and reference condition - Reproduce the specific computational mechanism in this laboratory. - Inspect the output, compare the reference condition with a changed or rejected condition where implem
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
import sys
print("Python",sys.version.split()[0])
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert sys.version_info >= (3,10)
## 3. Implementation
Read the comments and variable definitions before execution. Assertions must pass; inspect values, not just completion.
06Python · executable cell
PYTHON · Code cell
# =====================================================================
# N02 | Code cell 02 | IPv4 subnetting & CIDR
# Purpose: 3. Implementation Read the comments and variable definitions before execution. Assertions must pass; inspect values, not just completion.
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
import ipaddress, json
# Define the reusable operation check; keep its logic separate from the trial.
def check(ok, label, evidence):
if not ok: raise AssertionError(label)
return dict(check=label,passed=True,evidence=evidence)
# Define the reusable operation subnet; keep its logic separate from the trial.
def subnet():
n=ipaddress.ip_network('192.0.2.73/26',strict=False)
return [check(str(n.network_address)=='192.0.2.64' and str(n.broadcast_address)=='192.0.2.127' and len(list(n.hosts()))==62,'CIDR /26',str(n)),check(len(list(ipaddress.ip_network('192.0.2.72/31').hosts()))==2,'Point-to-point /31','2 addresses')]
### Step 2 · Run the reference calculation
Read the comments and variable definitions before execution. Assertions must pass; inspect values, not just completion.
08Python · executable cell
PYTHON · Code cell
# =====================================================================
# N02 | Code cell 03 | IPv4 subnetting & CIDR
# Purpose: Step 2 · Run the reference calculation Read the comments and variable definitions before execution. Assertions must pass; inspect values, not just completion.
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
# Set checks for the next computation or reference condition.
checks=subnet()
print(json.dumps(checks,indent=2))
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert checks and all(x["passed"] for x in checks)
## Original portal implementation (reference only)
These are the actual laboratory snippets. They are retained for comparison; follow the portal setup for WSL, hardware or services. They are **not** executed by Run all.
```bash
python3 verification/network_practical.py subnet
```
10Instructions · Markdown
## 4. Results and analysis
Record the actual output and whether the assertions pass. Identify a parameter to vary, state your prediction, repeat the reference calculation, then explain the changed result.
| Trial | Configuration | Observation | Interpretation |
|---|---|---|---|
| A | Reference | | |
| B | One controlled change | | |
| C | Reference repeat | | |
**Limitations:** Original independent networking reference; loopback traffic only where applicable. Notebook success does not certify external equipment or services.
11Instructions · Markdown
## Guided reasoning and evidence
A controlled comparison changes one independent input while keeping the other relevant inputs fixed; the dependent variable is the recorded output. Use this lab’s reference condition above.
**Independent task:** 2. Change Prefix length = 30. Baseline: 192.0.2.64/26, mask 255.255.255.192, 62 usable addresses. /30: network 192.0.2.72, 2 hosts. Restore /26. Record the named input, prediction, actual output and one limitation; restore the original condition and repeat.
| Trial | Input/configuration | Prediction | Observation | Evidence / limitation |
|---|---|---|---|---|
| A | Reference | | | |
| B | Changed input | | | |
| A repeat | Reference | | | |
A conclusion is supported only when it cites the recorded values or observed states and explains them with the experiment theory.
Shared research workbenches · network designer & advanced studiesConcurrent-device simulation & Monte Carlo research