Measure open and closed TCP ports on an owned loopback service.
The focus of this experiment is to interpret authorized local service inventory and port states. Students then distinguish observed service reachability from vulnerability evidence, and document scope and verify findings without external probing. 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
Interpret authorized local service inventory and port states.
Distinguish observed service reachability from vulnerability evidence.
Document scope and verify findings without external probing.
Record the relevant inputs, intermediate states and final verification result before changing the reference configuration.
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 interpret authorized local service inventory and port states, distinguish observed service reachability from vulnerability evidence, and document scope and verify findings without external probing.
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 document scope and verify findings without external probing. Separate predicted values from observations.
Prerequisite knowledge and related learning
Review the following catalogue prerequisites before starting. After completion, continue to Shodan — authorized IoT exposure inventory.
The specified isolated laboratory environment, with local synthetic inputs and authorized services only. Use the experiment-specific setup and verification instructions.
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.
Scientific concepts and engineering principles
Scientific architecture · NS02 · Nmap — authorized local service inventory
A TCP connect inventory classifies a controlled service as open, closed or filtered based on connection outcome. Port state does not prove vulnerability.
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 · TCP service-state evidence
A TCP connect inventory attempts the normal connection handshake against an authorized service. An open port accepts connections; a closed port can refuse them; filtering may cause timeout or another indication depending on the network. A port number alone does not establish the service version or vulnerability.
Worked example and engineering interpretation
Start the assigned local HTTP service and compare the approved localhost inventory before and after startup. Record port state and server status; stop the service and verify the state again. Use only the assigned targets and avoid interpreting an open port as proof of compromise.
Engineering principles · additional worked teaching example
Authorized inventory distinguishes listening service, network reachability and application authentication. A closed port can actively reject connection; filtered observations may be inconclusive. A banner does not establish software vulnerability.
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 Nmap — authorized local service inventory
Measure open and closed TCP ports on an owned loopback service.
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: Measure open and closed TCP ports on an owned loopback service.
Owned service inventory — complete its numbered steps and record the requested evidence.
Protocol state inspection — complete its numbered steps and record the requested evidence.
Compare observations with the reference checks and submit the required evidence.
Run the localhost TCP connect scan before starting an HTTP service, then start it on 127.0.0.1:8080 and repeat.
Reference check: SYN, SYN ACK, ACK; open.
RST ACK; closed.
No response/timeout in model.
8080 changes from closed to open if unused initially; other ports depend on local services.
Model boundary: Nmap TCP connect scans use the operating system connect call. Open means connection succeeds, closed means refusal, filtered means the scanner cannot determine openness because of filtering or lack of response. The virtual filtered state is a teaching model, not a guaranteed loopback observation. Only scan the fixed 127.0.0.1 targets in this experiment; do not scan third-party hosts.
Independent task and submission evidence
2. Protocol state inspection — complete its numbered steps and record the requested evidence. 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.
Service exposure
A network service binds a local address and port. A TCP connect scan attempts a connection: a successful connection indicates open, a refusal generally indicates closed, while no response or an administrative prohibition may indicate filtered. State is an observation from the scanner’s perspective.
Controlled comparison
Use only the loopback target and the selected ports. Record baseline, start a Python HTTP server, repeat the scan, stop it and scan again. The virtual filtered condition demonstrates a timeout without requiring a host firewall change.
Interpretation
An open port does not prove a vulnerable product. A service inventory is a starting point for verifying the expected application, configuration, version and owner-approved remediation.
Prerequisites: NS01
Algorithm structure and data flow. Use the simulation to inspect the corresponding numerical transformations.
Worked engineering reasoning and boundary conditions
A service inventory is not a vulnerability verdict. Open indicates a response consistent with a listening service, closed indicates no listener, filtered means the scanner cannot determine state due to filtering. Restrict work to authorized fixtures.
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.
Concept animation · operation pathway
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 · Approved local scope
Approved local scope
Approved local scope
three test services
Inventory
Approved local scope
three test services
Inventory
open / closed / filtered
Validate
Approved local scope
three test services
Inventory
open / closed / filtered
Validate
compare listener configuration
Report
Approved local scope
three test services
Inventory
open / closed / filtered
Validate
compare listener configuration
Report
exposure is not exploitability
Teaching example only; inspect live calculations or real practical evidence separately.
Interactive flashcards
Self-rated study progress is stored locally, not used for official grades.
Browse all explanationsWhat indicates an open TCP connect port?
Successful connection.
What distinguishes closed from filtered?
Refusal versus lack of a definitive response.
Why use localhost?
Controlled authorized target.
Does an open port prove vulnerability?
No.
What is a TCP connect scan?
A scan using normal OS TCP connection attempts.
What does an open TCP port typically return to SYN?
SYN-ACK.
What response usually indicates a closed TCP port?
RST or RST-ACK.
What does filtered mean?
The scanner cannot determine openness due to filtering or missing responses.
Why scan before starting the lab service?
To establish a baseline.
Why scan after stopping the server?
To verify the expected state change.
What does -p select?
The port or ports to inspect.
Why use -n in a local experiment?
To avoid DNS lookup variability.
Does an open port prove exploitability?
No, it establishes a reachable service under the scan conditions.
What is the authorized target in this lab?
The student's own loopback server or an explicitly assigned lab asset.
A localhost HTTP server is stopped after a successful connect scan. What state may change?
The selected port usually moves from open to closed if no other service or filtering is present.
Does a TCP connection refusal mean the host is unreachable?
No. A refusal generally implies that the target was reachable but the port was not listening.
Why repeat a service inventory with a known local service?
It establishes a controlled positive and negative case for interpreting the scanner’s output.
Virtual laboratory
Change inputs independently, play or step through the calculated states, expand a workstation, and compare your observations. Browser network models do not send or capture real packets.
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
Draw response sequence for local open and closed TCP ports. Compare with a modeled timeout; explain why timeout is ambiguous.
Engineering method — Authorized inventory distinguishes listening service, network reachability and application authentication. A closed port can actively reject connection; filtered observations may be inconclusive. A banner does not establish software vulnerability. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
02 · Compare or justify using evidence
For ports 8080,8081,8082 with only 8080 running, predict results before/after stopping the owned service. Record expected state changes and evidence.
Engineering method — Authorized inventory distinguishes listening service, network reachability and application authentication. A closed port can actively reject connection; filtered observations may be inconclusive. A banner does not establish software vulnerability. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
03 · Interpretation
Interpretation · Independent work
A dedicated local service is configured on port8000 but local inventory reports closed. Give diagnostic sequence without changing external systems.
Interpretation — Authorized inventory distinguishes listening service, network reachability and application authentication. A closed port can actively reject connection; filtered observations may be inconclusive. A banner does not establish software vulnerability. 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 · NS02-01
Given lab inventory: port A open, B closed, C filtered. Which status proves a vulnerability?
Intermediate · Calculate or trace
Independent theoretical exercise · NS02-02
Why is a filtered result not equivalent to closed?
Intermediate · Interpret the result
Independent theoretical exercise · NS02-03
A service is bound to loopback. Should a different LAN host be assumed to reach it?
Advanced · Analyze a condition
Independent theoretical exercise · NS02-04
Inventory shows three listening services but only two are required. What is the first defensive action?
Advanced · Diagnose or compare
Independent theoretical exercise · NS02-05
Compare baseline and post-hardening service counts 8 and 5.
Challenging · Engineering verification
Independent theoretical exercise · NS02-06
What evidence belongs in a local-only inventory report?
Activity sequence
Follow the setup commands, then each named activity. The detailed instructions, given values and recording fields appear below.
Compare observations with the reference checks and submit the required evidence.
Scientific experimental protocol
Research question: Measure open and closed TCP ports on an owned loopback service.
Independent variables: packet filter, service state and selected port. Dependent observations: packet counts, flags and local port state.
Controls: use the indicated baseline settings, vary one parameter at a time, and record actual results separately from the browser model. For timing comparisons use the same environment and report repetitions.
Experimental procedure
Before starting — tools and setup
Open Kali/WSL and keep each terminal open as instructed. Run the commands in their labeled terminals; use only the loopback target. Use the virtual simulator if tools or capture permissions are unavailable.
BASH · Command
# Kali/WSL: install the local tools
sudo apt update
sudo apt install -y nmap python3
# Terminal 1: baseline on your own machine only
nmap -sT -Pn -n -p 8080,8081,8082 127.0.0.1
# Terminal 2: launch local service
python3 -m http.server 8080 --bind 127.0.0.1
# Terminal 1: repeat inventory and save result
nmap -sT -Pn -n -p 8080,8081,8082 -oN local-inventory.txt 127.0.0.1
# Stop server in terminal 2 using Ctrl+C, repeat scan.
Complete the activities in order. Hold the controlled conditions fixed, record the input and actual output, and compare your observations with an independent calculation or test vector.
01
Owned service inventory
Open the exact workstation
Choose the relevant tab below, enter the assigned values in the activity steps, then use Step or Play to inspect intermediate calculations. Return to Experiment and record the results before changing the input.
Run the localhost TCP connect scan before starting an HTTP service, then start it on 127.0.0.1:8080 and repeat.
Compare open/closed results. Use virtual filtered condition to examine timeout; do not assume localhost always has a filtered port.
Stop the server and repeat to verify the change.
Evidence to record
Three inventories, port state and evidence.
Verification: Record the baseline and modified input separately, note the observed intermediate values, compare with the assigned calculation, and explain any mismatch. Do not replace observations with expected values.
02
Protocol state inspection
Open the exact workstation
Choose the relevant tab below, enter the assigned values in the activity steps, then use Step or Play to inspect intermediate calculations. Return to Experiment and record the results before changing the input.
Play open, closed and filtered virtual TCP paths; compare SYN-ACK, RST-ACK and timeout.
Explain why a port state or service banner alone does not prove a vulnerability.
Evidence to record
Packet event sequences and interpretation.
Verification: Record the baseline and modified input separately, note the observed intermediate values, compare with the assigned calculation, and explain any mismatch. Do not replace observations with expected values.
Trial
Procedure
Reference check
Your observation
Virtual open
Set port 8080 open and play.
SYN, SYN ACK, ACK; open.
Enter result
Virtual closed
Set closed and replay.
RST ACK; closed.
Enter result
Virtual filtered
Set filtered and replay.
No response/timeout in model.
Enter result
Actual inventory
Compare scan before and after running localhost HTTP service.
8080 changes from closed to open if unused initially; other ports depend on local services.
Enter result
Analysis and reporting
Why does closed differ from filtered? Why can port state change without a vulnerability? How should an inventory establish an authorized baseline?
Record environment, input values, output and deviations; retain traces or PCAP where appropriate. The table is temporary; save your own report.
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: Nmap TCP connect scans use the operating system connect call. Open means connection succeeds, closed means refusal, filtered means the scanner cannot determine openness because of filtering or lack of response. The virtual filtered state is a teaching model, not a guaranteed loopback observation. Only scan the fixed 127.0.0.1 targets in this experiment; do not scan third-party hosts. Default computational cells passed isolated local Python execution; physical equipment and live services require separate verification.
01Instructions · Markdown
# NS02 · Nmap — authorized local service inventory
**PSUT IoT Engineering Studio — Dr. Mohammad Alja’afreh**
## 1. Scientific objective
Follow the setup commands, then each named activity. The detailed instructions, given values and recording fields appear below.
Complete the analytical worksheet in the portal first. Record your predictions before running this notebook. This notebook is a bounded local computational investigation; use the portal’s separate WSL, hardware or Remix procedure for real interfaces.
02Instructions · Markdown
## Experiment-specific preparation
Measure open and closed TCP ports on an owned loopback service.
**Reference procedure (use the matching simulator/WSL tool where named, not an unrelated service):**
1. Owned service inventory — complete its numbered steps and record the requested evidence.
2. Protocol state inspection — complete its numbered steps and record the requested evidence.
3. Compare observations with the reference checks and submit the required evidence.
4. Run the localhost TCP connect scan before starting an HTTP service, then start it on 127.0.0.1:8080 and repeat.
5. Compare open/closed results. Use virtual filtered condition to examine timeout; do not assume localhost always has a filtered port.
**Evidence:** SYN, SYN ACK, ACK; open.
RST ACK; closed.
No response/timeout in model.
8080 changes from closed to open if unused initially; other ports depend on local services.
**Boundary:** Nmap TCP connect scans use the operating system connect call. Open means connection succeeds, closed means refusal, filtered means the scanner cannot determine openness because of filtering or lack of response. The virtual filtered state is a teaching model, not a guaranteed loopback observation. Only scan the fixed 127.0.0.1 targets in this experiment; do not scan third-party hosts.
03Instructions · Markdown
## 2. Reference configuration and investigation
1. Owned service inventory — complete its numbered steps and record the requested evidence.
2. Protocol state inspection — complete its numbered steps and record the requested evidence.
3. Compare observations with the reference checks and submit the required evidence.
Run cells in order; do not substitute model results for physical measurements.
04Instructions · Markdown
## 3. Analyze fictional local service observations without scanning external targets.
05Python · executable cell
PYTHON · Code cell
# =====================================================================
# NS02 | Code cell 01 | Nmap — authorized local service inventory
# Purpose: 3. Analyze fictional local service observations without scanning external targets.
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
# Set before for the next computation or reference condition.
before={8080:"closed",8081:"closed",8082:"closed"}
# Set after for the next computation or reference condition.
after={**before,8080:"open"}
print(before,after)
## 4. Compare inventory and explain that closed differs from filtered.
07Python · executable cell
PYTHON · Code cell
# =====================================================================
# NS02 | Code cell 02 | Nmap — authorized local service inventory
# Purpose: 4. Compare inventory and explain that closed differs from filtered.
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
# Set changed for the next computation or reference condition.
changed=[p for p in before if before[p]!=after[p]]
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert changed==[8080]
print(changed)
## Experimental analysis and submission
1. Record the reference input, predicted output and actual result.
2. Modify one independent variable and run the relevant cells again.
3. Explain the result using the theory and identify model limitations.
4. Save the notebook with outputs and retain the separate theoretical worksheet.
**Your derivation and conclusion:**
(Complete independently.)
09Instructions · 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. Protocol state inspection — complete its numbered steps and record the requested evidence. 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.
Local practical commands
Run the commands in the labeled terminals, only against your own loopback interface. If port 8080 is already occupied, stop your own service or use another assigned local port consistently.
BASH · Command
# Kali/WSL: install the local tools
sudo apt update
sudo apt install -y nmap python3
# Terminal 1: baseline on your own machine only
nmap -sT -Pn -n -p 8080,8081,8082 127.0.0.1
# Terminal 2: launch local service
python3 -m http.server 8080 --bind 127.0.0.1
# Terminal 1: repeat inventory and save result
nmap -sT -Pn -n -p 8080,8081,8082 -oN local-inventory.txt 127.0.0.1
# Stop server in terminal 2 using Ctrl+C, repeat scan.
The local utilities require installation and permission; the website simulator is independent of these commands.