Skip to main content
PSUT / IoTEngineering learning studio
WORKSPACE
Offline-first portalDr. Mohammad Alja’afreh
Embedded Systems StudioIoT Programming and ApplicationsExperimentsWorkspaces
ENGINEERING WORKSPACE
Home/Engineering Workspaces/N01 · Packet encapsulation & MTU
IoTPSUT IoT Engineering StudioPrincess Sumaya University for Technology · Dr. Mohammad Alja’afreh
Communication Networks · offline engineering
Networking and Communication

Packet encapsulation & MTU

Ask Dr. Mohammad · N01 →

Compute IPv4 header checksum and Ethernet frame size; distinguish payload, packet and frame.

Design experiment & verify evidence →
N01 · Laboratory mentorAsk about the current experiment, its algorithms or Python notebook.
Ask Dr. MohammadAdaptive practice
Learning workflow · Advanced networksN01 · Packet encapsulation & MTU
N01 · Academic orientation

Scope and objectives

Scope of the experiment

Compute IPv4 header checksum and Ethernet frame size; distinguish payload, packet and frame.

The focus of this experiment is to trace packet encapsulation and header contributions. Students then calculate IPv4 fragmentation payload alignment and total overhead, and verify fragment offsets, flags and MTU assumptions. 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

  • Trace packet encapsulation and header contributions.
  • Calculate IPv4 fragmentation payload alignment and total overhead.
  • Verify fragment offsets, flags and MTU assumptions.
  • Identify the configured inputs (Application bytes; Transport; IP MTU (bytes); Header modification) 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 trace packet encapsulation and header contributions, calculate IPv4 fragmentation payload alignment and total overhead, and verify fragment offsets, flags and MTU assumptions.

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 fragment offsets, flags and MTU assumptions. Separate predicted values from observations.

Prerequisite knowledge and related learning

Review the following catalogue prerequisites before starting. After completion, continue to IPv4 subnetting & CIDR.

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.

N01 · learning outcome

Understand the experiment

Protocol encapsulation and Ethernet frame

IPv4 without options · fixed teaching header lengths (bytes)
IPv4 without options · fixed teaching header lengths (bytes)

Scientific architecture · Packet encapsulation & MTU

Encapsulation and MTU — App data / 1000 B; TCP header / 20 B minimum; IPv4 header / 20 B minimum; Ethernet payload / 1040 B; MTU 1500 B / fits (no options)
Scientific concept map: Application payload — Bytes; TCP/UDP header — Transport segment; IP header — Packet and checksum; Ethernet — Frame / padding / FCS; MTU test — Payload limit.

Scientific foundations and analytical reasoning

Encapsulation adds headers at each layer. With no options IPv4 adds 20 bytes, UDP 8 and TCP 20; Ethernet adds header/FCS and minimum padding.

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 · Encapsulation and frame budgets

A transport segment is carried inside an IP packet, which is carried inside a link-layer frame. Each layer adds control information. IPv4 without options uses 20 header bytes, UDP adds 8, and basic TCP adds 20. Ethernet payload has a minimum length and a typical 1500-byte MTU; the Ethernet header and FCS are not part of that IP MTU.

Worked example and engineering interpretation

A 100-byte UDP application message produces a 128-byte IPv4 packet and a 146-byte ordinary Ethernet frame (14-byte header and 4-byte FCS, excluding preamble and interframe gap). Calculate payload efficiency using an explicitly stated boundary; overhead figures depend on the selected headers.

Engineering principles · additional worked teaching example

Encapsulation adds headers: for IPv4 without options and UDP, 20+8 bytes before application payload. For 80 B payload, IP length108 B, Ethernet frame126 B with 14 B header and 4 B FCS; IP MTU is not total link-frame length.

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 Packet encapsulation & MTU

Compute IPv4 header checksum and Ethernet frame size; distinguish payload, packet and frame.

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: Compute IPv4 header checksum and Ethernet frame size; distinguish payload, packet and frame.

  1. Set Application bytes = 32; Transport = UDP; IP MTU (bytes) = 1500; Header modification = none. Observe the calculated results and trace.
  2. Change Header modification = corrupt. Baseline: 60-byte IP packet, 78-byte Ethernet frame, valid checksum. Corruption: invalid checksum. Restore fault=none. Set payload=1480 and UDP: 1508-byte IP packet exceeds MTU 1500.
  3. Restore the reference values. IPv4 checksum covers the header only; Ethernet accounting includes FCS and padding but excludes preamble and interframe gap. TCP header length assumes no options.

