Skip to main content
PSUT / IoTEngineering learning studio
WORKSPACE
Offline-first portalDr. Mohammad Alja’afreh
Cyber Defense StudioIoT Security and PrivacyExperimentsWorkspaces
ENGINEERING WORKSPACE
Home/Engineering Workspaces/N05 · DNS & HTTP application services
IoTPSUT IoT Engineering StudioPrincess Sumaya University for Technology · Dr. Mohammad Alja’afreh
Communication Networks · offline engineering
Networking and Communication

DNS & HTTP application services

Ask Dr. Mohammad · N05 →

Read DNS header, transaction ID, query name and response code; verify actual local DNS-format and HTTP exchanges.

Design experiment & verify evidence →
N05 · Laboratory mentorAsk about the current experiment, its algorithms or Python notebook.
Ask Dr. MohammadAdaptive practice
Learning workflow · Advanced networksN05 · DNS & HTTP application services

Related course access: IoT Programming and Applications · IoT Security and Privacy — same laboratory, notebook and completion record.

N05 · Academic orientation

Scope and objectives

Scope of the experiment

Read DNS header, transaction ID, query name and response code; verify actual local DNS-format and HTTP exchanges.

The focus of this experiment is to distinguish DNS resolution from HTTP application exchange. Students then trace hostname lookup and request/response dependencies, and diagnose resolution versus transport or application failure. 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

  • Distinguish DNS resolution from HTTP application exchange.
  • Trace hostname lookup and request/response dependencies.
  • Diagnose resolution versus transport or application failure.
  • Identify the configured inputs (Query name; Response override) 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 distinguish DNS resolution from HTTP application exchange, trace hostname lookup and request/response dependencies, and diagnose resolution versus transport or application failure.

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 diagnose resolution versus transport or application failure. Separate predicted values from observations.

Prerequisite knowledge and related learning

Review the following catalogue prerequisites before starting. After completion, continue to TCP congestion window.

Environment and experimental methodology

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.

N05 · learning outcome

Understand the experiment

DNS message header · request and response

DNS fixed header: six 16-bit words, followed by sections
DNS fixed header: six 16-bit words, followed by sections

Scientific architecture · DNS & HTTP application services

DNS then HTTP — Client; DNS resolver; HTTP server; DNS query / 0>1; IP response / 1>0; Connect to resolved IP / 0>2; HTTP request / 0>2; HTTP response / 2>0
Scientific concept map: URL hostname — DNS lookup; Resolver — Address answer / TTL; TCP connection — Server endpoint; HTTP request — Method and resource; Response — Status and body.

Scientific foundations and analytical reasoning

DNS resolves names to records, while HTTP requests resources; a DNS error can prevent an HTTP exchange. DNS transaction IDs correlate responses.

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 · Name resolution and application requests

DNS resolves a name to resource records, including IPv4 A and IPv6 AAAA records. A resolver may cache responses according to TTL. The DNS transaction ID helps match a response, but additional checks are required in real implementations. HTTP then requests a resource from an endpoint; DNS success does not guarantee HTTP success.

Worked example and engineering interpretation

If a name resolves correctly but its HTTP service returns 404, the DNS step succeeded while the requested resource was absent. If resolution fails, no corresponding HTTP request may occur. Trace the two protocols separately and compare time and status.

Engineering principles · additional worked teaching example

DNS resolves names to resource records; HTTP consumes the address to establish a connection. A DNS transaction ID correlates a request and response; 0x00FF=255. QDCOUNT is question count, ANCOUNT answer count; NXDOMAIN means name does not exist, not HTTP 404.

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 DNS & HTTP application services

