Reproducible protocol experiments
Define a testable hypothesis and evidence plan
A reproducible experiment states the question, expected outcome, fixed input, controlled variables, exact tool version and limitations. Our question is whether a bounded offline reader correctly extracts selected IPv4 header fields from a known byte array and refuses incomplete input. The fixture contains one invented IPv4 header with documentation addresses, a declared 28-byte IP packet and eight payload bytes. There is no Ethernet header in this fixture. It is an inert local array, never transmitted. The reader does not interpret the payload, validate transport or authenticate data. A second example tests a shortened local copy, modeling capture truncation rather than deliberately injecting malformed traffic.
Decode only the fields you need
Read the first byte as version (upper four bits) and IHL (lower four bits, measured in 32-bit words). Hex 45 means IPv4 and five words, or 20 bytes. The total length field at bytes 2–3 is big-endian: 00 1c means 28 bytes. The TTL byte is 40 hex, or 64 decimal; protocol 11 hex is 17 decimal (UDP). Source c0 00 02 0a decodes to 192.0.2.10; destination c6 33 64 14 to 198.51.100.20. The eight payload bytes are an illustrative UDP header; no transport interpretation is required. Before decoding, require at least 20 bytes, version 4, IHL of at least five, a complete header and a total length not smaller than the header. Require that the declared packet fits the captured data. Return a clear classification for incomplete or out-of-scope records, not a fabricated partial result. Our reader deliberately supports only IHL=5 and no fragmentation; it is not a general IPv4 validator.
45 00 00 1c 00 01 00 00 40 11 8e 7e c0 00 02 0a c6 33 64 1430 39 00 35 00 08 00 00Use independent expected values
Hand-calculate the fields above before running a reader. Store the expected source, destination, TTL, protocol, header length and total length next to the fixture. The full record should be decoded; an array containing only the first 24 bytes should be classified truncated because 28 bytes were declared. A capture may have extra bytes from padding or framing, so this reader ignores trailing bytes beyond the declared IP length. It does not validate header checksum, option semantics, flags beyond its fragmentation scope, payload checksum, routing or delivery. Input bounds and unsupported variants are tested separately. The experiment compares exact values, not just whether a script exits successfully.
Make the evidence reproducible
Record fixture SHA-256, Python version, OS/architecture, reader revision, input representation and expected values. Run the provided validator locally with ordinary user privileges and no network access; it uses only the Python standard library. The included checks compare a scan with a trie, expected segment lengths, queue outcomes, state transitions and decoded fields. A passing result means the stated offline assertions held. It is not evidence that a NIC, router ASIC, Wireshark, protocol stack or ByteMind evaluator was executed. Reproducing actual hardware behavior would additionally require approved isolated equipment, interface and capture-point details, kernel/driver/firmware versions, offload settings, repeated measurements, a bounded workload and cleanup. Avoid unsupported changes to shared infrastructure.
Prepare the capstone evidence register
Make a table of expected and actual offline results, with evidence class and limitations. For an unexpected result, first confirm fixture identity and offsets, then check whether the implementation matches the declared subset. Do not adjust expected answers just to make a test pass. Keep the original failing record and explain any deliberate revision. In the capstone, reuse this discipline for addressing, routes, security policy, service dependencies and recovery. Each claim should be traceable to a requirement, documented source or explicitly labeled experiment.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Reproducible protocol experiments Quiz
Reason about standards, forwarding internals and reproducible experiments.
What does IPv4 first byte hex 45 encode?
Total length bytes 00 1c mean what?
Declared length is 28 but captured array is 24 bytes. What is the result?
What does a passing offline parser test prove?
Which evidence enables a repeatable comparison?