Reference check:

Model boundary:

Independent task and submission evidence

2. Change Header modification = corrupt. Baseline: 60-byte IP packet, 78-byte Ethernet frame, valid checksum. Corruption: invalid checksum. Restore fault=none. Set payload=1480 and UDP: 1508-byte IP packet exceeds MTU 1500. 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.

Compute IPv4 header checksum and Ethernet frame size; distinguish payload, packet and frame.

IPv4 checksum covers the header only; Ethernet accounting includes FCS and padding but excludes preamble and interframe gap. TCP header length assumes no options.

Worked engineering reasoning and boundary conditions

Engineering reference configuration: Application bytes = 32; Transport = UDP; IP MTU (bytes) = 1500; Header modification = none. In the classroom model, IP packet = 60 B; Ethernet frame incl. FCS = 78 B; Header checksum = Valid; MTU decision = Fits. Header checksum and MTU pass in this model. No actual Ethernet frame transmitted. IPv4 checksum covers the header only; Ethernet accounting includes FCS and padding but excludes preamble and interframe gap. TCP header length assumes no options.

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 fragmentation alignment

MTU and H are in bytes; for non-final fragments, payload is a multiple of eight bytes. H includes the actual IPv4 header; this calculation assumes fragmentation is allowed.

\[L_{\max}=8\left\lfloor\frac{\mathrm{MTU}-H}{8}\right\rfloor\]

Concept animation · packet structure

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.

Packet encapsulation & MTU: packet structureEthernetheader + FCS18 BIPv420 BUDP8 BPayload32 BPadding0 BField order; widths are schematic, not byte-proportional.

Step 1 of 5 · Ethernet header + FCS

Ethernet header + FCS

Ethernet header + FCS
18 bytes

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

Recall the concept before revealing its explanation.

0 / 3 revealed
N01 · 01 / 08What are the reference IPv4 packet and Ethernet frame lengths, and what happens after header corruption?Reveal explanation
Engineering explanation

Baseline: 60-byte IP packet, 78-byte Ethernet frame, valid checksum. Corruption: invalid checksum. Restore fault=none. Set payload=1480 and UDP: 1508-byte IP packet exceeds MTU 1500.

N01 · 02 / 08Which bytes does the IPv4 checksum protect, and which framing overheads are excluded?Reveal explanation
Engineering explanation

IPv4 checksum covers the header only; Ethernet accounting includes FCS and padding but excludes preamble and interframe gap. TCP header length assumes no options.

N01 · 03 / 08After restoring an unmodified header, which checksum and length observations must return to baseline?Reveal explanation
Engineering explanation

Restore fault=none; the header checksum must validate again and the reference 60-byte IP packet and 78-byte Ethernet frame must be reproduced.

N01 · 04 / 08Which fields contribute to the IP packet length?Reveal explanation
Engineering reasoning

The IP header plus its payload, including the transport header and application payload. Ethernet overhead is outside IP length.

N01 · 05 / 08Why use a changed header checksum as a negative test?Reveal explanation
Engineering reasoning

A corrupted covered header should fail checksum validation; restore the reference to verify the expected calculation returns.

N01 · 06 / 08A packet is carried in an Ethernet frame. Select every technically valid statement. A. An IPv4 header contributes to IP packet length. B. An Ethernet header and FCS contribute additional frame bytes. C. IP MTU includes the Ethernet preamble by definition. D. IPv4 checksum covers the entire Ethernet frame.Reveal explanation
Applied scenario

Correct: A. An IPv4 header contributes to IP packet length.; B. An Ethernet header and FCS contribute additional frame bytes.

N01 · 07 / 08In Packet encapsulation & MTU, which reference and changed settings are prescribed for Header modification?Reveal explanation
Controlled configuration

Header modification: none → corrupt; hold the remaining settings fixed.