Read DNS header, transaction ID, query name and response code; verify actual local DNS-format and HTTP exchanges.

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: Read DNS header, transaction ID, query name and response code; verify actual local DNS-format and HTTP exchanges.

  1. Set Query name = sensor.example; Response override = none. Observe the calculated results and trace.
  2. Change Query name = unknown.example. Baseline: NOERROR, A 192.0.2.10, TTL 60 s. Unknown name: NXDOMAIN. Restore. Inspect request/response hex; transaction ID must match.
  3. Restore the reference values. DNS negative response differs from timeout. HTTP status and body are separate from DNS resolution. The fictional DNS fixture is not a recursive resolver.

Reference check:

Model boundary:

Independent task and submission evidence

2. Change Query name = unknown.example. Baseline: NOERROR, A 192.0.2.10, TTL 60 s. Unknown name: NXDOMAIN. Restore. Inspect request/response hex; transaction ID must match. 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.

TrialChanged settingFixed settingsPredicted resultActual observation / unitsEvidence / uncertainty
A: baselineReferenceRecordPredictRecordRecord
B: one changeRecordSame as APredictRecordRecord
A: repeatRestoreSame as APredictRecordRecord

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.

Read DNS header, transaction ID, query name and response code; verify actual local DNS-format and HTTP exchanges.

DNS negative response differs from timeout. HTTP status and body are separate from DNS resolution. The fictional DNS fixture is not a recursive resolver.

Worked engineering reasoning and boundary conditions

Engineering reference configuration: Query name = sensor.example; Response override = none. In the classroom model, Query bytes = 32 B; Reply bytes = 48 B; RCODE = 0 NOERROR; A record = 192.0.2.10. Fictional authoritative-style response; no external resolver queried. NXDOMAIN is distinct from timeout. DNS negative response differs from timeout. HTTP status and body are separate from DNS resolution. The fictional DNS fixture is not a recursive resolver.

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 · independent state notebook

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.

DNS & HTTP application services: independent state notebook123Calculated state 1ItemTransaction IDValue0x1234Explanation

Step 1 of 3 · Calculated state 1

Calculated state 1

Item
Transaction ID
Value
0x1234
Explanation

Teaching example only; inspect live calculations or real practical evidence separately.

Recall the concept before revealing its explanation.

0 / 3 revealed
N05 · 01 / 08What DNS result, address and TTL should be returned for the reference name versus an unknown name?Reveal explanation
Engineering explanation

Baseline: NOERROR, A 192.0.2.10, TTL 60 s. Unknown name: NXDOMAIN. Restore. Inspect request/response hex; transaction ID must match.

N05 · 02 / 08Why is NXDOMAIN different from a DNS timeout or an HTTP error?Reveal explanation
Engineering explanation

DNS negative response differs from timeout. HTTP status and body are separate from DNS resolution. The fictional DNS fixture is not a recursive resolver.

N05 · 03 / 08How do you verify DNS recovery after changing the queried name?Reveal explanation
Engineering explanation

Restore sensor.example; compare NOERROR, the A record 192.0.2.10, TTL 60 s and matching request/response transaction ID.

N05 · 04 / 08Why match DNS transaction identifiers?Reveal explanation
Engineering reasoning

The identifier helps associate a response with its query; it is not a cryptographic authenticity guarantee.

N05 · 05 / 08Why is NXDOMAIN different from timeout?Reveal explanation
Engineering reasoning

NXDOMAIN is a DNS response indicating the queried name does not exist; timeout means no response was observed.

N05 · 06 / 08A DNS response is inspected. Select every technically valid statement. A. Match the transaction ID and question context. B. Check the response code before interpreting answers. C. A DNS answer alone proves the HTTP service works. D. Every DNS reply is necessarily a successful lookup.Reveal explanation
Applied scenario

Correct: A. Match the transaction ID and question context.; B. Check the response code before interpreting answers.

N05 · 07 / 08In DNS & HTTP application services, which reference and changed settings are prescribed for Query name?Reveal explanation
Controlled configuration

Query name: sensor.example → unknown.example; hold the remaining settings fixed.

