# Measure 6LoWPAN addresses and the fragment gate

Compare the address scope, compressed frame budget and delivery of a 52-byte report and a 300-byte diagnostic packet.

## Run on Linux x86-64 with Docker and X11

The image, Java, compiler and simulator ran on this host under Apptainer.
Docker is unavailable here: the laptop Docker invocation is syntax-reviewed,
not claimed as laptop-tested. Windows, macOS and ARM display setup is outside
this recipe. No paid service or account is required.

Download `lab-files.tar.gz` from this lab page. In a terminal:

```bash
mkdir cooja-lab
cd cooja-lab
tar -xzf ~/Downloads/lab-files.tar.gz
git clone --depth 1 --branch release/v4.9 https://github.com/contiki-ng/contiki-ng.git contiki-ng
test "$(git -C contiki-ng rev-parse HEAD)" = c20b12cd2db707d6c07918f8b26cfeb52cf298ca
git -C contiki-ng submodule update --init --depth 1 tools/cooja
test "$(git -C contiki-ng/tools/cooja rev-parse HEAD)" = 33d41ae9f8acd6075fb903b0bcd5b4122bad8d8f
mkdir -p jdk17 home/contiki-ng
curl -fL 'https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.20.1%2B1/OpenJDK17U-jdk_x64_linux_hotspot_17.0.20.1_1.tar.gz' -o jdk17.tar.gz
echo '3808d1d15e3ec6bd5b84057fb5d84c33d8a1536a258146bcea2e603fc726e08e  jdk17.tar.gz' | sha256sum -c -
tar -xzf jdk17.tar.gz --strip-components=1 -C jdk17
xhost +si:localuser:$(id -un)
bash cooja-6lowpan-addressing/docker-launch.sh
# After closing Cooja:
xhost -si:localuser:$(id -un)
```

The launcher binds the packet at `/lab`. Cooja loads `/lab/cooja-6lowpan-addressing.csc`
and compiles the included unmodified upstream C files. The project header enables
logging and any explicitly documented parameter changes. The supplied Makefiles
expect the recipe's `/home/user/contiki-ng` mount. The first Gradle build requires
Internet. To use your own native Java 17 installation, set CONTIKI in the supplied
Makefiles to your checkout and open the CSC with that release's Cooja.

The script starts automatically and stops at `TEST OK` or `TEST FAILED`. The GUI
stays open. Use **Mote output → Filter** to show the rows named in the steps;
clear the filter to inspect other messages. **File → Open simulation → Browse...**
loads another CSC. Reopen the original CSC for a fresh seed-1 run.
Times are simulated times, not wall-clock times. `expected-output.txt` is the
unaltered headless serial/test log, including actual measurements and the test result.

For headless Docker execution, replace `--gui --autostart` in the launcher with
`--no-gui --logdir=/lab/run-output` and remove the display requirement/mount.
Cooja writes `COOJA.testlog` under that writable output directory.

## Scenario and three reproducible runs

A building monitor sends a nominal 52-byte report; a diagnostic expansion grows
it to 300 bytes. Root 1 is at (0,0), receiver 2 at (35,0), seed 1, UDGM
50 m transmit / 100 m interference, success ratios 1. Both runs use unchanged
upstream regression applications from `tests/07-simulation-base/code-ipv6`.
Their existing `SIZE` parameter permits the legacy payload-growth experiment
without writing new C. `sender-52/project-conf.h` sets SIZE=52;
`sender-300/project-conf.h` sets SIZE=300. This size fixture initializes no
application message fields; its bytes and checksum may differ across native
loads. Compare addresses, length, time, ports and the one-packet identity within
each run; do not treat those bytes as temperature/humidity measurements.

| CSC | Real log | Expected result at 125 s |
|---|---|---|
| cooja-6lowpan-addressing.csc | expected-output.txt | 52 bytes accepted, no fragments |
| cooja-6lowpan-addressing-large.csc | expected-large-output.txt | 300 bytes accepted via four fragments |
| cooja-6lowpan-addressing-loss.csc | expected-loss-output.txt | first fragment only, no application delivery |

The root sends UDP on ports 61618 → 61618 at 80.549 s to
fd00::202:2:2:2. The small packet arrives at 80.558912 s and the large one
at 80.623824 s in the headless records. MAC payload capacity is 104 bytes.
Small case: IPv6+UDP+RPL headers 56 → 15, total 108 → 67, frag_needed=0.
Large case: total 356 → 315, four fragments. Compressed payload sizes and
fragment offsets are logged directly by the real 6LoWPAN stack.

In the loss run the ScriptRunner reacts to receiver 2's first-fragment log,
moving it to (300,0). Remaining radio fragments cannot reach it. Exactly one
input-fragment row remains and no datagram is delivered before the 125-second
observation ends. This measures incomplete delivery after fragment loss;
it does not claim that the log prints a reassembly-expiry event.

## Complete the legacy boundary record

* Address: mote ID, fe80:: scope, fd00::/64 lab prefix, root/next-hop identity;
  prefix owner is the isolated root configuration. Investigate neighbor state
  before claiming that an address proves reachability.
* Carry: the observed UDP ports and checksum remain reconstructible. Use the
  `compression:` and `uncompression:` rows to identify carried/derived fields.
  CID/context is logged by the stack; no mismatched-context fault is injected.
* Check: pair the one transmission's address, time, size and receiver result.
  If contexts differ, require a classified decode failure before release.
* Log: preserve both the constrained-link fragment records and the receiver
  acceptance. A missing Data line is a measured failure, not “sensor offline”.
* Gate: keep the 52-byte routine path; the 300-byte diagnostic requires an
  explicit fragmentation exception or a smaller/chunked, less-frequent transfer.
* Boundary: root 1 is a mesh root, not a configured host-facing border router.
  External prefix advertisement, upstream filtering, security keys and cloud
  return paths are **unproven**. A production release remains pending those
  owner records; this lab does not infer them from local success.

Finish with a decision: “ready with limits for the isolated 52-byte path;
large diagnostic redesigned or explicitly constrained; production border-router
and security evidence pending.” Name owners for firmware size/schema, shared
compression context, prefix/routing and upstream policy. Rerun all three cases
after a payload schema, firmware, prefix, context, route or security change.


## Tested version

Contiki-NG release/v4.9 c20b12cd, Cooja 4.8 (2022071901), Temurin 17.0.20.1, image sha256:b14d5afb0a2a852d9e72bbed607ead03f6ccc5f4d4dee44f0799110be2f4b609