N01 · 08 / 08What expected result distinguishes the reference and changed trials in Packet encapsulation & MTU?Reveal explanation
Expected observation

Baseline: 60-byte IP packet, 78-byte Ethernet frame, valid checksum. Corruption: invalid checksum. Restore fault=none. Set payload=1480 and UDP: 1508-byte IP packet exceeds MTU 1500.

Interactive networking and security instrument

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

Compute IPv4 header checksum and Ethernet frame size; distinguish payload, packet and frame.

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

Configure and observe

Model-linked protocol trace

Animated Packet encapsulation & MTU

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
    N01 · 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

    N01 · 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
    Packet encapsulation & MTU

    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 32 application bytes calculate UDP and TCP IP lengths and Ethernet lengths (14-byte header, 4-byte FCS, minimum frame 64).

    02 · Compare or justify using evidence

    For MTU1500 derive largest UDP and TCP payload without fragmentation. Explain what the IPv4 header checksum does and does not protect.

    03 · Calculation

    Calculation · Independent work

    For 1200 application bytes over IPv4/TCP (no options), find IP length and Ethernet frame size; how many application bytes fit a 1500 B IP MTU?

    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 · N01-01

    Use the reference configuration (Application bytes = 32; Transport = UDP; IP MTU (bytes) = 1500; Header modification = none), but change Application bytes = 0. The model reports IP packet = 28 B. Explain the governing rule and assumptions that make this output plausible; identify an independent verification method.

    Intermediate · Quantitative comparison

    Independent theoretical exercise · N01-02

    Two model observations of IP packet are 60 B (reference) and 28 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 · N01-03

    For Transport = TCP, the model supplies this excerpt from Calculated trace: Item · Value · Explanation Application payload · 32 B · TCP header · 20 B · IPv4 header · 20 B · Ethernet header + FCS · 18 B · Count rows whose Value value is exactly “20 B”, and identify the displayed row numbers. Explain what the count describes.

    Advanced · Reverse reasoning

    Independent theoretical exercise · N01-04

    An observation is IP packet = 72 B. Candidate A uses Application bytes = 32; Transport = UDP; IP MTU (bytes) = 1500; Header modification = none. Candidate B changes the listed settings (Transport = TCP) 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 · N01-05

    A student configures Header modification = corrupt while preserving all other reference settings, but copies the reference report of Header checksum = Valid. Evaluate whether the report is justified. Identify the first configuration/output check to perform.

    Challenging · Design a controlled verification

    Independent theoretical exercise · N01-06

    Design a controlled comparison for Packet encapsulation & MTU using reference Application bytes = 32; Transport = UDP; IP MTU (bytes) = 1500; Header modification = none and test Application bytes = 0. Specify the changed setting(s), measured metric IP packet, controls, repetitions, an acceptance check and what evidence can distinguish an actual implementation from the model.

    Challenging numerical variant 1

    Calculation · Independent work

    IPv4 payload 2400 B, 20 B header, MTU 1200 B, DF clear, no options. Every non-final fragment uses the maximum eight-byte-aligned payload. What is total transmitted IP bytes across this link (sum of all fragment sizes)?

    Challenging numerical variant 2

    Calculation · Independent work

    IPv4 payload 3400 B, 20 B header, MTU 1200 B, DF clear, no options. Every non-final fragment uses the maximum eight-byte-aligned payload. What is total transmitted IP bytes across this link (sum of all fragment sizes)?

    Challenging numerical variant 3

    Calculation · Independent work

    IPv4 payload 2100 B, 20 B header, MTU 1100 B, DF clear, no options. Every non-final fragment uses the maximum eight-byte-aligned payload. What is total transmitted IP bytes across this link (sum of all fragment sizes)?

    Step-by-step experimental procedure

    Compute IPv4 header checksum and Ethernet frame size; distinguish payload, packet and frame.

    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.

    Application bytes32
    TransportUDP
    IP MTU (bytes)1500
    Header modificationnone

    2 · Perform the investigation in order

    1. Set Application bytes = 32; Transport = UDP; IP MTU (bytes) = 1500; Header modification = none. Observe the calculated results and trace.
    2. Change Header modification = corrupt. Baseline: 60-byte IP packet, 78-byte Ethernet frame, valid checksum. Corruption: invalid checksum. Restore fault=none. Set payload=1480 and UDP: 1508-byte IP packet exceeds MTU 1500.
    3. Restore the reference values. IPv4 checksum covers the header only; Ethernet accounting includes FCS and padding but excludes preamble and interframe gap. TCP header length assumes no options.

    3 · Compare controlled trials

    TrialIndependent changeExpected checkObservation
    ReferenceUse reference inputs aboveBaseline: 60-byte IP packet, 78-byte Ethernet frame, valid checksum. Corruption: invalid checksum. Restore fault=none. Set payload=1480 and UDP: 1508-byte IP packet exceeds MTU 1500.Record actual result
    Controlled changeHeader modification = corruptBaseline: 60-byte IP packet, 78-byte Ethernet frame, valid checksum. Corruption: invalid checksum. Restore fault=none. Set payload=1480 and UDP: 1508-byte IP packet exceeds MTU 1500.Record actual result

    4 · Analyze and report

    IPv4 checksum covers the header only; Ethernet accounting includes FCS and padding but excludes preamble and interframe gap. TCP header length assumes no options.

    Required evidence: Record the packet encapsulation & mtu comparison and justify the changed outcome from the calculated trace.

    Model boundary: IPv4 checksum covers the header only; Ethernet accounting includes FCS and padding but excludes preamble and interframe gap. TCP header length assumes no options.

    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 changeHeader modification = corruptRecord 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: 60-byte IP packet, 78-byte Ethernet frame, valid checksum. Corruption: invalid checksum. Restore fault=none. Set payload=1480 and UDP: 1508-byte IP packet exceeds MTU 1500.
    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 packet

    ✓ 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 P37 and retain N01 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

    N01 · 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
    # n01 · Packet encapsulation & MTU **PSUT IoT Engineering Studio — Dr. Mohammad Alja’afreh** ## Introduction Compute IPv4 header checksum and Ethernet frame size; distinguish payload, packet and frame. ## 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 Compute IPv4 header checksum and Ethernet frame size; distinguish payload, packet and frame. **Reference procedure (use the matching simulator/WSL tool where named, not an unrelated service):** 1. Set Application bytes = 32; Transport = UDP; IP MTU (bytes) = 1500; Header modification = none. Observe the calculated results and trace. 2. Change Header modification = corrupt. Baseline: 60-byte IP packet, 78-byte Ethernet frame, valid checksum. Corruption: invalid checksum. Restore fault=none. Set payload=1480 and UDP: 1508-byte IP packet exceeds MTU 1500. 3. Restore the reference values. IPv4 checksum covers the header only; Ethernet accounting includes FCS and padding but excludes preamble and interframe gap. TCP header length assumes no options. **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
    # =====================================================================
    # N01 | Code cell 01 | Packet encapsulation & MTU
    # 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
    # =====================================================================
    # N01 | Code cell 02 | Packet encapsulation & MTU
    # 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, struct
    
    # 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 checksum; keep its logic separate from the trial.
    def checksum(data):
        if len(data)%2:data+=b'\0'
        total=sum(struct.unpack('!'+str(len(data)//2)+'H',data))
        while total>>16:total=(total&0xffff)+(total>>16)
        return (~total)&0xffff
    
    # Define the reusable operation packet; keep its logic separate from the trial.
    def packet():
        h=bytearray.fromhex('4500003c0001400040110000c0000201c0000202')
        struct.pack_into('!H',h,10,checksum(h)); bad=bytearray(h);bad[8]^=1
        return [check(checksum(h)==0,'Valid IPv4 header',h.hex()),check(checksum(bad)!=0,'Modified TTL invalidates checksum',bad.hex())]
    
    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
    # =====================================================================
    # N01 | Code cell 03 | Packet encapsulation & MTU
    # 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=packet()
    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 packet ```
    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 Header modification = corrupt. Baseline: 60-byte IP packet, 78-byte Ethernet frame, valid checksum. Corruption: invalid checksum. Restore fault=none. Set payload=1480 and UDP: 1508-byte IP packet exceeds MTU 1500. 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