N05 · 08 / 08What expected result distinguishes the reference and changed trials in DNS & HTTP application services?Reveal explanation
Expected observation

Baseline: NOERROR, A 192.0.2.10, TTL 60 s. Unknown name: NXDOMAIN. Restore. Inspect request/response hex; transaction ID must match.

Interactive networking and security instrument

Loading experiment-specific apparatus…
Previous model / additional reference tools
Simulation task

Read DNS header, transaction ID, query name and response code; verify actual local DNS-format and HTTP exchanges.

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 workbenchN05 · Existing model
Interactive computational experiment

Configure and observe

Model-linked protocol trace

Animated DNS & HTTP application services

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 events

    Inspect numerical or encoded protocol details
    N05 · Model-linked instrumentation

    Visual observation lens

    Back to controls ↑

    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.

    Open simulation view
    Baseline A
    Not captured
    Comparison B
    Not captured

    Capture a baseline to begin.

    Evidence portfolio →
    V19.0 · Contextual AI workspace

    Ask your engineering assistants

    N05 · current context

    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.

    Dr. Mohammad · offline
    Dr. Mohammad

    Offline curriculum-grounded assistance.

    Open local tutor
    DNS & HTTP application services

    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

    Decode a teaching header ID 0x1234, QDCOUNT=1, ANCOUNT=0; calculate decimal ID and explain fields.

    02 · Compare or justify using evidence

    Compare DNS NXDOMAIN, valid DNS plus HTTP404, and valid DNS plus HTTP200. Draw independent verification stages.

    03 · Protocol reasoning

    Protocol reasoning · Independent work

    A DNS response has ID 0x0102, QDCOUNT=1, ANCOUNT=0, RCODE=3. Decode the ID and diagnose why there is no subsequent HTTP connection under the simple client model.

    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.

    Intermediate · Explain a changed-input result

    Independent theoretical exercise · N05-01

    Use the reference configuration (Query name = sensor.example; Response override = none), but change Response override = nxdomain. The model reports Reply bytes = 32 B. Explain the governing rule and assumptions that make this output plausible; identify an independent verification method.

    Intermediate · Quantitative comparison

    Independent theoretical exercise · N05-02

    Two model observations of Reply bytes are 48 B (reference) and 32 B (changed condition). Compute signed change and, when the reference is nonzero, percentage change. Explain why units matter.

    Intermediate · Interpret a technical trace

    Independent theoretical exercise · N05-03

    For Query name = unknown.example, the model supplies this excerpt from Calculated trace: Item · Value · Explanation Transaction ID · 0x1234 · Question · unknown.example A IN · TTL · N/A · Count rows whose Value value is exactly “0x1234”, and identify the displayed row numbers. Explain what the count describes.

    Advanced · Reverse reasoning

    Independent theoretical exercise · N05-04

    An observation is Query bytes = 33 B. Candidate A uses Query name = sensor.example; Response override = none. Candidate B changes the listed settings (Query name = unknown.example) and keeps the remaining settings fixed. Which is consistent with the observation? If both can explain it, say what additional evidence is required.

    Advanced · Diagnose a reported mismatch

    Independent theoretical exercise · N05-05

    A student configures Query name = unknown.example while preserving all other reference settings, but copies the reference report of Query bytes = 32 B. Evaluate whether the report is justified. Identify the first configuration/output check to perform.

    Challenging · Design a controlled verification

    Independent theoretical exercise · N05-06

    Design a controlled comparison for DNS & HTTP application services using reference Query name = sensor.example; Response override = none and test Response override = nxdomain. Specify the changed setting(s), measured metric Reply bytes, controls, repetitions, an acceptance check and what evidence can distinguish an actual implementation from the model.

    Step-by-step experimental procedure

    Read DNS header, transaction ID, query name and response code; verify actual local DNS-format and HTTP exchanges.

    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.

    Query namesensor.example
    Response overridenone

    2 · Perform the investigation in order

    1. Set Query name = sensor.example; Response override = none. Observe the calculated results and trace.
    2. Change Query name = unknown.example. Baseline: NOERROR, A 192.0.2.10, TTL 60 s. Unknown name: NXDOMAIN. Restore. Inspect request/response hex; transaction ID must match.
    3. Restore the reference values. DNS negative response differs from timeout. HTTP status and body are separate from DNS resolution. The fictional DNS fixture is not a recursive resolver.

    3 · Compare controlled trials

    TrialIndependent changeExpected checkObservation
    ReferenceUse reference inputs aboveBaseline: NOERROR, A 192.0.2.10, TTL 60 s. Unknown name: NXDOMAIN. Restore. Inspect request/response hex; transaction ID must match.Record actual result
    Controlled changeQuery name = unknown.exampleBaseline: NOERROR, A 192.0.2.10, TTL 60 s. Unknown name: NXDOMAIN. Restore. Inspect request/response hex; transaction ID must match.Record actual result

    4 · Analyze and report

    DNS negative response differs from timeout. HTTP status and body are separate from DNS resolution. The fictional DNS fixture is not a recursive resolver.

    Required evidence: Record the dns & http application services comparison and justify the changed outcome from the calculated trace.

    Model boundary: DNS negative response differs from timeout. HTTP status and body are separate from DNS resolution. The fictional DNS fixture is not a recursive resolver.

    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.

    TrialIndependent changeDependent observation
    ReferenceUse reference inputs aboveRecord actual outcome and units
    Controlled changeQuery name = unknown.exampleRecord 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.

    Download NotebookOpen Google ColabAll Python notebooks

    Practical procedure & acceptance

    1. Restore reference and enter your prediction. Select Save baseline.
    2. Apply controlled change. Inspect metrics and protocol details. Compare the results with the following verification conditions.
    3. ✓ Expected: Baseline: NOERROR, A 192.0.2.10, TTL 60 s. Unknown name: NXDOMAIN. Restore. Inspect request/response hex; transaction ID must match.
    4. Restore reference. Confirm the same baseline results, then vary one field at a time. Record the changed configuration and explain any difference.
    5. 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 dns

    ✓ 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 P39 and retain N05 in the method and attachment. The supplemental labs do not change the core prerequisite graph or graded completion counters.

    Experimental Verification Center · Technical reference (online) · Download model source

    Learning progress

    Mark complete only after documenting your observations. This is not a verified result or official grade.

    View prerequisites and related learning

    Python / Google Colab laboratory

    N05 · 11 notebook cells · 3 executable Python cells

    Complete the theoretical investigation first. Run the cells in order, record actual outputs and compare against your prediction.

    How to execute

    1. Download this notebook and open Google Colab. Select File → Upload notebook and choose the downloaded .ipynb.
    2. Read the Markdown instructions before each executable cell. Use a Python runtime, run cells from top to bottom, and resolve imports if necessary.
    3. 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
    # n05 · DNS & HTTP application services **PSUT IoT Engineering Studio — Dr. Mohammad Alja’afreh** ## Introduction Read DNS header, transaction ID, query name and response code; verify actual local DNS-format and HTTP exchanges. ## 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 Read DNS header, transaction ID, query name and response code; verify actual local DNS-format and HTTP exchanges. **Reference procedure (use the matching simulator/WSL tool where named, not an unrelated service):** 1. Set Query name = sensor.example; Response override = none. Observe the calculated results and trace. 2. Change Query name = unknown.example. Baseline: NOERROR, A 192.0.2.10, TTL 60 s. Unknown name: NXDOMAIN. Restore. Inspect request/response hex; transaction ID must match. 3. Restore the reference values. DNS negative response differs from timeout. HTTP status and body are separate from DNS resolution. The fictional DNS fixture is not a recursive resolver. **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
    # =====================================================================
    # N05 | Code cell 01 | DNS & HTTP application services
    # 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)
    
    Ask Dr. Mohammad about this cell
    05Instructions · Markdown
    ## 3. Implementation Read the comments and variable definitions before execution. Assertions must pass; inspect values, not just completion.
    06Python · executable cell
    PYTHON · Code cell
    # =====================================================================
    # N05 | Code cell 02 | DNS & HTTP application services
    # 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 json, socket, struct, threading, urllib.request
    
    from http.server import BaseHTTPRequestHandler, HTTPServer
    
    # 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 exchange; keep its logic separate from the trial.
    def exchange(request, responder, family=socket.AF_INET):
        host='::1' if family==socket.AF_INET6 else '127.0.0.1'
        with socket.socket(family,socket.SOCK_DGRAM) as server, socket.socket(family,socket.SOCK_DGRAM) as client:
            server.bind((host,0)); client.settimeout(1); server.settimeout(1)
            client.sendto(request,server.getsockname())
            data,peer=server.recvfrom(4096); response=responder(data)
            if response is None: return None
            server.sendto(response,peer); received,origin=client.recvfrom(4096)
            assert origin[:2]==server.getsockname()[:2]
            return received
    
    # Define the reusable operation dns; keep its logic separate from the trial.
    def dns():
        def query(name):return bytes.fromhex('123401000001000000000000')+b''.join(bytes([len(x)])+x.encode() for x in name.split('.'))+b'\0\0\1\0\1'
        def respond(q):
            found=q==query('sensor.example');return q[:2]+struct.pack('!5H',0x8500 if found else 0x8503,1,int(found),0,0)+q[12:]+(bytes.fromhex('c00c000100010000003c0004c000020a') if found else b'')
        q=query('sensor.example');r=exchange(q,respond); n=exchange(query('unknown.example'),respond)
        out=[check(r[:2]==q[:2] and r[3]&15==0 and r[6:8]==b'\0\1' and r[-4:]==bytes([192,0,2,10]),'DNS-format UDP positive response',r.hex()),check(n[3]&15==3 and n[6:8]==b'\0\0','DNS-format NXDOMAIN',n.hex())]
        class Handler(BaseHTTPRequestHandler):
            def do_GET(self):
                body=b'{"temperature":25}' if self.path=='/temp' else b'Not found'; self.send_response(200 if self.path=='/temp' else 404);self.send_header('Content-Length',str(len(body)));self.end_headers();self.wfile.write(body)
            def log_message(self,*a):pass
        with HTTPServer(('127.0.0.1',0),Handler) as s:
            thread=threading.Thread(target=s.serve_forever,daemon=True);thread.start()
            try:
                opener=urllib.request.build_opener(urllib.request.ProxyHandler({}));url='http://127.0.0.1:'+str(s.server_port)
                with opener.open(url+'/temp',timeout=2) as res:out.append(check(res.status==200 and json.load(res)=={'temperature':25},'Actual HTTP GET','200 and JSON body'))
                try:opener.open(url+'/missing',timeout=2)
                except urllib.error.HTTPError as e:out.append(check(e.code==404,'Actual HTTP missing resource','404'))
                else:raise AssertionError('Expected HTTP 404')
            finally:s.shutdown();thread.join(timeout=2)
        return out
    
    Ask Dr. Mohammad about this cell
    07Instructions · Markdown
    ### 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
    # =====================================================================
    # N05 | Code cell 03 | DNS & HTTP application services
    # 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=dns()
    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)
    
    Ask Dr. Mohammad about this cell
    09Instructions · Markdown
    ## 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 dns ```
    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 Query name = unknown.example. Baseline: NOERROR, A 192.0.2.10, TTL 60 s. Unknown name: NXDOMAIN. Restore. Inspect request/response hex; transaction ID must match. 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 studies
    Concurrent-device simulation & Monte Carlo research
    Distributed digital twin · topology, protocol & battery research